Volatility from Daily Data

We have updated our algorithms to estimate volatility from daily data in blocks of thirty trading days.  Taking advantage of the serial dependence in the volatility structure, we are able to rescale the daily return data to obtain stable parameters that are closer to the point of price formation.  We are finding that the varying volatility accounts for almost all the serial dependence found in the absolute value of market logarithmic returns.  When we remove the volatility we are left with a stable random variable.  Thus we believe that market returns can be very modeled as the product of a stable random variable and a non-random scaling variable which is in fact a measure of market volatility.

Needs["StableM7`"];
AutoCorrelationF[data_,lag_]:=Module[{dataf,dataf1},dataf=Fourier[Join[data-Mean[data] ,Table[0.`,{lag}]]];
dataf1=Take[Chop[Fourier[Abs[dataf]^2]],lag+1] ;
(dataf1/(dataf1[[1]]))];
LogReturn[data_]:=Differences[Log[data]];
absecf0=Compile[{t,{s,_Real,1}},Abs[Mean[Exp[I t s]]]-1/E];
ABSECF0[t_?NumericQ,s_]:=absecf0[t,s];
Clear[SScale];
SScale[s_]:=Module[{cc,c0,c1},
c1=MeanDeviation[s];
(*generally this loop should not be entered*)
While[absecf0[1/c1,s]<0,c1=2c1;Print["Upper Bound Loop"]];
c0=c1;
While[absecf0[1/c0,s]>0,c1=c0;c0=0.8 c0];(*bracket solution from above*)
cc/.FindRoot[ABSECF0[1/cc,s],{cc,  c0,c1},Method->"Brent"]
];
EmpiricCDFList[data_] := Block[{prob,sel,del},
					
					prob= Table[(i-0.5)/Length[data],{i,Length[data]}];
					Transpose[Join[{Sort[data]},{prob}]]];
Clear[scdf];
scdf[(x_)?NumericQ,p_,type_]:=SCDF[x,p,type];(*trap to prevent LogLogPlot from symbolic processing*)
ft={0.5,0.1,0.05,0.01,0.005,0.001,0.0001};
lfticks=Transpose[{ft,ft}];
rfticks=Transpose[{ft,1-ft}];
Clear[DisplayLogStableFit];
DisplayLogStableFit[data_,parm_,type_Integer:1]:=Module[{clist,lt,rt,trt,lp1,lp2,lp3,lp4,lp5,nmn,nstd,xlim,xlim0},
clist=EmpiricCDFList[data];
	lt = Select[clist,#[[1]]<0&];
	rt= Select[clist,#[[1]]>0&];
	trt=Transpose[rt];
xlim0=Min[rt,Abs[lt]];
xlim=Max[{-Min[data],Max[data]}];
lp1=ListLogLogPlot[Abs[lt],PlotStyle->Blue,PlotRange->All,Frame->True,FrameTicks->{True,lfticks,None,rfticks},Axes->False];
lp2=ListLogLogPlot[Transpose[{trt[[1]],1- trt[[2]]}],PlotStyle->Red,PlotRange->All,Frame->True];
lp3= LogLogPlot[scdf[-x,parm,type],{x,xlim0,xlim},PlotStyle->Blue,PlotRange->All];
lp4= LogLogPlot[1-scdf[x,parm,type],{x,xlim0,xlim},PlotStyle->Red,PlotRange->All];
nmn=Mean[data];
nstd=StandardDeviation[data];
lp5= LogLogPlot[1-scdf[x,{2,0,nstd /Sqrt[2],nmn},1],{x,xlim0,4.5 nstd},PlotStyle->Green,PlotRange->All];
Show[lp1,lp2,lp3,lp4,lp5,PlotLabel->"Log Log Stable Distribution\nLeft Tail Blue, Right Red, (Normal Green)",PlotRange->All,(*AspectRatio->Automatic,*)FrameLabel->{"Abs[x]","Left Tail Probability ",None,"Right Tail Probability "}]];
LjungBox[data_,k_]:=Module[{rho,n},
n=Length[data];
rho=Drop[AutoCorrelationF[data,k],1];
n(n+2)Sum[rho[[j]]^2/(n-j),{j,1,k}]];
symbol="SPY";
data=FinancialData[symbol,All];
DateListPlot[data,PlotRange->All,Joined->True,PlotLabel-> symbol<>" Closing Price"]

lr=LogReturn[data[[All,2]]];
dt=Rest[data[[All,1]]];
DateListPlot[Transpose[{dt,lr}],Filling-> 0,FillingStyle-> Darker[Red],PlotStyle-> {Darker[Red],PointSize[0]},PlotRange->All,PlotLabel->symbol<>" Log Returns" ]

The plot below shows the stable scale factor, gamma, over blocks of thirty trading days as a measure of volatility.

m30=Mod[Length[lr],30];
lrp=Partition[Drop[lr,m30],30];
dtm=Median/@Partition[AbsoluteTime/@Drop[dt,m30],30];
scl=SScale/@lrp;
DateListPlot[Transpose[{dtm,scl}],Filling-> 0,FillingStyle-> Darker[Green],PlotStyle-> {Darker[Green],PointSize[0]},PlotRange->All,PlotLabel->symbol<>" Scale Factor" ]

Next the returns are rescaled for each thirty day period above; the graph is shown below.

lr1=Flatten[lrp/scl];
DateListPlot[Transpose[{Drop[dt,m30],Median[scl] lr1}],Filling-> 0,FillingStyle-> Darker[Blue],PlotStyle-> {Darker[Blue],PointSize[0]},PlotLabel->symbol<>" Rescaled Log Returns" ,PlotRange->All]

ListPlot[{AutoCorrelationF[Abs[Median[scl] lr1],200],AutoCorrelationF[Abs[Flatten[lrp]],200]},PlotStyle-> {Darker[Blue],Darker[Red]},Joined ->True,PlotLabel-> "Autocorrelation\nRaw Abs[Returns] - Red\nAbs[Rescaled Returns] - Blue",Frame->True]

The graphic above shows that most of the serial depenndence is removed, but the Ljung-Box test shows that there may be some minor depdence remaining in the data.

CellPrint[TextCell["Ljung-Box statistic raw data: "<>ToString[LjungBox[Abs[Flatten[lrp]],30]],"Text"]];
slb = LjungBox[Abs[lr1],30];
CellPrint[TextCell["Ljung-Box statistic rescaled data: "<>ToString[slb],"Text"]];
CellPrint[TextCell["Probability rescaled data are independent: "<>ToString[1-CDF[ChiSquareDistribution[30],slb]],"Text"]];

Ljung-Box statistic raw data: 8923.81

Ljung-Box statistic rescaled data: 69.5615

Probability rescaled data are independent: 0.0000555646

The log-log plot of the distribution function for the rescaled data is shown below.

parm1=SMLFit[lr1];
parm0={parm1[[1]],parm1[[2]],Median[scl],Median[scl]parm1[[4]]/parm1[[3]]};
parm2=SMLFit[Flatten[lrp]];
Quiet@DisplayLogStableFit[Flatten[lrp/scl] Median[scl],parm0]

The rescaled plot above shows a better fit on the tails than the raw data below.

Quiet@DisplayLogStableFit[Flatten[lrp],parm2]

An appropriate stable parameter set for the median rescaled data would be:

CellPrint[TextCell["α\t\tβ\t\tγ\t\tδ\t","Text"]];CellPrint[TextCell[StringJoin[ToString[#]<>"\t"&/@parm0],"Text"]];

α		β		γ		δ

1.89723	-0.161699	0.00611446	0.000567075

An appropriate stable parameter set for the future data would take the last (most recent) scaling point:

CellPrint[TextCell["α\t\tβ\t\tγ\t\tδ\t","Text"]];CellPrint[TextCell[StringJoin[ToString[#]<>"\t"&/@{parm1[[1]],parm1[[2]],Last[scl],Last[scl]parm1[[4]]/parm1[[3]]}],"Text"]];

α		β		γ		δ

1.89723	-0.161699	0.00417201	0.000386926

In summary, we find the same results for long range volatility as we do for the intraday data: the serial dependence in market returns can be accounted for by volatility.  Market returns can be modeled as a stable random variable multiplied by a scaling factor which measures volatility.  The scaling variable can be extracted from market return data and long range volatility behavior can be studied.

txcolor=RGBColor[181/255,18/255,27/255];
t1 = Graphics[Text[Hyperlink[Framed[Style["Financial Home", {txcolor, Bold, Larger}]], "../map/Overview.html"], {-5, 0}]];
t2 = Graphics[Text[Hyperlink[Framed[Style["Next", {txcolor, Bold, Larger}]],  "../r07c/VolatilityModel.html"], {0, -0.5}]];
t3 = Graphics[Text[Hyperlink[Framed[Style["Download Notebook", {txcolor, Bold, Larger}]], "../r07e/LongRangeVolatility.nb"], {5, 0}]];
t4 = Graphics[Text[Hyperlink[Framed[Style["Previous", {txcolor, Bold, Larger}]],  "../r07/Volatility.html"], {0, 0.5}]];

Show[ t1, t2, t3,t4, ImageSize -> 500]
CellPrint[TextCell["\n\n© Copyright " <>ToString[DateList[][[1]]]<>" mathestate    "<>DateString[DateList[],"DateShort"], "Text"]]

© Copyright 2010 mathestate    Mon 22 Mar 2010