Currently utilizing the node-ib npm package, I am aiming to execute a Combination Order.
Here are the steps I followed:
Obtaining the contract IDs for both leg definitions.
Once the program successfully obtains the conId value for each leg, it is then included in the ComboLeg object.
Subsequently, the placeOrder() method is invoked with the contract and order objects.
var leg1 = { conId: c1, ratio: 1, action: "SELL", exchange: "SMART", openClose: 0, shortSaleSlot: 0, designatedLocation: "" } var leg2 = { conId: c2, ratio: 1, action: "BUY", exchange: "SMART", openClose: 0, shortSaleSlot: 0, designatedLocation: "" } var legs = [leg1, leg2]; ib.placeOrder( 6, ib.contract.combo("USD", "USD", "SMART", legs), ib.order.limit("BUY", 1, 1) ); ib.reqOpenOrders();
The values of c1 and c2 represent the conIds.
I encountered difficulty in adding comboLegs to the contract, hence I modified /node_modules/ib/lib/contract/combo.js by introducing a new argument into the function.
function combo(symbol, currency, exchange, comboLegs) {
assert(_.isString(symbol), 'Symbol must be a string.');
return {
currency: currency || 'USD',
exchange: exchange || 'SMART',
secType: 'BAG',
symbol: symbol,
comboLegs: comboLegs || []
};
}
The last argument signifies my modification.
Although no errors were reported, the combo order failed to appear on the Trader WorkStation.
In contrast, regular orders were successfully added to the Trader WorkStation without any issues.
If anyone has insights on how to include a combo order on the Trader WorkStation using API through this npm, your assistance would be greatly appreciated.
Thank you all:)