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

Big lots handling speed.

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

    Big lots handling speed.

    I am creating strategy that trade 50+ contracts.
    This kind of lots unavoidable meets massive partial fills.

    While testing on Historical Replay I found out that speed of [execution or rendering or internal handling or something else] is slow. It freezing the chart.
    I moved from Set() managed approach to advanced Managed Approach and finally to Unmanaged.
    Unmanaged is about 30% faster, but it still freezing the chart.

    I tried to measure speed of OnBarUpdate(), OnOrderUpdate(), OnExecutionUpdate() methods, but I was unable to find the "speed leaks".
    It is, even, more strange because speed of handling of 1 lot is extremely high.

    Here is the video of the replay of the simplest strategy and the strategy source code.
    It use market entries only.
    Adding of protective orders - make strategy even more slow.

    Is this expected behaviour? Can I do something to let big orders work faster?
    What is the normal speed of order handling?




    PHP Code:
            protected override void OnBarUpdate()
            {

                if( 
    State != State.Realtime ) return;

                if( 
    Position.MarketPosition == MarketPosition.Flat )
                {
                    
    SubmitOrderUnmanaged0OrderAction.Buy,  OrderType.MarketLot );
                    return;
                }

                if( 
    Position.MarketPosition == MarketPosition.Long && Position.Quantity == Lot )
                {
                    
    SubmitOrderUnmanaged0OrderAction.SellOrderType.MarketLot*);

                }

                if( 
    Position.MarketPosition == MarketPosition.Short && Position.Quantity == Lot  )
                {
                    
    SubmitOrderUnmanaged0OrderAction.BuyOrderType.MarketLot*);

                }
            } 
    Attached Files
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic, thanks for your note.

    I'm not getting the same problem with historical playback. In Tool>Options>Trading, do you have "enforce partial fills" enabled for the simulator? Also please try this with a new database:

    Close out of NinjaTrader> Navigate to Documents\NinjaTrader 8\db and rename "NinjaTrader.sdf" to "NinjaTraderOLD.sdf" if you get the same problem with the new database, you can restore the old one.

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello, Chris.
      Thank you for the help.

      Yes, "Enforce partial fills" is enabled; that's the point: to test partial fills with big orders.

      I tried a new NinjaTrader.sdf file and I did not notice any changes.
      Multiple partial executions (even with same protective orders - not protective pair per execution) works works slow.

      I really hoped that Umnanaged will help.
      But, Umnanaged works as fast as Advanced Managed.

      What can I do?
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        Hi fx.practic, thanks for your reply.

        There's no further optimization that could be done outside of the custom strategy code. Either fewer orders would need to be traded or turn off enforce partial fills. Make sure you have NinjaTrader on a solid-state drive if possible.

        Chris L.NinjaTrader Customer Service

        Comment


          #5
          I spend some time testing partial executions on Playback and real-time connections.
          20+ parts makes strategy work significantly slower; 50+ causing chart freezing.

          This mean that any big order (say 50 contracts on NQ or 500 contracts on ES may cause strategy (and chart) freezing at regular market hours.

          To let NT serve clients with big orders I want to submit feature request: to make NT able to handle up to 50 partial executions in real-time.
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            Hi fx.practic, thanks for your reply.

            I didn't get the same problem when I tested the SampleMACrossover. This would also be expected to hang up a bit when you are running through replay at full speed. I would recommend to test this out on real time data in a high volume market for stress testing. Also, running the strategy from the Control Center instead of a chart can improve performance because no plot executions are being added.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello, Chris.
              Thank you for the prompt answer.

              The built-in strategy enters with lot 1.
              In attachment you may see the modification with additional Lot parameter.

              This is the video of how it works with Lot == 100.
              You may see on the video that chart inaccessible.

              Attached Files
              Last edited by fx.practic; 11-13-2019, 03:27 AM.
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Hello fx.practic,

                I am seeing the reported stutters when testing at 1x playback speed. We should understand the following before we file a request.

                1. Playback data is "pumped in" and UI refreshes at 1 second intervals
                2. Very large amounts of objects drawn on a chart (including execution markers) can cause a negative impact in performance on the chart

                As I have tested, the slowdown is coming from the large amount of execution markers that are being drawn on the chart. In a realistic context, are you building a strategy that is to be operating on a single tick (or similar) data series that is likely to experience large amounts of partial fills and submits orders in rapid succession? In such a case, you will see slowdowns when the strategy is added to the chart with Execution Markers set to Text and Marker or Markers Only, and we would advise using Do Not Plot or enabling the strategy from the Control Center.

                If the above is true and you are designing a strategy that would be expected to submit orders in rapid succession that would likely encounter large amounts of smaller partial fills, we could then request to have Execution Marker drawing improved.

                I look forward to being of further assistance.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Hello, Jim

                  Thank you for the answer.
                  I tried to check if your advice helpful and can't force partial fill neither on Simulated Data Feed, nor on Playback.
                  Do you have any idea?
                  I tried to turn On \ Off "Enforce Partial Fills" and to create a new workspase.
                  Attached Files
                  fx.practic
                  NinjaTrader Ecosystem Vendor - fx.practic

                  Comment


                    #10
                    Good to know that, thanks.

                    Comment


                      #11
                      Yes, with the Plot Executions OFF strategy works perfect: https://screencast-o-matic.com/watch/cqX0lkUyZJ
                      But with Plot Executions ON screen still refreshes about 8 times per second, but chart freezes: https://screencast-o-matic.com/watch/cqX0lEUyZ7
                      Last edited by fx.practic; 01-09-2020, 05:53 AM.
                      fx.practic
                      NinjaTrader Ecosystem Vendor - fx.practic

                      Comment


                        #12
                        Hello fx.practic,

                        We will be able to slow down a chart if we throw enough items to draw on it. This includes Execution Markers.

                        If you are designing a strategy that will likely create many executions in a partial fills and will commonly encounter partial filled orders between a few bars, then it would be best to run that strategy from the Control Center, or to disable execution markers.

                        I retested Force Partial Fills in Playback and on the Sim101 account and I did not see an issue where orders were not partially filling. If you are able to still encounter this, could you reach out to me via email and we can look more closely into that issue? Please email me at platformsupport [at] ninjartrader [dot] com with the text "Attn Jim," the ticket ID "2318817" and a link to this thread if that is the case.

                        I look forward to being of further assistance.
                        Last edited by NinjaTrader_Jim; 01-09-2020, 10:00 AM.
                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bmartz, 03-12-2024, 06:12 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_Zachary  
                        Started by Aviram Y, Today, 05:29 AM
                        4 responses
                        13 views
                        0 likes
                        Last Post Aviram Y  
                        Started by algospoke, 04-17-2024, 06:40 PM
                        3 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by gentlebenthebear, Today, 01:30 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by cls71, Today, 04:45 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X