I'm writing a strategy where I need to classify the trades as Buy/Sell according to whether it happened on the Ask/Bid (assume as if I build a Volume Ladder with Bid .vs. Ask).
The problem is that the data I get in live feed is different from what I get when I download replay data and run it, the live feed is also different when I compare it to my friend's data running live IQFeed (my friend's live-feed matches my Replay results).
For Example, on Friday Feb 4, after the open we traded at 1306, the result I got:
live feed 531 X 1620 (Bid X Ask)
Replay data downloaded from NT servers 244 X 1907 (Bid X Ask)
Notice that the TOTAL volume is the same, so I am not missing ticks in the live feed, only the classification is different.
Here is a snippest from my Strategy OnMarketData()
protected override void OnMarketData(MarketDataEventArgs e) { if (e.MarketDataType == MarketDataType.Bid) { m_bid = e.Price; m_bidSize = (int)e.Volume; } else if (e.MarketDataType == MarketDataType.Ask) { m_ask = e.Price; m_askSize = (int)e.Volume; } else if (e.MarketDataType == MarketDataType.Last && m_bidSize > 0 && m_askSize > 0) { if (e.Price >= m_ask) // Classify as Buy else if (e.Price <= m_bid) // Classify as Sell // ... } }
Thank you very much,
Yuval.
Comment