Learn R Programming

highfrequency (version 0.7.0.1)

spotDrift: Spot Drift Estimation

Description

Function used to estimate the spot drift of intraday (tick) stock prices/returns

Usage

spotDrift(
  data,
  method = "driftMean",
  ...,
  on = "minutes",
  k = 5,
  marketOpen = "09:30:00",
  marketClose = "16:00:00",
  tz = "GMT"
)

Arguments

data

Can be one of two input types, xts or data.table. It is assumed that the input comprises prices in levels.

method

Which method to be used to estimate the spot-drift. Currently, three methods are available, rolling mean and median as well as the kernel method of Christensen et al. 2018. The kernel is a left hand exponential kernel that will weigh newer observations more heavily than older observations.

...

Additional arguments for the individual methods. See details

on

What time-frame should the estimator be applied? Accepted inputs are "milliseconds", "seconds" and "secs" for seconds, "minutes" and "mins" for minutes, and "hours" for hours. Standard is minutes

k

How often should the estimation take place? If k is 5 the estimation will be done every fifth unit of on.

marketOpen

Opening time of the market, standard is "09:30:00"

marketClose

Closing time of the market, standard is "16:00:00"

tz

Time zone, standard is "GMT"

Value

An object of class "spotDrift" containing at least the estimated spot drift process. Input on what this class should contain and methods for it is welcome.

Details

The additional arguments for the mean and median methods are: periods for the rolling window length which is 5 by standard and align to allow for control of the alignment, should one wish to do so, the standard is "right". For the kernel mean estimator, the arguments meanBandwidth can be used to control the bandwidth of the drift estimator and the preAverage argument, which can be used to control the pre-averaging horizon. These arguments default to 300 and 5 respectively.

References

Christensen, Oomen and Reno (2018): The drift burst hypothesis (working paper) <DOI:10.2139/ssrn.2842535>.

Examples

Run this code
# NOT RUN {
# Example 1: Rolling mean and median estimators for 2 days
meandrift <- spotDrift(data = sampleTDataMicroseconds, k = 1, tz = "EST")
mediandrift <- spotDrift(data = sampleTDataMicroseconds, method = "driftMedian", 
                         on = "seconds", k = 30, tz = "EST")
plot(meandrift)
plot(mediandrift)

# Example 2: Kernel based estimator for one day
price <- sampleTData$PRICE
storage.mode(price) <- "numeric"
#kerneldrift <- spotDrift(price, method = "driftKernel", on = "minutes", k = 1)
#plot(kerneldrift)

# }

Run the code above in your browser using DataLab