Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 642 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
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 | 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