-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathGLD_GC.m
31 lines (22 loc) · 950 Bytes
/
GLD_GC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
clear;
% gc=load('//dellquad/Futures_data/inputData_GC_1600_20100802', 'tday', 'hhmm', 'cl');
gc=load('inputData_GC_1600_20100802', 'tday', 'hhmm', 'cl');
gld=load('inputData_ETF');
gld.cl=gld.cl(:, strcmp('GLD', gld.syms));
[tday idx1 idx2]=intersect(gc.tday, gld.tday);
gc.cl=gc.cl(idx1);
gld.cl=gld.cl(idx2);
% Long GLD and short GC
ret=(gld.cl-lag(gld.cl, 1))./lag(gld.cl, 1)-(gc.cl-lag(gc.cl, 1))./lag(gc.cl, 1);
ret(isnan(ret))=0;
cumret=cumprod(1+ret)-1;
plot(cumret);
riskFreeRate=0.02/252;
fprintf(1, 'Avg Ann Ret=%7.4f Sharpe ratio=%4.2f \n',252*smartmean(ret), sqrt(252)*smartmean(ret-riskFreeRate)/smartstd(ret-riskFreeRate));
fprintf(1, 'APR=%10.4f\n', prod(1+ret).^(252/length(ret))-1);
[maxDD maxDDD]=calculateMaxDD(cumret);
fprintf(1, 'Max DD =%f Max DDD in days=%i\n\n', maxDD, round(maxDDD));
%
% Avg Ann Ret= 0.0190 Sharpe ratio=-.07
% APR= 0.0191
% Max DD =-0.008247 Max DDD in days=91