Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account.PositionUpdate event parameter problem

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

    Account.PositionUpdate event parameter problem

    For Account.PositionUpdate Event, it's PositionEventArgs.MarketPosition has different value between Sim account and Live account.

    someAccount.PositionUpdate += OnPositionUpdate;

    private void OnPositionUpdate(object sender, PositionEventArgs e)
    {
    Print(string.Format("e.Operation={0}, e.MarketPosition={1}", e.Operation, e.MarketPosition);
    }
    Take 6B future for example:

    Buy 1 then sell 1 via Sim101 account:
    e.Operation=Add, e.MarketPosition=Long
    e.Operation=Remove, e.MarketPosition=Flat
    Buy 1 then sell 1 via Live account:
    e.Operation=Add, e.MarketPosition=Long
    e.Operation=Remove, e.MarketPosition=Short
    same close position operation but the e.MarketPosition is different, why?
    My live account provider is Continuum.
    Last edited by jjhou; 02-16-2017, 07:57 AM.

    #2
    Hello jjhou,

    Thank you for your note.

    Please see the following link under Multi-threaded consideration for an explanation of why this can happen.



    Using position.MarketPosition would yield the most current position.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Well, I added more detailed output to print, see the following:

      Buy 1 then sell 1 via Sim101 account:
      buy event: e.Operation=Add, e.MarketPosition=Long, e.Position.MarketPosition=Long, e.Quantity=1, e.Position.Quantity=1

      sell event: e.Operation=Remove, e.MarketPosition=Flat, e.Position.MarketPosition=Long, e.Quantity=0, e.Position.Quantity=1
      Buy 1 then sell 1 via Live account:
      buy event: e.Operation=Add, e.MarketPosition=Long, e.Position.MarketPosition=Long, e.Quantity=1, e.Position.Quantity=1

      sell event: e.Operation=Remove, e.MarketPosition=Short, e.Position.MarketPosition=Long, e.Quantity=0, e.Position.Quantity=1
      See? for the live account, e.Position.MarketPosition is not Flat neither.
      I don't think it's the multi-threaded caused, because I only have 1 long positon, it's impossible to have multiple partial position changes; and for this statement in the help document:
      Of course, the OnPositionUpdate() method parameters will eventually receive the event for "Flat" in the sequence the events were received.
      I received only one event when I close position, as you see above (the 2nd line printed) , no more events received, I didn't see any Flat value for live account.
      So I think it's a bug.

      By the way, my code is in an indicator, not a strategy.
      Last edited by jjhou; 02-19-2017, 10:02 PM.

      Comment


        #4
        Hello jjhou,

        In the helpguide link I provided, it mentions “events back from the broker API on thread "B". Given the SIM101 account does not have any information coming back from a broker API, you could expect this multithreading issue not to occur with the SIM101 account however may occur with the live account. Sim vs live does present a different thread.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          OK. But for this one:
          Of course, the OnPositionUpdate() method parameters will eventually receive the event for "Flat" in the sequence the events were received.
          I consider it as I will receive a event with some parameter='Flat' eventually no matter what multi-thread context is, Have I understood correctly? I have never received one like that, never.

          Comment


            #6
            Hello jjhou,

            We are currently investigating and I will follow up when we have more information.

            Thank you for your patience.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

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