Gamestudio Links
Zorro Links
Newest Posts
Get BMAP's filename...?
by Firoball
6 minutes 38 seconds ago
bone ang/pos
by 3run
Today at 15:41
Takeprofit and Stoploss
by sdelatorre
Today at 10:54
Save as .wmb
by Emre
Today at 05:57
Connors RSI implementation
by MatPed
Today at 00:37
multiple results graph in multi-asset scripts?
by SBGuy
Yesterday at 21:19
Verbose messages
by Sphin
Yesterday at 20:24
AUM Magazine
Latest Screens
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Forgotten Tales - Demo version
Who's Online
13 registered (ChrstphFr, JRA, mig, AndrewAMD, MatPed, 3run, jyd, krial057, alibaba, 1 invisible), 477 Guests and 4 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
bbn1982, selma, mbullied, Raisinbran, Grodt
17984 Registered Users
Topic Options
Rate This Topic
#466018 - 05/21/17 04:54 Optimal F in a Portfolio – Does Zorro Overrisk?
Ger1 Offline
Junior Member

Registered: 03/28/17
Posts: 58
Optimal F in a Portfolio – Does Zorro Overrisk?

After reading Ralph Vince’s publications I believe that the implementation of Optimal F in workshop 6 is not correct and might, in case of a multicomponent portfolio, lead to excessive risk (we are far to the right of the peak of the optimal f curve).
When setting FACTORS the optimal fractions for re-investment are calculated and as the manual states, these factors are calculated independently for each asset and algo. This means that we get the optimal fraction for re-investment of each asset and algo if we only traded this one algo and asset on its own (e.g. in Workshop 6: we only trade the trend strategy on EUR/USD, results of USD/JPY and countertrend are ignored).
However, if we add additional strategies (algos) and assets to the script the optimal f from before is not optimal anymore in context of a whole portfolio due to correlations between the various components.
Ralph Vince’s uses a simple example in his paper “The Leverage Space Model” (p.19)

He uses a coin-toss experiment were with tails one loses $1 and with head one wins $2. The probability of occurrence of either event obviously is 50%.
If we calculate optimal f we get a result of 0.25. This means that for maximum growth we have to invest $1 for every $4 at stake.
Now, if we extend this experiment and throw 2 (!) coins at the same time the optimal fraction to invest changes, even if there is NO correlation at all. In case of 0 correlation the optimal f would not be 0.25 anymore BUT 0.23 (if we invest the calculated 0.25 from before we already OVERRISK).

This gets worse in case that these two games are perfectly correlated (meaning that if one coin lands on head the other one will land on head too). In this case it would be the same as playing only one game. If we invested in each game the optimal f that we calculated for the isolated game (that is, optimal f = 0.25) we’d effectively invest 0.5 not 0.25 anymore (as described above, in case of a perfect correlation, the two coin tosses that we perform at the same time can be seen as 1). Looking at the optimal f curve (figure 12 in the paper) we are far to the right of the optimal f value if we invest 0.5 and consequently severely OVERRISK.

My question to the Zorro developers is whether I am missing something or whether there is a specific reason of why optimal F is implemented in such a way in workshop 6.
I specifically refer to (Margin = 0.5 * OptimalF * Capital * sqrt(1 + ProfitClosed/Capital))
As ProfitClosed calculates the profit for each component separately (and thus, effectively creates separated sub-accounts for each algo/asset component) would you suggest to split the initial capital into X parts as well? Through this procedure it would not be required to implement the Leverage Space Model which considers joint probabilities of trade results of X components.

Thanks in advance.

#466371 - 06/12/17 10:42 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: Ger1]
jcl Offline

Chief Engineer

Registered: 07/22/00
Posts: 26372
Loc: Frankfurt
A good observation. The reason why OptimalF reduces from 0.25 to 0.23 in uncorrelated events is that you toss the two coins at the same time. If you would toss them a time apart, the capital change from the first toss would affect the investment in the second toss and therefore the OptimalF factor would be again 0.25.

In Workshop 6, a coin toss is equivalent to opening a trade. Since trades are normally opened at different times, it's a situation more equivalent to uncorrelated single coin tosses than to multiple simultaneous coin tosses. The analogy is not perfect because trades overlap, but due to the 0.5 factor we don't overrisk.

#466496 - 06/18/17 01:26 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: jcl]
Ger1 Offline
Junior Member

Registered: 03/28/17
Posts: 58
Thanks for your reply jcl.

Your statement would make sense to me if only a very small number of algos/assets with no correlation were traded.

I am fully aware that a simultaneous coin toss play does not completely represent trading due to different timing of events, but to illustrate the point I'd like to use it for an extreme example.

As mentioned above, we evaluated that the optimal F for the coin toss experiment (I will call it market system A) is 0.25. Now I am trading further strategies (I'll call them market system B, C and D) and incidentally the optimal F is 0.25 too. Further the largest loss for all market systems is $1.

Again, this means for each trade I put in $1 for every $4 I got in my stake (OptimalF/Largest Loss * Balance). In case that market systems A - D have a trade open at the same time, 100% of my trading capital are invested.

All that is required to wipe out my entire account is all 4 market systems having their largest loss at the same time.
Unless my market systems are completely anti-correlated this won't take too long. Now it might be argued that trades are usually not opened at the same time, but if one system opens a trade and another system has not closed the trade yet this has exactly the same effect as I could not re-balance my account yet.

This is an extreme case but it illustrates the point that optimal F of a single system traded alone is not the same as the optimal F of that system traded in combination with other systems in a whole portfolio.

And as Ralph Vince states (he uses 10 strategies over 10 markets ==> 10*10 = 100 components), I could be optimal on 99 of these 100 components, yet so far off on one component on the Leverage Space that I am losing money.

A quick and dirty solution according to this article ( is to assume the worst case scenario that all correlations of all of the markets in our portfolio go to 1.00.

Optimal F of each market system would then be the optimal F of each market system traded alone divided by the total number of market systems in our portfolio.

From my example above, the optimal F of market systems A - D would then not be 0.25 for each but 0.0625 (0.25/4).

#467105 - 07/16/17 02:30 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: Ger1]
Ger1 Offline
Junior Member

Registered: 03/28/17
Posts: 58
Any feedback on above??

#467122 - 07/17/17 11:25 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: Ger1]
jcl Offline

Chief Engineer

Registered: 07/22/00
Posts: 26372
Loc: Frankfurt
Same answer as above. It depends on whether the systems are always in the market or only trade punctually. If they are always in the market, you must treat them as separate systems and reduce the capital accordingly. If they only trade punctually, you can treat them as a single system and trade with all your capital.

#467145 - 07/18/17 09:18 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: jcl]
Ger1 Offline
Junior Member

Registered: 03/28/17
Posts: 58
Thanks a lot jcl! This makes sense to me.

From your experience, what is the best way to achieve this?

Would you do something like this?

Margin = .5*OptimalF*Balance/NumOpenTotal;

In other words decreasing your trade size based on how many trades are open.

Or would it be better to limit the total trade number to rather than reducing risk per trade?


#467170 - 07/19/17 09:33 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: Ger1]
jcl Offline

Chief Engineer

Registered: 07/22/00
Posts: 26372
Loc: Frankfurt
No, I would not use an algorithm at all for reinvesting in live trading mode. You normally want manual control over reinvestment, so in all trade systems that I know you manually enter the invested capital. OptimalF is then used only for distributing the capital among the assets and algos of the portfolio.

#472888 - 05/28/18 15:44 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: jcl]
nemozny Offline

Registered: 05/28/18
Posts: 1
I can't agree with trading in optimal f in independent mode (jcl says "If they are always in the market, you must treat them as separate systems and reduce the capital accordingly."), so as strategies doesn't relate one to another and you trade them as independent systems (0.25f in the discussion above).
1. For daily trading the positions are open at the same time for different systems, I don't think the entry moment is valid argument here. The strategies influence one another in capital perspective.
If optimal f means optimal capital allocation, you cannot ignore capital dependencies.
One intraday and one daily trading system is a different thing, I am not arguing that.
Intercorrelation in the perspective of the modern (tangent) portfolio is irrelevant here.
2. Calculating optimal f in LSPM mode (0.23f in example above) produces the optimal f for every each one of the strategies to obtain highest geometric growth together, so there cannot exist any different (lower) value, contrary to distributing optimal f via the number of systems (out of total) produces very different results (suboptimal to LSPM result - more evenly distributed, probably).
3. I gathered the information from several Vince's books and I found a little light in each of them. In LSPM book the calculation is illustrated in detail there and Vince always takes individual probabilities (of trade occurring) in account in the calculation, though he says you can aggregate the profits on daily, weekly, monthly periods/bins, it doesn't matter.
So again, time of entry is irrelevant.
4. I tested my LSPM calculation taking systems A, B, C and entering them multiple times into calculation - i.e. [A, B, A, B, C], so simulating 5 systems (to prove my algo can handle). The results are of course that optimal f for original 3 systems [0.37, 0, 0.63] are EQUAL to results from 5 systems, although my algo distributes the sums a little [0.3, 0, 0.07, 0, 0.63]. Summing each A, each B, C produces [0.37, 0, 0.63] again.
This proves that correlation is irrelevant, only maximum geometric growth matters here.
5. I am not arguing Zorro's version here, I think you just changed the capital to squared capital.
6. I was not satisfied with genetic algorithm calculation speed and accuracy, so I am calculating optimal f with increasing accuracy and narrowing from 0.1 -> 0.01 -> 0.001, so my results should be pretty accurate.

I am not an expert though, I just spent the last 3-4 weeks studying Vince's work.
And I have to say there is a TON of misconception about optimal f out there.

#473043 - 06/11/18 10:03 Re: Optimal F in a Portfolio – Does Zorro Overrisk? [Re: nemozny]
Ger1 Offline
Junior Member

Registered: 03/28/17
Posts: 58
Thanks nemozny. Very good points, however I have different a conclusion about point (4).
To me it rather proves that correlation is indeed important.
Going to your example and trading [A, B, A, B, C].
Obviously the two A systems have a correlation of exactly 1. Due to this, the sum of the optimal Fs of the two A systems is equal to trading only one A system [A, B, C].

If correlation were smaller than 1, the sums of the individual optimal Fs of trading [A, B, A, B, C] would be greater than trading [A, B, C].

Going back to point (2), you are definitely right that dividing the individual optimal Fs by the total number of systems leads to suboptimal results but you are at least on the safe side as you assume a correlation between the systems of 1 (as discussed above).

Because of that, I think that optimal F as it is used in the workshop scripts probably overrisks when trading multiple assets and algos and it would be better to either calculate optimal F with the LSPM or divide the individual optimal Fs by the total number of assets and algos.

I also wonder if you could share the optimal Fs of trading each system on its own.


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

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