-
Notifications
You must be signed in to change notification settings - Fork 6
/
PEvol.m
37 lines (23 loc) · 869 Bytes
/
PEvol.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
function sigma_hat = PEvol(H,L,k)
%PEvol() Computes historical volatility using Parkinson estimator
% PEvol() function computes historical volatility using Parkinson
% estimator and extreme price values.
% INPUT:
% H - highs
% L - lows
% k - rolling window size. integer
% OUTPUT:
% sigma_hat - historical volatility estimate
% Petr Javorik (2016) [email protected]
% http://mmquant.net/introduction-to-volatility-models-with-matlab-sma-ewma-cc-range-estimators/
% input check
assert(k <= length(H),'Window length is greater than time series length!');
assert(length(H)==length(L),'Sizes of High and Low series are not equal');
% PE computation
sigma_hat = zeros(size(H));
sqlogdiff = log(H./L).^2;
for t = k+1:length(H)
sigma_hat(t,1) = 1/4*k*log(2) * sum(sqlogdiff(t-k:t-1));
end
sigma_hat = sqrt(sigma_hat);
end