Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 559 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Avoid peeking bias of the OptimalF #459498
05/24/16 11:26
05/24/16 11:26
Joined: Mar 2015
Posts: 336
Rogaland
N
nanotir Offline OP
Senior Member
nanotir  Offline OP
Senior Member
N

Joined: Mar 2015
Posts: 336
Rogaland
Hi

I am not sure if this can workout but I write it here as an idea to avoid the peeking bias introduced by optimalF parameteres:
The point is to calculate the OptimalF parameters for each test period after each training period of each WFO cycle. Then we would get 1.fac 2.fac and so on as there are 1.par 2.par files for the parameteres of each training cycle. The Test period after each WFO cylce could be splitted in the test period to calculate the OptimalF and then a pure out-of-sample period where the optimalF calculated are applied. So each training cylce has in reality two test periods, one to calculate the optimalF and another to actually test the strategy.
At the end, the whole test would be cover by different out-of-sample periods which use diferent optimalF parameteres.


As well it maybe possible that the robustness of the strategy could be tested by slightly changing the OptimalF parameteres. Something like NumSampleCycles applied to the OptimalF values where at each cycle the OptimalF parameters are slightly different from the previous cycle. Since the strategy will behave slightly different during live trading, the optimalF parameteres would change if that live period would be considered as well into the calculation but that difference should not produce an unprofitable strategy from one that looks profitable in first place.

Last edited by Nanitek; 05/24/16 12:11.
Re: Avoid peeking bias of the OptimalF [Re: nanotir] #459544
05/25/16 00:34
05/25/16 00:34
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Well spotted, and you raise a very good point. OptimalF is calculated over the entire simulation period, but is then applied to the simulation from the start. This introduces a weak form of look-ahead bias to strategies that trade using OptimalF for position sizing. I would also like to see separate .fac files for each WFO cycle.

Re: Avoid peeking bias of the OptimalF [Re: boatman] #459554
05/25/16 11:12
05/25/16 11:12
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, we can do that. The reason why we calculated OptimalF for the whole period was that this factor needs a lot of data, including all drawdowns, for being useful. The factors calculated from single WFO periods turned out more or less random.

Re: Avoid peeking bias of the OptimalF [Re: jcl] #459563
05/25/16 23:08
05/25/16 23:08
Joined: Mar 2015
Posts: 336
Rogaland
N
nanotir Offline OP
Senior Member
nanotir  Offline OP
Senior Member
N

Joined: Mar 2015
Posts: 336
Rogaland
Could the test period be splitted between some to calculate the optimalF and other to applied it?
Or could the NumSampleCycles increase the data so that enough data is used to calculated each fac file?

what about changing slightly the optimalF parameters through some cycles to evaluate how the final performance is affected by that change? I robuts strategy should remain profitable after chaging slightly the optimalF parameters... I guess.

Re: Avoid peeking bias of the OptimalF [Re: nanotir] #459567
05/26/16 07:10
05/26/16 07:10
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The strategy result has a linear dependence on OptimalF. If you have a portfolio of 4 components, as in the tutorial, and change one of the factors by 10%, the overal result will change by about 2.5%.

A more severe bias problem is excluding unprofitable components that have a zero OptimalF factor. This can affect the result much more.

NumSampleCycles won't help here, but I believe the best idea is still to use different factors in the backtest than in live trading. The factors for the backtest are then calculated from the last cycle, for live trading from the whole period. This will reduce the profit in the backtest, but eliminate the bias.

Re: Avoid peeking bias of the OptimalF [Re: jcl] #459571
05/26/16 09:03
05/26/16 09:03
Joined: Mar 2015
Posts: 336
Rogaland
N
nanotir Offline OP
Senior Member
nanotir  Offline OP
Senior Member
N

Joined: Mar 2015
Posts: 336
Rogaland
I see it is kind of tricky.
I was thinking about splitting the test period in one to calculate the optimalF and one to apply it, but it maybe not enough data for that.

The bias when optimalF=0 will be allways there somehow because those assets/algo combinations have a low PF anyways and anyone would take them away during the strategy development since there are allways some assets who do not fit into the behaviour that the strategy wants to exploit.

Another thing is when one get too optimistic optimalF. It can be reduceded so that a trade those not take all the margin as explained in the tutorial, but if the avg optimalF of all nonzero values is x and the standard desvitation of that mean is y, maybe artifitially the optimalF whichs is above that range could be reduced to that value or 2 or 3 times that value. If OptimalF is cero one avoid enter in an asset/algo which could behave good or bad. But if the optimalF is too good, then too optimistic results introduce bias.

This is something that anyone can do. But I do not know if it make sense to reduce artifitially the optimalF is this way for the too optimistic values.

Re: Avoid peeking bias of the OptimalF [Re: jcl] #461880
08/27/16 10:02
08/27/16 10:02
Joined: Apr 2014
Posts: 45
Germany
webradio Offline
Newbie
webradio  Offline
Newbie

Joined: Apr 2014
Posts: 45
Germany
The thread is three months old, nevertheless...
Is there meanwhile a way to obtain more realistic (not selection biased due to OptimalF from the future) test results for Z systems?
I was thinking about the following approach to solve this task at least partially:
- first, delete (move to a different directory) history files for 2016;
- then let Zorro calculate OptimalF on data up to 2014. Copy OptF column from Z1.txt test result file and paste it to .par file;
- then put 2016 history files back where they were; run Test again and check the equity curve during 2016 (the earlier part is biased).

Is it a feasible way?

Originally Posted By: jcl
... I believe the best idea is still to use different factors in the backtest than in live trading. The factors for the backtest are then calculated from the last cycle, for live trading from the whole period. This will reduce the profit in the backtest, but eliminate the bias.

Last edited by webradio; 08/27/16 10:06.

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