Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling 'OnMarketData' method for strategy

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

    Error on calling 'OnMarketData' method for strategy

    I have this strange error, that occurs sporadically on various days for Replay Mode.

    The body of the function is:
    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
    		{
    			if (m_actualMarketData == null)
    			{
    				Out("m_actualMarketData == null");
    				throw new InvalidOperationException("m_actualMarketData == null");
    			}
    			if (e == null)
    			{
    				Out("MarketDataEventArgs == null");
    				throw new InvalidOperationException("MarketDataEventArgs == null");
    			}
    			if (e.MarketDataType == null)
    			{
    				Out("e.MarketDataType == null");
    				throw new InvalidOperationException("e.MarketDataType == null");
    			}
    			m_actualMarketData.OnMarketData(e);
    		}
    ActualMarketData.OnMarketData is:
    Code:
    if (e.MarketDataType == MarketDataType.Last)
    				{					
    					Last = e.Price;
    				}
    ActualMarketData constructor is:
    Code:
    public ActualMarketData()
    			{
    				Last = 0.0;
    			}
    ActualMarketData.Last is a property:
    Code:
    public double Last { get; private set; }
    Update:
    function Out() is this (It is called many times before the point of crash in OnMarketData):
    Code:
    private void Out(string msg)
    		{
    			if (!EnableLog || msg == null)
    			{
    				return;
    			}
    
    			string line = string.Empty;
    
    			if (CurrentBar > 0)
    			{
    				line = string.Format("{0:yyyy-MM-dd HH:mm:ss}:{1}", Time[0], msg);
    			}
    			else
    			{
    				line = msg;
    			}
    
    			Print(line);
    			try
    			{
    				System.IO.File.AppendAllText(m_filename, line + System.Environment.NewLine);
    			}
    			catch (Exception ex)
    			{
    				Print("Cannot log to " + m_filename + ": " + ex.ToString());
    			}
    		}
    The error I get:
    **NT** Error on calling 'OnMarketData' method for strategy 'ABC: Object reference not set to an instance of an object.

    How could that be possible?

    Thank you.
    Last edited by alex.nt; 11-21-2013, 01:50 AM.

    #2
    Alex, would not see anything standing out, best practice in those cases would be chasing the issue down and with standard C# try / catch.

    Comment


      #3
      Traces contain this:
      2013-11-21 01:25:27:233 Cbi.Globals.ProcessEventArgsInThreadContext, exception caught: Object reference not set to an instance of an object.: MarketDataEventArgs: Instrument='ES 12-13 Globex' Type=Bid Price=1744.25 Volume=506 Time=22/10/2013 9:38:46 AM

      Comment


        #4
        Thanks Alex, we would need to reproduce it here on our end if possible. Do you see this consistently on replay data for the ES on Oct 22nd?

        Would you mind sending us your replay data file and script to support so we could further look into it and consult with dev?

        Comment


          #5
          Thank you for your reply.

          Unfortunately the issue appears to be very sporadic, and it only reproduces itself for one client, so I am limited in terms of debugging.

          We will continue monitoring this, if the issue occurs above the acceptance level we will send you the script.

          Comment


            #6
            Thanks Alex, sounds good. Please keep us in the loop.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            656 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            371 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
            579 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X