Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 945 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to take profit on a short put at 50% of initial premium #479532
04/04/20 16:26
04/04/20 16:26
Joined: Apr 2020
Posts: 1
T
tanhwuser Offline OP
Guest
tanhwuser  Offline OP
Guest
T

Joined: Apr 2020
Posts: 1
Hi all

I'm new to Zorro - it looks like a fabulous system.

I'm trying to put up an algo where I sell 0.05 delta puts on the SPY.

I have Workflow 8 as a base and tweaked it to the following.
However, I want to exit my put options when the profit hits 50% of initial premium, rather than wait till expiration.
How do I do it in the code below?

Thanks a lot.



// Workshop 8: Simple Option system //////////////////////////////////////////
#include <contract.c>

#define PREMIUM 2.00
#define DAYS 6*7

void run()
{
StartDate = 20120101;
EndDate = 20200401;
BarPeriod = 1440;
set(PLOTNOW,LOGFILE);

History = ".t8"; // real options data
//History = "a.t8"; // artificial options data
assetList("AssetsIB");
asset("SPY");
Multiplier = 100;

// load today's contract chain
if(!contractUpdate(Asset,0,CALL|PUT)) return;

// Enter new positions
if(!NumOpenShort) {
if(combo(
0,0,
contractFind(PUT,DAYS,PREMIUM,2),1,
0,0,0,0))
{
MarginCost = comboMargin(-1,3);
enterShort(comboLeg(2));
}
}
}

Re: How to take profit on a short put at 50% of initial premium [Re: tanhwuser] #479542
04/05/20 07:50
04/05/20 07:50
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
A combo has at least two legs. Combos with no first leg probably won't work.

For the profit taget I think, select the contract and then set TakeProfit = 0.5 * contractPrice(ThisContract).



Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1