Continuous research on the trend of stock index (Hurst index)

Source: Internet
Author: User

Only the basic suitable for small white MATLAB Implementation code, in-depth research in addition to the need to improve the algorithm, I suggest a good study of chaos and fractal, do not say let you grasp the trend, at least not big loss, this capital profit and loss callback I have studied before.

function [line_h,rs]=dfax_0322 (x)
Percent-of-initialization data processing
% x=importdata (' IF.txt '); [line_h,rs]=dfax_0322 (x); line_h
%x=1000*rand (4000,1); [line_h,rs]=dfax_0322 (x); line_h
X=x (:); x=x+2;% prevent 0 in X
X1=log ([X (2:end)])-log (x); x=x1 (1:end-1);% elimination of short-term autocorrelation of sequences to meet the requirements of R/S analysis for observing objects independently
% X=cumsum (X-mean (x));
%x=log (x (:));
N=length (x);
Xulie=[8:floor (N/2)];% means dividing X into floor (N/xulie (i)) segment

Percent processing input

Len_xulie=length (Xulie);
Rs=zeros (1,len_xulie);% initialization sequence with a bad mark

Percent of the RS process
For Flag_i=1:len_xulie
M=xulie (flag_i);
Junzhi_ij=zeros (1,floor (N/xulie (flag_i)));% initialization mean
Biaozhuencha_ij=zeros (1,floor (N/xulie (flag_i)));% Initialization standard deviation
Jicha_ij=zeros (1,floor (N/xulie (flag_i))),% initialization very poor
For Flag_j=1:floor (N/xulie (flag_i))
Yuansu_ij=x ([m* (Flag_j-1) +1:m*flag_j]);
Junzhi_ij (1,flag_j) =mean (YUANSU_IJ);
Biaozhuencha_ij (1,flag_j) =sqrt (Mean (Yuansu_ij-junzhi_ij (1,flag_j)). ^2);
Leijilicha_ij=cumsum (Yuansu_ij-junzhi_ij (1,flag_j));
Jicha_ij (1,flag_j) =max (Leijilicha_ij)-min (LEIJILICHA_IJ);
End
RS (1,flag_i) =mean (JICHA_IJ./BIAOZHUENCHA_IJ);
End

Percent-fitting piecewise Xulie and Rs sequences to find the Hurst exponent
Temp1=find (isNaN (RS)); RS (TEMP1) =[];xulie (TEMP1) =[];
Line_h=polyfit (log10 (Xulie), log10 (RS), 1);

Percent drawing
% subplot (1,2,1);p lot (x);
% subplot (1,2,2);
% Plot (log10 (N./xulie (1:len_xulie)), log10 (RS (1:len_xulie)), ' Ro ');
% Plot (log10 (N./xulie (1:len_xulie)), Polyval (LINE_H,LOG10 (N./xulie)), ' 1:len_xulie ');
% title ([' Fitted linear slope ', Num2str (Line_h (1))]);
% Log_n_rs=[log10 (N./xulie (1:len_xulie); log10 (RS (1:len_xulie))];
%

The relationship between Percent Hurst index and correlation
% (1) When 0.5% (2) when h=0.5, stating that the time series is irrelevant, is an independent stochastic process, that is, the current state does not affect the future state.
% (3) when 0

There are three forms of the Hurst Index:
% 1. If h=0.5, indicates that the time series can be described by random walk;
% 2. If 0.5% 3. If 0≤h<0.5, it indicates that the pink noise (anti-persistent) is the mean-value recovery process.
In other words, as long as the h≠0.5, you can use a biased Brownian motion (fractal Brownian motion) to describe the time series data.

Percent Polyfit (Fit) and Polyval (interpolation) application examples
% x = (0:0.1:2.5) ';
% y = Erf (x);
% P = polyfit (x,y,6);
% Y1=polyval (p,x);
% subplot (1,3,1);p lot (x, y, '-b* ');
% subplot (1,3,2);p lot (x,y1, '-ro ');
% subplot (1,3,3);p lot (x, y, '-b* '), hold On;plot (x,y1, '-ro ');

Input of Percent-N
% 2.^[2:15] '
% 4
% 8
% 16
% 32
% 64
% 128
% 256
% 512
% 1024
% 2048
% 4096
% 8192
% 16384
% 32768
End

Continuous research on the trend of stock index (Hurst index)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.