全部版块 我的主页
论坛 金融投资论坛 六区 金融学(理论版) 金融工程(数量金融)与金融衍生品
2832 2
2009-07-13
(一)股价收益率序列的波动群集性如何进行检验
用软件如何实现?
这个问题已困扰我多日
有没有哪个好心人可以指点我一二
不胜感激!
(二)Alexander的x%滤波法则如何实现?
Fama(1965)这样定义x%滤波法则:如果一只证券的日收盘价格上涨了至少x%,那么买入并持有,直到证券的价格在随后的高点下降了至少x%,于此同时卖出并持有空头。持有这个空头直到日收盘价格从随后的低点上升了x%,与此同时买进平仓,向任何方向波动X%以内不予考虑。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2009-7-13 08:31:21
回答问题1,可以用重标极差法,计算hurst来说明,可以使用的软件有很多,只要可以编程的软件都可以。
我以前写的MATLAB程序如下,供学习讨论:
function [logRS,logERS,V,h,H,C,R,MaxV]=RSana(x,method,q)

if nargin<1 | isempty(x)==1
   error('You should provide a time series.');
else
   % x must be a vector
   if min(size(x))>1
      error('Invalid time series.');
   end
   x=x(:);
   % N is the time series length
   N=length(x);
end

if nargin<2 | isempty(q)==1
   q=0;
else
    if q=='auto'
        t=autocorr(x,1);
        t=t(2);
        q=((3*N/2)^(1/3))*((2*t/(1-t^2))^2)^(1/3);
    else
        % q must be a scalar
        if sum(size(q))>2
            error('q must be scalar.');
        end
        % q must be integer
        if q-round(q)~=0
            error('q must be integer.');
        end
        % q must be positive
        if q<0
            error('q must be positive.');
        end
    end
end

% n is the period lenght
n=5:floor(N/3);

for i=1:length(n)
   
    % Calculate the sub-periods
    a=floor(N/n(i));
    % Calculate the number of data that not used
    b=mod(N,n(i));
   
    % Make the sub-periods matrix (use last a*n(i) data)
    X=reshape(x(1+b:a*n(i)+b),n(i),a);
   
    % Estimate the mean of each sub-period
    ave=mean(X);
   
    % Remove the mean from each sub-period
    cumdev=X-ones(n(i),1)*ave;
   
    % Estimate the cumulative deviation from the mean
    cumdev=cumsum(cumdev);
   
    % Estimate the standard deviation
    switch method
    case 'Hurst'
        % Hurst-Mandelbrot variation
        stdev=std(X);
    case 'Lo'
        % Lo variation
        for j=1:a
            sq=0;
            for k=0:q
                v(k+1)=sum(X(k+1:n(i),j)'*X(1:n(i)-k,j))/(n(i)-1);
                if k>0
                    sq=sq+(1-k/(q+1))*v(k+1);
                end
            end
            stdev(j)=sqrt(v(1)+2*sq);
        end
    case 'MW'
        % Moody-Wu variation
        for j=1:a
            sq1=0;
            sq2=0;
            for k=0:q
                v(k+1)=sum(X(k+1:n(i),j)'*X(1:n(i)-k,j))/(n(i)-1);
                if k>0
                    sq1=sq1+(1-k/(q+1))*(n(i)-k)/n(i)/n(i);
                    sq2=sq2+(1-k/(q+1))*v(k+1);
                end
            end
            stdev(j)=sqrt((1+2*sq1)*v(1)+2*sq2);
        end
    case 'Parzen'
        % Parzen variation
        if mod(q,2)~=0
            error('For the "Parzen" variation q must be dived by 2.');
        end
        for j=1:a
            sq1=0;
            sq2=0;
            for k=0:q
                v(k+1)=sum(X(k+1:n(i),j)'*X(1:n(i)-k,j))/(n(i)-1);
                if k>0 & k<=q/2
                    sq1=sq1+(1-6*(k/q)^2+6*(k/q)^3)*v(k+1);
                elseif k>0 & k>q/2
                    sq2=sq2+(1-(k/q)^3)*v(k+1);
                end
            end
            stdev(j)=sqrt(v(1)+2*sq1+2*sq2);
        end
    otherwise
        error('You should provide another value for "method".');
    end
   
    % Estiamte the rescaled range
    rs=(max(cumdev)-min(cumdev))./stdev;
   
    clear stdev
   
    % Take the logarithm of the mean R/S
    logRS(i,1)=log(mean(rs));
   
    % Initial calculations for the log(E(R/S))
    j=1:n(i)-1;
    s=sqrt((n(i)-j)./j);
    s=sum(s);
        
    % The estimation of log(E(R/S))
    %ERS=s/sqrt(n(i)*pi/2);
    % Other estimations of E(R/S)
    ERS=(n(i)-0.5)/n(i)*s/sqrt(n(i)*pi/2);
    %ERS=sqrt(n(i)*pi/2);
        
    logERS(i,1)=log(ERS);
        
        
    % Estimate V and VE
    V(i,1)=mean(rs)/sqrt(n(i));
    VE(i,1)=ERS/sqrt(n(i));
   
    h(i,1)=log(n(i));
end

% Figure output
% Calcuate the Hurst index using of BP network to make regression
[H,C,R]=postreg(logRS',h');

[H1,C1,R1]=postreg(V',h');

% Text lacation xlabel
range = max(h)-(max(h)-min(h))/8;

% Find the Max value of V and the time period MaxV_N
MaxV_h=h(find(V==max(V)));
MaxV=exp((MaxV_h));

% Plot logRS and logRS* logERS and y=x line 2.1.1
subplot(2,1,1);
plot(h,logRS,'r','linewidth',1.5);
hold on;

y=C+H*h;
plot(h,y,'b','linewidth',1.5);
hold on;

plot(h,0.5*h+C,'k','linewidth',1.5);
hold on;

plot(h,logERS,'c','linewidth',1.5);

grid on;

% Description

% Text loaction ylabel
high1=min(logRS):((max(logRS)-min(logRS))/8):(min(logRS)+3*((max(logRS)-min(logRS))/8));

text(range,high1(4),'Red-logRS','HorizontalAlignment','left');
text(range,high1(3),'Blue-logRS*','HorizontalAlignment','left');
text(range,high1(2),'Cyan-logERS','HorizontalAlignment','left');
text(range,high1(1),'Black-y=C+0.5*log(n)','HorizontalAlignment','left');
title('Graph of logRS logRS* logERS and y=x');
xlabel('log(n)');

% Plot V line V* and Max value of V 2.1.2
subplot(2,1,2);
y1=C1+H1*h;
plot(h,y1,'y','linewidth',1.5);
hold on;

plot(MaxV_h,max(V),'k-*');
hold on;

plot(h,V,'g','linewidth',1.5);
hold on;

plot(h,VE,'m','linewidth',1.5);

grid on;

% Description
% Text location ylabel
high2=min(V):((max(V)-min(V))/8):(min(V)+3*((max(V)-min(V))/8));

text(range,high2(4),'Black-MaxV','HorizontalAlignment','left');
text(range,high2(3),'Green-V','HorizontalAlignment','left');
text(range,high2(2),'Yellow-V*','HorizontalAlignment','left');
text(range,high2(1),'Magenta-VE','HorizontalAlignment','left');
title('Graph of MaxV V V* and VERS');
xlabel('log(n)');
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2009-7-13 11:07:30
非常感谢
我只要在matlab中导入数据
然后f5
就可以运行处结果了吧
我试着做一下
不过我不懂matlab
只是对eviews比较了解
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群