Posted By: jbhunter
Negative OrderLimit for selling options - 12/27/20 23:01
How might one put in a limit order in IB if you are selling options and receiving premium?
It appears that TWS is looking for a negative value for the Limit. When I use OrderLimit=3.87, you get a pending order like the picture below. When using OrderLimit=-3.87 (negative) then the order is put in as a Market order.
[img]https://ibb.co/rHdsBh9[/img]
[img]https://ibb.co/wcJYcrH[/img]
Asset=NIO, priceClose=47.01
!Get Option Chain NIO-OPT--0.00--SMART/ISLAND--USD
Asset=NIO, contractsFound=1178
NIO,Put,20201231,47.0000,0.0000,1.8900,1.8900,100,0,NIO-OPT-20201231-47.00-P-SMART
NIO,Call,20201231,47.0000,0.0000,1.9800,1.9800,100,0,NIO-OPT-20201231-47.00-C-SMART
putPrice=1.89 callPrice=1.98
NIO, putMid=1.89, callMid=1.98, straddleMid=3.87
OrderLimit=3.87
[NIO::SP02712] Place 1 Put 20201231 47.00 100@1.89
!Order Message:
BUY 1 Combo
Warning: your order will not be placed at the exchange until 2020-12-28 09:30:00 US/Eastern NIO-BAG--0.00--SMART/--USD
It appears that TWS is looking for a negative value for the Limit. When I use OrderLimit=3.87, you get a pending order like the picture below. When using OrderLimit=-3.87 (negative) then the order is put in as a Market order.
[img]https://ibb.co/rHdsBh9[/img]
[img]https://ibb.co/wcJYcrH[/img]
Code
var p = priceClose(); printf("\nAsset=%s, priceClose=%.2f",s,p); int num = contractUpdate(Asset,0,PUT|CALL); printf("\nAsset=%s, contractsFound=%i",Asset,num); CONTRACT* put = contractFind(PUT,1,p,6); CONTRACT* call = contract(CALL,put->Expiry,put->fStrike); contractPrint(put, TO_WINDOW); contractPrint(call, TO_WINDOW); var putPrice = contractPrice(put); var callPrice = contractPrice(call); printf("\nputPrice=%.2f callPrice=%.2f",putPrice,callPrice); var putMid = 0.5*(put->fBid+put->fAsk); var callMid = 0.5*(call->fBid+call->fAsk); printf("\n%s, putMid=%.2f, callMid=%.2f, straddleMid=%.2f",Asset,putMid,callMid,putMid+callMid); int pos = -1; CONTRACT* straddle = combo(put,pos,call,pos,0,0,0,0); OrderLimit = round_to(putMid+callMid,2); printf("\nOrderLimit=%.2f",OrderLimit); //contractPrint(straddle,TO_WINDOW); enterLong(comboLeg(1)); enterLong(comboLeg(2));
Asset=NIO, priceClose=47.01
!Get Option Chain NIO-OPT--0.00--SMART/ISLAND--USD
Asset=NIO, contractsFound=1178
NIO,Put,20201231,47.0000,0.0000,1.8900,1.8900,100,0,NIO-OPT-20201231-47.00-P-SMART
NIO,Call,20201231,47.0000,0.0000,1.9800,1.9800,100,0,NIO-OPT-20201231-47.00-C-SMART
putPrice=1.89 callPrice=1.98
NIO, putMid=1.89, callMid=1.98, straddleMid=3.87
OrderLimit=3.87
[NIO::SP02712] Place 1 Put 20201231 47.00 100@1.89
!Order Message:
BUY 1 Combo
Warning: your order will not be placed at the exchange until 2020-12-28 09:30:00 US/Eastern NIO-BAG--0.00--SMART/--USD