If I run print statements from the various event handlers looking at price changes here is what I am seeing.
1. Bar Update Event: Print whenever GetCurrentBid() or GetCurrentAsk() != a variable I created to hold a prior bid or ask price from the prior bar update.
2. OnMarketDepth Event: Print whenever the same occurs. Example such as:
if (marketDepthUpdate.MarketDataType == MarketDataType.Ask && marketDepthUpdate.Operation == Operation.Update && GetCurrentAsk() == marketDepthUpdate.Price)
{
if(VariablePriorPriceUpdate != marketDepthUpdate.Price )
{
Print( "This is where the update occurs");
}
}
3. OnMarketData Event: Print Whenever the same occurs. Example such as:
if (marketDataUpdate.MarketDataType == MarketDataType.Last)
{
if (marketDataUpdate.Price == marketDataUpdate.Ask)
{
{
If( VariablePriorPriceUpdate != marketDataUpdate.Ask)
{
Print("This is where the update occurs")
}
}
}
}
So in this example lets assume that all 3 event handlers are tracking the same price level change from ask = 2000 to ask = 1999.75. Also lets assume that I am running the OnBarUpdate on less than a 10 tick time series, so it will fire fairly quickly. What I have noticed, is that the timing of all 3 events typically runs like this.
1. Bar Update runs first.
2. OnMarketDepth runs second
3. OnMarketData runs third.
When I see the print times, and associated bid and ask volumes from the OnBarUpdate, I will always need to run through around 20-100 ask depth / bid depth updates before I get to the exact same matching bid and ask volume.
I have enclosed an example of the data prints that I have mentioned above. In this data example you can clearly see what I am referring to where the OnBarUpdate runs ahead of the OnMarketDepth and OnMarketData events.
Here are my questions:
1. Can you confirm that my understanding is correct and that what I am seeing aligns with the way it is designed.
2. Can you explain why the OnBarUpdate event catches price level changes first every time? To me, this doesn't quite add up. Considering that the OnMarketDepth event has a sample rate hundreds of times more granular it stands to reason that this event handler would observe price changes first, yet, it still lags behind the less granular OnBarUpdate event which samples the data far less often.
3. If someone was building a low latency strategy with the aim to capture price change events as quickly as possible it appears from my research the fasted event handler would be the OnBarUpdate event. Can you confirm this.
Thanks,
Ian
Comment