• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketDataEventArgs.Time out of order with multiple data series

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

    MarketDataEventArgs.Time out of order with multiple data series

    Hi everyone,

    I have a question regarding the invocation behavior of the OnMarketData method for strategies that work with multiple series. When I run a test via Playback, and print in my strategy the value of the Time property of the MarketDataEventArgs event, I realize that they arrive out of order. This occurs only in the milliseconds granularity.

    For example:
    Time, Time.Ticks, Instrument
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.777, 636679060497770000, CL 09-18
    07/23/2018 01:27:29.835, 636679060498350000, ES 09-18
    07/23/2018 01:27:29.781, 636679060497810000, CL 09-18

    In this example, the instrument event ES 09-18 arrives at the strategy before the last instrument event CL 09-18.

    Is this behavior expected? If so, what is the reason for it?

    Thanks!
    Attached Files

    #2
    Hello ViniMob,

    This would be expected behavior.

    Behind the scenes there are data threads for the instruments that are receiving data from the connection. This then feeds data to instrument consumers (scripts, charts, or anything needing data) running in different threads in intervals. Because of this there is no guaranteed order that OnMarketData will update for any instrument.

    A tip on the same subject, GetCurrentAsk() and GetCurrentBid() get an immediate snapshot of the data from the instrument thread before this is processed and delivered to instrument consumers and these will also appear out of order (ahead of) data updating in OnMarketData.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the answer!

      Comment


        #4
        Enjoying the post, I have another related question. This should be an easy one, but I am trying to understand a simple difference related to time between market replay and realtime in ninjatrader.

        I performed a simple test with this same strategy, only printing the time.Tick value of the incoming MarketDataEventArgs, running in market replay and in real time, for the same time period. I noticed that there are time differences. For example:

        realtime time.tick
        09/13/2018 05:11:58.137
        09/13/2018 05:11:58.143
        09/13/2018 05:12:01.939
        09/13/2018 05:12:21.607
        09/13/2018 05:12:31.597

        market replay time.tick
        09/13/2018 05:11:58.101
        09/13/2018 05:11:58.113
        09/13/2018 05:12:01.886
        09/13/2018 05:12:21.558
        09/13/2018 05:12:31.554


        I suppose these differences are due to the fact that they are two different data providers. That's right? But in addition, this time information represents exactly the time of what?

        Thanks!

        Comment


          #5
          Hello ViniMob,

          Thank you for your response.

          The time you are pulling for realtime is through OnBarUpdate(), correct?

          If that is the case then you are looking at the Tick update to the bar in realtime through OnBarUpdate() versus the market data type update to OnMarketData().

          If you need further detail please post your code used for this test.

          Please let me know if you have any questions.
          Patrick H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by healthooa, Today, 01:28 AM
          0 responses
          5 views
          0 likes
          Last Post healthooa  
          Started by superkolleech, Today, 12:46 AM
          0 responses
          7 views
          0 likes
          Last Post superkolleech  
          Started by harjinderjit, Yesterday, 08:24 PM
          0 responses
          19 views
          0 likes
          Last Post harjinderjit  
          Started by Againmain1, Yesterday, 03:04 AM
          1 response
          26 views
          1 like
          Last Post NinjaTrader_ShawnB  
          Started by jmahon, 06-05-2020, 11:44 PM
          2 responses
          20 views
          0 likes
          Last Post jmahon
          by jmahon
           
          Working...
          X