- UID
- 2
- 积分
- 2892617
- 威望
- 1396340 布
- 龙e币
- 1496277 刀
- 在线时间
- 13326 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-12-25
|
[API-数据查询] 东方财富(Python/C++量化) - 数据查询函数【history_n - 查询历史行情最新n条】
函数原型:- history_n(symbol, frequency, count, end_time=None, fields=None, skip_suspended=True,
- fill_missing=None, adjust=ADJUST_NONE, adjust_end_time='', df=False)
复制代码 参数:
返回值:参考Tick对象或者Bar对象。
当df = True时,返回
示例:- history_n_data = history_n(symbol='SHSE.600519', frequency='1d', count=100, end_time='2020-10-20 15:30:00', fields='symbol, open, close, low, high, eob', adjust=ADJUST_PREV, df=True)
复制代码 输出:- symbol open ... high eob
- 0 SHSE.600519 1350.2278 ... 1350.3265 2020-05-22 00:00:00+08:00
- 1 SHSE.600519 1314.6434 ... 1350.8010 2020-05-25 00:00:00+08:00
- 2 SHSE.600519 1354.0629 ... 1354.1321 2020-05-26 00:00:00+08:00
- 3 SHSE.600519 1343.3086 ... 1344.2970 2020-05-27 00:00:00+08:00
- 4 SHSE.600519 1322.5214 ... 1331.3878 2020-05-28 00:00:00+08:00
复制代码 当df = False时, 返回
示例:- history_n_data = history_n(symbol='SHSE.600519', frequency='1d', count=2, end_time='2020-10-20 15:30:00', fields='symbol, open, close, low, high, eob', adjust=ADJUST_PREV, df=False)
复制代码 输出:- [{'symbol': 'SHSE.600519', 'open': 1725.0, 'close': 1699.0, 'low': 1691.9000244140625, 'high': 1733.97998046875, 'eob': datetime.datetime(2020, 10, 19, 0, 0, tzinfo=tzfile('PRC'))}, {'symbol': 'SHSE.600519', 'open': 1699.989990234375, 'close': 1734.0, 'low': 1695.0, 'high': 1734.969970703125, 'eob': datetime.datetime(2020, 10, 20, 0, 0, tzinfo=tzfile('PRC'))}]
复制代码 注意:
1.返回的list/DataFrame是以参数eob/bob的升序来排序的
2.若输入无效标的代码,返回空列表/空DataFrame
3.若输入代码正确,但查询字段包含无效字段,返回的列表、DataFrame只包含 eob、symbol和输入的其他有效字段
4.end_time中月,日,时,分,秒均可以只输入个位数,例:'2017-7-30 20:0:20',但若对应位置为零,则0不可被省略,如不可输入'2017-7-30 20: :20'
5. skip_suspended 和 fill_missing 参数暂不支持
6. 单次返回数据量最大返回33000, 超出部分不返回
7. end_time输入不存在日期时,会报错details = “Can’t parse string as time: 2020-10-40 15:30:00” |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|