carry_forward_window_gen: Create a sliding window iterator generator

Description Usage Arguments Value

View source: R/windows.r

Description

Create a sliding window iterator generator

Usage

1
carry_forward_window_gen(sorted_times, interval, skip = 1)

Arguments

sorted_times

a vector of date-times in ascending order.

interval

a time interval. The default is minutes(5).

skip

elements on the interval.

Value

an iterator that, when called with nextElem returns the indices in the next window. If there is only one value in the window the last valid index is returned as the first. This allows for carrying prices forward when transactions are sparse in time. data(aapl_fix) aapl_fix$dt_string = paste(aapl_fix$sys_date, aapl_fix$sys_time) aapl_fix$dt = strptime(aapl_fix$dt_string, " it = carry_forward_window_gen(aapl_fix$dt) window1 = nextElem(it) aapl_fix$dt[c(window1[1], tail(window1, 1)] window2 = nextElem(it) aapl_fix$dt[c(window2[1], tail(window2, 1)]


hafen/nxcore documentation built on May 17, 2019, 2:03 p.m.