ÎncepețiÎncepe gratuit

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.

Acest exercițiu face parte din cursul

Importing and Managing Financial Data in R

Vezi cursul

Instrucțiuni pentru exercițiu

  • 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.

Exercițiu interactiv practic

Încearcă acest exercițiu completând acest cod de exemplu.

# 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 = ___)
Editează și rulează codul