make_dates: Creates date ranges so as to batch up large API calls into...

View source: R/currencies.R

make_datesR Documentation

Creates date ranges so as to batch up large API calls into many smaller ones

Description

Creates date ranges so as to batch up large API calls into many smaller ones

Usage

make_dates(start_date, end_date, n_days)

Arguments

start_date

A start date (of the form "2010-01-01")

end_date

An end date

n_days

The maximum number of days in each period

Value

A data.frame containing start and end dates for periods of length no longer than n_days

Examples


# Simple test
start_date = "2010-01-01"
end_date = "2020-06-30"
n_days = 365
priceR:::make_dates(start_date, end_date, n_days)

# With lots of periods
start_date = "2010-01-01"
end_date = "2020-06-30"
n_days = 20
priceR:::make_dates(start_date, end_date, n_days)

# Less than one period
start_date = "2020-01-01"
end_date = "2020-06-30"
n_days = 365
priceR:::make_dates(start_date, end_date, n_days)

# 366 days (note 2020 was a leap year)
start_date = "2019-07-30"
end_date = "2020-07-29"
n_days = 365
priceR:::make_dates(start_date, end_date, n_days)

# 365 days
start_date = "2019-07-30"
end_date = "2020-07-28"
n_days = 365
priceR:::make_dates(start_date, end_date, n_days)

# 1095 days (3 years)
start_date = "2019-07-30"
end_date = "2022-07-28"
n_days = 365
priceR:::make_dates(start_date, end_date, n_days)


priceR documentation built on Oct. 22, 2023, 1:10 a.m.