Deadlook in reqHistoricalData with invalid requests
krambox opened this issue · 1 comments
If an invalid combination of parameters or invalid strings are passed to the reqHistoricalData function, there is a deadlook.
Example
import ibkr, { IBKRConnection, IbkrEvents, HistoricalData } from '@stoqey/ibkr';
const ibkrEvents = IbkrEvents.Instance;
const main = async () => {
// @ts-ignore
const connectionStatus = await ibkr({ port: 7496, host: '127.0.0.1' });
HistoricalData.Instance;
const symbol = 'aapl'
const data = await HistoricalData.Instance.reqHistoricalData({
symbol,
endDateTime: '',
durationStr: '1 W',
barSizeSetting: '1 day',
//whatToShow: 'TRADES',
whatToShow: 'YIELD_BID'
})
console.log(data)
IBKRConnection.Instance.disconnectIBKR()
};
main();
The log writes the error in debug mode, but there is no error from the Promise
Log
error Historical Market Data Service error message:No historical market data for AAPL/STK@NASDAQBBO BidYield 1d
I have not yet checked if there are exceptions in other functions.
Thank you for throwing this in, I have multiple places with this same issue,
The solution I could think of is listening for IBKR error
event, then use a string for matching if we have an error,
for example in the sample you provided above, we know that No historical market data for AAPL
will always be the same for AAPL and other symbols too, e.g No historical market data for TSLA
for TSLA
I added the implementation in #24, please suggest more ideas if you have any in mind