Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by 7th_zorro. 04/16/24 13:19
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (Quad, alibaba, rki, 7th_zorro), 365 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Negative OrderLimit for selling options #482126
12/27/20 23:01
12/27/20 23:01
Joined: Mar 2020
Posts: 41
J
jbhunter Offline OP
Newbie
jbhunter  Offline OP
Newbie
J

Joined: Mar 2020
Posts: 41
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]


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

Re: Negative OrderLimit for selling options [Re: jbhunter] #482541
02/21/21 01:33
02/21/21 01:33
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline
Newbie
strimp099  Offline
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
IB tracks at the position level. So what you’re seeing in the IB chart is your combined position which is not any sort of exchange price. If you enter a buy limit for a short spread that’s saying that you will buy the position back at that price which generates a debit (a positive number). If you enter a negative value that tells IB you want to open a credit spread (a negative number) which would get you shorter your straddle. The chart is misleading because it just prints the position price. A stop loss would be a debit that’s greater than the credit you received. For example you enter a stop loss at 5. That means that volatility has increased and its now more expensive. The net trade would be -3.87+5=1.13 debit or loss on the trade.

In my experience this gets a bit counterintuitive especially when your spread goes OTM. One way to get a feel for this is to trade manually in your IB demo account.

Last edited by strimp099; 02/21/21 06:51.

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1