Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Replay101 and Sim101 order handling

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

    Replay101 and Sim101 order handling

    Testing with Replay101 and Sim101 shows an anomaly between how orders are handled in Replay101 and Sim101.

    When an entry order is submitted to Sim101 connected to a live broker data feed, the Enter returns before any Order Updates occur.

    When an entry order is submitted to Replay101 connected to the Market Replay Connection using downloaded replay data, the Enter does not return until after all Order Updates required to successfully complete the Enter and fill the order have occurred.

    Is this the expected behaviour? Is it documented and I just missed it (entirely possible)?

    This difference in behaviour is profound and has very significant implications for handling these events in a consistent manner.

    Would it not be better to have consistent behaviour for both (indeed, all) situations: the Enter returns as soon as the order has been created and is Pending Submit, but before the first Order Update occurs?

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    Thanks for your post.

    I am unclear as what you are referring to as an order update. Please clarify are you referring to the order status, new last price coming in, ect?
    BrandonNinjaTrader Customer Service

    Comment


      #3
      Order Update

      OnOrderUpdate for updates to individual orders.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Thanks for your reply.

        Please clarify what is returning that you are comparing the difference.
        BrandonNinjaTrader Customer Service

        Comment


          #5
          Clarification

          The sequence of events is as follows in the identified circumstances:

          For Sim101 connected to a live broker data feed:
          Code:
          IOrder = EnterLong() ; // Submit an order
          // The EnterLong() method returns an IOrder
          OnOrderUpdate(); // Receive PendingSubmit order update
          OnOrderUpdate(); // Receive Accepted order update
          OnOrderUpdate(); // Receive other order updates as expected
           ...
          OnOrderUpdate(); // Receive Filled order update
          For Replay101 connected to the Replay Data Connection with downloaded replay data:
          Code:
          IOrder = EnterLong() ; // Submit an order
          OnOrderUpdate(); // Receive PendingSubmit order update
          OnOrderUpdate(); // Receive Accepted order update
          OnOrderUpdate(); // Receive other order updates as expected
           ...
          OnOrderUpdate(); // Receive Filled order update
          
          // The EnterLong() method now returns an IOrder ...
          // ... BUT only after all expected order updates have been received
          It is the difference in the sequence of entering an order by calling the entry method and the timing of the return of the entry method in relation to order updates that is inconsistent and therefore requires separate order handling code for the separate connections.

          In my opinion, all entry orders submitted to any connection should behave the same, at least functionally, even if the actual sequence of received updates may vary because of the nature of the order, but it will not vary because of a distinctly different code path that acts inconsistently with other code paths.

          In summary, I believe all orders should behave as for Sim101. That is, as soon as the order is processed and is ready to be submitted to the connection (i.e. PendingSubmit), the Entry method should return with an IOrder immediately.

          Hope that helps to explain.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #6
            Hi jeronymite,

            I'll need to test this. I appreciate your patience while I test.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi jeronymite,

              I did a quick test of this and I am not able to reproduce these results.

              Below is a link to a video I created of this test.
              http://screencast.com/t/QpTC8ndh9IN9

              Let me know if you have questions about this video.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Interesting

                Many thanks for taking the trouble to make the video and show the demonstration. I really appreciate it!

                I will send output separately that shows the sequence for Replay101 vs Sim101.

                Thanks.
                Multi-Dimensional Managed Trading
                jeronymite
                NinjaTrader Ecosystem Vendor - Mizpah Software

                Comment


                  #9
                  Output from testing

                  I have attached output from testing on Replay101. It shows the behaviour I described.

                  Most grateful for your insights. Thanks.
                  Attached Files
                  Multi-Dimensional Managed Trading
                  jeronymite
                  NinjaTrader Ecosystem Vendor - Mizpah Software

                  Comment


                    #10
                    Hi jeronymite,

                    While I do not have your code so I do not know what order these prints should be in, just at a glance it looks like EnterPosition is called before the OnOrderUpdates..

                    Is EnterPosition printed at the time the IOrder is returned?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Code structure

                      The code is structured in this (pseudo-code) manner:
                      Code:
                      private void EnterPosition()
                      {
                      Print (Timestamp+"EnterPosition Submit EnterLong() ...") ;
                      EntryOrder = EnterLong() ;
                      Print (Timestamp+"EnterPosition EnterLong() returned EntryOrder = ...") ;
                      }
                      
                      protected override void OnOrderUpdate(IOrder ThisOrder)
                      {
                      Print (Timestamp+"OnOrderUpdate ThisOrder = ...") ;
                      }
                      Hence, the sequence shows that all output from all OnOrderUpdate invocations by NT occur "during" the EnterLong invocation; i.e. before the EnterLong completes.

                      Hope that makes it clearer. Thanks.
                      Multi-Dimensional Managed Trading
                      jeronymite
                      NinjaTrader Ecosystem Vendor - Mizpah Software

                      Comment


                        #12
                        Hello jeronymite,

                        Thank you for your response.

                        Do you have output of this scenario on the SIM101 account?

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by carnitron, Today, 08:42 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post carnitron  
                        Started by strategist007, Today, 07:51 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post strategist007  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        44 responses
                        3,974 views
                        3 likes
                        Last Post jhudas88  
                        Started by rbeckmann05, Today, 06:48 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post rbeckmann05  
                        Started by rhyminkevin, Today, 04:58 PM
                        4 responses
                        58 views
                        0 likes
                        Last Post dp8282
                        by dp8282
                         
                        Working...
                        X