library(dplyr)
# Basic example - By 3 seconds
idx <- tk_make_timeseries("2016-01-01 00:00:00", by = "3 sec", length_out = 3)
idx
# Make next three timestamps in series
idx %>% tk_make_future_timeseries(length_out = 3)
# Make next 6 seconds of timestamps from the next timestamp
idx %>% tk_make_future_timeseries(length_out = "6 sec")
# Basic Example - By 1 Month
idx <- tk_make_timeseries("2016-01-01", by = "1 month",
length_out = "12 months")
idx
# Make 12 months of timestamps from the next timestamp
idx %>% tk_make_future_timeseries(length_out = "12 months")
# --- APPLICATION ---
# - Combine holiday sequences with future sequences
# Create index of days that FB stock will be traded in 2017 based on 2016 + holidays
FB_tbl <- FANG %>% dplyr::filter(symbol == "FB")
holidays <- tk_make_holiday_sequence(
start_date = "2017-01-01",
end_date = "2017-12-31",
calendar = "NYSE")
# Remove holidays with skip_values, and remove weekends with inspect_weekdays = TRUE
FB_tbl %>%
tk_index() %>%
tk_make_future_timeseries(length_out = "1 year",
inspect_weekdays = TRUE,
skip_values = holidays)
Run the code above in your browser using DataLab