ranaroussi / ezibpy

ezIBpy, a Pythonic Client for Interactive Brokers API
Apache License 2.0
324 stars 116 forks source link

[#162] Historical Market Data Service error message:No historical market data for EUR/CASH@FXSUBPIP Last 1d #24

Closed dsoong1 closed 5 years ago

dsoong1 commented 5 years ago

error retrieving FX cash historical data (i.e. EUR.USD). Interactive Brokers does not disseminate TRADES data for cash FX. You need to use a different value for whatToShow than the default.

solution:

def requestHistoricalData(...):
    self.ibConn.reqHistoricalData(
                tickerId       = tickerId,
                contract       = contract,
                endDateTime    = end_datetime,
                durationStr    = lookback,
                barSizeSetting = resolution,
                whatToShow     = data, <<<<<
                useRTH         = int(rth),
                formatDate     = int(format_date)
            )

if contract.m_secType in ['CASH', 'CFD'], then override whatToShow=="MIDPOINT" or "BID" or "ASK", instead of "TRADES"

ranaroussi commented 5 years ago

The parameter data is changeable... Just use:

ibConn.requestHistoricalData(..., data='MIDPOINT')

That being said, I've updated the method to default to MIDPOINT when requesting data for CASH/CFD.