Stock Prices simulation and statistics

1 回表示 (過去 30 日間)
Afua Amoako Dadey
Afua Amoako Dadey 2020 年 7 月 20 日
Hello, Please can someone help me with how to write a code to use the indices whose time are not more than 60 seconds from the attached different LSEs. Specifically, i am considering the different close prices from the different LSEs below.
%close prices in matrix
nstock_val=[Close(1:30928,1) Close1(1:30928,1) Close2(1:30928,1) Close3(1:30928,1) Close4(1:30928,1)]; % reading the data
t = (Gmttime); % reading the data
time = datetime(t,'inputformat','dd.MM.yyyy HH:mm:ss.SSS');
LSE_matrix =log(nstock_val); %log of the datanstock_val=[Close(1:30928,1) Close1(1:30928,1) Close2(1:30928,1) Close3(1:30928,1) Close4(1:30928,1)]; % reading the data
I=1:(size(LSE_matrix,1)-1); % selecting the indices of all prices but the last time when stock was opened
% data = time(:,1);
% id = [false; diff(time(:,1))> seconds(60)];%finds all row indices where the previous row
% %differs by more than 60 seconds
% data(id,:) = [];% deletes all data in those rows.
% time(id) = [];
I= I(diff(time(:,1)) <= seconds(60));
dLSE_col1 = LSE_matrix(I+1,1) - LSE_matrix(I,1);% log difference
dLSE_col2 = LSE_matrix(I+1,2) - LSE_matrix(I,2);
dLSE_col3 = LSE_matrix(I+1,3) - LSE_matrix(I,3);
dLSE_col4 = LSE_matrix(I+1,4) - LSE_matrix(I,4);
dLSE_col5 = LSE_matrix(I+1,5) - LSE_matrix(I,5);
matrix_logdiff=[dLSE_col1 dLSE_col2 dLSE_col3 dLSE_col4 dLSE_col5];
nsample = floor((2/3)* length(matrix_logdiff)); %two thirds of the log
% difference of the data
matrix_logdiff_nsample = matrix_logdiff(1:nsample,:);
mean_vec = mean(matrix_logdiff_nsample); %finding the mean.
%
mean_vec = mean_vec';
%
cov_matrix = cov(matrix_logdiff_nsample); %the covariance
dt=1;
%GBM parameter estimate
capbhat = sqrtm(cov_matrix./dt);
ahat_vec = (mean_vec/dt)+ diag((capbhat).^2)/2;
s0_vector =[nstock_val(nsample,1) nstock_val(nsample,2) nstock_val(nsample,3) nstock_val(nsample,4) nstock_val(nsample,5)];
s0_vector = s0_vector';

回答 (0 件)

カテゴリ

Help Center および File ExchangePrice and Analyze Financial Instruments についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by