Introduction

This notebook is part of a series of web pages on mathestate created with Mathematica that explore the use of stable distributions with financial data.  Each page of the site is associated with a downloadable notebook that created the page.  The notebooks are designed to be able to used with the financial data base that is built into version 6.0.  This and the other notebooks use free stable distribution software which can be downloaded from the site; the closed cells can be opened to explore all the algorithms in detail.  The links at the bottom of the Volatility section will take the user directly into the middle of the financial section of mathestate.  The Financial Home button leads to a navigation page which gives an overview of the financial wing of the site and links to other pages in the site.

The mathestate site also has extensive pages on real estate investment, using analysis with Mathematica programs, including an number of demonstrations on the Wolfram Demonstrations Project.  

Roger Brown PhD
Robert Rimmer MD
mathestate@gmail.com

Volatility

In the section on fitting market data, we presented the idea that a non-stationary stable distribution which has a varying γ or scale parameter might be a reasonably accurate model for financial data.  In this section we take the concept another step forward and suggest that the γ parameter is the best measure of volatility.  Traditionally, volatility is measured using the sample standard deviation.  This will work if you want to sort a portfolio to find the order of risk in its components, but the process of measuring a sample standard deviation implies that this measure exists for the distribution from which the data are drawn.  The variance and standard deviation (square root of variance) do not exist for stable distributions other than the normal distribution.  (See Variance Page)  The standard deviation of a normal distribution is related to the stable γ parameter by a factor of (Sqrt[2]).  We have developed a method of estimating the γ parameter of any stable distribution that is independent of the other parameters and will use that in this section.  While all stable parameters are needed to calculate stable probabilities, the γ parameter is the most important for financial data, for the following reasons.
	1.  It is generally many times larger than δ.
	2.   β is generally near zero and does not add a lot to the probability calculation.
	3.  For most financial data α is in a narrow range, 1.7 - 1.9 if the data is corrected for a non-stationary γ parameter.

We think the best way to use the gamma parameter is with intraday data, but for long time frames this may not be practical so we show a method of calculating a moving γ from daily data.  In the graph below we take the same data set the SPY since 1993 and show a moving average γ with a 30 trading day or six week time frame.

data=FinancialData["SPY",All];
DateListPlot[data,Joined->True,PlotLabel->"SPY Price"]

lr=Differences[Log[data[[All,2]]]];
absecf0=Compile[{t,{s,_Real,1}},Abs[Mean[Exp[I t s]]]-1/E];
ABSECF0[t_?NumericQ,s_]:=absecf0[t,s];
QkScale[s_]:= Module[{c0,cc},
c0 =QuartileDeviation[s] ;(*this is best for alpha>1,not a reliable starting point as alpha -> 0*)
(*Absolute value of result is taken in case negative root is found*)
Abs[cc/.FindRoot[ABSECF0[1/cc,s],{cc,c0}]]];
scl=Quiet[Table[QkScale[Take[lr,{i-29,i}]],{i,30,Length[lr]}]];
DateListPlot[Transpose[{data[[31;;,1]],scl}],Joined->True, PlotLabel -> "Scale factor for previous 30 trading days"]

We can see from the plot above that the scale factor or stable γ rose dramatically through the 1990s and finally peaked at the market bottom following the 2000 market high.  Subsequently there was a several year period of low volatility, γ, similar to the early 1990s, but the period of low volatility has come to an end in 2007.

In the plot below we use the moving γ, or volatility, to adjust the log returns and find that most of the serial dependence in the structure of the daily log returns disappears.

lr2=Drop[lr,29]/scl;
AutoCorrelationF[data_,lag_]:=Module[{dataf,dataf1,n},n=Length[data];dataf=Fourier[Join[data-((Plus@@data)/n),Table[0.`,{lag}]]];dataf1=Take[Chop[Fourier[dataf Conjugate[dataf]]],lag+1] N[(Sqrt[n+lag])];(dataf1/(dataf1[[1]]))];
ListPlot[{AutoCorrelationF[Abs[lr],126],AutoCorrelationF[Abs[lr2],126]},PlotRange->All,Joined->True,PlotLabel->"One Day Autocorrelation Abs[LogReturn]\nRaw Data  -- Blue\nScaled Data  -- Red",Frame->True,Axes->False]

The calculated α parameter for the scaled data is much higher; β is about the same.

<<Stable`StableM`
p1=SFit[lr];
p2=SFit[lr2];
TableForm[{p1,p2},TableHeadings-> {{"Raw Data","Scaled Data"},{"α","β","γ","δ"}},TableSpacing-> {1,5}]

Looking at the log-log fits (described on the previous page), we see that the tail fit to the scaled data is more accurate for the α parameter estimated from the scaled data.

EmpiricCDFList[data_] := Block[{prob,sel,del},
					
					prob= Table[(i-0.5)/Length[data],{i,Length[data]}];
					Transpose[Join[{Sort[data]},{prob}]]];
Clear[DisplayLogStableFit];
scdf[x_?NumericQ,parm_,type_:1,opts___]:=SCDF[x,parm,type,opts];
DisplayLogStableFit[data_,parm_,type_Integer:1]:=Module[{clist,lt,rt,trt,lp1,lp2,lp3,lp4,lp5,nmn,nstd},
clist=EmpiricCDFList[data];
	lt = Select[clist,#[[1]]<0&];
	rt= Select[clist,#[[1]]>0&];
	trt=Transpose[rt];
lp1=ListLogLogPlot[Abs[lt],PlotStyle->Blue,PlotRange->All];
lp2=ListLogLogPlot[Transpose[{trt[[1]],1- trt[[2]]}],PlotStyle->Red,PlotRange->All];
lp3= LogLogPlot[scdf[-x,parm,type],{x,0.0001,-4 Min[data]},PlotStyle->Blue,PlotRange->All];
lp4= LogLogPlot[1-scdf[x,parm,type],{x,0.0001,-4 Min[data]},PlotStyle->Red,PlotRange->All];
nmn=Mean[data];
nstd=StandardDeviation[data];
lp5= LogLogPlot[1-scdf[x,{2,0,nstd /Sqrt[2],nmn},1],{x,0.0001,4 nstd},PlotStyle->Green,PlotRange->All];
Show[lp1,lp2,lp3,lp4,lp5,PlotLabel->"Log Log Left Tail Blue, Right Red, (Normal Green)",AspectRatio->Automatic,PlotRange->All]];

g1=Quiet[DisplayLogStableFit[lr,p1]];
g2=Quiet[DisplayLogStableFit[lr2,p2]];
Show[g1, PlotLabel-> "Raw Fit\nLog Log Left Tail Blue, Right Red, (Normal Green)"]
Show[g2, PlotLabel-> "Scaled Fit\nLog Log Left Tail Blue, Right Red, (Normal Green)"]

We conclude by again suggesting that the best way to view financial data is with a non-stationary model.  A stable distribution with a varying γ parameter seems to well describe actual financial time series.  Using the methods above, one could estimate the α and β parameters of a stable distribution for a long time series, by scaling the data to a constant γ.  δ would have to be estimated; there might be a number of ways to do this.  Since δ is the expected daily return, it might be related to current interest rate structure with added component to compensate for stock market risk or it might just be the long term daily expected market return.  For short time frames the value chosen is not very important compared to the estimate for γ, which might be taken as the value for the most recent period, if you are interested in what might happen in the near future.  Since it is possible to estimate stable γ independently of other parameters, we suggest that stable γ be adopted as a measure of volatility for financial returns.

Futures prices show the same phenomenon as stock prices, but they are more difficult to deal with because the contracts are expiring.  The Energy Information Administration keeps track of energy related futures prices, adjusting the forward contracts as they expire.  We have prepared a page on oil prices using their data.

We do not believe that the algorithm to find stable γ independently of other parameters is published anywhere, so we provide a full explanation of it.  For small samples, it is not particularly accurate, so we prefer it for intraday data where there are up to 391 minute intervals for each sample.  The advantage of using it for a small sample is that it is not biased by the other parameters when a parameter search is performed with some minimization strategy, and it seems to work, eliminating the evidence for serial dependence in the absolute value of the return.

txcolor=RGBColor[181/255,18/255,27/255];
t1 = Graphics[Text[Hyperlink[Framed[Style["Financial Home", {txcolor, Bold, Larger}]], "http://www.mathestate.com/tools/Financial/map/Overview.html"], {-5, 0}]];
t2 = Graphics[Text[Hyperlink[Framed[Style["Next", {txcolor, Bold, Larger}]],  "http://www.mathestate.com/tools/Financial/r08/Crash.html"], {0, -0.5}]];
t3 = Graphics[Text[Hyperlink[Framed[Style["Download Notebook", {txcolor, Bold, Larger}]], "http://www.mathestate.com/tools/Financial/r07/Volatility.nb"], {5, 0}]];
t4 = Graphics[Text[Hyperlink[Framed[Style["Previous", {txcolor, Bold, Larger}]],  "http://www.mathestate.com/tools/Financial/r06/MarketData.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 2007 mathestate    Fri 7 Dec 2007