Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

OnMarketData vs OnMarketDepth

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    OnMarketData vs OnMarketDepth

    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) } } } }
    Last edited by mgin98; 04-22-2010, 12:16 PM.

    #2
    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.
    TimNinjaTrader Customer Service

    Comment


      #3
      Isn't OnMarketData just OnMarketDepth level 0???
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        Hi rt6176,

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

        Comment


          #5
          Originally posted by NinjaTrader_Tim View Post
          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.
          Last edited by mgin98; 04-22-2010, 03:49 PM.

          Comment


            #6
            Originally posted by rt6176 View Post
            Isn't OnMarketData just OnMarketDepth level 0???
            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.

            Comment


              #7
              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.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                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?

                Comment


                  #9
                  Hi mgin98,

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

                  Comment


                    #10
                    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

                    Comment


                      #11
                      Thanks Paco. Not directly related but an interesting read.

                      Comment


                        #12
                        update

                        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.



                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by wzgy0920, 04-20-2024, 06:09 PM
                        2 responses
                        26 views
                        0 likes
                        Last Post wzgy0920  
                        Started by wzgy0920, 02-22-2024, 01:11 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post wzgy0920  
                        Started by wzgy0920, Yesterday, 09:53 PM
                        2 responses
                        49 views
                        0 likes
                        Last Post wzgy0920  
                        Started by Kensonprib, 04-28-2021, 10:11 AM
                        5 responses
                        191 views
                        0 likes
                        Last Post Hasadafa  
                        Started by GussJ, 03-04-2020, 03:11 PM
                        11 responses
                        3,231 views
                        0 likes
                        Last Post xiinteractive  
                        Working...
                        X