Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
Deeplearning Script
by wolfi. 02/26/24 12:46
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/22/24 16:22
AssetAdd() vs. modern asset list?
by jcl. 02/21/24 15:01
How many still using A8
by Aku_Aku. 02/20/24 12:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 595 guests, and 7 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
Page 1 of 2 1 2
Optimize in a ranked asset portfolio #481711
10/20/20 18:09
10/20/20 18:09
Joined: Jan 2017
Posts: 11
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 11
Israel
I'm trying to implement in Zorro this R code provided in this site: IGM strategy

The code looks like this:

Code
vars Returns[6];
var  cumRets[6];
int  days = 0;	

function run()
{
//	set(PARAMETERS+LOGFILE+PLOTNOW);
	set(LOGFILE+PLOTNOW);
	BarPeriod    = 1440;
	LookBack     = 240;
	Verbose      = 0;
	NumWFOCycles = 5;
	
	
	
	int i;
	for(i=0;i<6;i++)
	{
		asset(Assets[i]);
		Returns[i] = series((price(0)-price(1))/price(1));
	}
	
	days++;
	
	if (days%20 == 0 && days>240) { // once a month do
		exitTrade();
		while(asset(loop("MDY", "TLT", "EEM", "ILF", "EPP", "FEZ")))
		{
			vars retSubset = Returns[Itor1];
			cumRets[Itor1] = Sum(retSubset,optimize(60,20,240,20));
		}
		
		int * Idx = sortIdx (cumRets, -6);
//		printf("\n %i", Idx[0]);
		asset(Assets[Idx[0]]);
		enterLong();
	}

}


The TEST phase works correctly, but the TRAIN phase optimize the last asset only, then the TEST issue an error that no .par file is available for each asset.
The manual explains that the TRAIN runs each asset with all available parameters value, then continue to the next asset.
In this specific strategy the position is taken only after all assets are ranked by their returns, in my understanding the current TEST approach can't handle such situation.
Am I correct or there is some hack to overcome this situation?

Re: Optimize in a ranked asset portfolio [Re: dBc] #481719
10/21/20 18:34
10/21/20 18:34
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
Is there a specific reason in this script to not use the assetloop?

Re: Optimize in a ranked asset portfolio [Re: dBc] #481720
10/22/20 06:25
10/22/20 06:25
Joined: Jan 2017
Posts: 11
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 11
Israel
I'm using while(asset(loop... optimize( ...
If I use asset - loop to calculate the returns, I got the same results, no optimization is made.

Last edited by dBc; 10/22/20 06:58.
Re: Optimize in a ranked asset portfolio [Re: dBc] #481726
10/24/20 08:32
10/24/20 08:32
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
The manual suggests using an while (asset(loop()) - while (algo(loop())) structure for optimizing params per component. Try adding the "algo" loop.

Re: Optimize in a ranked asset portfolio [Re: Zheka] #481730
10/24/20 11:54
10/24/20 11:54
Joined: Jan 2017
Posts: 11
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 11
Israel
Hi Zheka, I don't understand how to add a while(algo(loop when there is only one algorithm in this strategy.

I'm not sure that Zorro can optimize a rotation strategy. It seems that Zorro's optimization algorithm optimizes each asset separately.

Re: Optimize in a ranked asset portfolio [Re: dBc] #481731
10/24/20 12:03
10/24/20 12:03
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
Well, Zorro can optimize a rotation strategy, but then if you don't want to optimize every asset seperate, you'll need to move out your optimize calls from the assetcalls.
You need to manually define the optimize steps and values to optimize for.

Also looking at the newest beta, offers you plenty of options to optimize, at least latest with the version >=2.33 you can optimize everything.

Re: Optimize in a ranked asset portfolio [Re: dBc] #481734
10/24/20 17:34
10/24/20 17:34
Joined: Jan 2017
Posts: 11
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 11
Israel
Thanks danatrader.
I do not agree with you, I think Zorro (at least in the free version), uses in its optimization algorithm a "vertical" approach.
When optimizing a portfolio of assets, Zorro looks at each asset separately, and no asset influences the optimization of other one.
In a rotation strategy one might optimize in a sense that there are influences in the optimization process between the asset ("horizontal" optimization).
In a horizontal optimization one would end with different parameter values for each asset.

If I would proceed with the R code provided in the attached link, and add an optimization code, I could easily get a different "lookback" period for each of the 6 assets candidates.
I'm not saying that optimizing each asset look-back would be the best approach for this strategy, but at least it's dame a trail.

Re: Optimize in a ranked asset portfolio [Re: dBc] #481735
10/24/20 18:15
10/24/20 18:15
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
I am sorry, may you explain in different words?

You say, "It seems that Zorro's optimization algorithm optimizes each asset separately."

Then you state, "In a horizontal optimization one would end with different parameter values for each asset."

Isn't that contradicting?
Then again, with beta 2.33 you can use R-Code for optimization.

Last edited by danatrader; 10/24/20 18:15.
Re: Optimize in a ranked asset portfolio [Re: dBc] #481736
10/24/20 18:25
10/24/20 18:25
Joined: Jan 2017
Posts: 11
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 11
Israel
danatrader thanks for your feedback.

Yes it's contradicting. Zorro in my poor opinion optimizes in a "vertical" sense. And I'm looking to optimize in a "horizontal" sense.
I'll look into beta 2.33 to see if it can help me.

Re: Optimize in a ranked asset portfolio [Re: dBc] #481737
10/24/20 19:03
10/24/20 19:03
Joined: Mar 2019
Posts: 357
D
danatrader Offline
Senior Member
danatrader  Offline
Senior Member
D

Joined: Mar 2019
Posts: 357
You maybe want to create a synthetic asset, optimize it and then select based on the optimize timeframe of the synthetic asset choose the best performing, the one with the most weight within the synthetic.

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1