@stoqey/ibkr
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -23,3 +23,3 @@ "use strict"; | ||
ib.on('contractDetails', handleContract); | ||
ib.once('contractDetailsEnd', function (reqIdX) { | ||
ib.on('contractDetailsEnd', function (reqIdX) { | ||
if (reqId === reqIdX) { | ||
@@ -26,0 +26,0 @@ ib.off('contractDetails', handleContract); |
@@ -253,3 +253,3 @@ "use strict"; | ||
}; | ||
self.ib.once('openOrderEnd', function () { | ||
self.ib.on('openOrderEnd', function () { | ||
var openOrders = Object.keys(openedOrders).map(function (key) { return openedOrders[key]; }); | ||
@@ -256,0 +256,0 @@ handleOpenOrders(openOrders); |
@@ -70,3 +70,3 @@ "use strict"; | ||
// We are in profit | ||
log_1.log("logPortfolio:profit shares = " + position + ", costPerShare -> " + averageCost + " marketPrice -> " + marketPrice + " ", contractIdWithSymbol); | ||
log_1.verbose("logPortfolio:profit shares = " + position + ", costPerShare -> " + averageCost + " marketPrice -> " + marketPrice + " ", contractIdWithSymbol); | ||
} | ||
@@ -153,2 +153,3 @@ else { | ||
appEvents.off('position', handlePosition); | ||
log_1.verbose('getPortfolios positionEnd', "********************** =", portfoliosData && portfoliosData.length); | ||
self.currentPortfolios = portfoliosData; | ||
@@ -162,8 +163,11 @@ IbkrEvents_publisher_1.publishDataToTopic({ | ||
}; | ||
ib.once('positionEnd', function () { | ||
var positionEnd = function () { | ||
if (done) { | ||
return; | ||
} | ||
var portfoliosData = Object.keys(portfolios).map(function (portfolioKey) { return portfolios[portfolioKey]; }); | ||
log_1.log('getPortfolios positionEnd', "********************** ="); | ||
log_1.log('getPortfolios positionEnd', "********************** " + (portfoliosData && portfoliosData.length) + " symbols=" + portfoliosData.map(function (u) { return u.localSymbol; })); | ||
handlePositionEnd(portfoliosData); | ||
}); | ||
ib.off('positionEnd', positionEnd); | ||
}; | ||
ib.on('positionEnd', positionEnd); | ||
ib.on('position', handlePosition); | ||
@@ -170,0 +174,0 @@ ib.reqPositions(); |
@@ -64,2 +64,3 @@ "use strict"; | ||
function PriceUpdates() { | ||
var _this = this; | ||
this.subscribers = {}; | ||
@@ -72,5 +73,7 @@ this.subscribersWithTicker = []; | ||
*/ | ||
ibEvents.on(events_1.IBKREVENTS.SUBSCRIBE_PRICE_UPDATES, function (data) { | ||
that.subscribe(data); | ||
}); | ||
ibEvents.on(events_1.IBKREVENTS.SUBSCRIBE_PRICE_UPDATES, function (data) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, that.subscribe(data)]; | ||
}); | ||
}); }); | ||
/** | ||
@@ -80,5 +83,7 @@ * When request to unsubscribe to market data | ||
*/ | ||
ibEvents.on(events_1.IBKREVENTS.UNSUBSCRIBE_PRICE_UPDATES, function (data) { | ||
that.unsubscribe(data); | ||
}); | ||
ibEvents.on(events_1.IBKREVENTS.UNSUBSCRIBE_PRICE_UPDATES, function (data) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, that.unsubscribe(data)]; | ||
}); | ||
}); }); | ||
} | ||
@@ -133,6 +138,7 @@ Object.defineProperty(PriceUpdates, "Instance", { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var ib, opt, contractArg, tickType, that, symbol, contractObj, contract, includesForexOrOpt; | ||
var that, ib, opt, contractArg, tickType, symbol, contractObj, contract, includesForexOrOpt; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
that = this; | ||
ib = connection_1.IBKRConnection.Instance.getIBKR(); | ||
@@ -142,3 +148,3 @@ opt = args && args.opt; | ||
if (isEmpty_1.default(contractArg)) { | ||
return [2 /*return*/, log_1.verbose('contract is not defined', contractArg)]; | ||
return [2 /*return*/]; // verbose('contract is not defined', contractArg); | ||
} | ||
@@ -150,5 +156,4 @@ // If string, create stock contract as default | ||
tickType = (args && args.tickType) || (opt && opt.tickType) || 'ASK'; | ||
that = this; | ||
symbol = (contractArg && contractArg.symbol) || contractArg; | ||
log_1.log('contract before getting details', contractArg); | ||
log_1.log('contract before getting details', symbol); | ||
return [4 /*yield*/, contracts_1.getContractDetails(contractArg)]; | ||
@@ -176,3 +181,3 @@ case 1: | ||
// Check if we already have the symbol | ||
if (this.subscribers[symbol]) { | ||
if (that.subscribers[symbol]) { | ||
// symbol is already subscribed | ||
@@ -184,3 +189,3 @@ return [2 /*return*/, log_1.verbose('PriceUpdates.subscribe', symbol.toLocaleUpperCase() + " is already subscribed")]; | ||
// Add this symbol to subscribersTicker | ||
this.subscribersWithTicker.push(__assign({ symbol: symbol, tickerId: that.subscribers[symbol], tickType: tickType }, contract)); | ||
this.subscribersWithTicker.push(__assign(__assign({}, contract), { symbol: symbol, tickerId: that.subscribers[symbol], tickType: tickType })); | ||
setImmediate(function () { | ||
@@ -187,0 +192,0 @@ that.ib.reqMktData(that.subscribers[symbol], contract, '', false, false); |
@@ -42,3 +42,3 @@ "use strict"; | ||
}); | ||
ib.once('scannerDataEnd', handleScannerData); | ||
ib.on('scannerDataEnd', handleScannerData); | ||
ib.reqScannerSubscription(randomTicker, { | ||
@@ -45,0 +45,0 @@ instrument: instrument, |
{ | ||
"name": "@stoqey/ibkr", | ||
"private": false, | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "NodeJS Interactive Brokers wrapper & utilities", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
263409
2761