Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

QUESTION: mEvent.Ask and mEvent.Bid when NOT using tick replay

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

    QUESTION: mEvent.Ask and mEvent.Bid when NOT using tick replay

    I understand that, when in tick replay mode, it is necessary to acquire the current best bid and best ask prices by evaluating marketDataEventArgs.Bid and marketDataEventArgs.Ask upon notification of a market data event with MarketDataType == MarketDataType.Last.

    However, the existing documentation leaves undefined whether or not the value of marketDataEventArgs.Bid and marketDataEventArgs.Ask have valid values when not in tick replay. So that's the question: Do they ever contain valid values when not in tick replay, and if so, under what conditions?

    Thanks!

    #2
    So what did you find in your test?

    Comment


      #3
      sledge,

      I didn't try to test until the exchanges were all closed. And then I tried using Market Playback. And I couldn't get that to work. Is that a known problem?

      Comment


        #4
        Originally posted by strategesis View Post
        sledge,

        I didn't try to test until the exchanges were all closed. And then I tried using Market Playback. And I couldn't get that to work. Is that a known problem?
        I am having all sorts of random issues in Playback-MR. It has come a long way since Beta1.

        Comment


          #5
          So now that the futures exchanges are operating again, I've been able to run a test.

          I have an indicator class which defines three instance variables:

          double lastPrice;
          double bestAsk;
          double bestBid;

          And it has the following method:

          Code:
          		
          		protected override void OnMarketData(MarketDataEventArgs mEvent) {
          
          			switch (mEvent.MarketDataType) {
          				case MarketDataType.Last:
          					lastPrice = mEvent.Price;
          					var ltBestAsk = mEvent.Ask;
          					var ltBestBid = mEvent.Bid;
          					var bestAskChanged = ltBestAsk != bestAsk;
          					var bestBidChanged = ltBestBid != bestBid;
          					if (bestAskChanged || bestBidChanged) {
          						Print(mEvent.Time + ": mEvent.Type = " + mEvent.MarketDataType + "; lastPrice = " + lastPrice + 
          							"; bestBid = " + bestBid +  (bestBidChanged ? "; LTBESTBID = " : "; ltBestBid = ") + ltBestBid + 
          							"; bestAsk = " + bestAsk + (bestAskChanged ? "; LTBESTASK = " : "; ltBestAsk = ") + ltBestAsk);
          					}
          					break;
          				case MarketDataType.Ask:
          					bestAsk =  mEvent.Price;
          					break;
          				case MarketDataType.Bid:
          					bestBid =  mEvent.Price;
          					break;
          				default:
          					return;
          			}
          			
          		}
          Any cases where the value provided by mEvent.Ask when mEvent.MarketDataType == MarketDataType.Last is not the same as the most recent value of mEvent.Price when mEvent.MarketDataType was equal to MarketDataType.Ask will be reported to the output window, as will any cases where the value provided by mEvent.Bid when mEvent.MarketDataType == MarketDataType.Last is not the same as the most recent value of mEvent.Price when mEvent.MarketDataType was equal to MarketDataType.Bid.

          Both of those things do happen. Frequently:

          8/23/2015 5:42:27 PM: mEvent.Type = Last; lastPrice = 1962; bestBid = 1961.5; ltBestBid = 1961.5; bestAsk = 1961.75; LTBESTASK = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.5; bestBid = 1961.75; LTBESTBID = 1961.5; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.25; bestBid = 1961.75; LTBESTBID = 1961.25; bestAsk = 1962; ltBestAsk = 1962
          8/23/2015 5:42:32 PM: mEvent.Type = Last; lastPrice = 1961.25; bestBid = 1961.75; LTBESTBID = 1961.25; bestAsk = 1962; ltBestAsk = 1962

          But what does this mean? Does it mean that the value of mEvent.Ask and mEvent.Bid are only valid when in tick replay mode? Or does it mean that, when the best bid or the best ask price change "at the same time" that a new tick occurs, that both events will be reported by the same mEvent?
          Last edited by strategesis; 08-23-2015, 07:14 PM.

          Comment


            #6
            The marketDataUpdate.Ask and Bid are updated every time there is a last update. That is the only time those fields are updated. This happens in real-time and historically, so there should not be a difference.

            In other words, when a last tick occurs, the current marketDataUpdate.Bid/Ask is updated with their current values.
            MatthewNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, 04-17-2024, 06:40 PM
            5 responses
            45 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by arvidvanstaey, Today, 02:19 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by mmckinnm, Today, 01:34 PM
            3 responses
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by f.saeidi, Today, 01:32 PM
            2 responses
            8 views
            0 likes
            Last Post f.saeidi  
            Started by alifarahani, 04-19-2024, 09:40 AM
            9 responses
            55 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X