龙听期货论坛's Archiver

C
+
+


 微信: QQ:

龙听 发表于 2024-3-6 19:17

东方财富(Python/C++量化) - 数据查询函数【history_n - 查询历史行情最新n条】

函数原型:[code]history_n(symbol, frequency, count, end_time=None, fields=None, skip_suspended=True,
          fill_missing=None, adjust=ADJUST_NONE, adjust_end_time='', df=False)[/code]参数:

[img]http://p.algo2.net/2024/0306/922fb30818f65.png[/img]

返回值:参考Tick对象或者Bar对象。

当df = True时,返回

[img]http://p.algo2.net/2024/0306/393e0e58aec6d.png[/img]

示例:[code]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)[/code]输出:[code] 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[/code]当df = False时, 返回

[img]http://p.algo2.net/2024/0306/0a995dfcaad73.png[/img]

示例:[code]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)[/code]输出:[code][{'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'))}][/code]注意:

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”

页: [1]