Appendix C: Some RATS Programs for Duration Models

The data used are adjusted time durations of intraday transactions of IBM stock from November 1 to November 9, 1990. The file name is ibm1to5.txt and it has 3534 observations.

Program for Estimating a WACD(1,1) Model

all 0  3534:1

open data ibm1to5.txt

data(org=obs) / x r1

set psi = 1.0

nonlin a0 a1 b1 al

frml gvar = a0+a1*x(t-1)+b1*psi(t-1)

frml gma = %LNGAMMA(1.0+1.0/al)

frml gln =al*gma(t)+log(al)-log(x(t)) $

  +al*log(x(t)/(psi(t)=gvar(t)))-(exp(gma(t))*x(t)/psi(t))**al

smpl 2 3534

compute a0 = 0.2, a1 = 0.1, b1 = 0.1, al = 0.8

maximize(method=bhhh,recursive,iterations=150) gln

set fv = gvar(t)                      

set resid = x(t)/fv(t)

set residsq = resid(t)*resid(t)

cor(qstats,number=20,span=10) resid

cor(qstats,number=20,span=10) residsq

Program for Estimating a GACD(1,1) Model

all 0  3534:1

open data ibm1to5.txt

data(org=obs) / x r1

set psi = 1.0

nonlin a0 a1 b1 al ka

frml cv = a0+a1*x(t-1)+b1*psi(t-1)

frml gma = %LNGAMMA(ka)

frml lam = exp(gma(t))/exp(%LNGAMMA(ka+(1.0/al)))

frml xlam = x(t)/(lam(t)*(psi(t)=cv(t)))

frml gln =-gma(t)+log(al/x(t))+ka*al*log(xlam(t))

   -(xlam(t))**al

smpl 2 3534

compute a0 = 0.238, a1 = 0.075, b1 = 0.857, al = 0.5, ka = 4.0

nlpar(criterion=value,cvcrit=0.00001)

maximize(method=bhhh,recursive,iterations=150) gln

set fv = cv(t)                      

set resid = x(t)/fv(t)

set residsq = resid(t)*resid(t)

cor(qstats,number=20,span=10) resid

cor(qstats,number=20,span=10) residsq

Program for Estimating a TAR-WACD(1,1) Model

The threshold 3.79 is prespecified.

all 0 3534:1

open data ibm1to5.txt

data(org=obs) / x rt

set psi = 1.0

nonlin a1 a2 al b0 b2 bl

frml u = ((x(t-1)-3.79)/abs(x(t-1)-3.79)+1.0)/2.0

frml cp1 = a1*x(t-1)+a2*psi(t-1)

frml gma1 = %LNGAMMA(1.0+1.0/al)

frml cp2 = b0+b2*psi(t-1)

frml gma2 = %LNGAMMA(1.0+1.0/bl)

frml cp = cp1(t)*(1-u(t))+cp2(t)*u(t)

frml gln1 =al*gma1(t)+log(al)-log(x(t)) $

 +al*log(x(t)/(psi(t)=cp(t)))-(exp(gma1(t))*x(t)/psi(t))**al

frml gln2 =bl*gma2(t)+log(bl)-log(x(t)) $

 +bl*log(x(t)/(psi(t)=cp(t)))-(exp(gma2(t))*x(t)/psi(t))**bl

frml gln = gln1(t)*(1-u(t))+gln2(t)*u(t)

smpl 2 3534

compute a1 = 0.2, a2 = 0.85, al = 0.9

compute b0 = 1.8, b2 = 0.5, bl = 0.8

maximize(method=bhhh,recursive,iterations=150) gln

set fv = cp(t)                        

set resid = x(t)/fv(t)

set residsq = resid(t)*resid(t)

cor(qstats,number=20,span=10) resid

cor(qstats,number=20,span=10) residsq

Exercises

5.1 Let rt be the log return of an asset at time t. Assume that {rt} is a Gaussian white noise series with mean 0.05 and variance 1.5. Suppose that the probability of a trade at each time point is 40% and is independent of rt. Denote the observed return by Inline. Is Inline serially correlated? If yes, calculate the first three lags of autocorrelations of Inline.

5.2 Let Pt be the observed market price of an asset, which is related to the fundamental value of the asset Pt* via Eq. (5.9). Assume that ΔPt* = Pt* - Pt-1* forms a Gaussian white noise series with mean zero and variance 1.0. Suppose that the bid–ask spread is two ticks. What is the lag-1 autocorrelation of the price change series ΔPt = PtPt−1 when the tick size is Inline? What is the lag-1 autocorrelation of the price change when the tick size is Inline?

5.3 The file ibm-d2-dur.txt contains the adjusted durations between trades of IBM stock on November 2, 1990. The file has three columns consisting of day, time of trade measured in seconds from midnight, and adjusted durations.

a. Build an EACD model for the adjusted duration and check the fitted model.

b. Build a WACD model for the adjusted duration and check the fitted model.

c. Build a GACD model for the adjusted duration and check the fitted model.

d. Compare the prior three duration models.

5.4 The file mmm9912-dtp.txt contains the transactions data of the stock of 3M Company in December 1999. There are three columns: day of the month, time of transaction in seconds from midnight, and transaction price. Transactions that occurred after 4:00 pm Eastern time are excluded.

a. Is there a diurnal pattern in 3M stock trading? You may construct a time series nt, which denotes the number of trades in a 5-minute time interval to answer this question.

b. Use the price series to confirm the existence of a bid–ask bounce in intraday trading of 3M stock.

c. Tabulate the frequencies of price change in multiples of tick size Inline. You may combine changes with 5 ticks or more into a category and those with − 5 ticks or beyond into another category.

5.5 Consider again the transactions data of 3M stock in December 1999.

a. Use the data to construct an intraday 5-minute log return series. Use the simple average of all transaction prices within a 5-minute interval as the stock price for the interval. Is the series serially correlated? You may use Ljung–Box statistics to test the hypothesis with the first 10 lags of the sample autocorrelation function.

b. There are seventy-seven 5-minute returns in a normal trading day. Some researchers suggest that the sum of squares of the intraday 5-minute returns can be used as a measure of daily volatility. Apply this approach and calculate the daily volatility of the log return of 3M stock in December 1999. Discuss the validity of such a procedure to estimate daily volatility.

5.6 The file mmm9912-adur.txt contains an adjusted intraday trading duration of 3M stock in December 1999. There are thirty-nine 10-minute time intervals in a trading day. Let di be the average of all log durations for the ith 10-minute interval across all trading days in December 1999. Define an adjusted duration as tj/exp(di), where j is in the ith 10-minute interval. Note that more sophisticated methods can be used to adjust the diurnal pattern of trading duration. Here we simply use a local average.

a. Is there a diurnal pattern in the adjusted duration series? Why?

b. Build a duration model for the adjusted series using exponential innovations. Check the fitted model.

c. Build a duration model for the adjusted series using Weibull innovations. Check the fitted model.

d. Build a duration model for the adjusted series using generalized gamma innovations. Check the fitted model.

e. Compare and comment on the three duration models built before.

5.7 To gain experience in analyzing high-frequency financial data, consider the trade data of Boeing stock from December 1 to December 5, 2008. The data are in five files: taq-td-ba12012008.txt to taq-td-ba12052008.txt. Each file has five columns, namely hour, minute, second, price, and volume. Only transactions within the normal trading hours (9:30 am to 4:00 pm Eastern time) are kept. Construct a time series of the number of trades in an intraday 5-minute time interval. Is there any diurnal pattern in the constructed series? You can simply compute the sample ACF of the series to answer this question.

5.8 Again, consider the high-frequency data of Boeing stock from December 1 to December 5, 2008. Construct an intraday 5-minute return series. Note that the price of the stock in a 5-minute interval (e.g., 9:30 to 9:35 am) is the last transaction price within the time interval. For simplicity, ignore overnight returns. Are there serial correlations in the 5-minute return series? Use 10 lags of the ACF and 5% significance level to perform of test.

5.9 Consider the same problem as in Exercise 5.8, but use 10-minute time intervals.

5.10 Again, consider the high-frequency data of Boeing stock. Compute the percentage of consecutive transactions without price change in the sample.

References

Box, G. E. P. and Cox, D. R. (1964). An analysis of transformations (with discusions). Journal of the Royal Statistical Society, Series B 26: 211–246.

Box, G. E. P. and Tiao, G. C. (1975). Intervention analysis with applications to economic and environmental problems. Journal of the American Statistical Association 70: 70–79.

Campbell, J. Y., Lo, A. W., and MacKinlay, A. C. (1997). The Econometrics of Financial Markets. Princeton University Press, Princeton, NJ.

Cho, D., Russell, J. R., Tiao, G. C., and Tsay, R. S. (2003). The magnet effect of price limits: Evidence from high frequency data on Taiwan stock exchange. Journal of Empirical Finance 10: 133–168.

Chou, R. Y. (2005). Forecasting financial volatilities with extreme values: The conditional autoregressive range (CARR) model. Journal of Money, Credit and Banking 37: 561–582.

Engle, R. F. and Russell, J. R. (1998). Autoregressive conditional duration: A new model for irregularly spaced transaction data. Econometrica 66: 1127–1162.

Ghysels, E. (2000). Some econometric recipes for high-frequency data cooking. Journal of Business and Economic Statistics 18: 154–163.

Hasbrouck, J. (1992). Using the TORQ Database. Stern School of Business, New York University, New York.

Hasbrouck, J. (1999). The dynamics of discrete bid and ask quotes. Journal of Finance 54: 2109–2142.

Hauseman, J., Lo, A., and MacKinlay, C. (1992). An ordered probit analysis of transaction stock prices. Journal of Financial Economics 31: 319–379.

Lo, A. and MacKinlay, A. C. (1990). An econometric analysis of nonsynchronous trading. Journal of Econometrics 45: 181–212.

McCulloch, R. E. and Tsay, R. S. (2000). Nonlinearity in high frequency data and hierarchical models. Studies in Nonlinear Dynamics and Econometrics 5: 1–17.

Roll, R. (1984). A simple implicit measure of the effective bid-ask spread in an efficient market. Journal of Finance 39: 1127–1140.

Rydberg, T. H. and Shephard, N. (2003). Dynamics of trade-by-trade price movements: Decomposition and models. Journal of Financial Econometrics 1: 2–25.

Stoll, H. and Whaley, R. (1990). Stock market structure and volatility. Review of Financial Studies 3: 37–71.

Tsay, R. S.(2009). Autoregressive conditional duration models. In Applied Econometrics, Palgrave Handbook of Econometrics, Vol. 2, T. C. Mills and K. Patterson (eds.), Basingstoke, Hampshire, UK.

Wood, R. A. (2000). Market microstructure research databases: History and projections. Journal of Business & Economic Statistics 18: 140–145.

Zhang, M. Y., Russell, J. R., and Tsay, R. S. (2001). A nonlinear autoregressive conditional duration model with applications to financial transaction data. Journal of Econometrics 104: 179–207.

Zhang, M. Y., Russell, J. R., and Tsay, R. S. (2008). Determinants of bid and ask quotes and implications for the cost of trading. Journal of Empirical Finance 15: 656–678.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset