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

TWS Variable minimum price increment error (stock)

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

    TWS Variable minimum price increment error (stock)

    Dear forum,

    I have been trying to submit live limit orders to TWS (Traders Workstation) automatically using ninjascript. The problem is that occasionally the orders are rejected because they do not comply with the minimum price increment of the given instrument. I found out that that NinjaTrader does round the price of the orders you submit to the nearest valid tick size, which is specified in the corresponding instrument's configuration and by default set to 0.01. However, the stock instruments I am planning to trade (AEB) all have a complex tick size table, which specifies the tick size based on the current price of the instrument (see example below).

    Therefore, it is impossible to correct the minimum increment errors by filling in a specific single value in the instrument's configuration. I found out that the TWS API does have methods to request the minimum increment for instruments/contracts (see https://interactivebrokers.github.io...increment.html), but I could not find any documentation on NT's side. Is there any known way to retrieve the correct price increment, either from TWS or the internet? Or is there a logical underlying structure that can be hard-coded in ninjascript?

    Thank you for your consideration!

    Example tick size table (retrieved from the IB contract database: https://www.interactivebrokers.co.uk...ex.php?f=463):

    Click image for larger version

Name:	example_ticksize_table.png
Views:	296
Size:	31.7 KB
ID:	1047880
    Attached Files

    #2
    Hello frankrood,

    Thank you for the note.

    The TickSize property in NinjaScript is readonly, so it is not possible to vary the tick size of an instrument from within code. I will submit a feature request to have this functionality added in a future update so that we can support instruments that vary in tick size. Currently, the only way to change the tick size of an instrument would be Tools>Instruments>Double click the desired instrument>change the Tick Size field.

    Please let me know if I can assist further.

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      Thank you for your quick response. It would be great to see such a feature in the future, so thank you for submitting it to the dev team.

      As it is currently not possible to configure the TickSize property of the Instruments as coded in NinjaTrader, a different strategy is needed to submit orders to TWS with the correct tick size. As TWS has the correct tick size information available (according to the official TWS API reference, there is a function that can be used to request the correct tick size, see https://interactivebrokers.github.io...increment.html), there must be some way to access this information through NinjaTrader.

      My question is: Is there any way in which the tick size information from TWS can be accessed/retrieved in NinjaScript? As there already exists an API function for this specific purpose, is there a way to access this function in NinjaScript?

      Comment


        #4
        frankrood,

        Thank you for the reply.

        Yes, you can access the TickSize in NinjaScript but it is read-only. The request I submitted was to have that property editable through a script. Currently, it is not supported to change the tick size programmatically. Even though Interactive brokers provides an API call for this item, it does not mean that is implemented in the Interactive Brokers connection adapter for NinjaTrader (the code that runs when you connect to your IB account through the platform).

        I received the feature tracking ID for future reference:

        SFT-1212

        Please check the release notes upon each release to track added features:



        Please let me know if I can assist further.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X