Gamestudio Links
Zorro Links
Newest Posts
MT4/5 Bridge: Stability & Latency?
by Zheka. 02/28/21 15:05
Zorro - import diff time zones csv
by Neb. 02/28/21 12:23
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/26/21 13:15
MACD / Stoch useage
by TraderTom. 02/25/21 21:22
findContract not finding a contract
by AndrewAMD. 02/25/21 11:53
New Zorro version 2.35
by jcl. 02/24/21 14:40
AUM Magazine
Latest Screens
Scheherazade's Journey
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Who's Online Now
9 registered members (Lozoteva, OptimusPrime, 1ND1G0, TraderTom, Dooley, AndrewAMD, 3run, NewBorn, 1 invisible), 480 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
VinVillin, Santofimio, LorraineJones, SkNiX, wongkrezi
18601 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: 37
J
jbhunter Offline OP
Newbie
jbhunter  Offline OP
Newbie
J

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