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
2 registered members (AndrewAMD, Imhotep), 567 guests, and 4 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
Zorro Syntax Error OptionsSimulate.c #478262
09/26/19 15:08
09/26/19 15:08
Joined: Sep 2019
Posts: 3
P
Phrendo Offline OP
Guest
Phrendo  Offline OP
Guest
P

Joined: Sep 2019
Posts: 3
Hi all!

I am seeking to figure out how to generate the .t8 data following the article here. https://financial-hacker.com/algorithmic-options-trading/
I downloaded the scripts that he is using for this, but for some reason im getting a syntax error on yield(). This script itself is as it arrived and includes the "#include <contract.c>". Any ideas on why I am getting the following response or how I can debug it?

syntax error
< var Interest = 0.01*yield(); >

Thanks!

Re: Zorro Syntax Error OptionsSimulate.c [Re: Phrendo] #478263
09/26/19 15:41
09/26/19 15:41
Joined: Sep 2019
Posts: 3
P
Phrendo Offline OP
Guest
Phrendo  Offline OP
Guest
P

Joined: Sep 2019
Posts: 3
SOLVED --
I am not sure why this is but it appears that 'Interest' is a keyword. Once I renamed that variable (two locations), I then ran into an Undeclared identifier related to the 'i' in the for loop. I added the include for default.c, but that did not solve it. I then added a declare for the i and that solved it (int i = 0;).


Code
// Simulation von Options/FOP-Daten aus dem Underlying. 

#include <contract.c>

string Name = "SPY"; 
string FileName = "History\\SPYa.t8";
var StrikeMax[3] = { 20,40,80 }; // 3 strike ranges with different steps
var StrikeStep[3] = { 0.5,1,5 };  // stepwidths for the 3 ranges
var MinStrike = 10;
int DaysMax = 150;		// max expiration
var BidAskSpread = 0.8, BidAskSpreadMin = 0.02; // Bid/Ask spread percent and offset
var Dividend = 0.02;
int Type = 0; // or EUROPEAN, or FUTURE
int ExpireDay = FRIDAY;

/////////////////////////////////////////////////////////

CONTRACT* c;
int N = 0;
int i = 0;

void run() 
{
	BarPeriod = 1440;
	StartDate = 2011;
	EndDate = 2018;
	LookBack = 21; // for volatility
	BarOffset = 16*60+30; // needed for same-day values
	
	assetList("AssetsIB");
	assetHistory(Name,FROM_STOOQ|UNADJUSTED);
	asset(Name);

	static int TotalContracts;
	if(is(FIRSTINITRUN)) {
		N = 0;
		initRQL();
		int MaxContractsPerDay = 2*(1+2*(StrikeMax[0]/StrikeStep[0] + StrikeMax[1]/StrikeStep[1] + StrikeMax[2]/StrikeStep[2])) * (1+DaysMax/7);
		TotalContracts = (1+EndDate-StartDate)*252*MaxContractsPerDay;
		printf("\nAllocating %d Contracts",TotalContracts);
		c = (CONTRACT*)dataNew(1,TotalContracts,9);
		if(!c) { printf(" - failed"); quit(); }
	}

	var HistVolOV = VolatilityOV(20);
	var Unl = priceClose();
	var Interests = 0.01*yield();

	
	if(!is(LOOKBACK)) {
		if(N >= TotalContracts || year() > EndDate) quit();
		var Strike;
		int Days = 1;
		while((dow()+Days)%7 != ExpireDay) Days++;
		for(; Days <= DaysMax; Days += 7)
		for(Strike = max(MinStrike,round(Unl-StrikeMax[2],StrikeStep[2])); Strike <= Unl+StrikeMax[2]; Strike)
		for(i = 0; i < 2; i++)
		{
			c->time = wdate();
			c->fUnl = Unl;
			c->fStrike = Strike;
			c->Type = Type + ifelse(i,PUT,CALL);
			c->Expiry = ymd(c->time+Days);
			c->fBid = contractVal(c,Unl,HistVolOV,Dividend,Interests);
			if(c->fBid < 0.01) continue; // contract is not traded
			c->fAsk = (1.+BidAskSpread/100)*c->fBid + BidAskSpreadMin;

			if(abs(Unl-Strike) < StrikeMax[0]) 
				Strike = round(Strike + StrikeStep[0],StrikeStep[0]);
			else if(abs(Unl-Strike) < StrikeMax[1]) 
				Strike = round(Strike + StrikeStep[1],StrikeStep[1]);
			else Strike = round(Strike + StrikeStep[2],StrikeStep[2]);
			N++; c++;
		}
	}
	
	if(is(EXITRUN)) {
		printf("\nSaving %d records to %s",N,FileName);
		dataSort(1);	// reverse the entry order
		dataSave(1,FileName,0,N);
		printf("\nOk!");
	}
}

Re: Zorro Syntax Error OptionsSimulate.c [Re: Phrendo] #478275
09/27/19 09:43
09/27/19 09:43
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, that was an old script. A predefined variable "Interest" was implemented some time later, which led to a conflict with that script.

Re: Zorro Syntax Error OptionsSimulate.c [Re: Phrendo] #483668
07/06/21 13:58
07/06/21 13:58
Joined: Jan 2021
Posts: 15
Chennai
M
monarch Offline
Newbie
monarch  Offline
Newbie
M

Joined: Jan 2021
Posts: 15
Chennai
@Phrendo - Thanks for this post. I was struggling with the same issue yesterday and now I have the script working.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1