Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Difference between methods?

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

    Difference between methods?

    I would like to ask,
    what is the fundamental difference between these 2 methods?

    OnExecutionUpdate(...) and OnPositionUpdate(...)

    Is see them like the same:
    Anytime OnExecutionUpdate(...) is called --> then OnPositionUpdate(...) has to be immediately called too, because after any execution, position is changed always.

    So in this context, I see these methods like the same event and the second OnPositionUpdate(...) looks like redundant. Isn't it ?
    Last edited by misova; 10-08-2015, 10:57 AM.

    #2
    Hello misova,


    The OnExecution() method is called on an incoming execution. An execution is another name for a fill of an order.
    The OnPositionUpdate() method is called everytime a position managed by a strategy changes state.


    OnExecution()
    OnPositionUpdate()
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Shawn,

      could you please be more specific what specific "changes" related to the position you mean?

      I can imagine only:
      • increase of the position size
      • decrease of the position size


      Both these events are directly caused by any execution. From this point of view, I cannot spot the difference between the execution and change-of-the-position.
      I see them like the same thing.

      What "changes" of the position do you mean, if they are not only executions?
      Are there any other "changes" of the position, that I am missing?

      Comment


        #4
        Hello,

        You can't have a position in the market without first executing an order. Once you have your position, any changes made to that position will be possible by using OnPositionUpdate().


        OnExecution() is for execution events for the order and OnPositionUpdate() is for the position updates.


        OnPositionUpdate() doesn't assign or read any OrderID's, however, OnExecution will as that information is only available once your order fills.


        I have included the OnExecution() and OnPositionUpdate() help guides in my previous post, which details exactly what each method can do.
        Shawn B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by misova View Post
          Thank you Shawn,

          could you please be more specific what specific "changes" related to the position you mean?

          I can imagine only:
          • increase of the position size
          • decrease of the position size


          Both these events are directly caused by any execution. From this point of view, I cannot spot the difference between the execution and change-of-the-position.
          I see them like the same thing.

          What "changes" of the position do you mean, if they are not only executions?
          Are there any other "changes" of the position, that I am missing?
          Having a position update handler means that you do not have to track the effect of executions on the position, but can instead directly query for the current position.

          Consider entering multiple orders with or without exits. If there is no position handler, you would have to track the workings of the execution handler in order to determine the current position.

          Comment


            #6
            Thanx Koganam,
            that makes sense.

            On the other side, I don't see some huge added value in this method, as the net-position calculation is easy = SUM of all execution-quantities.

            But it is OK - now I understand and see, there is nothing special about that method,
            It is convenient extension above executions.
            Last edited by misova; 10-08-2015, 02:38 PM.

            Comment


              #7
              Thank you Shawn,
              I understand the basics and I've read the docs you provided with links.

              I am more asking about, what is the added value of OnPositionUpdate(...) above OnExecutionUpdate(...), but koganam provided some explanation.
              Last edited by misova; 10-08-2015, 02:37 PM.

              Comment


                #8
                There are Order, Execution, and Position objects. Throughout the lifetime of those objects, they will be added/removed/changed. When any of those actions occur, the corresponding method is called and this event is exposed for 3rd party programmers. There may be no value to you in getting Position object in your strategy since you can logically conclude this occurred when the Execution is added, but there is value in this happening internally as we track all orders, executions and positions for various reasons.

                If your strategy is tracking a position object and you wanted to know when that changed, then you would want to check this in the PostionUpdate handler. If you don't, then no, you don't need to override it.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Originally posted by misova View Post
                  Thanx Koganam,
                  that makes sense.

                  On the other side, I don't see some huge added value in this method, as the net-position calculation is easy = SUM of all execution-quantities.

                  But it is OK - now I understand and see, there is nothing special about that method,
                  It is convenient extension above executions.
                  I gave you just one example of where it might be useful. There are other uses, where you would get better position information than by just tracking executions. What happens for example if you are doing your own Overfill handling? The execution sequence can be somewhat indeterminate: which is why there was a reported overfill in the first place.

                  Comment


                    #10
                    Matthew, thank you for explanation.
                    It's more clear now.

                    Comment


                      #11
                      Thanx koganam,
                      interesting and good to know.
                      I was not fully aware of this before.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Lloyd143, Today, 05:24 PM
                      1 response
                      18 views
                      0 likes
                      Last Post NinjaTrader_ShawnB  
                      Started by Hagar, Today, 04:38 PM
                      1 response
                      14 views
                      0 likes
                      Last Post NinjaTrader_ShawnB  
                      Started by [email protected], Today, 04:49 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post bpatel20@gmail.com  
                      Started by forrestang, Today, 02:05 PM
                      3 responses
                      24 views
                      0 likes
                      Last Post NinjaTrader_ChrisL  
                      Started by harryodell55, Today, 01:30 PM
                      3 responses
                      28 views
                      0 likes
                      Last Post NinjaTrader_ChrisL  
                      Working...
                      X