Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
I have a problem with EFrontier.c #486859
10/29/22 20:04
10/29/22 20:04
Joined: Oct 2022
Posts: 5
2
2cents Offline OP
Newbie
2cents  Offline OP
Newbie
2

Joined: Oct 2022
Posts: 5
( @jcl : I know this may not be the right place and that maybe I should have posted a comment on the blog, but as far as I can remember I couldn't post pictures there )

I was trying the EFrontier.c script from the 2016 Repository and this was the result. Look at the X and Y scales.
[Linked Image]

I removed the 4 with negative mean (according to Heatmap.c) thinking it was up to that, and replaced them with SOYB. Based on what is written in the post I would have expected a value just under 11.87, the mean of SPY. Instead, no difference. The scale remained of the same order of magnitude.

At that point I remembered the last comment of the post (evidently valid suggestion, since the change appears in Heatmap.c), and I started messing with the X and Y values of plotBar and plotGraph.
if(is(EXITRUN)) {
int i,j;
for(i=0; i<N; i++) {
Means[i] = Moment(Returns[i],LookBack,1);
for(j=0; j<N; j++)
Covariances[N*i+j] = 252*Covariance(Returns[i],Returns[j],LookBack);
//Covariances[N*i+j] = Covariance(Returns[i],Returns[j],LookBack);
}

var BestV = markowitz(Covariances,Means,N,0);
var MinV = markowitzVariance(0,0);
var MaxV = markowitzVariance(0,1);

PlotScale = 8;
PlotHeight1 = 300;
int Steps = 50;
for(i=0; i<Steps; i++) {
var V = MinV + i*(MaxV-MinV)/Steps;
var R = markowitzReturn(0,V);
plotBar("Frontier",i,V,252*100*R,LINE|LBL2,BLACK);
//plotBar("Frontier",i,V,100*R,LINE|LBL2,BLACK);
}
plotGraph("Max Sharpe",(BestV-MinV)*Steps/(MaxV-MinV),
252*100*markowitzReturn(0,BestV),SQUARE,GREEN);
//100*markowitzReturn(0,BestV),SQUARE,GREEN);
}

[Linked Image]

Now the scales have more plausible values, w/ Frontier = 11.12

I did well?
I'm not deep in math, but it seems that now the "if (is (EXITRUN)) {}" block calculates the daily values, and that multiplying by 252 gives the annual values again. But I don't understand why, can someone explain it to me?
Yet the script is identical to that of the post, apart from PlotScale and PlotHeight1. Has Zorro changed the markowitz * functions over the years?

Last edited by 2cents; 10/29/22 23:27.

Don't poke the bear
Re: I have a problem with EFrontier.c [Re: 2cents] #486860
10/30/22 15:18
10/30/22 15:18
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
Yes the script used daily returns. Not annual returns.

I am not sure that the plot scale multiplying with 252 for getting annual returns is correct. Markowitz is a black box to me but the effect on covariance is probably nonlinear. I would rather modify the return calculation from (price(0)-price(1)) to (price(0)-price(252)).


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1