PDA

View Full Version : OnMarketData vs OnMarketDepth


mgin98
04-22-2010, 12:13 PM
I'm using v7.x.14 and have an indicator that tracks inside bid/ask size between OnMarketData and OnMarketDepth. I'm aware that NT doesn't catalogue transactions at the sub-millisecond level so I'm using an index (idx++) for each transaction but find that OnMarketData transactions are being written (streamwrite), hence processed, before OnMarketDepth transactions. Are these parallel data streams that are multithreaded or is the data stream linear (for lack of a better term)?

For example, when an order comes through and GetCurrentAskVolume() is not changing, I'm expecting OnMarketDepth to show the size changing (+ or - due to adds/cancels) with each transaction, not a stream of changes "long" after the fact. Instead, what I see is OnMarketData for 20 transactions, then followed by 20+ OnMarketDepth transactions, as opposed to OnMarketData, OnMarketDepth, OnMarketData, OnMarketDepth etc. Granted, all of this is occurring within the same second, but I still would think it's a parallel stream where I would get data from both methods as they occurred. Below is the basic code I'm using.

protectedoverridevoid OnMarketDepth(MarketDepthEventArgs e)
{
if (file != null) {
if (Historical) return;
if (e.MarketDataType == MarketDataType.Ask && e.Position == 0)
{
idx++;
aa = a;
a = e.Volume;
d = a - aa;
if(d > 0)
{
sw.WriteLine(a + "," + aa "," + d) } } } }

protectedoverridevoid OnMarketData(MarketDataEventArgs e)
{
if (file != null) {
if (Historical) return;
idx++;
aa1 = a1;
a1 = GetCurrentAskVolume();
d1 = a1 - aa1;
if(d1 > 0)
{
sw.WriteLine("" + "," + "" + "," + "" + "," + a1 + "," + aa1 "," + d1) } } } }

NinjaTrader_Tim
04-22-2010, 12:39 PM
Hi mgin98,

Thank you for your post.

NT is multithreaded and the events are asynchronous. It is possible to experience such a sequence of events.

RJay
04-22-2010, 01:34 PM
Isn't OnMarketData just OnMarketDepth level 0??? :confused:

NinjaTrader_Tim
04-22-2010, 02:45 PM
Hi rt6176,

OnMarketData is the same as OnMarketDepth for the current values. For example, the current Bid and Ask.

mgin98
04-22-2010, 03:46 PM
Hi mgin98,

Thank you for your post.

NT is multithreaded and the events are asynchronous. It is possible to experience such a sequence of events.

Thanks for such a quick response NT_Tim,

The sequence of events are consistent, not simply a possibility, and I see little asynchronous about the relationship between OnMarketData and OnMarketDepth. OnMarketDepth e.Position == 0 lags OnMarketData. Maybe it's just not apparent (or important) unless you're coding at the transaction level. So I guess what I'm trying to find out is if it's a limitation of the platform or is it how the data is being delivered to the platform from the provider.

mgin98
04-22-2010, 04:56 PM
Isn't OnMarketData just OnMarketDepth level 0??? :confused:


Yes, but my comment relates to the observation that marketdepth may lag marketdata. OnMarketData is limited in it's real-time display during certain types of market orders whereas OnMarketDepth is not (should not be). I just need to know if it's by (NT) design or a limitation of the data provider.

Such things are not important to minute/second/tick traders but it is important to HFT.

NinjaTrader_Josh
04-22-2010, 05:17 PM
mgin98,

The events trigger whenever the data comes in from your data provider. If you get bursted data it will display as such. If the provider sends to you L1 data and then L2 data then you will see that. If it wants to do the opposite, then you will see that as well.

mgin98
04-22-2010, 05:23 PM
Thanks for the response NT_Josh. That's what I needed to know.

Another quick question. Do the replay files that NT7 host, come from Zenfire, NT internal servers or another provider?

NinjaTrader_Tim
04-23-2010, 06:26 AM
Hi mgin98,

The Market Replay data is from NT servers, that record data from the provider.

pacoferre
04-23-2010, 11:23 PM
Hi,

If you are dealing with Last and DailyVolume events at OnMarketData, perhaps you could read the thread i opened.

There are OTC orders only affecting to DailyVolume events.

Best regards,

Paco Ferre

mgin98
04-24-2010, 11:20 AM
Thanks Paco. Not directly related but an interesting read.

mgin98
10-28-2010, 11:37 AM
Just to add to this thread for those who are searching for related info. My original question was related to replay data. But my understanding per the attached thread, is that in live market, onmarketdata and onmarketdepth events should arrive in sync.

http://www.ninjatrader.com/support/forum/showpost.php?p=201167&postcount=25

http://www.ninjatrader.com/support/forum/showpost.php?p=201171&postcount=26