Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, kzhao, 7th_zorro), 714 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Workshop 6: Portfolio strategies, Kelly factors #396640
03/08/12 19:19
03/08/12 19:19
Joined: Mar 2012
Posts: 6
C
chrisr Offline OP
Newbie
chrisr  Offline OP
Newbie
C

Joined: Mar 2012
Posts: 6
Dear all,

first of all thanks for this great application! I have been looking a long time for walk forward optimization and portfolio trading in a freeware tool.

Experimenting with Zorro for 2 days, I have not yet encountered any bugs, but I will keep you posted on this.

Concerning portfolio trading: Could you please share a preliminary workshop page or example code to realize portfolio trading (I'm not so good at coding from scratch rather than modifying existing example code)?

Thanks and cheers
Chris

Re: Workshop 6: Portfolio strategies, Kelly factors [Re: chrisr] #396704
03/09/12 10:14
03/09/12 10:14
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks for the kind words. We haven't written code for workshop 6 yet. Basically, portfolio strategies use the "while" and "loop" functions for looping through all desired assets and trade strategy algorithms. Here's an example for a nested loop over 3 assets and 2 algorithms:

Code:
void algo1()
{
   //... trade algorithm 1 goes here 
}

void algo2()
{
   //... trade algorithm 2 goes here 
}

void tradeFunction();
string name;

function run()
{
//... some setup goes here

// portfolio loop
	while(name = loop((string)"EUR/USD",(string)"USD/CHF",(string)"GBP/USD",0))
		while(tradeFunction = loop(algo1,algo2,0))
		{
			asset(name);
			tradeFunction();
		}
}



Training this strategy will also generate Kelly factors for the 6 asset/algo combinations.

Re: Workshop 6: Portfolio strategies, Kelly factors [Re: jcl] #397013
03/13/12 12:46
03/13/12 12:46
Joined: Mar 2012
Posts: 6
C
chrisr Offline OP
Newbie
chrisr  Offline OP
Newbie
C

Joined: Mar 2012
Posts: 6
Thanks, that helped me a lot!

After some testing I have written/adapted portfolio trading code as follows:
- 1 mean reverting strategy (as used in the workshop examples with further optimization of the fixed parameters): 5 parameters to be optimized
- 1 trend following strategy (likewise as above): 3 parameters to be optimized
- cycling through all assets for which historical data is delivered by jcl, so that each strategy is applied to each asset (btw: I use 240 minutes time frame for MR strategy and 60 minutes for TF)
- optimization done with MODE=RISKLIMIT
- testing done with MODE=OPTIMIZED+RISKLIMIT+MARGINLIMIT+TICKS
- Walk forward optimization with 8 steps

Test results are as follows:
- Using 4x oversampling: 197%, sharpe ratio 1.57
- Using no oversampling: 267%, sharpe ratio 1.79
- In both results I get nice upward stepping equity curves

What puzzles me is the fact that I get better results both in terms of risk and profit using no oversampling. On top of that with 4x oversampling it takes forever to calculate [one day of training vs ca 1.5h using no oversampling on my machine]. In addition it threw an error message at the end of the optimization (Too many trades) which I ignored several times to finish the test and to get the last fac and nfac files.

What makes me a bit uncomfortable about going live with this strategy is the fact that walk forward analysis is most profitable with 8 steps, but if I only vary by +/- 1 steps the results get far worse.

Is this a sign of an unstable/over optimized strategy or can I still assume that the system will be profitable during live trading?

Another question concerning live implementation of this system:

Using 8 steps for walk forward optimization I assume that the data set (minus Look back period) is divided by 8 to perform the walk forward test of each data set slice.

Does this mean in live trading I have to stop after the same (slice) period to make a new optimization or is there a way to automate this process (so that I can leave the strategy alone and it will automatically reoptimize itself at the right moment)?

Thanks for your input and happy to get further advice on how to improve my approach (as well as hints on how to get in the area of Z1 performance figures => of course without revealing too many secrets about it).

Kind regards
Chris

Re: Workshop 6: Portfolio strategies, Kelly factors [Re: chrisr] #397092
03/14/12 14:37
03/14/12 14:37
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Always use oversampling. The results without oversampling can differ by more than 50%, but this is due to a statistical fluctuation because you have less data.

A heavy difference by changing the WFO steps by +/-1 hints that the number of cycles or the DataSplit value is not good. Most likely, either the test period or the training period is too short and does not contain enough trades, so the results are random. Modify DataSplit and cycle number until the result stays relatively stable on small changes.

I also forgot in my above code something important:

if(Train) Mode |= SKIP1+SKIP2;

You need to reserve 1/3 of the training period for Kelly factor generation. Otherwise, the Kelly factors are generated from in sample data, which causes bias. They should be generated from out of sample data.

In life trading, you must indeed make a new optimization after every slice, but you don't need to stop. Zorro detects when the parameters are updated and continues with the new parameters.

Re: Workshop 6: Portfolio strategies, Kelly factors [Re: jcl] #397122
03/14/12 19:50
03/14/12 19:50
Joined: Feb 2012
Posts: 37
S
stevegee58 Offline
Newbie
stevegee58  Offline
Newbie
S

Joined: Feb 2012
Posts: 37
Where is Workshop 6? I can't find it on the web site.

Re: Workshop 6: Portfolio strategies, Kelly factors [Re: stevegee58] #397182
03/16/12 09:38
03/16/12 09:38
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
It's still missing, along with several other features planned for Zorro for the near future. They all will be added one by one in the next updates.

Re: Workshop 6: Portfolio strategies, Kelly factors [Re: jcl] #397204
03/16/12 14:20
03/16/12 14:20
Joined: Mar 2012
Posts: 6
C
chrisr Offline OP
Newbie
chrisr  Offline OP
Newbie
C

Joined: Mar 2012
Posts: 6
Concerning MODE=SKIP1+SKIP2

In the online manual (http://zorro-trader.com/en/mode.htm on the bottom of the page) the following example is given in the same context:

MODE=SKIP3 ...

Which approach is better in order to obtain more robust optimization results?

Last edited by chrisr; 03/16/12 14:22.
Re: Workshop 6: Portfolio strategies, Kelly factors [Re: chrisr] #397206
03/16/12 14:32
03/16/12 14:32
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
It depends on where you want more data: on parameter optimization or on Kelly factor generation.

If you have only 1 or 2 parameters, skipping two weeks for parameter optimization and using them for the Kelly factors might give better results. If you have more parameters, or only few trades, skipping only one week (SKIP3) is probably better.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1