erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.85k stars 772 forks source link

reqHistoricalData function lacking tickerId #677

Closed sumobull closed 11 months ago

sumobull commented 11 months ago

Hi, the reqHistoricalData function appears to lack the ability for me to specify the tickerId argument as the native IB API does. This prevents me from running multithreaded routines to grab data as it keeps reusing the same tickerId number which IB doesn't like. Each thread is attempting to grab data for a different instrument.

Is there a workaround for this or am I missing something?

Thx in advance.

 ./get_historical_data
INSTRUMENT: BTC
dict_keys(['md_time_series_list', 'period', 'contract', 'exchange'])

INSTRUMENT: ETH
dict_keys(['md_time_series_list', 'period', 'contract', 'exchange'])

INSTRUMENT: LTC
dict_keys(['md_time_series_list', 'period', 'contract', 'exchange'])

INSTRUMENT: BCH
dict_keys(['md_time_series_list', 'period', 'contract', 'exchange'])

Error 322, reqId 3: Error processing request.-'bX' : cause - Duplicate ticker ID for API historical data query, contract: Crypto(symbol='BCH', exchange='PAXOS')
Error 322, reqId 3: Error processing request.-'bX' : cause - Duplicate ticker ID for API historical data query, contract: Crypto(symbol='LTC', exchange='PAXOS')

ib_insync reqHistoricalData function. reqId appears to be the session ID.

def reqHistoricalData(
            self, reqId, contract, endDateTime, durationStr, barSizeSetting,
            whatToShow, useRTH, formatDate, keepUpToDate, chartOptions):

Native IB API Function. "4102" is the tickerId.

self.reqHistoricalData(4102, ContractSamples.EurGbpFx(), queryTime,"1 M", "1 day", "MIDPOINT", 1, 1, False, [])