Learn R Programming

highfrequency (version 0.6.5)

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"

References

Christensen, Oomen and Reno (2018) <DOI:10.2139/ssrn.2842535>.

Examples

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

# Example 2: Kernel based estimator for one day
price <- sample_tdata$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