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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            44 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            54 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            34 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            95 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            57 views
            0 likes
            Last Post PaulMohn  
            Working...
            X