run() delayed with IB and many assets

Posted By: MegaTanker

run() delayed with IB and many assets - 04/20/22 11:51

I'm using BarOffset with daily bars to trigger the run() function at the desired trading time. When I try this out, I notice that the actual execution is delayed around 10 minutes after the time set in the script. When I reduce the number of assets being looped from around 60 to just 3, the delay becomes much shorter as well, though it's still not very precise. I'm assuming this is related to slow price requests from IB.

1. Is there anything that can be done about this, to execute the run() more precisely with many assets?

2. I notice the timestamp in the status bar updates much less frequently with many assets. What triggers an update of this timestamp?

3. How exactly does Zorro build these daily candles with BarOffsets? Does it collect live data in some interval and then use this data to construct the candle when it closes?
Posted By: jcl

Re: run() delayed with IB and many assets - 04/20/22 14:10

Price requests from IB can be up to 10 seconds. And prices are updated immediately before the run function, so with several 100 assets you can indeed get a 10 minutes delay.

Price requests are much faster when you activate the 'fast' price type - see https://zorro-project.com/manual/en/brokercommand.htm. Otherwise, when your trading is time critical, set BarOffset accordingly earlier.

Zorro builds daily candles in the way you described. In your case they are collected every 10 minutes.
Posted By: MegaTanker

Re: run() delayed with IB and many assets - 04/20/22 14:33

I see, thank you. The 'fast' mode makes the delay bearable, cuts it down to around a minute delay with 60 assets.
© 2024 lite-C Forums