CTP 合成的K线数据校验

1分钟K线数据的校验

# 通达信数据
tdx=get_data()['2023-9-13'] 
# tick合成的K线 修改数据格式与通达信统一
df=pd.read_csv('./test/rb2401_1m.csv')
df['date'] = pd.to_datetime(df['date'])+datetime.timedelta(minutes=1)
df.set_index('date',inplace=True)
df['openInterest']=df['openInterest'].astype(int)
df=df['2023-9-13']
for date,v,tv,o,to,oi,toi in zip(df.index,df['volume'],tdx['volume'],df['open'],tdx['open'],df['openInterest'],tdx['open_interest']):
    if v!=tv:
        print('v:',date,v,tv) #成交量不同的打印出来
    if o!=to:
        print('o:',date,o,to) #开盘价不同的打印出来
    if oi!=toi:
        print('oi:',date,oi,toi) #持仓量不同的打印出来    

如果没通过,再检查tick数据与K线的关系

import csv

with open('./ticktest/rb2401_tick.csv', encoding='utf-8') as f:
    rows = csv.reader(f)
    next(rows)
    last_row = last_last_row = None
    for i, row in enumerate(rows, 2):
        row.append(row[0].split(':')[2])  # 将分钟追加到列表末
        # 连续的3个tick1表示最近,1和2都是00分,3不是00分,1和2的volume不同,2和3的volume也不同
        if row[-1] == '00' and last_row[-1] == '00' and last_last_row[-1] != '00' and row[3] != last_row[3] and last_row[3] != last_last_row[3]:
            print(i, row)
        last_last_row = last_row
        last_row = row

 

posted @   C羽言  阅读(123)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示