R/functions.r
storethat_futures_market.Rd
Provided with a set of Bloomberg futures active contract tickers, term structure positions, roll parameters and a time period, retrieves the corresponding futures market historical data previously stored in a storethat SQLite database.
storethat_futures_market( file, type, active_contract_tickers, start, end, TS_positions, roll_type, roll_days, roll_months, roll_adjustment, verbose )
file | a scalar chatacter vector. Specifies the target storethat SQLite database file. |
---|---|
type | a scalar character vector, 'term structure' or 'aggregate'. 'term structure'
returns individual futures chain data for a selected portion of the term structure
(specify desired positions in |
active_contract_tickers | a chatacter vector. Specifies the futures active contract Bloomberg tickers to query data for. |
start | a scalar character vector. Specifies the starting date for the query in the following format: 'yyyy-mm-dd'. |
end | a scalar character vector. Specifies the end date for the query in the following format: 'yyyy-mm-dd'. |
TS_positions | an integer vector. Specifies the term structure positions to query data for. |
roll_type | a scalar chatacter vector. Specifies roll type to use for term structure ticker construction. Must be one of 'A', 'B', 'D', 'F', 'N', 'O' or 'R'. |
roll_days | a scalar integer vector. Specifies the day the roll should be done.
Refers to the day of the month ( |
roll_months | a scalar integer vector. Specifies the month the roll should be done.
Refers to the number of months before a reference date ( |
roll_adjustment | a scalar chatacter vector. Specifies roll adjustment method to use for term structure ticker construction. Must be one of 'D', 'N', 'R', or 'W'. |
verbose | a logical scalar vector. Should progression messages be printed? Defaults to TRUE. |
An S4 object of class FuturesTS (type = 'term structure'
) or
FuturesAggregate (type = 'aggregate'
).
"GFUT <GO>" on a Bloomberg terminal.
The rolls dataset in the
BBGsymbols package
(finRes suite) for details
regarding the roll_type
& roll_adjustment
parameters.
The fields dataset in the BBGsymbols package for details on the Bloomnerg fields used here.
if (FALSE) { storethat_futures_market(type = 'term structure', active_contract_tickers = c("W A Comdty", "KWA Comdty"), start = "2000-01-01", end = as.character(Sys.Date()), TS_positions = 1L:5L, roll_type = "A", roll_days = 0L, roll_months = 0L, roll_adjustment = "N") storethat_futures_market(type = "aggregate", active_contract_tickers = c("W A Comdty", "KWA Comdty"), start = "2000-01-01", end = as.character(Sys.Date())) }