Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PositionUpdate from Addon Approach vs Strategy OnPositionUpdate

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

    PositionUpdate from Addon Approach vs Strategy OnPositionUpdate

    Does the Addon Account callback PositionUpdate have any of the
    Rithmic or IB related issues mentioned in OnExecutionUpdate?

    Is PositionUpdate guaranteed to be called after every ExecutionUpdate?
    Is PositionUpdate guaranteed to be called for all order types?
    (ChartTrader, ATI, OFI, manual, Strategy, ATM, DOM, etc)

    Using the Addon approach, I want to be able to submit orders, and
    also watch for the moment the account position has become flat.

    As far as watching for the Flat event,
    I think PositionUpdate is the best (only?) way to do this, correct?
    Are there any other ways?

    With PositionUpdate, what can I truly rely on?

    Are there any caveats to using PositionUpdate?
    ​That's why I'm asking about the guarantees.

    I mean, I want PositionUpdate to be called every time the
    account position becomes flat (for any given instrument, of
    course) no matter what happened to cause that ... can I
    rely on that guarantee of notification delivery via this
    callback?

    EDIT: I'm not really concerned about the sequence of events,
    I just want to know that for all broker technology adapters, esp
    Rithmic, IB, Continuum, the PositionUpdate callback can be
    reliably used to monitor when the position becomes flat.

    EDIT-2: I'm doing this from an indicator, if that matters.

    Last edited by bltdavid; 03-02-2023, 08:07 PM.

    #2
    Hello bltdavid,

    Yes that would be the same for any tool that uses those events for those brokers. You would have to take the same precautions as a strategy. If you want to use the information from OnPositionUpdate you would need to use the passed in variables as mentioned in the help guide note. The note for OnPositionUpdate also mentions that you should instead use OnExecution if you are trying to drive your logic.

    •Rithmic and Interactive Brokers Users: When using a NinjaScript strategy it is best practice to only work with passed by value data from OnExecution. Instances of multiple fills at the same time for the same instrument might result in an incorrect OnPositionUpdate, as sequence of events are not guaranteed due to provider API design. For an example on protecting positions with this approach, see OnExecutionUpdate()
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Yes that would be the same for any tool that uses those events for those brokers. You would have to take the same precautions as a strategy. If you want to use the information from OnPositionUpdate you would need to use the passed in variables as mentioned in the help guide note. The note for OnPositionUpdate also mentions that you should instead use OnExecution if you are trying to drive your logic.
      The 'passed in variables' comment -- how does that apply to Account's PositionUpdate callback?
      That callback has a PositionEventArgs, which doesn't seem to be documented.

      Looking at the Account callback ExecutionUpdate, the ExecutionEventArgs is also not documented.

      Why are these critical arguments not documented?

      Comment


        #4
        Hello bltdavid,

        Those items are not documented because that is part of the advanced development portion of NinjaScript. A majority of the addon section is not documented and makes the assumption that you are already well versed in C# coding and exploring C# objects using intellepromt/intellesense. There are some specific samples on certain topics but you will find that a lot of items like event arguments or properties in the account/addon are not documented.

        The passed in value in this case would be the PositionEventArgs because no strategy is being used. Strategies have additional passed in values on their overrides because they are virtualized and have their own properties separate from the account. You still need to take the same considerations as a strategy when using the account directly, instead of relying on the values of saved variables to contain the correct current value you would want to use the information that the event is providing through its argument.

        You can find a unmanaged strategy sample in the following forum post that shows one way to work with IB/Rthmic events to help correctly calculate the position information based on the OnOrderUpdate event. Its possible to completely avoid using OnExecution and OnPositonUpdate for these brokers due to how their api sends events. You could do a similar task in an addon to accommodate the out of order events or incorrect position updates in certain cases.

        Hello, I connected to Interactive brokers. My strategy uses OnOrderUpdate, OnExecution, and OnPositionUpdate and my strategy uses orderName as a key for example to identify Enter signalName or exit signalName and other uses. But According to help manual : The problem is that the order name does not passed by value data


        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Those items are not documented because that is part of the advanced development portion of NinjaScript. A majority of the addon section is not documented and makes the assumption that you are already well versed in C# coding and exploring C# objects using intellepromt/intellesense. There are some specific samples on certain topics but you will find that a lot of items like event arguments or properties in the account/addon are not documented.
          Yep, NinjaScript Editor's intellisense has been an invaluable resource.

          Nonetheless, there are plenty of things that should be documented,
          such as this, this, and this.

          It's a real sorry state of affairs for NinjaTrader to expect me to seek
          advanced development information via intellisense, and then when
          there is a question about what I find, you guys can't comment further
          because it's undocumented.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by leojimenezp, Today, 04:04 PM
          0 responses
          4 views
          0 likes
          Last Post leojimenezp  
          Started by NM_eFe, Today, 06:14 AM
          2 responses
          12 views
          0 likes
          Last Post NM_eFe
          by NM_eFe
           
          Started by realblubb, 04-28-2024, 09:28 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by TAJTrades, 04-28-2024, 09:46 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by llanqui, 04-28-2024, 10:32 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X