Skip to content

Commit

Permalink
Update Java ref, reqHistoricalData, reqMktData. (#106)
Browse files Browse the repository at this point in the history
* Update reqMktData and reqHistoricalData, refresh ref
* Package-lock bump
* Update constants
* Update docs
  • Loading branch information
zgsrc authored and pilwon committed Jul 11, 2017
1 parent af1761c commit 1e90f73
Show file tree
Hide file tree
Showing 88 changed files with 12,021 additions and 6,197 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ ib.connect()
.reqExecutions(reqId, filter)
.reqFundamentalData(reqId, contract, reportType)
.reqGlobalCancel()
.reqHistoricalData(tickerId, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate)
.reqHistoricalData(tickerId, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate)
.reqIds(numIds)
.reqManagedAccts()
.reqMarketDataType(marketDataType)
.reqMktData(tickerId, contract, genericTickList, snapshot)
.reqMktData(tickerId, contract, genericTickList, snapshot, regulatorySnapshot)
.reqMktDepth(tickerId, contract, numRows)
.reqNewsBulletins(allMsgs)
.reqOpenOrders()
Expand Down
17 changes: 14 additions & 3 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,19 @@ exports.MIN_SERVER_VER = {
REQ_HISTORICAL_NEWS : 117,
REQ_HEAD_TIMESTAMP : 118,
REQ_HISTOGRAM : 119,
SERVICE_DATA_TYPE : 120
SERVICE_DATA_TYPE : 120,
AGG_GROUP : 121,
UNDERLYING_INFO : 122,
CANCEL_HEADTIMESTAMP : 123,
SYNT_REALTIME_BARS : 124,
CFD_REROUTE : 125,
MARKET_RULES : 126,
PNL : 127,
NEWS_QUERY_ORIGINS : 128,
SERVER_VER_UNREALIZED_PNL : 129
};



exports.BAG_SEC_TYPE = 'BAG';

// FA msg data types
Expand Down Expand Up @@ -318,7 +328,8 @@ exports.TICK_TYPE = {
DELAYED_MODEL_OPTION:83,
LAST_EXCH:84,
LAST_REG_TIME:85,
NOT_SET:86
FUTURES_OPEN_INTEREST:86,
UNKNOWN:2147483647
};

exports.EXERCISE_ACTION = {
Expand Down
10 changes: 6 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ IB.prototype.reqSecDefOptParams = function(reqId, underlyingSymbol, futFopExchan


IB.prototype.reqHistoricalData = function (tickerId, contract, endDateTime, durationStr,
barSizeSetting, whatToShow, useRTH, formatDate) {
barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate) {
assert(_.isNumber(tickerId), '"tickerId" must be an integer - ' + tickerId);
assert(_.isPlainObject(contract), '"contract" must be a plain object - ' + contract);
assert(_.isString(endDateTime), '"endDateTime" must be a string - ' + endDateTime);
Expand All @@ -279,9 +279,10 @@ IB.prototype.reqHistoricalData = function (tickerId, contract, endDateTime, dura
assert(_.isString(whatToShow), '"whatToShow" must be a string - ' + whatToShow);
assert(_.isNumber(useRTH), '"useRTH" must be an integer - ' + useRTH);
assert(_.isNumber(formatDate), '"formatDate" must be an integer - ' + formatDate);
assert(_.isBoolean(keepUpToDate), '"keepUpToDate" must be an boolean - ' + keepUpToDate);

this._send('reqHistoricalData', tickerId, contract, endDateTime, durationStr,
barSizeSetting, whatToShow, useRTH, formatDate);
barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate);

return this;
};
Expand All @@ -308,13 +309,14 @@ IB.prototype.reqMarketDataType = function (marketDataType) {
return this;
};

IB.prototype.reqMktData = function (tickerId, contract, genericTickList, snapshot) {
IB.prototype.reqMktData = function (tickerId, contract, genericTickList, snapshot, regulatorySnapshot) {
assert(_.isNumber(tickerId), '"tickerId" must be an integer - ' + tickerId);
assert(_.isPlainObject(contract), '"contract" must be a plain object - ' + contract);
assert(_.isString(genericTickList), '"genericTickList" must be a string - ' + genericTickList);
assert(_.isBoolean(snapshot), '"snapshot" must be a boolean - ' + snapshot);
assert(_.isBoolean(regulatorySnapshot), '"regulatorySnapshot" must be a boolean - ' + regulatorySnapshot);

this._send('reqMktData', tickerId, contract, genericTickList, snapshot);
this._send('reqMktData', tickerId, contract, genericTickList, snapshot, regulatorySnapshot);

return this;
};
Expand Down
26 changes: 20 additions & 6 deletions lib/outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ Outgoing.prototype.reqGlobalCancel = function () {
};

Outgoing.prototype.reqHistoricalData = function (tickerId, contract, endDateTime, durationStr,
barSizeSetting, whatToShow, useRTH, formatDate) {
var version = 5;
barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate) {
var version = 6;

if (this._controller._serverVersion < 16) {
return this._controller.emitError('It does not support historical data backfill.');
Expand Down Expand Up @@ -1006,8 +1006,6 @@ Outgoing.prototype.reqHistoricalData = function (tickerId, contract, endDateTime
args.push(formatDate);
}



if (_.isString(contract.secType) &&
C.BAG_SEC_TYPE.toUpperCase() === contract.secType.toUpperCase()) {
if (!_.isArray(contract.comboLegs)) {
Expand All @@ -1023,6 +1021,14 @@ Outgoing.prototype.reqHistoricalData = function (tickerId, contract, endDateTime
});
}
}

if (this._controller._serverVersion >= C.MIN_SERVER_VER.SYNT_REALTIME_BARS) {
args.push(keepUpToDate);
}

if (this._controller._serverVersion >= C.MIN_SERVER_VER.LINKING) {
args.push("");
}

this._send(args);
};
Expand All @@ -1049,7 +1055,7 @@ Outgoing.prototype.reqMarketDataType = function (marketDataType) {
this._send(C.OUTGOING.REQ_MARKET_DATA_TYPE, version, marketDataType);
};

Outgoing.prototype.reqMktData = function (tickerId, contract, genericTickList, snapshot) {
Outgoing.prototype.reqMktData = function (tickerId, contract, genericTickList, snapshot, regulatorySnapshot) {
if (this._controller._serverVersion < C.MIN_SERVER_VER.SNAPSHOT_MKT_DATA && snapshot) {
return this._controller.emitError('It does not support snapshot market data requests.');
}
Expand All @@ -1068,7 +1074,7 @@ Outgoing.prototype.reqMktData = function (tickerId, contract, genericTickList, s
}
}

var version = 10;
var version = 11;

var args = [C.OUTGOING.REQ_MKT_DATA, version, tickerId];

Expand Down Expand Up @@ -1143,6 +1149,14 @@ Outgoing.prototype.reqMktData = function (tickerId, contract, genericTickList, s
if (this._controller._serverVersion >= C.MIN_SERVER_VER.SNAPSHOT_MKT_DATA) {
args.push(snapshot);
}

if (this._controller._serverVersion >= C.MIN_SERVER_VER.REQ_SMART_COMPONENTS) {
args.push(regulatorySnapshot);
}

if (this._controller._serverVersion >= C.MIN_SERVER_VER.LINKING) {
args.push("");
}

this._send(args);
};
Expand Down
2 changes: 2 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function _findKeyForValue(object, value) {
return key;
}
}

return C.TICK_TYPE.UNKNOWN;
}

function incomingToString(incoming) {
Expand Down
Loading

0 comments on commit 1e90f73

Please sign in to comment.