Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to specify an instrument's Exchange in the API's Command function?

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

    How to specify an instrument's Exchange in the API's Command function?

    Certain instruments have the same symbol name on different exchanges. It appears that IB requires the Exchange and maybe even the Primary Exchange to be specified when trading these instruments, otherwise it returns an error saying it is basically too ambiguous.

    When using the API "Command" function, how can the instrument's Exchange be specified?

    From https://ninjatrader.com/support/help...functions.htm:
    int Command(string command, string account, string instrument, string action, int quantity, string o rderType, double limitPrice, double stopPrice,
    string timeInForce, string oco, string orderId, s tring strategy, string strategyId)

    Can the exchange be specified as a prefix to the "instrument" parameter? Ex: NASDAQ.Open or NASDAQ:Open or NASDAQ/Open
    ("Open", the symbol for Opendoor Technologies Inc, is a problematic for IB through NT not because it is on different exchanges but because it collides with a reserved keyword.)
    (I haven't tried the prefixes shown above to see if any will work because I wanted to get a complete definitive answer to the question.)

    Here is the only relevant info I could find at IB [https://interactivebrokers.github.io...ontracts.html] :
    Stocks
    • Contract contract = new Contract();
      contract.Symbol = "IBKR";
      contract.SecType = "STK";
      contract.Currency = "USD";
      //In the API side, NASDAQ is always defined as ISLAND in the exchange field
      contract.Exchange = "ISLAND";
    For certain smart-routed stock contracts that have the same symbol, currency and exchange, you would also need to specify the primary exchange attribute to uniquely define the contract. This should be defined as the native exchange of a contract, and is good practice to include for all stocks:
    • Contract contract = new Contract();
      contract.Symbol = "MSFT";
      contract.SecType = "STK";
      contract.Currency = "USD";
      contract.Exchange = "SMART";
      //Specify the Primary Exchange attribute to avoid contract ambiguity
      // (there is an ambiguity because there is also a MSFT contract with primary exchange = "AEB")
      contract.PrimaryExch = "ISLAND";
    For the purpose of requesting market data, the routing exchange and primary exchange can be specified in a single 'exchange' field if they are separated by a valid component exchange separator, for instance exchange = "SMART:ARCA". The default separators available are colon ":" and slash "/".

    #2
    Hello N4Apound,

    Thank you for your message.


    Unfortunately, the exchange cannot be customized from within NinjaTrader. The software will use the same exchange for all orders on an instrument and its data based on the Instrument's Settings in the Tools > Instruments window. This information is set automatically by the server.

    Please let me know if you have any additional questions.
    Justin D.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      105 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      53 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      35 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      38 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      74 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X