Description Usage Arguments Details Value Examples
Given an OHLC time series at high periodicity (say seconds), calculates the OHLC prices at a lower periodicity (say minutes).
1 2 3 4 5 6 | to_period(
oh_lc,
period = "minutes",
k = 1,
end_points = xts::endpoints(oh_lc, period, k)
)
|
|
An OHLC time series of prices in xts format. |
|
aggregation interval ("seconds", "minutes", "hours", "days", "weeks", "months", "quarters", and "years"). |
|
The number of periods to aggregate over (for example if
|
|
An integer vector of end points. |
The function to_period()
performs a similar aggregation as
function xts::to.period()
from package
xts, but has
the flexibility to aggregate to a user-specified vector of end points. The
function to_period()
simply calls the compiled function
toPeriod()
(from package
xts), to
perform the actual aggregations. If end_points
are passed in
explicitly, then the period
argument is ignored.
A OHLC time series of prices in xts format, with a lower periodicity defined by the end_points.
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
# Define end points at 10-minute intervals (HighFreq::SPY is minutely bars)
end_points <- rutils::calc_endpoints(HighFreq::SPY["2009"], inter_val=10)
# Aggregate over 10-minute end_points:
rutils::to_period(oh_lc=HighFreq::SPY["2009"], end_points=end_points)
# Aggregate over days:
rutils::to_period(oh_lc=HighFreq::SPY["2009"], period="days")
# Equivalent to:
xts::to.period(x=HighFreq::SPY["2009"], period="days", name=rutils::get_name(colnames(HighFreq::SPY)[1])
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.