Description Usage Arguments Zipline Documentation Examples
fly_schedule_function()
allows you to schedule an R function to run at
timed iterations. Helpers are defined to declare the frequency at which
to execute the function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | fly_schedule_function(func, date_rule = NULL, time_rule = NULL,
half_days = TRUE, calendar = NULL)
every_day()
month_end(days_offset = 0L)
month_start(days_offset = 0L)
week_end(days_offset = 0L)
week_start(days_offset = 0L)
every_minute()
market_close()
market_open()
|
func |
The function to execute at timed intervals. Must take |
date_rule |
One of: |
time_rule |
One of: |
half_days |
A boolean. Should this rule fire on half days? |
calendar |
Calendar used to reconcile date and time rules. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Just print i at each iteration
scheduled_fn <- function(context, data) {
print(context$i)
}
fly_initialize <- function(context) {
# Init to 0
context$i = 0L
# No extra timing arguments means "Always" (every day / every minute)
fly_schedule_function(scheduled_fn)
}
fly_handle_data <- function(context, data) {
# Increment day
context$i <- context$i + 1L
}
# You should see the context$i variable printed at each day
performance <- fly_run_algorithm(
fly_initialize,
fly_handle_data,
start = as.Date("2015-01-01"),
end = as.Date("2016-01-01")
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.