pilwon / node-ib

Interactive Brokers TWS API client library for Node.js
381 stars 133 forks source link

historicalDataEnd is never emitted #135

Open tredondo opened 5 years ago

tredondo commented 5 years ago

This can be seen in the example, or simplified:

const ib = new (require('ib'))({
  // clientId: 0,
  // host: '127.0.0.1',
  // port: 7496
}).on('error', err => {
  console.error(err.message);
}).on('result', (event, args) => {
  console.log(event, '---', args);
});

ib.connect();

ib.reqHistoricalData(
  // tickerId, contract, endDateTime, durationStr, barSizeSetting
  1, ib.contract.stock('SPY', 'SMART', 'USD'), '20160308 12:00:00', '1 W', '1 day',
  // whatToShow, useRTH, formatDate, keepUpToDate
  'TRADES', 1, 1, false
);

setTimeout(() => ib.disconnect(), 5 * 1000);

The last event is

historicalData --- [ 1, 'finished-20160301 12:00:00-20160308 12:00:00', -1, -1, ... ]

Why isn't historicalDataEnd emitted, when reqHistoricalData was called with keepUpToDate = false?