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)
NDX also trades weekly as NDXP and SPX trades weekly as SPXW. That adds to the confusion since I trade weekly - I would need one code for the weekly expiry SPXW and another code if next week is a monthly to trade SPX
Figured it out. There's a mixing of NDX and NDXP in the coding Also, looks like with the below code you can't pull data for an expiry farther out than the next monthly expiry. So for example if the next expiry for the monthly NDX is 13th April, then you CAN'T pull data for weekly NDXP for any expiry after that - for some reason. spread1_contract = Contract() spread1_contract.symbol = "NDX" spread1_contract.secType = "BAG" spread1_contract.currency = "USD" spread1_contract.exchange = "SMART" option1 = Option('NDX', '20200409', call1_strike1, call1_type1, 'SMART', tradingClass='NDXP') option2 = Option('NDX', '20200409', call1_strike2, call1_type2, 'SMART', tradingClass='NDXP') contracts = [option1, option2] ib.qualifyContracts(*contracts)