| calc_season | R Documentation |
Calculate the intraday seasonality aggregations over a single-column xts time series.
calc_season(xtsv, endp = format(zoo::index(xtsv), "%H:%M"))
xtsv |
A single-column xts time series. |
endp |
A vector of character strings representing points in
time, of the same length as the argument |
The function calc_season() 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.
An xts time series with mean aggregations over the seasonality interval.
# 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 <- calc_season(xtsv=xtsv)
chart_Series(x=var_seasonal, name=paste(colnames(var_seasonal),
"daily seasonality of variance"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.