开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: Same code not work for Hong Kong stock options


 

Sorry, here is the code :

from ib_async import *

ib = IB()

ib.connect('127.0.0.1', 7497)

ticker = '941'

ccy = 'HKD'

exchange = 'SEHK'

expiry = '20240627'

strike = 75

leg1 = Option(ticker, expiry, strike, 'C', exchange=exchange, currency=ccy)

leg2 = Option(ticker, expiry, strike, 'P', exchange=exchange, currency=ccy)

ib.qualifyContracts(leg1, leg2)

ib.sleep(4)

combo_legs = [

? ? ComboLeg(conId=leg1.conId, ratio=1, action='BUY'),

? ? ComboLeg(conId=leg2.conId, ratio=1, action='BUY')]

combo_contract = Contract(symbol=ticker, secType='BAG', currency=ccy, exchange=exchange, comboLegs=combo_legs)

order = LimitOrder('BUY', 1, 0.7)

trade = ib.placeOrder(combo_contract, order)

ib.sleep(3)

ib.disconnect()

Join [email protected] to automatically receive all group messages.