% SP500.mat is a MATLAB data set with 2 columns. First is closing price
% (adjusted for splits and dividends) from 1/4/1988 - 6/10/2020.

load SP500.mat;
data = SP500;
p = data(:,1);

% Constructing a sequence of returns

p_0 = p(2:end,1);
p_1 = p(1:end-1,1);
r = log (p_0./p_1);
n = size(r,1);
t = (1:1:n);

mu_hat=mean(r);
sigma2_hat = (1/n)*sum((r-mean(r)).^2);

[mu_hat sigma2_hat ]

figure(1)
plot(t,r)
box off
grid off
xlabel('time')
ylabel('log returns')
title('log-returns S&P500 from 01.04.1988 - 06.10.2020')


