策略运行在5分钟周期上,引用15分钟的数据:[Python]  复制代码 context.data_len = 400
    context.s_SH510500 = "SH510500"
    open_data = history_bars(context.s_SH510500, context.data_len, '15m', 'open', True, True, True) 
    high_data = history_bars(context.s_SH510500, context.data_len, '15m', 'high', True, True, True) 
    low_data = history_bars(context.s_SH510500, context.data_len, '15m', 'low', True, True, True) 
    close_data = history_bars(context.s_SH510500, context.data_len, '15m', 'close', True, True, True) 
    volume_data = history_bars(context.s_SH510500, context.data_len, '15m', 'volume', True, True, True) 
print(
        f'{str(context.now)}\n'
        f'open: {open_data[-1]:.3f}\n'
        f'high: {high_data[-1]:.3f}\n'
        f'low: {low_data[-1]:.3f}\n'
        f'close: {close_data[-1]:.3f}\n'
        f'volume: {volume_data[-1]:.3f}\n'
    ) 
 
按照API的解释: 
include_now        bool        是否包括不完整的bar数据。默认为False,不包括。举例来说,当前1分钟k时间为09:39的时候获取上一个5分钟线数据,默认将获取到09:31~09:35合成的5分钟线,即最近一根完整的5分钟线数据。如果设置为True,则将获取到09:36~09:39之间合成的"不完整"5分钟线,即最新一根5分钟线数据。  照理说 include_now 设置为 True 了,输出的每个 close 基本都不同、volume 肯定不同、同一个 15min 内的 open 一定一样 
但是这是输出数据: 
09:22:47 > 2025-01-02 09:35:00 
           open: 5.713 
           high: 5.714 
           low: 5.675 
           close: 5.692 
           volume: 550748.000 
            
09:22:47 > 2025-01-02 09:40:00 
           open: 5.713 
           high: 5.714 
           low: 5.675 
           close: 5.692 
           volume: 550748.000 
            
09:22:47 > 2025-01-02 09:45:00 
           open: 5.713 
           high: 5.714 
           low: 5.675 
           close: 5.692 
           volume: 550748.000 
            
09:22:47 > 2025-01-02 09:50:00 
           open: 5.692 
           high: 5.700 
           low: 5.682 
           close: 5.688 
           volume: 192940.000 
            
09:22:47 > 2025-01-02 09:55:00 
           open: 5.692 
           high: 5.700 
           low: 5.682 
           close: 5.688 
           volume: 192940.000 
            
09:22:47 > 2025-01-02 10:00:00 
           open: 5.692 
           high: 5.700 
           low: 5.682 
           close: 5.688 
           volume: 192940.000 
            
09:22:47 > 2025-01-02 10:05:00 
           open: 5.688 
           high: 5.695 
           low: 5.668 
           close: 5.671 
           volume: 285547.000 
            
09:22:47 > 2025-01-02 10:10:00 
           open: 5.688 
           high: 5.695 
           low: 5.668 
           close: 5.671 
           volume: 285547.000 
            
09:22:47 > 2025-01-02 10:15:00 
           open: 5.688 
           high: 5.695 
           low: 5.668 
           close: 5.671 
           volume: 285547.000  哪里有问题,请老师帮忙看一下,谢谢! 
 
 |