periods: Change the period of an 'xts' dataset

Description Usage Arguments Examples

Description

Transform the minutely intraday stock price data into different frequencies

Usage

1
periods(dataset, k=10, on="minutes", xtsConvert=NULL, output="xts")

Arguments

dataset

an 'ohlcv' dataset, must be 'xts' class. if not, 'xtsConvert = TRUE' can be used for transformation.

on

the frequency of time period. must be an integer.

k

time period. it can be used with following syntax: "minutes", "hours", "days" and "months"

xtsConvert

data transformation into 'xts' class.

output

the output class of periodic conversion data. it can be transformed into "xts", data."frame" and "data.table" classes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# DO NOT RUN!
# conversion of 1-min Apple Inc. stock prices into 10-min
aapl <- intraday_live("aapl"),
aapl_10min <- periods(aapl, k=10, on="minutes")

# minutely data to hourly data
aapl <- intraday_live("aapl"),
aapl_10min <- periods(aapl, k=1, on="hours")


# convert from a 'data.table' minutely data into hourly 'xts' data.
csco_dt <- intraday_live(stock="csco", type="data.table")
csco_1h <- periods(csco_dt, k=1, on="hours", xtsConvert = TRUE)
csco_1h_df <- periods(csco_dt, k=1, on="hours", xtsConvert = TRUE, output="data.frame")

egeor90/intraday documentation built on May 17, 2019, 2:14 a.m.