diffohlc: Calculate the reduced form of an _OHLC_ time series, or...

View source: R/rutils.R

diffohlcR Documentation

Calculate the reduced form of an OHLC time series, or calculate the standard form from the reduced form of an OHLC time series.

Description

Calculate the reduced form of an OHLC time series, or calculate the standard form from the reduced form of an OHLC time series.

Usage

diffohlc(ohlc, reducit = TRUE, ...)

Arguments

ohlc

An OHLC time series of prices in xts format.

reducit

A Boolean argument: should the reduced form be calculated or the standard form? (default is TRUE)

...

Additional arguments to function xts::diff.xts().

Details

The reduced form of an OHLC time series is obtained by calculating the time differences of its Close prices, and by calculating the differences between its Open, High, and Low prices minus the Close prices. The standard form is the original OHLC time series, and can be calculated from its reduced form by reversing those operations.

Value

An OHLC time series with five columns for the Open, High, Low, Close prices, and the Volume, and with the same time index as the input series.

Examples

# Calculate reduced form of an OHLC time series
diff_VTI <- rutils::diffohlc(rutils::etfenv$VTI)
# Calculate standard form of an OHLC time series
VTI <- rutils::diffohlc(diff_VTI, reducit=FALSE)
identical(VTI, rutils::etfenv$VTI[, 1:5])

algoquant/rutils documentation built on April 18, 2024, 12:05 a.m.