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) } } } }
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) } } } }