agg_stats_r | R Documentation |
R
code.Calculate the aggregation (weighted average) of a statistical estimator over
a OHLC time series using R
code.
agg_stats_r(ohlc, calc_bars = "ohlc_variance", weighted = TRUE, ...)
... |
additional parameters to the function |
ohlc |
An OHLC time series of prices and trading volumes, in xts format. |
calc_bars |
A character string representing a function for calculating statistics for individual OHLC bars. |
weighted |
Boolean argument: should estimate be weighted
by the trading volume? (default is |
The function agg_stats_r()
calculates a single number
representing the volume weighted average of statistics of individual
OHLC bars.
It first calls the function calc_bars
to calculate a vector of
statistics for the OHLC bars.
For example, the statistic may simply be the difference between the
High minus Low prices. In this case the function
calc_bars
would calculate a vector of High minus
Low prices.
The function agg_stats_r()
then calculates a trade volume
weighted average of the vector of statistics.
The function agg_stats_r()
is implemented in R
code.
A single numeric value equal to the volume weighted average of an estimator over the time series.
# Calculate weighted average variance for SPY (single number)
variance <- agg_stats_r(ohlc=HighFreq::SPY, calc_bars="ohlc_variance")
# Calculate time series of daily skew estimates for SPY
skew_daily <- apply.daily(x=HighFreq::SPY, FUN=agg_stats_r, calc_bars="ohlc_skew")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.