to_period: Aggregate an _xts_ time series to a lower periodicity.

View source: R/rutils.R

to_periodR Documentation

Aggregate an xts time series to a lower periodicity.

Description

Given an xts time series at high periodicity (say seconds), calculate the OHLC prices at a lower periodicity (say minutes).

Usage

to_period(timeser, period = "minutes", k = 1)

Arguments

timeser

An xts time series of prices.

period

Aggregation interval ("seconds", "minutes", "hours", "days", "weeks", "months", "quarters", and "years").

k

The number of periods to aggregate over (for example if period="minutes" and k=2, then aggregate over two minute intervals.)

Details

The function to_period() is a wrapper for the function xts::to.period() from package xts.

Value

A OHLC time series of prices in xts format, with a lower periodicity.

Examples

## Not run: 
# Aggregate the OHLC prices from minutes to days:
ohlc <- rutils::to_period(timeser=HighFreq::SPY["2009"], period="days")

## End(Not run)


algoquant/rutils documentation built on June 10, 2025, 3:55 p.m.