Last chance! 50% off unlimited learning
Sale ends in
The result will contain the open and close for the given period, as well as the maximum and minimum prices over the new period, reflected in the new high and low, respectively.
If volume for a period was available, the new volume will also be calculated.
to.minutes(x)
to.minutes3(x)
to.minutes5(x)
to.minutes10(x)
to.minutes15(x)
to.minutes30(x)
to.hourly(x)
to.daily(x,drop.time=TRUE)to.weekly(x,drop.time=TRUE)
to.monthly(x,drop.time=TRUE)
to.quarterly(x,drop.time=TRUE)
to.yearly(x,drop.time=TRUE)
to.period(x, period = months, name, ...)
quantmod.OHLC
, with new periodicity.It is also possible to pass a single time series, such as a univariate exchange rate, and return an OHLC object of lower frequency - e.g. the weekly OHLC of the daily series.
Setting drop.time
to TRUE
(the default)
will convert a series that includes a time
component into one with just a date index, as the time index
is often of little value in lower frequency series.
It is not possible to convert a series from a lower periodicity to a higher periodicity - e.g. weekly to daily or daily to 5 minute bars, as that would require magic.
as.quantmod.OHLC
, getSymbols
,
apply.monthly
# download daily US/EU exchange rate from
# the FRED system
getSymbols("DEXUSEU",src="FRED")
getSymbols("QQQQ",src="yahoo")
# look at the data : )
DEXUSEU # univariate time series
QQQQ # OHLC already
# now it's a yearly OHLC
dex1 <- to.yearly(DEXUSEU)
# first monthly, then to yearly
dex2 <- to.yearly(to.monthly(DEXUSEU))
identical(dex1,dex2) # it's the same!
q1 <- to.yearly(QQQQ)
q2 <- to.yearly(to.monthly(QQQQ))
# these don't match - sometimes dates
# are off depending on when cutoffs
# occur - so BE CAREFUL when converting
# a converted object!
identical(q1,q2)
Run the code above in your browser using DataLab