Hi Community,
My coder wrote a code to execute a simple call spread for AAPL (call spread described below). It works for other equity options. Why doesn't it work for Index options like NDX and SPX? Why can't I just change 'AAPL' to 'NDX'?
spread1_contract = Contract()
spread1_contract.symbol = "AAPL"
spread1_contract.secType = "BAG"
spread1_contract.currency = "USD"
spread1_contract.exchange = "SMART"
option1 = Option('AAPL', '20200409', 260, 'C', 'SMART', tradingClass='AAPL')
option2 = Option('AAPL', '20200409', 265, 'C', 'SMART', tradingClass='AAPL')
contracts = [option1, option2]
ib.qualifyContracts(*contracts)
leg1 = ComboLeg()
leg1.conId = option1.conId
leg1.ratio = 1
leg1.action = "BUY"
leg1.exchange = "SMART"
leg2 = ComboLeg()
leg2.conId = option2.conId
leg2.ratio = 1
leg2.action = "SELL"
leg2.exchange = "SMART"
spread1_contract.comboLegs = []
spread1_contract.comboLegs.append(leg1)
spread1_contract.comboLegs.append(leg2)
ib_call1_order = Order()
ib_call1_order.orderType = 'SNAP PRIM'
ib_call1_order.action = 'BUY'
ib_call1_order.totalQuantity = 3
trade = ib.placeOrder(spread1_contract, ib_call1_order)
My coder wrote a code to execute a simple call spread for AAPL (call spread described below). It works for other equity options. Why doesn't it work for Index options like NDX and SPX? Why can't I just change 'AAPL' to 'NDX'?
spread1_contract = Contract()
spread1_contract.symbol = "AAPL"
spread1_contract.secType = "BAG"
spread1_contract.currency = "USD"
spread1_contract.exchange = "SMART"
option1 = Option('AAPL', '20200409', 260, 'C', 'SMART', tradingClass='AAPL')
option2 = Option('AAPL', '20200409', 265, 'C', 'SMART', tradingClass='AAPL')
contracts = [option1, option2]
ib.qualifyContracts(*contracts)
leg1 = ComboLeg()
leg1.conId = option1.conId
leg1.ratio = 1
leg1.action = "BUY"
leg1.exchange = "SMART"
leg2 = ComboLeg()
leg2.conId = option2.conId
leg2.ratio = 1
leg2.action = "SELL"
leg2.exchange = "SMART"
spread1_contract.comboLegs = []
spread1_contract.comboLegs.append(leg1)
spread1_contract.comboLegs.append(leg2)
ib_call1_order = Order()
ib_call1_order.orderType = 'SNAP PRIM'
ib_call1_order.action = 'BUY'
ib_call1_order.totalQuantity = 3
trade = ib.placeOrder(spread1_contract, ib_call1_order)
