使用Java API(我想这适用于任何其他TWS Interactive Brokers客户端API)我收到错误“找不到请求的安全定义”常见问题解答和其他资源非常无益.
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);
解决方法:
这里的关键是contractId字段应该留空.使用contractId提交会导致安全性错误.