TWS Interactive Brokers API - How to Fix "No Security Definition found for request"?

Using the Java API (and, I think, this applies to any other TWS Interactive Brokers API). I get the error "There is no security definition for the request." Frequently asked questions and other resources were useless.

    Contract contract = new Contract();

    int id = incId;           

    System.out.println("Oder Id " + id );

    // use UTC seconds as transaction id

    // This is the problem you need to have a blank contractId
    contract.m_conId = 12345;
    contract.m_symbol = signal.symbol;
    contract.m_secType = "STK";
    contract.m_expiry = "";
    contract.m_strike = 0;
    contract.m_exchange = "SMART";
    contract.m_primaryExch = "ISLAND";
    contract.m_currency = "USD";

    //etc

    Order order = new Order();

    // set order fields
    order.m_account = "XXXXXX";
    order.m_orderId = id;
    //etc

    GetInstance().wrapper.m_client.placeOrder(id, contract, order);
+5
source share
5 answers

The key point here is that the contractId field should be empty. Sending using contractId causes a security error.

+4
source

Other possible causes of this error may include:

- ConId must be set to 0.

-The TradingClass .

- LocalSymbol GlobalSymbol.

- .

- .

+1

. :

https://pennies.interactivebrokers.com/cstools/contract_info/v3.9/index.php

, CL:

con.connect()

contract = Contract()
contract.m_symbol = "CL"
contract.m_exchange = ""
contract.m_currency = "USD"
contract.m_secType = "FUT"

con.reqContractDetails(1, contract)

time.sleep(2)

con.disconnect()
0

, , SecIdType SecId.

, :

IBApi.Order order = new IBApi.Order()
{
    Account = OrderCreationConfig.IndividualAccount
    , ClientId = OrderCreationConfig.OrderSlaveClientId //1
    , Action = orderNodeEntity.OrderAction //"BUY"
    , TotalQuantity = orderNodeEntity.NrOfStocks
    , OrderType = OrderCreationConfig.OrderTypeLMT //"LMT"
    , Tif = OrderCreationConfig.OrderTifGTC //"GTC"
    , OcaType = OrderCreationConfig.OcaTypeId //3
    , LmtPrice = price
    , AuxPrice = 0
    , TrailStopPrice = double.MaxValue
    , VolatilityType = 0
    , DeltaNeutralOrderType = "None"
};

IBApi.Contract contract = new IBApi.Contract()
{
      Symbol = orderNodeEntity.Symbol
     , SecType = OrderCreationConfig.ContractSecTypeSTK //"STK"
     , Strike = 0
     , Right = OrderCreationConfig.ContractRightQuestionMark //"?"
     , Exchange = OrderCreationConfig.ContractExchangeIsland //"ISLAND"
     , Currency = OrderCreationConfig.ContractCurrencyUSD //"USD"
     , LocalSymbol = orderNodeEntity.Symbol
     , TradingClass = null        
     , SecIdType = OrderCreationConfig.ContractSecIdTypeISIN //"ISIN"
     , SecId = this.GetISINCode(orderNodeEntity.Symbol) //"US0378331005" 
};
0

, "SMART".

My use case was to receive all the contracts that I currently hold and submit the MOC order. I got the contract using the reqPositions method, but the contracts in these return values ​​still threw this error.

Setting up an exchange on SMART under these contracts solved the problem for me.

0
source

All Articles