Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 17,605 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Correlations Heatmap #465739
05/10/17 22:08
05/10/17 22:08
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Trying the correlations heatmap script from Financial Hacker with an own ETF set I run in 034 (no asset data) and 047 (not enough bars). I think this depends on that the lifetime of the selected ETFs is too short or I should adjust the test period and the LookBack accordingly. Shall the ratio be kept or is a LookBack of 4*252 in a test period of 5 years also okay?
Nevertheless LookBacks of some years are long periods in my understanding, what periods are criticized with 'They used too long, mean-reverting time periods for sampling the returns and covariances', are 10 or 20 years meant to be too long?

Finally a coding question:
Code:
100*annual(Moment(Returns[i],LookBack,1))

Where the annual function is hidden?

Thanks, Sphin

Re: Correlations Heatmap [Re: Sphin] #465754
05/11/17 07:45
05/11/17 07:45
Joined: Jul 2000
Posts: 28,022
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,022
Frankfurt
Yes, the history of some ETFs goes back only a few years, so they can not be used for backtests. The lookback period for portfolio rebalancing is normally 6..12 months. If I remember right, Z8 uses 200 days.

The annual function was in the script:

var annual(var daily)
{
return pow(daily+1.,252)-1.;
}

Re: Correlations Heatmap [Re: jcl] #465766
05/11/17 15:22
05/11/17 15:22
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quote:
The lookback period for portfolio rebalancing is normally 6..12 months
I meant the LookBack period of the Correlation/Heatmap script that is set originally to 6*252 and these 6 years I think are a long time concerning a total period of 7 years.

Thanks for the hint to the script archives these I totally missed to see ...

Re: Correlations Heatmap [Re: Sphin] #465776
05/11/17 22:29
05/11/17 22:29
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Modifying some parameters the heatmap turns completely to white. While debugging I read in the manual about plotHeatmap:
Quote:
The matrix elements must be in the 0..1 range
That's strange because Pearson correlation ranges from -1 to 1 and so do the Correlations' values in the original script if I print them to log.

Re: Correlations Heatmap [Re: Sphin] #465866
05/15/17 21:59
05/15/17 21:59
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
There are some other questions:

1. Is the declaration

var Correlations[NN][NN]

equal to

var Correlations[NN * NN] ?


I thought that Correlations[NN][NN] defines a 2-dimensonal variable for use as Correlations[0][0], Correlations[0][1] etc.? In the financial hacker script Correlations is defined this way but used as a 1-dimensioal variable with

Correlations[N*i+j] = Correlation(Returns[i],Returns[j],LookBack)


2. plotHeatmap()

Correlation ranges from -1 to 1 but plotHeatmap() only from 0..1, so

Code:
function main() {
	
        ...
	
	Correlations[0] = 1;
	Correlations[1] = 0;
	Correlations[2] = -0.5;
	Correlations[3] = -1;
	
	plotHeatmap("Correlation",Correlations,2,2);
}


leads to



Isn't it a bit confusing to display the whole spectrum from 0 (no correlation) to -1 (perfect negative correlation) with the same color?

Thanks, Sphin


Moderated by  Petra 

Gamestudio download | 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