克隆策略
In [12]:
import requests
import json


# 策略id
ids = ["ad8e6c08-d492-11eb-b747-9a8e001243a4", "notebook_id2"]
user = "kobe"
api_token = """
xxxxxxxxxxxxxxxx
"""


# 获取策略指标
def get_strategy_metrics(notebook_id, owner, api_token):
    url = f"https://bigquant.com/bigwebapi/algo_info/plot_return?owner={owner}&notebook_id={notebook_id}&limit=-1&api_key={api_token}"
    response = requests.get(url)
    sharpe = response.json()["data"]["algo_info_plot_return"]["sharpe"]
    return sharpe

# 获取策略信号
def get_strategy_signal(api_token, ids):
    url = 'https://bigquant.com/bigwebapi/algo_info/planned_orders'
    headers = {'Authorization': 'Bearer {}'.format(api_token.strip().replace("\n", ""))}
    data = {
        'id_list': ids
    }
    r = requests.post(url=url, data=data, headers=headers)
    res_dict = json.loads(r.text)
    return res_dict

sharpes = [get_strategy_metrics(ids[i], user, api_token) for i in range(len(ids))]
res_dict = get_strategy_signal(api_token, ";".join(ids))
signals = [res_dict["data"][i]["planned_orders"] for i in range(len(ids))]
In [14]:
sharpes
Out[14]:
[0.0, 0.29433305479284455]
In [13]:
signals
Out[13]:
[[{'sid': '000756.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 11100,
   'name': '新华制药',
   'price': 8.67,
   'hold_percent': 0.009168925801111765},
  {'sid': '002947.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 15800,
   'name': '恒铭达',
   'price': 25.34,
   'hold_percent': 0.038145216089889744},
  {'sid': '605058.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 4200,
   'name': '澳弘电子',
   'price': 24.36,
   'hold_percent': 0.009747717993737824},
  {'sid': '603688.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 3800,
   'name': '石英股份',
   'price': 22.87,
   'hold_percent': 0.008279920048125139},
  {'sid': '688639.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 1600,
   'name': '华恒生物',
   'price': 49.73,
   'hold_percent': 0.007580796244093861},
  {'sid': '300732.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 9000,
   'name': '设研院',
   'price': 10.49,
   'hold_percent': 0.008994859408366447},
  {'sid': '300710.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 2600,
   'name': '万隆光电',
   'price': 35.51,
   'hold_percent': 0.008796307485826084},
  {'sid': '000032.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 10700,
   'name': '深桑达A',
   'price': 19.89,
   'hold_percent': 0.020276591080042074},
  {'sid': '603161.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 14100,
   'name': '科华控股',
   'price': 14.63,
   'hold_percent': 0.019653496275140937},
  {'sid': '002879.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 5800,
   'name': '长缆科技',
   'price': 15.13,
   'hold_percent': 0.008360712769005288},
  {'sid': '688669.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 2500,
   'name': '聚石化学',
   'price': 33.3,
   'hold_percent': 0.007931596713764503},
  {'sid': '688016.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 200,
   'name': '心脉医疗',
   'price': 406.52,
   'hold_percent': 0.007746192663254163},
  {'sid': '603996.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 37800,
   'name': '*ST中新',
   'price': 2.77,
   'hold_percent': 0.00997580499112824},
  {'sid': '000609.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 51800,
   'name': '*ST中迪',
   'price': 2.93,
   'hold_percent': 0.01446018209771644},
  {'sid': '603713.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 1200,
   'name': '密尔克卫',
   'price': 110.3,
   'hold_percent': 0.012610524216623058},
  {'sid': '603103.SHA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 5800,
   'name': '横店影视',
   'price': 14.68,
   'hold_percent': 0.008112046493654832},
  {'sid': '002452.SZA',
   'direction': '卖',
   'dt': '2021-06-24 15:00:00',
   'amount_after_adjust': 49300,
   'name': '长高集团',
   'price': 5.36,
   'hold_percent': 0.025176078899926034},
  {'sid': '002608.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 48500,
   'name': '江苏国信',
   'price': 6.57,
   'hold_percent': 0.03035872234063051},
  {'sid': '300835.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 4600,
   'name': '龙磁科技',
   'price': 43.46,
   'hold_percent': 0.019046883947494826},
  {'sid': '300859.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 6800,
   'name': '*ST西域',
   'price': 23.38,
   'hold_percent': 0.015147110774067695},
  {'sid': '300909.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 3100,
   'name': '汇创达',
   'price': 43.82,
   'hold_percent': 0.012942269799293665},
  {'sid': '600370.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 40400,
   'name': '三房巷',
   'price': 3.05,
   'hold_percent': 0.011739715880721466},
  {'sid': '601002.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 23200,
   'name': '晋亿实业',
   'price': 4.9,
   'hold_percent': 0.010830797770819805},
  {'sid': '688081.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 4200,
   'name': '兴图新科',
   'price': 25.15,
   'hold_percent': 0.010063838569068402},
  {'sid': '002200.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 19200,
   'name': 'ST云投',
   'price': 5.24,
   'hold_percent': 0.009585370356497527},
  {'sid': '603896.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 2600,
   'name': '寿仙谷',
   'price': 35.94,
   'hold_percent': 0.008902824304156278},
  {'sid': '688059.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 500,
   'name': '华锐精密',
   'price': 169.69,
   'hold_percent': 0.008083559437589781},
  {'sid': '688189.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 1700,
   'name': '南新制药',
   'price': 50.11,
   'hold_percent': 0.00811614329435984},
  {'sid': '000585.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 50100,
   'name': '*ST东电',
   'price': 1.72,
   'hold_percent': 0.008209988612835012},
  {'sid': '003011.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 2500,
   'name': '海象新材',
   'price': 32.88,
   'hold_percent': 0.007831558557014319},
  {'sid': '300244.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 2100,
   'name': '迪安诊断',
   'price': 37.3,
   'hold_percent': 0.007462846493563645},
  {'sid': '300840.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 5200,
   'name': '酷特智能',
   'price': 15.06,
   'hold_percent': 0.0074611315537336425},
  {'sid': '600867.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 6600,
   'name': '通化东宝',
   'price': 11.71,
   'hold_percent': 0.007363379983423464},
  {'sid': '603601.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 6800,
   'name': '再升科技',
   'price': 11.21,
   'hold_percent': 0.007262579631193279},
  {'sid': '000529.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 13700,
   'name': '广弘控股',
   'price': 5.48,
   'hold_percent': 0.0071528234820730785},
  {'sid': '603038.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 5800,
   'name': '华立股份',
   'price': 12.52,
   'hold_percent': 0.00691844837197265},
  {'sid': '605128.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 2000,
   'name': '上海沿浦',
   'price': 34.62,
   'hold_percent': 0.006596801879412062}],
 [{'sid': '002359.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 141300,
   'name': '北讯退',
   'price': 0.48,
   'hold_percent': 0.067824},
  {'sid': '600706.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 6100,
   'name': '曲江文旅',
   'price': 6.92,
   'hold_percent': 0.042212},
  {'sid': '600614.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 141300,
   'name': '退市鹏起',
   'price': 0.24,
   'hold_percent': 0.033912},
  {'sid': '600466.SHA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 9800,
   'name': '蓝光发展',
   'price': 2.96,
   'hold_percent': 0.029008},
  {'sid': '002350.SZA',
   'direction': '买',
   'dt': '2021-06-24 09:30:00',
   'amount_after_adjust': 5100,
   'name': '北京科锐',
   'price': 5.11,
   'hold_percent': 0.026061}]]