pilwon / node-ib

Interactive Brokers TWS API client library for Node.js
382 stars 134 forks source link

Bracket orders #156

Open jajuanm2 opened 4 years ago

jajuanm2 commented 4 years ago

Anyone had any luck with bracket orders. I have it working but when you cancel the parent it does not cancel the two child orders. I set the parent order on the two child orders and that works fine.

jajuanm2 commented 4 years ago

Looks like the parent ID option is missing for some order types like limit or market.

jajuanm2 commented 4 years ago

I fixed it buy updating the limit order as follows

module.exports = function (action, quantity, price, transmitOrder, parentId) { assert(.isString(action), 'Action must be a string.'); assert(.isNumber(quantity), 'Quantity must be a number.'); assert(_.isNumber(price), 'Price must be a number.');

if (transmitOrder === undefined) { transmitOrder = true; }

return { action: action, lmtPrice: price, orderType: 'LMT', totalQuantity: quantity, transmit: transmitOrder, parentId: parentId || 0 }; };