Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ib

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ib - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

lib/errors.js

8

index.js

@@ -1,7 +0,1 @@

/*
* index.js
*/
'use strict';
exports = module.exports = require('./lib');
module.exports = require('./lib');

@@ -1,7 +0,1 @@

/*
* lib/constants.js
*/
'use strict';
exports.VERSION = 'twsapi_macunix.970.01';

@@ -8,0 +2,0 @@

@@ -1,7 +0,1 @@

/*
* lib/contract/stock.js
*/
'use strict';
var assert = require('assert');

@@ -11,3 +5,3 @@

function stock(symbol, exchange, currency) {
module.exports = function (symbol, exchange, currency) {
assert(_.isString(symbol), 'Symbol must be a string.');

@@ -21,5 +15,2 @@

};
}
// Public API
module.exports = exports = stock;
};

@@ -1,7 +0,1 @@

/*
* lib/contract/combo.js
*/
'use strict';
var assert = require('assert');

@@ -11,3 +5,3 @@

function combo(symbol, currency, exchange) {
module.exports = function (symbol, currency, exchange) {
assert(_.isString(symbol), 'Symbol must be a string.');

@@ -21,5 +15,2 @@

};
}
// Public API
module.exports = exports = combo;
};

@@ -1,7 +0,1 @@

/*
* lib/contract/forex.js
*/
'use strict';
var assert = require('assert');

@@ -22,3 +16,3 @@

function forex(symbol, currency) {
module.exports = function (symbol, currency) {
assert(_.isString(symbol), 'Symbol must be a string.');

@@ -42,5 +36,2 @@ if (!_.isString(currency)) { currency = 'USD'; }

};
}
// Public API
module.exports = exports = forex;
};

@@ -1,7 +0,1 @@

/*
* lib/contract/future.js
*/
'use strict';
var assert = require('assert');

@@ -11,3 +5,3 @@

function future(symbol, expiry, currency, exchange) {
module.exports = function (symbol, expiry, currency, exchange) {
assert(_.isString(symbol), 'Symbol must be a string.');

@@ -23,5 +17,2 @@ assert(_.isString(expiry), 'Expiry must be a string.');

};
}
// Public API
module.exports = exports = future;
};

@@ -1,7 +0,1 @@

/*
* lib/contract/index.js
*/
'use strict';
exports.combo = require('./combo');

@@ -8,0 +2,0 @@ exports.forex = require('./forex');

@@ -1,7 +0,1 @@

/*
* lib/contract/option.js
*/
'use strict';
var assert = require('assert');

@@ -11,3 +5,3 @@

function option(symbol, expiry, strike, right, exchange, currency) {
module.exports = function (symbol, expiry, strike, right, exchange, currency) {
assert(_.isString(right), 'Right must be a string.');

@@ -28,5 +22,2 @@ assert(_.isString(symbol), 'Symbol must be a string.');

};
}
// Public API
module.exports = exports = option;
};

@@ -1,7 +0,1 @@

/*
* lib/contract/stock.js
*/
'use strict';
var assert = require('assert');

@@ -11,3 +5,3 @@

function stock(symbol, exchange, currency) {
module.exports = function (symbol, exchange, currency) {
assert(_.isString(symbol), 'Symbol must be a string.');

@@ -21,5 +15,2 @@

};
}
// Public API
module.exports = exports = stock;
};

@@ -1,16 +0,10 @@

/*
* lib/controller.js
*/
'use strict';
var util = require('util');
var _ = require('lodash'),
CommandBuffer = require('command-buffer');
var _ = require('lodash');
var CommandBuffer = require('command-buffer');
var C = require('./constants'),
Socket = require('./socket'),
Incoming = require('./incoming'),
Outgoing = require('./outgoing');
var C = require('./constants');
var Socket = require('./socket');
var Incoming = require('./incoming');
var Outgoing = require('./outgoing');

@@ -94,4 +88,4 @@ function Controller(ib, options) {

var eventOfArgs = args[0],
argsOfArgs = args.slice(1);
var eventOfArgs = args[0];
var argsOfArgs = args.slice(1);

@@ -125,3 +119,2 @@ if (!_.contains(['connected', 'disconnected', 'error', 'received', 'sent', 'server'], eventOfArgs)) {

// Public API
module.exports = exports = Controller;
module.exports = Controller;

@@ -1,7 +0,1 @@

/*
* lib/incoming.js
*/
'use strict';
var util = require('util');

@@ -12,2 +6,3 @@

var C = require('./constants');
var errors = require('./errors');

@@ -18,42 +13,43 @@ function Incoming(controller) {

this._dataQueue = [];
this._emitQueue = [];
}
Incoming.prototype._ACCT_DOWNLOAD_END = function () {
var version = this.dequeueInt(),
accountName = this.dequeue();
var version = this.dequeueInt();
var accountName = this.dequeue();
this._controller.emit('accountDownloadEnd', accountName);
this._emit('accountDownloadEnd', accountName);
};
Incoming.prototype._ACCOUNT_SUMMARY = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt(),
account = this.dequeue(),
tag = this.dequeue(),
value = this.dequeue(),
currency = this.dequeue();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
var account = this.dequeue();
var tag = this.dequeue();
var value = this.dequeue();
var currency = this.dequeue();
this._controller.emit('accountSummary', reqId, account, tag, value, currency);
this._emit('accountSummary', reqId, account, tag, value, currency);
};
Incoming.prototype._ACCOUNT_SUMMARY_END = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
this._controller.emit('accountSummaryEnd', reqId);
this._emit('accountSummaryEnd', reqId);
};
Incoming.prototype._ACCT_UPDATE_TIME = function () {
var version = this.dequeueInt(),
timeStamp = this.dequeue();
var version = this.dequeueInt();
var timeStamp = this.dequeue();
this._controller.emit('updateAccountTime', timeStamp);
this._emit('updateAccountTime', timeStamp);
};
Incoming.prototype._ACCT_VALUE = function () {
var version = this.dequeueInt(),
key = this.dequeue(),
value = this.dequeue(),
currency = this.dequeue(),
accountName = null;
var version = this.dequeueInt();
var key = this.dequeue();
var value = this.dequeue();
var currency = this.dequeue();
var accountName = null;

@@ -64,3 +60,3 @@ if (version >= 2) {

this._controller.emit('updateAccountValue', key, value, currency, accountName);
this._emit('updateAccountValue', key, value, currency, accountName);
};

@@ -79,9 +75,9 @@

this._controller.emit('commissionReport', commissionReport);
this._emit('commissionReport', commissionReport);
};
Incoming.prototype._BOND_CONTRACT_DATA = function () {
var version = this.dequeueInt(),
reqId = -1,
i;
var version = this.dequeueInt();
var reqId = -1;
var i;

@@ -134,4 +130,4 @@ if (version >= 3) {

var secIdListCount,
tagValue;
var secIdListCount;
var tagValue;

@@ -153,8 +149,8 @@ if (version >= 5) {

this._controller.emit('bondContractDetails', reqId, contract);
this._emit('bondContractDetails', reqId, contract);
};
Incoming.prototype._CONTRACT_DATA = function () {
var version = this.dequeueInt(),
reqId = -1;
var version = this.dequeueInt();
var reqId = -1;

@@ -213,5 +209,5 @@ if (version >= 3) {

var secIdListCount,
tagValue,
i;
var secIdListCount;
var tagValue;
var i;

@@ -231,22 +227,22 @@ if (version >= 7) {

this._controller.emit('contractDetails', reqId, contract);
this._emit('contractDetails', reqId, contract);
};
Incoming.prototype._CONTRACT_DATA_END = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
this._controller.emit('contractDetailsEnd', reqId);
this._emit('contractDetailsEnd', reqId);
};
Incoming.prototype._CURRENT_TIME = function () {
var version = this.dequeueInt(),
time = this.dequeueInt();
var version = this.dequeueInt();
var time = this.dequeueInt();
this._controller.emit('currentTime', time);
this._emit('currentTime', time);
};
Incoming.prototype._DELTA_NEUTRAL_VALIDATION = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();

@@ -258,10 +254,10 @@ var underComp = {};

this._controller.emit('deltaNeutralValidation', reqId, underComp);
this._emit('deltaNeutralValidation', reqId, underComp);
};
Incoming.prototype._ERR_MSG = function () {
var errorCode,
errorMsg,
id,
version = this.dequeueInt();
var errorCode;
var errorMsg;
var id;
var version = this.dequeueInt();

@@ -355,26 +351,26 @@ if (version < 2) {

this._controller.emit('execDetails', reqId, contract, exec);
this._emit('execDetails', reqId, contract, exec);
};
Incoming.prototype._EXECUTION_DATA_END = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
this._controller.emit('execDetailsEnd', reqId);
this._emit('execDetailsEnd', reqId);
};
Incoming.prototype._FUNDAMENTAL_DATA = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt(),
data = this.dequeue();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
var data = this.dequeue();
this._controller.emit('fundamentalData', reqId, data);
this._emit('fundamentalData', reqId, data);
};
Incoming.prototype._HISTORICAL_DATA = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt(),
startDateStr,
endDateStr,
completedIndicator = 'finished';
var version = this.dequeueInt();
var reqId = this.dequeueInt();
var completedIndicator = 'finished';
var startDateStr;
var endDateStr;

@@ -387,12 +383,12 @@ if (version >= 2) {

var itemCount = this.dequeueInt(),
date,
open,
high,
low,
close,
volume,
WAP,
hasGaps,
barCount;
var itemCount = this.dequeueInt();
var date;
var open;
var high;
var low;
var close;
var volume;
var WAP;
var hasGaps;
var barCount;

@@ -414,64 +410,64 @@ while (itemCount--) {

this._controller.emit('historicalData', reqId, date, open, high, low, close, volume, barCount, WAP, hasGaps);
this._emit('historicalData', reqId, date, open, high, low, close, volume, barCount, WAP, hasGaps);
}
// send end of dataset marker
this._controller.emit('historicalData', reqId, completedIndicator, -1, -1, -1, -1, -1, -1, -1, false);
this._emit('historicalData', reqId, completedIndicator, -1, -1, -1, -1, -1, -1, -1, false);
};
Incoming.prototype._MANAGED_ACCTS = function () {
var version = this.dequeueInt(),
accountsList = this.dequeue();
var version = this.dequeueInt();
var accountsList = this.dequeue();
this._controller.emit('managedAccounts', accountsList);
this._emit('managedAccounts', accountsList);
};
Incoming.prototype._MARKET_DATA_TYPE = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt(),
marketDataType = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
var marketDataType = this.dequeueInt();
this._controller.emit('marketDataType', reqId, marketDataType);
this._emit('marketDataType', reqId, marketDataType);
};
Incoming.prototype._MARKET_DEPTH = function () {
var version = this.dequeueInt(),
id = this.dequeueInt(),
position = this.dequeueInt(),
operation = this.dequeueInt(),
side = this.dequeueInt(),
price = this.dequeueFloat(),
size = this.dequeueInt();
var version = this.dequeueInt();
var id = this.dequeueInt();
var position = this.dequeueInt();
var operation = this.dequeueInt();
var side = this.dequeueInt();
var price = this.dequeueFloat();
var size = this.dequeueInt();
this._controller.emit('updateMktDepth', id, position, operation, side, price, size);
this._emit('updateMktDepth', id, position, operation, side, price, size);
};
Incoming.prototype._MARKET_DEPTH_L2 = function () {
var version = this.dequeueInt(),
id = this.dequeueInt(),
position = this.dequeueInt(),
marketMaker = this.dequeue(),
operation = this.dequeueInt(),
side = this.dequeueInt(),
price = this.dequeueFloat(),
size = this.dequeueInt();
var version = this.dequeueInt();
var id = this.dequeueInt();
var position = this.dequeueInt();
var marketMaker = this.dequeue();
var operation = this.dequeueInt();
var side = this.dequeueInt();
var price = this.dequeueFloat();
var size = this.dequeueInt();
this._controller.emit('updateMktDepthL2', id, position, marketMaker, operation, side, price, size);
this._emit('updateMktDepthL2', id, position, marketMaker, operation, side, price, size);
};
Incoming.prototype._NEWS_BULLETINS = function () {
var version = this.dequeueInt(),
newsMsgId = this.dequeueInt(),
newsMsgType = this.dequeueInt(),
newsMessage = this.dequeue(),
originatingExch = this.dequeue();
var version = this.dequeueInt();
var newsMsgId = this.dequeueInt();
var newsMsgType = this.dequeueInt();
var newsMessage = this.dequeue();
var originatingExch = this.dequeue();
this._controller.emit('updateNewsBulletin', newsMsgId, newsMsgType, newsMessage, originatingExch);
this._emit('updateNewsBulletin', newsMsgId, newsMsgType, newsMessage, originatingExch);
};
Incoming.prototype._NEXT_VALID_ID = function () {
var version = this.dequeueInt(),
orderId = this.dequeueInt();
var version = this.dequeueInt();
var orderId = this.dequeueInt();
this._controller.emit('nextValidId', orderId);
this._emit('nextValidId', orderId);
};

@@ -672,7 +668,7 @@

var comboLeg,
comboLegsCount,
orderComboLeg,
orderComboLegsCount,
price;
var comboLeg;
var comboLegsCount;
var orderComboLeg;
var orderComboLegsCount;
var price;

@@ -712,4 +708,4 @@ if (version >= 29) {

var smartComboRoutingParamsCount,
tagValue;
var smartComboRoutingParamsCount;
var tagValue;

@@ -784,4 +780,4 @@ if (version >= 26) {

var algoParamsCount,
tagValue;
var algoParamsCount;
var tagValue;

@@ -822,3 +818,3 @@ if (version >= 21) {

this._controller.emit('openOrder', order.orderId, contract, order, orderState);
this._emit('openOrder', order.orderId, contract, order, orderState);
};

@@ -829,12 +825,12 @@

this._controller.emit('openOrderEnd');
this._emit('openOrderEnd');
};
Incoming.prototype._ORDER_STATUS = function () {
var version = this.dequeueInt(),
id = this.dequeueInt(),
status = this.dequeue(),
filled = this.dequeueInt(),
remaining = this.dequeueInt(),
avgFillPrice = this.dequeueFloat();
var version = this.dequeueInt();
var id = this.dequeueInt();
var status = this.dequeue();
var filled = this.dequeueInt();
var remaining = this.dequeueInt();
var avgFillPrice = this.dequeueFloat();

@@ -871,3 +867,3 @@ var permId = 0;

this._controller.emit('orderStatus', id, status, filled, remaining, avgFillPrice,
this._emit('orderStatus', id, status, filled, remaining, avgFillPrice,
permId, parentId, lastFillPrice, clientId, whyHeld);

@@ -906,8 +902,8 @@ };

var position = this.dequeueInt(),
marketPrice = this.dequeueFloat(),
marketValue = this.dequeueFloat(),
averageCost = 0.0,
unrealizedPNL = 0.0,
realizedPNL = 0.0;
var position = this.dequeueInt();
var marketPrice = this.dequeueFloat();
var marketValue = this.dequeueFloat();
var averageCost = 0.0;
var unrealizedPNL = 0.0;
var realizedPNL = 0.0;

@@ -930,3 +926,3 @@ if (version >= 3) {

this._controller.emit('updatePortfolio', contract, position, marketPrice, marketValue,
this._emit('updatePortfolio', contract, position, marketPrice, marketValue,
averageCost, unrealizedPNL, realizedPNL, accountName);

@@ -936,5 +932,5 @@ };

Incoming.prototype._POSITION = function () {
var version = this.dequeueInt(),
account = this.dequeue(),
contract = {};
var version = this.dequeueInt();
var account = this.dequeue();
var contract = {};

@@ -955,4 +951,4 @@ contract.conId = this.dequeueInt();

var pos = this.dequeueInt(),
avgCost = 0;
var pos = this.dequeueInt();
var avgCost = 0;
if (version >= 3) {

@@ -962,3 +958,3 @@ avgCost = this.dequeueFloat();

this._controller.emit('position', account, contract, pos, avgCost);
this._emit('position', account, contract, pos, avgCost);
};

@@ -969,32 +965,32 @@

this._controller.emit('positionEnd');
this._emit('positionEnd');
};
Incoming.prototype._REAL_TIME_BARS = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt(),
time = this.dequeueInt(),
open = this.dequeueFloat(),
high = this.dequeueFloat(),
low = this.dequeueFloat(),
close = this.dequeueFloat(),
volume = this.dequeueInt(),
wap = this.dequeueFloat(),
count = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
var time = this.dequeueInt();
var open = this.dequeueFloat();
var high = this.dequeueFloat();
var low = this.dequeueFloat();
var close = this.dequeueFloat();
var volume = this.dequeueInt();
var wap = this.dequeueFloat();
var count = this.dequeueInt();
this._controller.emit('realtimeBar', reqId, time, open, high, low, close, volume, wap, count);
this._emit('realtimeBar', reqId, time, open, high, low, close, volume, wap, count);
};
Incoming.prototype._RECEIVE_FA = function () {
var version = this.dequeueInt(),
faDataType = this.dequeueInt(),
xml = this.dequeue();
var version = this.dequeueInt();
var faDataType = this.dequeueInt();
var xml = this.dequeue();
this._controller.emit('receiveFA', faDataType, xml);
this._emit('receiveFA', faDataType, xml);
};
Incoming.prototype._SCANNER_DATA = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
numberOfElements = this.dequeueInt();
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var numberOfElements = this.dequeueInt();

@@ -1025,6 +1021,6 @@ var contract = {

var distance = this.dequeue(),
benchmark = this.dequeue(),
projection = this.dequeue(),
legsStr = null;
var distance = this.dequeue();
var benchmark = this.dequeue();
var projection = this.dequeue();
var legsStr = null;

@@ -1035,29 +1031,29 @@ if (version >= 2) {

this._controller.emit('scannerData', tickerId, rank, contract, distance,
this._emit('scannerData', tickerId, rank, contract, distance,
benchmark, projection, legsStr);
}
this._controller.emit('scannerDataEnd', tickerId);
this._emit('scannerDataEnd', tickerId);
};
Incoming.prototype._SCANNER_PARAMETERS = function () {
var version = this.dequeueInt(),
xml = this.dequeue();
var version = this.dequeueInt();
var xml = this.dequeue();
this._controller.emit('scannerParameters', xml);
this._emit('scannerParameters', xml);
};
Incoming.prototype._TICK_EFP = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
tickType = this.dequeueInt(),
basisPoints = this.dequeueFloat(),
formattedBasisPoints = this.dequeue(),
impliedFuturesPrice = this.dequeueFloat(),
holdDays = this.dequeueInt(),
futureExpiry = this.dequeue(),
dividendImpact = this.dequeueFloat(),
dividendsToExpiry = this.dequeueFloat();
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var tickType = this.dequeueInt();
var basisPoints = this.dequeueFloat();
var formattedBasisPoints = this.dequeue();
var impliedFuturesPrice = this.dequeueFloat();
var holdDays = this.dequeueInt();
var futureExpiry = this.dequeue();
var dividendImpact = this.dequeueFloat();
var dividendsToExpiry = this.dequeueFloat();
this._controller.emit('tickEFP', tickerId, tickType, basisPoints, formattedBasisPoints,
this._emit('tickEFP', tickerId, tickType, basisPoints, formattedBasisPoints,
impliedFuturesPrice, holdDays, futureExpiry,

@@ -1068,15 +1064,15 @@ dividendImpact, dividendsToExpiry);

Incoming.prototype._TICK_GENERIC = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
tickType = this.dequeueInt(),
value = this.dequeueFloat();
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var tickType = this.dequeueInt();
var value = this.dequeueFloat();
this._controller.emit('tickGeneric', tickerId, tickType, value);
this._emit('tickGeneric', tickerId, tickType, value);
};
Incoming.prototype._TICK_OPTION_COMPUTATION = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
tickType = this.dequeueInt(),
impliedVol = this.dequeueFloat();
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var tickType = this.dequeueInt();
var impliedVol = this.dequeueFloat();

@@ -1093,8 +1089,8 @@ if (impliedVol < 0) { // -1 is the "not yet computed" indicator

var optPrice = Number.MAX_VALUE,
pvDividend = Number.MAX_VALUE,
gamma = Number.MAX_VALUE,
vega = Number.MAX_VALUE,
theta = Number.MAX_VALUE,
undPrice = Number.MAX_VALUE;
var optPrice = Number.MAX_VALUE;
var pvDividend = Number.MAX_VALUE;
var gamma = Number.MAX_VALUE;
var vega = Number.MAX_VALUE;
var theta = Number.MAX_VALUE;
var undPrice = Number.MAX_VALUE;

@@ -1141,11 +1137,11 @@ if (version >= 6 || tickType == C.TICK_TYPE.MODEL_OPTION) { // introduced in version == 5

this._controller.emit('tickOptionComputation', tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice);
this._emit('tickOptionComputation', tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice);
};
Incoming.prototype._TICK_PRICE = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
tickType = this.dequeueInt(),
price = this.dequeueFloat(),
size = 0;
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var tickType = this.dequeueInt();
var price = this.dequeueFloat();
var size = 0;

@@ -1162,3 +1158,3 @@ if (version >= 2) {

this._controller.emit('tickPrice', tickerId, tickType, price, canAutoExecute);
this._emit('tickPrice', tickerId, tickType, price, canAutoExecute);

@@ -1185,3 +1181,3 @@ var sizeTickType = -1;

if (sizeTickType != -1) {
this._controller.emit('tickSize', tickerId, sizeTickType, size);
this._emit('tickSize', tickerId, sizeTickType, size);
}

@@ -1192,28 +1188,36 @@ }

Incoming.prototype._TICK_SIZE = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
tickType = this.dequeueInt(),
size = this.dequeueInt();
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var tickType = this.dequeueInt();
var size = this.dequeueInt();
this._controller.emit('tickSize', tickerId, tickType, size);
this._emit('tickSize', tickerId, tickType, size);
};
Incoming.prototype._TICK_SNAPSHOT_END = function () {
var version = this.dequeueInt(),
reqId = this.dequeueInt();
var version = this.dequeueInt();
var reqId = this.dequeueInt();
this._controller.emit('tickSnapshotEnd', reqId);
this._emit('tickSnapshotEnd', reqId);
};
Incoming.prototype._TICK_STRING = function () {
var version = this.dequeueInt(),
tickerId = this.dequeueInt(),
tickType = this.dequeueInt(),
value = this.dequeue();
var version = this.dequeueInt();
var tickerId = this.dequeueInt();
var tickType = this.dequeueInt();
var value = this.dequeue();
this._controller.emit('tickString', tickerId, tickType, value);
this._emit('tickString', tickerId, tickType, value);
};
Incoming.prototype._emit = function () {
this._emitQueue.push(arguments);
};
Incoming.prototype.dequeue = function () {
return this._dataQueue.shift();
if (this._dataQueue.length == 0) {
throw new errors.UnderrunError();
}
var result = this._dataQueue.shift();
return result;
};

@@ -1238,16 +1242,39 @@

Incoming.prototype.process = function () {
var constKey,
token;
var constKey;
var token;
var dataQueueSnapshot;
while (token = this.dequeueInt()) {
constKey = this._controller._ib.util.incomingToString(token);
if (constKey && _.has(this.constructor.prototype, '_' + constKey) && _.isFunction(this['_' + constKey])) {
this['_' + constKey]();
} else {
this._controller.emitError('Unknown incoming first token: ' + token);
while (true) {
dataQueueSnapshot = this._dataQueue.slice();
try {
// Clear the Emit Queue; if this doesn't get cleared, it piles up whenever there's an error (added by heberallred)
this._emitQueue = [];
token = this.dequeueInt();
constKey = this._controller._ib.util.incomingToString(token);
if (constKey && _.has(this.constructor.prototype, '_' + constKey) && _.isFunction(this['_' + constKey])) {
this['_' + constKey]();
} else {
this._controller.emitError('Unknown incoming first token: ' + token);
}
} catch (e) {
if (!e instanceof errors.UnderrunError) {
throw e;
}
// Put data back in the queue, and don't emit any events.
this._dataQueue = this._dataQueue.concat(dataQueueSnapshot);
return;
}
// Drain _emitQueue.
var self = this;
var toEmit = this._emitQueue;
this._emitQueue = [];
_.forEach(toEmit, function (payload) {
self._controller.emit.apply(self._controller, payload);
});
}
};
// Public API
module.exports = exports = Incoming;
module.exports = Incoming;

@@ -1,15 +0,9 @@

/*
* lib/index.js
*/
var assert = require('assert');
var events = require('events');
var util = require('util');
'use strict';
var assert = require('assert'),
events = require('events'),
util = require('util');
var _ = require('lodash');
var C = require('./constants'),
Controller = require('./controller');
var C = require('./constants');
var Controller = require('./controller');

@@ -408,3 +402,2 @@ function IB(options) {

// Public API
module.exports = exports = IB;
module.exports = IB;

@@ -1,7 +0,1 @@

/*
* lib/order/index.js
*/
'use strict';
exports.limit = require('./limit');

@@ -8,0 +2,0 @@ exports.market = require('./market');

@@ -1,7 +0,1 @@

/*
* lib/order/limit.js
*/
'use strict';
var assert = require('assert');

@@ -11,3 +5,3 @@

function limit(action, quantity, price, transmitOrder) {
module.exports = function (action, quantity, price, transmitOrder) {
assert(_.isString(action), 'Action must be a string.');

@@ -28,5 +22,2 @@ assert(_.isNumber(quantity), 'Quantity must be a string.');

};
}
// Public API
module.exports = exports = limit;
};

@@ -1,7 +0,1 @@

/*
* lib/order/market.js
*/
'use strict';
var assert = require('assert');

@@ -11,6 +5,6 @@

function market(action, quantity, transmitOrder) {
assert(_.isString(action), 'Action must be a string.');
assert(_.isNumber(quantity), 'Quantity must be a string.');
module.exports = function (action, quantity, transmitOrder) {
assert(_.isString(action), 'Action must be a string.');
assert(_.isNumber(quantity), 'Quantity must be a string.');
if (transmitOrder === undefined) {

@@ -20,11 +14,8 @@ transmitOrder = true;

return {
action: action,
orderType: 'MKT',
totalQuantity: quantity,
transmit: transmitOrder
};
}
// Public API
module.exports = exports = market;
return {
action: action,
orderType: 'MKT',
totalQuantity: quantity,
transmit: transmitOrder
};
};

@@ -1,7 +0,1 @@

/*
* lib/order/stop.js
*/
'use strict';
var assert = require('assert');

@@ -11,7 +5,7 @@

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

@@ -21,12 +15,9 @@ transmitOrder = true;

return {
action: action,
auxPrice: price,
orderType: 'STP',
totalQuantity: quantity,
transmit: transmitOrder
};
}
// Public API
module.exports = exports = stop;
return {
action: action,
auxPrice: price,
orderType: 'STP',
totalQuantity: quantity,
transmit: transmitOrder
};
};

@@ -1,7 +0,1 @@

/*
* lib/order/stopLimit.js
*/
'use strict';
var assert = require('assert');

@@ -11,8 +5,8 @@

function stopLimit(action, quantity, limitPrice, stopPrice, transmitOrder) {
assert(_.isString(action), 'Action must be a string.');
assert(_.isNumber(quantity), 'Quantity must be a string.');
assert(_.isNumber(stopPrice), 'Stop price must be a number.');
assert(_.isNumber(limitPrice), 'Limit price must be a number.');
module.exports = function (action, quantity, limitPrice, stopPrice, transmitOrder) {
assert(_.isString(action), 'Action must be a string.');
assert(_.isNumber(quantity), 'Quantity must be a string.');
assert(_.isNumber(stopPrice), 'Stop price must be a number.');
assert(_.isNumber(limitPrice), 'Limit price must be a number.');
if (transmitOrder === undefined) {

@@ -22,13 +16,10 @@ transmitOrder = true;

return {
action: action,
lmtPrice: limitPrice,
auxPrice: stopPrice,
orderType: 'STP LMT',
totalQuantity: quantity,
transmit: transmitOrder
};
}
// Public API
module.exports = exports = stopLimit;
return {
action: action,
lmtPrice: limitPrice,
auxPrice: stopPrice,
orderType: 'STP LMT',
totalQuantity: quantity,
transmit: transmitOrder
};
};

@@ -1,7 +0,1 @@

/*
* lib/outgoing.js
*/
'use strict';
var _ = require('lodash');

@@ -577,4 +571,4 @@

var lower,
upper;
var lower;
var upper;

@@ -1299,3 +1293,2 @@ if (this._controller._serverVersion >= 19) {

// Public API
module.exports = exports = Outgoing;
module.exports = Outgoing;

@@ -1,10 +0,4 @@

/*
* lib/socket.js
*/
var net = require('net');
var util = require('util');
'use strict';
var net = require('net'),
util = require('util');
var _ = require('lodash');

@@ -24,2 +18,3 @@

this._waitingAsync = false;
this.dataFragment = ''; // Prevents partial packets from getting lost (added by heberallred)
}

@@ -31,9 +26,15 @@

this._controller.run('sendAsync', [C.CLIENT_VERSION]);
this._controller.run('sendAsync', [this._controller.options.clientId]);
this._controller.run('sendAsync', [C.CLIENT_VERSION, this._controller.options.clientId]);
};
Socket.prototype._onData = function (data) {
var tokens = data.toString().split(EOL).slice(0, -1);
var dataWithFragment = this.dataFragment + data.toString();
var tokens = dataWithFragment.split(EOL); //.slice(0, -1);
if (tokens[tokens.length-1] != ''){
this.dataFragment = tokens[tokens.length-1];
} else {
this.dataFragment = '';
}
tokens = tokens.slice(0, -1);
this._controller.emit('received', tokens.slice(0), data);

@@ -47,3 +48,2 @@

this._controller._serverConnectionTime = this._controller._incoming.dequeue();
this._controller.emit('server', this._controller._serverVersion, this._controller._serverConnectionTime);

@@ -130,3 +130,2 @@ }

// Public API
module.exports = exports = Socket;
module.exports = Socket;

@@ -1,7 +0,1 @@

/*
* lib/util.js
*/
'use strict';
var C = require('./constants');

@@ -39,3 +33,2 @@

// Public API
exports.incomingToString = incomingToString;

@@ -42,0 +35,0 @@ exports.numberToString = numberToString;

{
"name": "ib",
"description": "Interactive Brokers TWS (or IB Gateway) API client library for Node.js",
"version": "0.1.6",
"version": "0.1.7",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc