-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathplotting.m
91 lines (60 loc) · 2.23 KB
/
plotting.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
%% Sharpe & Max Drawdown for Non-Regime-Dependent Strategy
prets = [];
for i=50:length(Returns)-1
Returnz = Returns(1:50,2:11);
er = mean(Returnz);
cv = cov(Returnz);
w = inv(cv)*er';
w=w+abs(w); % Short-sell constraint
w=w/sum(w);
pret = Returns(i,2:11)*w;
prets = [prets pret];
end
%input('Press Enter to Calculate Non-RS Strategy: Monthly Rebalancing with Short Sell Constraint')
%plot(ret2price(prets),'rx');
NonRegimeDependentMean = mean(prets)*12
NonRegimeDependentVolatility = std(prets)*sqrt(12)
NRDSharpe = (NonRegimeDependentMean-Returns(end,1)*12) / NonRegimeDependentVolatility
NRDMaxDrawDown = maxdrawdown(ret2price(prets))
%% PLOTTING: Mean Variance Portfolio & RS Strategy
clf
plot(ret2price(rets),'k-','LineWidth',3)
hold on
plot(ret2price(Returns(51:end,12)),'g-','LineWidth',2);
plot(ret2price(prets),'k:','LineWidth',2);
plot(ret2price(Returns(51:end,6)),'r-','LineWidth',2);
plot(ret2price(Returns(51:end,4)),'b-','LineWidth',2);
Legends = {'RS Strategy', 'World','Non-Regime-Dependent Strategy','Swiss SPI','US S&P500'};
lgd = legend(Legends,'Location','Northwest','FontSize',20);
set(gca, 'Xtick', [0:12:240])
set(gca, 'XtickLabel', [1998:1:2018],'FontSize',12)
input('Press Enter')
%% PLOTTING: Probabilities
clf
hold on
plot(out.Spec_Out{end}.smoothProb(50:end,1),'k-');
plot(out.Spec_Out{end}.filtProb(50:end,1),'b--');
set(gca, 'Xtick', [0:12:240])
set(gca, 'XtickLabel', [1998:1:2018],'FontSize',12)
legend({'Smooth Probability','Filter Probability'},'Location','Southeast','FontSize',20)
input('Press Enter')
%% PLOTTING: Strategy & WORLD
clf
pld = [pld(:,2:end)];
plot(pld,'-','LineWidth',1);
hold on
%plot(ret2price(rets),'k-','LineWidth',3)
hold on
set(gca, 'Xtick', [0:12:240])
set(gca, 'XtickLabel', [1998:1:2018],'FontSize',12)
hold on
%Set Y ticks
a=[cellstr(num2str(get(gca,'ytick')'*100))];
pct = char(ones(size(a,1),1)*'%');
new_yticks = [char(a),pct];
%set(gca,'yticklabel',new_yticks,'FontSize',14)
ylabel('Cumulative Return','FontSize',24)
hold on
plot(ret2price(rets),'k-','LineWidth',3);
Legends = {'China','Japan','US','EMBI', 'Switzerland','North America', 'EU', 'UK', 'Pacific', 'EM','World','RS Strategy'};
lgd = legend(Legends,'Location','Northwest','FontSize',14);