原来打算使用在tickString里取lastTimestamp来判断读价格的时间,但是,在paper account下测试,偶尔会出现tickString那里取不到lastTimestamp的情况,今天就是这样。 之前在edemo测试时,也会出现读不到lastTimestamp的情况,那时认为正式的环境应该会有,所以还是保持基于lastTimestamp来判断时间的算法。 如果lastTimestamp不是必然提供的,那么,类似每10分钟判断一次价格的这种算法,就不能借助lastTimestamp了,需要自己加定时器,定时读价格,但是这样的话很难和 historical data取到的数对应上,也就是说,取历史数据和实时读数会有误差,这种误差也不知道会在多大程度上影响交易规则的判断和交易策略的使用。 对历史数据做模拟得到的交易结果随之存在误差,参考价值降低了。 有没有哪位前辈或者IB的人员解释一下,lastTimestamp到底在什么情况下会有,什么情况下不出现???
I don't have experience with the callback tickString(). My guess is that when no last time stamp is returned, this tick is not a valid one. Next time when you can't catch the last time stamp, check out if the volume is changed, if not then just ignore this tick. There is a way to workaround it, if you are certain this is a valid tick. Remember the last tick's time stamp, then add the time difference to the tick without time stamp returned. I jsut stamp these ticks with my computer times, don't care much about minor time gaps.
ib不是一个可靠的datafeed,它类似于中国的股票市场行情,差异是中国市场每5、6秒发一个SNAPSHOT,IB每0.5秒发一个。另外,可以调time & sales(在ANALYSIS-REAL TIME CHARTS里)来对比看看,是不是同一个TIMESTAMP(只能精确到秒)上的若干个QUOTE会只播报第一个的时间。
非常感谢各位前辈的回帖! 我打算在tickprice里读本地时间进行间隔判断,先假设这种误差是可以接受的,实在是差异太大,再做打算 因为根据现在的情况,把希望寄托在lastTimestamp的准确读取上,还不如自己在tickprice方法里计算时间间隔
黄忠兄,万分的抱歉,这段时间实在是非常的忙,我觉得海洋论坛藏龙卧虎,参加这次聚会的前辈更是高手中的高手,我真的非常希望能够借这个机会向各位前辈认真学习,可是我现在确实没有时间,个人原因不便多说,敬请原谅!
First call currentTime(long time) to know the time difference between TWS server and your local time, and adjust tiem stamps accordingly.