adviseLong Bug

Posted By: trenki2

adviseLong Bug - 01/27/17 13:20

The following script can reproduce a potential bug. The script downloads asset history from Yahoo for the symbol "FRE.DE" and then tries to trade it.
The adviseLong functionality then tries to generate a function name with a . in it and therefore the script can not run in test mode.

Code:
// Gives a compiler error when trying to run the script after training
// The problem seems to be the . in the asset name downloaded from Yahoo.
// Zorro tries to generate a C function with a . in it.
// The asset name "FRE.DE" is a valid Yahoo finance asset name.
// https://finance.yahoo.com/quote/FRE.DE?p=FRE.DE

// Warning 034: No asset data for FRE.DE
// Rules: Test7  2000..2016 (5 cores)
// Train FRE.DE_L -Mar 2010- 53.0%
// Rules stored in Test7_1.c

// Run Test7..
// Walk-Forward Test: Test7 FRE.DE 2000..2016
// Error in 'line 3: 
// syntax error
// < int FRE.DE_L(float* sig) >
// Read Test7_1.c

int run()
{
	set(RULES | TESTNOW);

	BarPeriod = 1440;
	StartDate = 2000;
	TradesPerBar = 2;
	Hedge = 5;
	
	NumWFOCycles = 5;
	NumCores = -1;
	
	assetHistory("FRE.DE", FROM_YAHOO);
	
	while (asset(loop("FRE.DE")))
	{
		vars price = series(priceClose());
		var rsi2 = RSI(price, 2);
		var ma = SMA(price, 50);
		var ratio = price[0] / ma;
		
		LifeTime = 1;
		if (adviseLong(PERCEPTRON, 0, rsi2, ratio) > 55)
			enterLong();
	}
}

Posted By: jcl

Re: adviseLong Bug - 01/27/17 14:04

Asset names are used for file names and also for variables in the rules, so they must not contain special characters. Rename "FRE.DE" to "FRE" after downloading it from Yahoo.
Posted By: trenki2

Re: adviseLong Bug - 01/27/17 14:57

Yes that will work but requires manual effort. Then I need to use two different asset names. One for downloading the history from Yahoo, this must be "FRE.DE" (or any other non US stock history) and then I need a second asset name "FRE" without the . in the asset loop.

Things would be 10x simpler and would not require any special code to go around that issue if Zorro would simply allow a . in the asset name and make a valid variable/function name out of it for instance by using

Code:
int FRE_DE_L(float* sig)



instead of the not working:
Code:
int FRE.DE_L(float* sig)



All that would be required is a string replace of special characters to _ in the Zorro code that produces the variable name.

This could be an enhancement for future Zorro versions, so using non US stock history symbols from Yahoo just works without special treatment.
Posted By: jcl

Re: adviseLong Bug - 01/27/17 16:56

Yes, that makes sense. I'll put it on the to do list.

However, brokers and Yahoo have often different asset names, so in many cases you must rename them anyway.
Posted By: trenki2

Re: adviseLong Bug - 01/27/17 17:05

Yes for that I used the BrokerSymbol column in the Assets.csv file. That works well.
© 2024 lite-C Forums