-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp_AutoCorrelations.m
More file actions
147 lines (130 loc) · 6.15 KB
/
App_AutoCorrelations.m
File metadata and controls
147 lines (130 loc) · 6.15 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
function App_AutoCorrelations
% SIMPLE_GUI2 Select a data set from the pop-up menu, then
% click one of the plot-type push buttons. Clicking the button
% plots the selected data in the axes.
% Create and then hide the UI as it is being constructed.
f = figure('Visible','off','Position',[360,500,450,285]);
% Construct the components.
hsurf = uicontrol('Style','pushbutton',...
'String','Daily','Position',[315,150,100,25],...
'Callback',@surfbutton_Callback);
hDailySquared = uicontrol('Style','pushbutton',...
'String','Daily Squared','Position',[315,120,100,25],...
'Callback',@DailySquaredbutton_Callback);
hWeekly = uicontrol('Style','pushbutton',...
'String','Weekly','Position',[315,90,100,25],...
'Callback',@Weeklybutton_Callback);
hWeeklySquared = uicontrol('Style','pushbutton',...
'String','Weekly Squared','Position',[315,60,100,25],...
'Callback',@WeeklySquaredbutton_Callback);
htext = uicontrol('Style','text','String','Select Data',...
'Position',[325,220,60,15]);
hpopup = uicontrol('Style','popupmenu',...
'String',{'S&P Comp','MLGTRSA','MLCORPM','WILURET','CRBSPOT','JPUSEEN'},...
'Position',[300,190,100,25],...
'Callback',@popup_menu_Callback);
ha = axes('Units','pixels','Position',[50,60,200,185]);
align([htext,hpopup,hsurf,hDailySquared,hWeekly,hWeeklySquared],'Center','None');
% Initialize the UI.
% Change units to normalized so components resize automatically.
f.Units = 'normalized';
ha.Units = 'normalized';
htext.Units = 'normalized';
hpopup.Units = 'normalized';
hsurf.Units = 'normalized';
hDailySquared = 'normalized';
hWeekly = 'normalized';
hWeeklySquared = 'normalized';
%% Generate the data to plot.
Autocorr_Daily = evalin('base','Autocorr_Daily'); % Daily Autocorrelation
Autocorr_DailySquared = evalin('base','Autocorr_DailySquared'); %Auto-correlation of market risk
Autocorr_WeeklySquared = evalin('base','Autocorr_WeeklySquared'); %Auto-correlation of weekly risk
Autocorr_Weekly = evalin('base','Autocorr_Weekly'); %Auto-correlation of weekly returns
%Creating matrix of auto-correlation for each asset class
SP_data = [Autocorr_Daily(1:10,1),Autocorr_DailySquared(1:10,1),Autocorr_Weekly(1:10,1),Autocorr_WeeklySquared(1:10,1)];
MLG_data = [Autocorr_Daily(1:10,2),Autocorr_DailySquared(1:10,2),Autocorr_Weekly(1:10,2),Autocorr_WeeklySquared(1:10,2)];
MLCORP_data = [Autocorr_Daily(1:10,3),Autocorr_DailySquared(1:10,3),Autocorr_Weekly(1:10,3),Autocorr_WeeklySquared(1:10,3)];
WILURET_data = [Autocorr_Daily(1:10,4),Autocorr_DailySquared(1:10,4),Autocorr_Weekly(1:10,4),Autocorr_WeeklySquared(1:10,4)];
CRBSPOT_data = [Autocorr_Daily(1:10,5),Autocorr_DailySquared(1:10,5),Autocorr_Weekly(1:10,5),Autocorr_WeeklySquared(1:10,5)];
JPUSEEN_data = [Autocorr_Daily(1:10,6),Autocorr_DailySquared(1:10,6),Autocorr_Weekly(1:10,6),Autocorr_WeeklySquared(1:10,6)];
%Setting the lags (x axis)
x = (1:10);
% Create a plot in the axes.
current_data = SP_data;
bar(x,current_data(:,1))
hold on
line([0,0;10,10],...
[Autocorr_Daily(11,1),-Autocorr_Daily(11,1);Autocorr_Daily(11,1),-Autocorr_Daily(11,1)],...
'Color','k','LineStyle','--')
hold off
% Assign the a name to appear in the window title.
f.Name = 'Auto-Correlation of Returns';
% Move the window to the center of the screen.
movegui(f,'center')
% Make the window visible.
f.Visible = 'on';
% Pop-up menu callback. Read the pop-up menu Value property to
% determine which item is currently displayed and make it the
% current data. This callback automatically has access to
% current_data because this function is nested at a lower level.
function popup_menu_Callback(source,eventdata)
% Determine the selected data set.
str = get(source, 'String');
val = get(source,'Value');
% Set current data to the selected data set.
switch str{val}
case 'S&P Comp' % User selects S&P Comp.
current_data = SP_data;
case 'MLGTRSA' % User selects MLGTRSA.
current_data = MLG_data;
case 'MLCORPM' % User selects MLCCORPM.
current_data = MLCORP_data;
case 'WILURET' % User selects WILURET.
current_data = WILURET_data;
case 'CRBSPOT' % User selects CRBSPOT.
current_data = CRBSPOT_data;
case 'JPUSEEN' % User selects JPUSEEN.
current_data = JPUSEEN_data;
end
end
%Function to graph Daily returns
function surfbutton_Callback(source,eventdata) %Displaying Daily Autocorrelation
% Display surf plot of the currently selected data.
bar(x,current_data(1:10,1))
hold on
line([0,0;10,10],...
[Autocorr_Daily(11,1),-Autocorr_Daily(11,1);Autocorr_Daily(11,1),-Autocorr_Daily(11,1)],...
'Color','k','LineStyle','--')
hold off
end
%Function to graph daily Squared returns
function DailySquaredbutton_Callback(source,eventdata) %Displaying Daily Autocorrelation
% Display surf plot of the currently selected data.
bar(x,current_data(1:10,2))
hold on
line([0,0;10,10],...
[Autocorr_DailySquared(11,1),-Autocorr_DailySquared(11,1);Autocorr_DailySquared(11,1),-Autocorr_DailySquared(11,1)],...
'Color','k','LineStyle','--')
hold off
end
%Function to graph Weekly returns
function Weeklybutton_Callback(source,eventdata) %Displaying Daily Autocorrelation
% Display surf plot of the currently selected data.
bar(x,current_data(1:10,3))
hold on
line([0,0;10,10],...
[Autocorr_Weekly(11,1),-Autocorr_Weekly(11,1);Autocorr_Weekly(11,1),-Autocorr_Weekly(11,1)],...
'Color','k','LineStyle','--')
hold off
end
%Function for Graphing Daily Squared returns
function WeeklySquaredbutton_Callback(source,eventdata) %Displaying Daily Autocorrelation
% Display surf plot of the currently selected data.
bar(x,current_data(1:10,4))
hold on
line([0,0;10,10],...
[Autocorr_WeeklySquared(11,1),-Autocorr_WeeklySquared(11,1);Autocorr_WeeklySquared(11,1),-Autocorr_WeeklySquared(11,1)],...
'Color','k','LineStyle','--')
hold off
end
end