How to take profit on a short put at 50% of initial premium

Posted By: tanhwuser

How to take profit on a short put at 50% of initial premium - 04/04/20 16:26

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));
}
}
}
Posted By: Petra

Re: How to take profit on a short put at 50% of initial premium - 04/05/20 07:50

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).

© 2024 lite-C Forums