@fantasia949/ib-connector
Advanced tools
Comparing version 1.0.29 to 1.0.30
@@ -80,3 +80,4 @@ // ref: http://interactivebrokers.github.io/tws-api/market_data_type.html | ||
READY: 'ready', | ||
COMMAND_SEND: 'command' | ||
COMMAND_SEND: 'command', | ||
TIMEOUT: 'timeout' | ||
} | ||
@@ -83,0 +84,0 @@ |
@@ -204,3 +204,2 @@ import assert from 'assert' | ||
async getMarketRule (marketRuleId) { | ||
console.log('tesssfsaffsa'); | ||
const command = makeRequestSubscriptionCommand(INTENT.MARKET_RULE, marketRuleId) | ||
@@ -499,2 +498,4 @@ const response = await this._getData(command, MARKETDATA_EVENT.MARKET_RULE) | ||
_getData (command, completeEvent, acumulateEvents = [], onAcumulate, initialAcumulatedData, done) { | ||
const TIMEOUT_SECONDS = 2 | ||
return new Promise((resolve, reject) => { | ||
@@ -508,2 +509,3 @@ try { | ||
let offEvents = [] | ||
let timeoutId = undefined | ||
@@ -521,2 +523,6 @@ let acumulatedData = initialAcumulatedData | ||
const onFinished = (data, event) => { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId) | ||
timeoutId = undefined | ||
} | ||
resolve({ data: acumulateEvents.length ? acumulatedData : data, event }) | ||
@@ -535,2 +541,9 @@ offEvents.forEach(off => off()) | ||
this._onceMessageEvent(completeEvent, onFinished) | ||
timeoutId = setTimeout(() => { | ||
if (this._socket) { | ||
this._socket.off(completeEvent) | ||
onFinished(undefined, EVENT.TIMEOUT) | ||
} | ||
}, TIMEOUT_SECONDS * 1000) | ||
} | ||
@@ -629,5 +642,9 @@ }) | ||
const onMessage = message => { | ||
const { event, data } = JSON.parse(message) | ||
if (event === eventName) { | ||
cb(data, eventName) | ||
try { | ||
const { event, data } = JSON.parse(message) | ||
if (event === eventName) { | ||
cb(data, eventName) | ||
} | ||
} catch (err) { | ||
console.error(err) | ||
} | ||
@@ -634,0 +651,0 @@ } |
@@ -76,4 +76,4 @@ import IbConnector from './interactive_brokers' | ||
// await testNewsArticle(ib, 'BRFG', 'BRFG$0af99099') | ||
// await testInstrumentDetail(ib, facebookSymbol) | ||
await testMarketRule(ib, 239) | ||
await testInstrumentDetail(ib, facebookSymbol) | ||
// await testMarketRule(ib, 239) | ||
// await testMatchingSymbols(ib, facebookSymbol) | ||
@@ -131,2 +131,5 @@ // await testInstrumentFundamental(ib, facebookSymbol) | ||
const result = await ib.getInstrumentDetails(exSymbol) | ||
console.log('test'); | ||
console.log(result[0].minTick ); | ||
// .toString().split('.')[1].length | ||
console.log(result) | ||
@@ -133,0 +136,0 @@ } |
{ | ||
"name": "@fantasia949/ib-connector", | ||
"version": "1.0.29", | ||
"version": "1.0.30", | ||
"description": "Interactive Brokers connector", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/fantasia949/IB-Connector", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100073
3587