ibapi: Futures and reqHistoricalData "321 Error validating request.-'bS' : cause - Please enter a local symbol or an expiry"

Viewed 135

Problem:

> "321   Error validating request.-'bS' : cause - Please enter a local
> symbol or an expiry"

I have no luck with reqHistoricalData, I can't find any symbol as a minimum viable working product, I just need a baseline and what I hope to see is OHLCV data for futures contracts.

What I've tried: I don't have the same issue when using getMarketData for the same future contract object.

Various symbols and annotated their errors next to the contract object.

#needs to be set to live data

from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.common import *
from ibapi.contract import *
import time

class TestApp(EWrapper, EClient):
    def __init__(self):
        EClient.__init__(self, self)
        
    def error(self, reqId, errorCode, errorString):
        print("Error: ", reqId, " ", errorCode, " ", errorString)
        
    def historicalData(self, reqId, bar):
        print("HistoricalData. ", reqId, " Date:", bar.date, "Open:", bar.open, "High:", bar.high, "Low:", bar.low, "Close:", bar.close, "Volume:", bar.volume, "Count:", bar.barCount, "WAP:", bar.average)
              
def main():
    app = TestApp()
    app.connect("127.0.0.1", 7497, 0)    
    
    #"200   No security definition has been found for the request"
    BTC_futures__contract = Contract()
    BTC_futures__contract.symbol = 'BRR'
    BTC_futures__contract.secType = 'FUT'
    BTC_futures__contract.exchange = 'CMECRYPTO'
    BTC_futures__contract.lastTradeDateOrContractMonth  = '202003' 
    
    "321   Error validating request.-'bS' : cause - Please enter a local symbol or an expiry"
    ES_contract = Contract()
    #ES_contract.symbol = "ES"
    ES_contract.symbol = "ESM2"
    #added
    
    ES_contract.LocalSymbol = 'ES IND'
    ES_contract.TradingClass = 'ES'
    
    ES_contract.secType = "FUT"
    ES_contract.exchange = "GLOBEX"
    ES_contract.currency = "USD"
    ES_contract.lasttradedateorcontractmonth = "202206"
    
    RTY_contract = Contract()
    #RTY_contract.symbol = "ES"
    RTY_contract.symbol = "RTY"
    #added
    
    #RTY_contract.LocalSymbol = 'ES IND'
    #RTY_contract.TradingClass = 'ES'
    
    RTY_contract.secType = "FUT"
    RTY_contract.exchange = "GLOBEX"
    RTY_contract.currency = "USD"
    RTY_contract.lasttradedateorcontractmonth = "202206"
    
    #app.reqHistoricalData(1, ES_contract, "", "1 D", "1 min", "MIDPOINT", 1, 1, False, [])
    #snapshot
    app.reqHistoricalData(1, RTY_contract, "", "1 D", "1 min", "MIDPOINT", 1, 1, False, [])
    
    app.run()
    
    time.sleep(2)
    app.disconnect()
    
if __name__ == "__main__":
    main()
0 Answers
Related