Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (sleakz, AndrewAMD), 684 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
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