Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

onExecution Price Format Bug with IB

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

    onExecution Price Format Bug with IB

    Using IB, there is a bug with respect to price format in the callback for executions. It (sometimes) is off by a factor of 100. For example, Trading ZC, everything is quoted as 650 1/4. In reality, corn really trades at 6.5025, but all charts and data (i.e. bid/ask/trade data from onBarUpdate or onMarketData) will multiply this number by 100 to get the usual format for this contract of 650 1/4. Accordingly, the tick size is 0.25 (as opposed to 0.0025), and the point value is $50 (as opposed to $5000).

    I received an execution on ZC at 647, and the execution.price came through as 6.47. It was not multiplied by 100 as it should have been. The issue is I did math on this number (expecting 647, like all of the other callbacks) and obviously got an erroneous result. A subsequent order was rejected and I was able to get out at a small loss because I noticed the issue right away, but it could have been much worse had I not been glued to the screen.

    I could live with it (although it is not the expected behaviour) if it always gave you the execution price in the same format, but it does not. Sometimes it is multiplied by 100, other times it is not. I've confirmed this in simulation as well.

    For now, I'm going to implement a workaround at the top of onExecution, if price is less than 25, multiply it by 100, else do nothing --- as long as corn or wheat do not trade below twenty five cents, I should be covered.

    Obviously, NT should handle all of this behind the scenes...please investigate and advise. Let me know if you have trouble recreating this. Thanks,

    kc

    #2
    Just did some more testing...to clarify...I do not have to multiply by 100 in simulation, but do have to multiply by 100 in live mode. Not sure at this point if it is intermittent or not...I think I was running a live strategy alongside a sim strategy and the prints were intermixed so I thought it was only happening sometimes. In reality, I think it is just a sim vs. live difference with the callback, which definitely is a bug if you ask me...

    Comment


      #3
      Hello,

      Thanks for the forum post.

      Yes this is correct, you ran into an IB API bug that they are actually sending the order execution price back in the wrong format that is not consistent with the format they send the data out as. We have presented this to them and we do not know if or when this bug will be resolved unfortunately at this time.

      Therefor we are awaiting development on IB's side to correct the issue.

      Instruments we have seen this occur on is: ZC, ZW and ZS
      BrettNinjaTrader Product Management

      Comment


        #4
        Ok, here is a response from IB's API Support team:

        All API programs connect at backend of the Trader Workstation. In this particular case, both the TWS and API receive the same raw data. However, TWS has to convert some of the future contracts (ZW, ZC, and ZS) from decimal number to fraction format. Below, it is an example from my API program and TWS. For this type of contracts your API program must convert the value to fraction in attempt to make it identical with the TWS.
        They are indicating that the API receives and sends out market data in the decimal format, and that they only convert it (i.e. multiply by 100) in order to display it in TWS. But that converted data is then being sent out through the API it appears. It is true that ZW, ZS, and ZC actually have multipliers (point values) of 5000 in reality per their contract specs. 1 contract of ZW is for 5000 bushels of wheat at $6.5025 per bushel. However, it is common to quote them with point values of 50 (thus multiplied by 100), and that is how these contracts are setup in the Instrument manager. IB also reports the position (i.e. Position.AvgPrice) in the decimal form, and thus NT calculates all of the unrealized PnL incorrectly as well.

        They have asked me to provide an example of this, which I can't really do on my side through NT (b/c at that point they will argue that NT did not process the data correctly). Can someone on the support team run a quick IB API test to prove to them that they are sending out quotes with the data multiplied by 100 and executions and average prices that are not multiplied by 100?

        Comment


          #5
          Hello,

          We have already submitted this in to IB API support and they already have it on their list. However users running into the same issue with more reports will most likely increase the chances of it getting resolved quicker.

          Please see this proof of output from NinjaTrader and IP API program. You can see here that the order state receives the fill price in XXXX.XX format. Then you can see the execution price is recieved from IB as price XX.XXXX.


          9/30/2011 10:31:00 AM|1|32|Order='1748685163/XXXXX' Name='Short Entry' New state=Filled Instrument='ZS 11-11' Action=SellShort Limit price=0 Stop price=0 Quantity=1 Filled=1 Fill price=1197.25 Error=NoError Native error=''




          9/30/2011 10:31:00 AM|1|16|Execution='ZS 11-11/0000ee6c.4e84f3f1.01.01' Instrument='ZS 11-11' Account='XXXXXX' Exchange=ECbot Price=11.9725 Quantity=1 Market position=Short Operation=Insert Order='XXXXXX' Time='9/30/2011 10:31:00 AM'
          BrettNinjaTrader Product Management

          Comment


            #6
            Thanks Brett. I have sent this example along and will update this thread when I hear back.

            Comment


              #7
              Corn volume

              I have an issue with volume in Corn data from IB. When I reload my pit session chart intraday, about half the volume dissapears. I have had this happen several times and was wondering if this is related to the issue reported here?

              Mpe

              Comment


                #8
                Hello,

                Would not be related to this issue. Would actually be related to this forum thread:

                http://www.ninjatrader.com/support/f...t=25700&page=6

                Where this is a limitation of the IB API and there is unfortunately nothing on Ninja Traders side that can be done to correct it.

                -Brett
                BrettNinjaTrader Product Management

                Comment


                  #9
                  I have noticed similar dollars/cents conversion problems on instruments LE and HE. However, I note that the two NinjaTrader APIs IOrder.AvgFillPrice in OnExecution and Position.AvgPrice in OnBarUpdate give two different results, one multiplied by 100 and the other not. Are you sure you're not doing some conversion of your own inside NT?

                  Comment


                    #10
                    Hello,

                    Development isolated this and no we are not doing any multiplication. Otherwise all instruments would be affected.

                    Furthermore you found the exact cause of the problem.

                    Order fill price is correct, therefor iOrder object fill price would be correct. However the execution report which we use for the Position.AvgPrice comes back from IB in a different format which throws of position reporting.

                    NT expects the execution report to have the same format as the instrument and it simply isnt the case on these instruments. There is no update on IB on the status of this.

                    KC Trader were you ever able to get any more information from them on this when you checked into it?

                    -Brett
                    BrettNinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by digo098, Yesterday, 11:54 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post digo098
                    by digo098
                     
                    Started by digo098, Yesterday, 11:41 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post digo098
                    by digo098
                     
                    Started by Robeeq, Yesterday, 06:41 PM
                    0 responses
                    25 views
                    0 likes
                    Last Post Robeeq
                    by Robeeq
                     
                    Started by suprsnipes, Today, 02:24 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post suprsnipes  
                    Started by Giorgetto, Today, 02:15 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Giorgetto  
                    Working...
                    X