Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fill prices not on tick increments

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

    Fill prices not on tick increments

    Hello,

    I'm doing backtesting on FGBS. I might be missing something obvious, but why does the fill engine allow fill prices which aren't on tick increments. E.g. buy limit order submitted for 109.505, fill price is 109.507. Tick Size is 0.005. See attached examples.

    thanks
    Dave
    Attached Files

    #2
    Hello,

    Thanks for the forum post.

    You are looking at the Average Price column and not the fill price of that exact trade. The average price is why you will see this since it is a simple average of entry prices.

    Have a great rest of the day.

    Comment


      #3
      Hi, thanks for the reply. There is only one contract per trade, so the everage price should be identical to the fill price.

      Comment


        #4
        Hello,

        You would need to check your code then.

        You will see that the time this occurred there were two buys on FGBL at the same time with two different entry names.

        -Brett

        Comment


          #5
          Hi Brett,

          I'm not sure why this would need my code checking. This is a question about what the fill engine is doing. I'm just submitting an order. Also, I don't see duplicate buys - look at my example, on 15/09 - only one trade.

          Comment


            #6
            Hello,

            I checked again I see the duplicate buy.

            Two buys in the same direction would average giving you a value that is an average. This average does not have to be a tick size increment and the answer to your question is this is expected with the fill engine and more precisely this isn't the fill engine doing this, Its the average price column.

            To clarify again, if you want to look at what the fill engine is doing you need to be in the executions tab looking at the exact execution data. Not averaged data on the trades tab.

            -Brett

            Comment


              #7
              If there is a duplicate buy entry then please tell me which two lines.

              OK, let me take a different approach. The executions tab confirms that the execution is at a tick increment. But the trades tab, and consequently the P&L has an entry price which is not the same as the exection. There is only ONE entry, for ONE contract, so no chance of an average price being different to the entry price. If you don't believe that, take a look at the attached trades and execs, and you will clearly see the first one, on 27/07 has an exec price of 108.270, but a trade entry price of 108.269

              I know what this is related to, and how to fix it (the limit price specified originally is 108.269. which is not a problem for market orders) but the behaviour of the trade tab and the P&L is quite clearly wrong.
              Attached Files

              Comment


                #8
                please see screenshot below where I see the two entries to explain this.
                Attached Files

                Comment


                  #9
                  Brett,

                  I completely fail to see how you could see those as duplicates, for the following reasons.

                  1. They are 16 days apart
                  2. The second one is an exit, not an entry
                  3. The average of the execution prices 109.455 and 109.505 is nowhere near 109.507

                  Furthermore,. and correct me if I'm wrong, but I would expect the average price of an order to be the average of all the executions for filling that order. So if the quantity is one contract and that's the minimum tradeable, then the average price for that order must be the same as the fill price and it's irrelevent whether there are other orders next to it that look the same.

                  Comment


                    #10
                    Hello,

                    Looking closer your results I'm having issue matching up the results to what you say. Believe I would need to replicate your results on my side at this point as from your screenshot you originally provided with the issue. All the actions are buy's from what I see which would lead me to believe that technically you would be in a 10L or more position according to what I'm seeing as there are no exits in this screenshot. They are all Buys with the buy name of LE's which mean long entries.

                    Please send in your steps to reproduce this with your strategy and send this into support at ninjatrader dot com ATTN: Brett so I can look closer into this.

                    -Brett

                    Comment


                      #11
                      Brett,

                      See the scrollbar icon? That's not a full list of entries and exits. I provided the list just to show that the limit price and average price were different even for a a one contract order. See my previous post, that is the key point.

                      To reproduce, although the screenshots kind of prove the point, do a load of limit entries, one contract, exit an hour later, and make sure limit prices are not on a tick boundary. I don't know if it matters, but it's an unmnanaged strategy.

                      Comment


                        #12
                        Furthermore did some more research on the fill type:

                        else if (order.OrderType == OrderType.Limit)
                        {
                        // Orders are filled when traded through the limit price not at the limit price
                        double nextLow = NextLow;
                        double nextHigh = NextHigh;
                        if ((order.OrderAction == Cbi.OrderAction.Buy && order.LimitPrice > nextLow + epsilon)
                        || (order.OrderAction == Cbi.OrderAction.BuyToCover && order.LimitPrice > nextLow + epsilon)
                        || (order.OrderAction == Cbi.OrderAction.Sell && order.LimitPrice < nextHigh - epsilon)
                        || (order.OrderAction == Cbi.OrderAction.SellShort && order.LimitPrice < nextHigh - epsilon))
                        FillPrice = order.LimitPrice; // set fill price

                        }


                        You can see here that FillPrice = order.LimitPrice in some scenarios. If you feed it a limit price that is not valid it will cause the fill to fill at that price on backtests. You would need to use Instrument.Round2TickSize() on your limit order submits to make sure you are submitting them at the correct limit price.

                        -Brett

                        Comment


                          #13
                          Brett,

                          I think you're missing the point. The fill price is correct, as shown on the executions. This is what you would expect the sim engine to do - to fill at a price that can exist. The wrong fill price is then assigned to the order, and that wrong fill price is then used on the order tab and the trades tab so making the P&L incorrect.

                          It's rather worrying that those values aren't assigned correctly - it doesn't look very robust to me.

                          Comment


                            #14
                            Thanks for the feedback.

                            Sent into development.

                            -Brett

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Aviram Y, Today, 05:29 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post Aviram Y  
                            Started by quantismo, 04-17-2024, 05:13 PM
                            3 responses
                            25 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by ScottWalsh, 04-16-2024, 04:29 PM
                            7 responses
                            34 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by cls71, Today, 04:45 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post cls71
                            by cls71
                             
                            Started by mjairg, 07-20-2023, 11:57 PM
                            3 responses
                            216 views
                            1 like
                            Last Post PaulMohn  
                            Working...
                            X