关于模拟交易API

新手专区
标签: #<Tag:0x00007fcc113e0758>

(冰柠檬) #1

模拟交易 我现在能抓取到每日的买卖计划 这个没问题,如果我想抓取 每日的持仓信息 这个要怎么获取呢 参数应该修改那个呢? 谢谢大神帮忙解答


(iQuant) #2

您是想下载一段时期策略的持仓情况,是吗?


(冰柠檬) #3

是这样的 但是 不是通过网页手动下载,,是想通过python代码 直接获取类似 这个买入计划的详细信息({‘metadata’: {‘total_count’: 1}, ‘result’: True, ‘statusCode’: 200, ‘message’: ‘请求成功’, ‘data’: [{‘notebook_id’: ‘5be3cd2c-1977-11e9-846d-0a580a81010c’, ‘strategy_name’: ‘1天一调仓止损’, ‘last_run_date’: ‘2019-01-18’, ‘planned_orders’: [{‘direction’: ‘卖’, ‘sid’: ‘600025.SHA’, ‘price’: 3.22, ‘hold_percent’: 0.07262428163604713, ‘name’: ‘华能水电’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 22669}, {‘direction’: ‘卖’, ‘sid’: ‘002871.SZA’, ‘price’: 22.33, ‘hold_percent’: 0.08357976192082286, ‘name’: ‘伟隆股份’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 3762}, {‘direction’: ‘卖’, ‘sid’: ‘603008.SHA’, ‘price’: 9.53, ‘hold_percent’: 0.07888779956442447, ‘name’: ‘喜临门’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 8320}, {‘direction’: ‘卖’, ‘sid’: ‘300717.SZA’, ‘price’: 14.29, ‘hold_percent’: 0.06625394775499455, ‘name’: ‘华信新材’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 4660}, {‘direction’: ‘卖’, ‘sid’: ‘600702.SHA’, ‘price’: 25.23, ‘hold_percent’: 0.08652710019771762, ‘name’: ‘舍得酒业’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 3447}, {‘direction’: ‘卖’, ‘sid’: ‘600182.SHA’, ‘price’: 15.74, ‘hold_percent’: 0.0694061724806077, ‘name’: ‘S佳通’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 4432}, {‘direction’: ‘卖’, ‘sid’: ‘601908.SHA’, ‘price’: 3.41, ‘hold_percent’: 0.09992238379498164, ‘name’: ‘京运通’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 29452}, {‘direction’: ‘卖’, ‘sid’: ‘603970.SHA’, ‘price’: 14.97, ‘hold_percent’: 0.06313625713628676, ‘name’: ‘中农立华’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 4239}, {‘direction’: ‘卖’, ‘sid’: ‘002124.SZA’, ‘price’: 8.17, ‘hold_percent’: 0.1000305329572003, ‘name’: ‘天邦股份’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 12306}, {‘direction’: ‘卖’, ‘sid’: ‘000056.SZA’, ‘price’: 4.79, ‘hold_percent’: 0.09849803843497944, ‘name’: ‘皇庭国际’, ‘dt’: ‘2019-01-21 15:00:00’, ‘amount_after_adjust’: 20668}, {‘direction’: ‘买’, ‘sid’: ‘002451.SZA’, ‘price’: 15.33, ‘hold_percent’: 0.023336042179600096, ‘name’: ‘摩恩电气’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 1530}, {‘direction’: ‘买’, ‘sid’: ‘300325.SZA’, ‘price’: 3.78, ‘hold_percent’: 0.019319459899533552, ‘name’: ‘德威新材’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 5137}, {‘direction’: ‘买’, ‘sid’: ‘000587.SZA’, ‘price’: 3.04, ‘hold_percent’: 0.015310498802379564, ‘name’: ‘金洲慈航’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 5062}, {‘direction’: ‘买’, ‘sid’: ‘002017.SZA’, ‘price’: 9.92, ‘hold_percent’: 0.010343477408382526, ‘name’: ‘东信和平’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 1048}, {‘direction’: ‘买’, ‘sid’: ‘600677.SHA’, ‘price’: 12.5, ‘hold_percent’: 0.007859966711384007, ‘name’: ‘航天通信’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 632}, {‘direction’: ‘买’, ‘sid’: ‘603768.SHA’, ‘price’: 12.23, ‘hold_percent’: 0.012314040708201156, ‘name’: ‘常青股份’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 1012}, {‘direction’: ‘买’, ‘sid’: ‘603637.SHA’, ‘price’: 15.49, ‘hold_percent’: 0.01052605747056051, ‘name’: ‘镇海股份’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 683}, {‘direction’: ‘买’, ‘sid’: ‘601700.SHA’, ‘price’: 6.37, ‘hold_percent’: 0.011148049469204667, ‘name’: ‘风范股份’, ‘dt’: ‘2019-01-21 09:30:00’, ‘amount_after_adjust’: 1759}]}], ‘info’: ‘’}
) 类似这种


(冰柠檬) #4

类似这种


(达达) #5

1、您是订阅了别人策略想通过API看策略的历史持仓么?
2、还是您自己做策略回测想获从回测结果取历史持仓?


(冰柠檬) #6

我自己的策略 想做模拟交易 看了那个模拟交易API 我能拿到每天的买入和卖出信号那张表了, 另外我想获取历史持仓信息那张表 。这个能做到么?


(polll) #7
import requests
import json

def request_position_by_api_key(uname, key,
                                notebook_id):
    dl_url = 'https://bigquant.com/bigwebapi/algo_info/position?owner={0}&notebook_id={1}&page=1&limit=-1'.format(
    uname, notebook_id)


    params = {'api_key': key}
    r = requests.get(url=dl_url, params=params)
    return json.loads(r.text)['data']['positions_lists'][0]

key = ''xxxx这里是你自己的api_key'''

print(request_position_by_api_key('xxx你的用户名', key, 'xxx你要查询的notebook_id'))

(冰柠檬) #8

ok 谢谢 拿到了


(冰柠檬) #9

辛苦了 谢谢