OnTick execution policy
The onTick method is called on a tick unless the tick occurred more than 1 second ago or it is not among the last 3 ticks for the particular instrument. The last tick for each instrument always "survives", with an exception if it occurred during the execution of IOrder.waitForUpdate. An IStrategy instance occupies a single thread, which means that a tick can be "skipped" (following the aforementioned policy) during any IStrategy thread's method call - for instance an onBar method call.
Example
Consider an example where every fourth tick sleeps for 2 seconds.
We have 4 subsequent ticks:
tick1 (08:16:05 797)
tick2 (08:16:06 798)
tick3 (08:16:07 378)
tick4 (08:16:07 926)
The onTick execution sequence is the following:
onTick tick1 (08:16:05 797), current time: 08:16:05 840
onTick tick1 slept for 2 seconds
onTick tick2 (08:16:06 798), current time: 08:16:07 841 (tick2 survived because currentTime - tickTime < 1 sec)
onTick tick3 (08:16:07 378), current time: 08:16:07 841 (tick3 survived because currentTime - tickTime < 1 sec)
onTick tick4 (08:16:07 926), current time: 08:16:08 039 (tick4 happened already after the onTick execution of tick4)
Consider 4 more ticks later on:
tick5 (08:16:23 858)
tick6 (08:16:24 407)
tick7 (08:16:24 961)
tick8 (08:16:25 837)
The onTick execution sequence is the following:
onTick tick5 (08:16:23 858), current time: 08:16:24 119
onTick tick5 slept for 2 seconds
onTick tick8 (08:16:25 837), current time: 08:16:26 119 (tick6 and tick7 got skipped because for both currentTime - tickTime > 1 sec)
The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.