erdewit / ib_insync

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

cannot place order with micro Crude Oil futures #641

Closed blackivory closed 10 months ago

blackivory commented 10 months ago

from ib_insync import * util.startLoop()

import logging

ib = IB() ib.connect('127.0.0.1', 7498, clientId=11)

contract=Future('MCL', '202310', 'NYMEX') contract = ContFuture('MCL','NYMEX', tradingClass="futures") ib.qualifyContracts(contract)

order = MarketOrder('BUY', 1, outsideRth=True) trade = ib.placeOrder(contract, order)

ib.sleep(1) trade.log

assert trade in ib.trades()

ib.disconnect()**


**hi boys ,

i tried both - contract=Future('MCL', '202310', 'NYMEX') contract = ContFuture('MCL','NYMEX', tradingClass="futures")

it returns the same below error to me ,any insight would be appreciate !**


Error 478, reqId 60: Parameters in request conflicts with contract parameters received by contract id: requested expiry 20230920, in contract 20230919; Canceled order: Trade(contract=ContFuture(conId=586292141, symbol='MCL', lastTradeDateOrContractMonth='20230920', multiplier='100', exchange='NYMEX', currency='USD', localSymbol='MCLV3', tradingClass='MCL'), order=MarketOrder(orderId=60, clientId=11, action='BUY', totalQuantity=1, outsideRth=True), orderStatus=OrderStatus(orderId=60, status='Cancelled', filled=0.0, remaining=0.0, avgFillPrice=0.0, permId=0, parentId=0, lastFillPrice=0.0, clientId=0, whyHeld='', mktCapPrice=0.0), fills=[], log=[TradeLogEntry(time=datetime.datetime(2023, 9, 14, 6, 19, 36, 121449, tzinfo=datetime.timezone.utc), status='PendingSubmit', message='', errorCode=0), TradeLogEntry(time=datetime.datetime(2023, 9, 14, 6, 19, 36, 123449, tzinfo=datetime.timezone.utc), status='Cancelled', message='Error 478, reqId 60: Parameters in request conflicts with contract parameters received by contract id: requested expiry 20230920, in contract 20230919;', errorCode=478)], advancedError='')

blackivory commented 10 months ago

its the same if i use contract=Future('MCL', '202311', 'NYMEX')

Error 478, reqId 64: Parameters in request conflicts with contract parameters received by contract id: requested expiry 20231020, in contract 20231019;

erdewit commented 10 months ago

Try the IB help desk.