// Workshop 8: Simple Option system //////////////////////////////////////////
#include <contract.c>
#define PREMIUM 3.00
void run()
{
StartDate = 20210104;
EndDate = 20210110;
BarPeriod = 1;
set(PLOTNOW,LOGFILE);
History = "*.t8"; // options data for price history
assetList("AssetsTS");
asset("SPX");
Multiplier = 100;
// load today's contract chain
if(!contractUpdate(Asset,0,CALL|PUT)) return;
// Enter new positions
if(!NumOpenShort && !is(LOOKBACK)) {
if(combo(
contractFind(CALL,2,PREMIUM,2),1,
contractFind(PUT,2,PREMIUM,2),1,
0,0,0,0))
{
MarginCost = comboMargin(-1,3);
enterShort(comboLeg(1));
enterShort(comboLeg(2));
}
}
}