season_ality: Perform seasonality aggregations over a single-column _xts_...

View source: R/HighFreq.R

season_alityR Documentation

Perform seasonality aggregations over a single-column xts time series.

Description

Perform seasonality aggregations over a single-column xts time series.

Usage

season_ality(xtsv, endp = format(zoo::index(xtsv), "%H:%M"))

Arguments

xtsv

A single-column xts time series.

endp

A vector of character strings representing points in time, of the same length as the argument xtsv.

Details

The function season_ality() calculates the mean of values observed at the same points in time specified by the argument endp. An example of a daily seasonality aggregation is the average price of a stock between 9:30AM and 10:00AM every day, over many days. The argument endp is passed into function tapply(), and must be the same length as the argument xtsv.

Value

An xts time series with mean aggregations over the seasonality interval.

Examples

# Calculate running variance of each minutely OHLC bar of data
xtsv <- ohlc_variance(HighFreq::SPY)
# Remove overnight variance spikes at "09:31"
endp <- format(index(xtsv), "%H:%M")
xtsv <- xtsv[!endp=="09:31", ]
# Calculate daily seasonality of variance
var_seasonal <- season_ality(xtsv=xtsv)
chart_Series(x=var_seasonal, name=paste(colnames(var_seasonal),
  "daily seasonality of variance"))
  

algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.