Download code

Jump to: navigation, search

Back to High_Frequency_Finance

Download for Windows: zip

Download for UNIX: zip, tar.gz, tar.bz2

volatility_estimated

f_sampled=@(dt_step)data.value(arrayfun(@(d)find(dts>d,1),dts(1):dt_step:dts(end)),2);
sampling = [1:240]/60;
volatilities = repmat(nan, length(sampling),1);
for s=1:length(sampling)
    S = f_sampled( sampling(s));
    volatilities(s)=100*std( diff(S)./S(2:end))/sqrt(sampling(s))*sqrt(8.5*256);
end
figure;
plot( sampling, volatilities, 'k', sampling, volatilities, '.k')
xlabel('Time step (hours)');
ylabel('Volatility (empirical)');
title( data.title)


sampling

[data.date, idx] = sort(data.date);
data.value = data.value(idx,:);
dts = mod(data.date,1)/datenum(0,0,0, 1,0,0);
dt_step = 1/6;
sample = dts(1):dt_step:dts(end);
idx_from = arrayfun(@(d)find(dts>d,1),sample);
figure;
plot( dts, data.value(:,2), '.k');
ax = axis; axis([min(dts) max(dts) ax(3:4)]);
ylabel(data.colnames{2});
title( data.title)
hold on
stem( sample, data.value(idx_from,2), 'or');
hold off


plot_data

dts = mod(data.date,1)/datenum(0,0,0, 1,0,0);
figure; 
a1=subplot(4,1,1:3);
plot( dts, data.value(:,2), '.k');
ax = axis; axis([min(dts) max(dts) ax(3:4)]);
ylabel(data.colnames{2});
title( data.title)
a2=subplot(4,1,4);
stem( dts, data.value(:,3),'.','linewidth',2);
ylabel('Volume')
linkaxes([a1,a2],'x')


read_euronext

row_data = urlread( [ 'http://www.euronext.com/tools/datacentre/' ...
    'dataCentreDownloadExcell.jcsv?' ...
    'quote=on&volume=on&lan=EN&cha=2593&time=on&' ...
    'selectedMep=1&isinCode=FR0000133308&typeDownload=1&' ...
    'format=xls&indexCompo=']);

parsed_data = regexp( row_data, [ '(?<date>[0-9][0-9]:[0-9][0-9]:[0-9][0-9])' ...
    '[^0-9]+(?<id>[0-9]+)[^0-9]+(?<price>[0-9]+.[0-9]+)[^0-9]+(?<volume>[0-9]+)' ], 'names')

data = struct('title', 'France Telecom the 17th of July', ...
    'value', [cellfun(@(x)str2num(x), {parsed_data.id})', ...
    cellfun(@(x)str2num(x), {parsed_data.price})', cellfun(@(x)str2num(x), {parsed_data.volume})'], ...
    'date', datenum( {parsed_data.date}, 'HH:MM:SS'), ...
    'colnames', {{ 'id', 'Price', 'Volume'}})


hijacker
hijacker
hijacker
hijacker