 
等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
- FireScript
|
没有现成的,需要自己实现逻辑的。
如果是当日的序号:
一般是这样,用history_bars_date 函数获取当天的数据,直接看下当前数据长度即可.获取数据时候 注意设置 include_now=True. 而且还有拼凑一个当日的开始和结束日期和时间,这个可以按照下面这样处理:
#获取基准合约最新行情日期
context.current_date = datetime.strptime(str(int(get_dynainf(context.run_info.base_book_id,229)+19000000)), "%Y%m%d")
begin_time = time(0, 0, 0)
end_time = time(19, 0, 0)
context.current_begin_date = context.current_date.replace(hour=begin_time.hour, minute=begin_time.minute, second=begin_time.second)
context.current_end_date = context.current_date.replace(hour=end_time.hour, minute=end_time.minute, second=end_time.second)
用上面获取的开始和结束时间 来执行 history_bars_date 从而获取仅当日的数据.
|
|