Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time on MarketDataEventArgs

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

    Time on MarketDataEventArgs

    Hello,

    What is the value of Time property on MarketDataEventArgs?
    In a first glance it should be the DateTime of every change, (Bid, Ask or prices) but it seems to be the DateTime of last trade. Is that right?
    Maybe there is not much difference in liquidity instruments but definitively there are a lot of differences in non-liquidity instruments.

    Regards

    #2
    jbesada,

    It should be the time of that particular OnMarketData call. Are you noticing something different?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Unfortunately yes, I have noticed that always change whit MarketDataType=Last, but not with Bid and Ask (it keeps previous value).
      So, at the end, when you analyze a file data you can see always a change on Time if a Trade occurs:
      1303 0 1303 1303.75 22 69 49345
      1303 0 1303 1303.75 22 47 49345
      1303 0 1303.25 1303.75 22 47 49345
      1303 0 1303.25 1303.75 22 45 49345
      1303 0 1303.25 1304 22 69 49345
      1303 0 1303 1304 24 69 49345
      1303 0 1303.25 1304 22 69 49345
      1304 2 1303.25 1304 22 69 49760
      As you can see, there is a big jump on last column (seconds from midnight). My guest, e.Time is not updated with ‘Bid’ and ‘Ask’ events, just with ‘Last’ event. Can you confirm it?
      I have reviewed my code deeply and I cannot find another explanation…


      Regards

      Comment


        #4
        jbesada,

        There would only be second resolution here, so no milliseconds. Could you show me your code?
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Here is my code. As you can see, every change is recorded creating a new line but Time changes with 'Last' type only:

          protected override void OnMarketData(MarketDataEventArgs e)
          {
          string strMD="", strML="";
          string strDate ="";
          long lLastVolume=0;
          bool bUpdate=false;
          try
          {
          lock(oLock)
          {
          switch(e.MarketDataType)
          {
          case MarketDataType.Bid:
          dBid=e.Price;
          lBidSize=e.Volume;
          bUpdate=true;
          break;
          case MarketDataType.Ask:
          dAsk=e.Price;
          lAskSize=e.Volume;
          bUpdate=true;
          break;
          case MarketDataType.Last:
          dLast=e.Price;
          lLastVolume=e.Volume;
          bUpdate=true;
          break;
          }
          if (bUpdate && dLast>0 && dBid>0 && dAsk>0)
          {
          TimeSpan ts = e.Time.ToUniversalTime() - DateTime.Now.Date;
          strDate= ts.TotalSeconds.ToString();
          strMD = dLast.ToString().Replace(',', '.') +"\t" + lLastVolume + "\t" + dBid.ToString().Replace(',', '.') + "\t" + dAsk.ToString().Replace(',', '.') + "\t" + lBidSize + "\t" + lAskSize + "\t" + strDate;
          twMD.WriteLine(strMD);
          }
          }
          }catch(System.Exception ex)
          {
          Print("Something was wrong on OnMarketData! : " + ex.Message);
          }
          }

          Comment


            #6
            jbesada,

            Here is example output for me :

            Code:
            ASK : 6/25/2012 9:53:13 AM
            ASK : 6/25/2012 9:53:13 AM
            ASK : 6/25/2012 9:53:13 AM
            BID : 6/25/2012 9:53:13 AM
            ASK : 6/25/2012 9:53:13 AM
            ASK : 6/25/2012 9:53:13 AM
            ASK : 6/25/2012 9:53:13 AM
            LAST : 6/25/2012 9:53:14 AM
            BID : 6/25/2012 9:53:14 AM
            LAST : 6/25/2012 9:53:14 AM
            BID : 6/25/2012 9:53:14 AM
            BID : 6/25/2012 9:53:14 AM
            ASK : 6/25/2012 9:53:14 AM
            ASK : 6/25/2012 9:53:14 AM
            This is expected output, because we are not seeing the times at millisecond resolution. Time stamps do not have these milliseconds displayed. I am noticing that last occurs before subsequent bid/asks, but these subsequent bid/asks are happening after the last quote, you just aren't able to get their time stamps at millisecond resolution. If you could you would see they are happening at different times.

            Here is an example of my code :

            Code:
                            protected override void OnMarketData(MarketDataEventArgs e)
            		{
            			if ( e.MarketDataType == MarketDataType.Ask)
            			{
            				Print("ASK : "+e.Time.ToString());
            			}
            			else if ( e.MarketDataType == MarketDataType.Bid)
            			{
            				Print("BID : "+e.Time.ToString());
            			}
            			else if ( e.MarketDataType == MarketDataType.Last)
            			{
            				Print("LAST : "+e.Time.ToString());
            			}
            		}
            You could try keeping track of your own time stamps for these that include millisecond resolution, but it wouldn't work on historical data.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Hi Adam,


              I know time have only resolution of seconds. I think I haven’t asked about milliseconds. My question is not related with it.
              My question is why always time changes (resolution of seconds) always with Last quote and NEVER with Bid/Ask quotes.

              Regards

              Comment


                #8
                Hi Adam,

                Any update of this issue?

                Regards

                Hi Adam,
                --------

                I know time have only resolution of seconds. I think I haven’t asked about milliseconds. My question is not related with it.
                My question is why always time changes (resolution of seconds) always with Last quote and NEVER with Bid/Ask quotes.

                Regards

                Comment


                  #9
                  Bid ask data may not be natively time stamped from the provider. Something the provider will need to follow up on. If its time stamped from the exchange then NT will order it in the format received. Last data is most likely time stamped from the server however bid and ask data is not guaranteed to be time stamped and I know with a lot of providers it is not.

                  -Brett
                  BrettNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  649 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  370 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  576 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X