这是一个关于如何在复杂的过程中找到故障点的问题。 (如果你能弄清楚到底出了什么问题......哇。)
我使用 QuickFix
和 Python 2.7
连接到 future 市场,我使用 pandas
处理数据并将其放入数据帧等。过程如下:
连接到 TT FIX 适配器,提供交换访问。
提交 MarketDataIncrementalRefreshRequest,这会产生流数据(每次进行交易时都会报告)。因此,繁忙期间传入消息之间的时间间隔可能约为 10 毫秒。
每条消息都会被解析、转换为
pandas
数据帧,并与该市场预先存在的数据帧连接起来。代码:#df is dataframe of trades with 10 columns df.index = pd.to_datetime(df.TIME) #concatenate with prior data #TS_DIC is a dictionary holding trade data for various markets try: df_prev = TS_DIC[market_key] TS_DIC[market_key] = pd.concat([df_prev,df]) except: #in the case this is the first message received: TS_DIC[market_key] = df #now write to disk try: #if file exists just write to_file = open('path/for/data', 'a+') df.to_csv(mode='a+', path_or_buf= to_file, header=False, index=False) to_file.close() except: #create the file with headers and write to_file = open(path+name, 'wb') df.to_csv( path_or_buf= to_file, index=False) to_file.close()
这个过程工作正常,有时持续几个小时,有时持续几分钟,然后就停止工作了。从来没有任何错误,它只是停止。结果是存在间隙的数据。我可以通过再次执行步骤 2 来重新开始该过程。
我非常感谢任何习惯于高通量数据甚至这些软件包的人的帮助。
这里可能出现什么问题?我如何找出出了什么问题?
最佳答案
我想让任何遇到这个问题的人知道我是如何解决这个问题的:
打印上述注释所建议的错误实际上并没有帮助解决问题。数据仍然会停止而不会出现打印错误。原因是有时 QuickFix 会出于某种原因脱机启动,然后会自动重新登录。显然这是 FIX 应用程序必须处理的事情。
发生了什么:因为我手动启动数据下载,所以每次离线启动时,数据都会停止。因此,通过将数据请求放入 QuickFix 的 OnLogon 函数中,我能够在程序登录时自动重复下载请求。
这解决了我的问题。感谢 CasualDemon 和 cpburnz。
关于python - 如何找出我的流数据停止的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21640477/