ComenzarEmpieza gratis

Aggregate irregular intra-day data

Intraday data can be huge, with hundreds of thousands of observations per day, millions per month, and hundreds of millions per year. These datasets often need to be aggregated before you can work with them.

You learned how to aggregate daily data in the Introduction to xts and zoo course. This exercise will use to.period() to aggregate intraday data to an OHLC series. You often need to specify both period and k arguments to aggregate intraday data.

The intraday_xts object contains one trading day of random data.

Este ejercicio forma parte del curso

Importing and Managing Financial Data in R

Ver curso

Instrucciones del ejercicio

  • Use to.period() to convert intraday_xts into a 5-second price series called xts_5sec.
  • Use to.period() to convert intraday_xts into a 10-minute price series called xts_10min.
  • Use to.period() to convert intraday_xts into a 1-hour price series called xts_1hour.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Convert raw prices to 5-second prices
xts_5sec <- to.period(intraday_xts, period = "___", k = ___)

# Convert raw prices to 10-minute prices
xts_10min <-

# Convert raw prices to 1-hour prices
xts_1hour <- to.period(___, period = "___", k = ___)
Editar y ejecutar código