I've just discovered something which is potentially quite undesirable for those of us who are running live strategies using multiple instruments (e.g. if you were trading a spread or had an indicator which requires simultaneous prices of two or more instruments). My example below trades two instruments.
In my strategy, I want the key decision making run only once per minute (assuming 1 minute bars) so I have the following check (at the start of OnBarUpdate) to ensure that we only run the code when bars of one of the two instruments triggers OnBarUpdate():
return;
Print("Synced: " + Times[0][0] + " / " + Times[1][0] );
else
Print(" Error : " + Times[0][0] + " / " + Times[1][0]);
Synced: 2/20/2019 3:21:00 PM / 2/20/2019 3:21:00 PM
Synced: 2/20/2019 3:22:00 PM / 2/20/2019 3:22:00 PM
Error : 2/20/2019 3:22:00 PM / 2/20/2019 3:23:00 PM
Synced: 2/20/2019 3:24:00 PM / 2/20/2019 3:24:00 PM
Synced: 2/20/2019 3:25:00 PM / 2/20/2019 3:25:00 PM
Synced: 2/20/2019 3:26:00 PM / 2/20/2019 3:26:00 PM
Error : 2/20/2019 3:26:00 PM / 2/20/2019 3:27:00 PM
It doesn't seem to be an issue with my data vendor as both Kinetick and Interactive Brokers have demonstrated similar behavior.
The one thing I had in mind is to put some sort of code at the start of OnBarUpdate to mark what new bars have been received, and to only proceed once all the new bars for the relevant instruments have been received. However, this seems quite clunky and isn't what I would perceive to be the expected behavior in this situation.
Do you have any recommendations to solve this issue?
Thanks in advance!
Comment