make_sim_prices_matrix.Rd
Transforms a wrangled contracts dataframe (the output of
wrangle_contracts_on_oi
) into a wide numerical matrix for simulation.
Returns a matrix with 3 columns per symbol plus the date. Symbols appear as
suffixes in the column names (the *
below).
Handles missing data by filling forward the last value, except for leading NAs which persist.
make_sim_prices_matrix(wrangled_contracts)
dataframe output of wrangle_contracts_on_oi()
Wide numerical matrix with the following columns:
date: numerical days since epoch
close_current_contract_*
: n
columns designating the closing price
(closepoint_value) of the current contract for each symbol.
close_previous_contract_*
: n
columns designating the closing price
(closepoint_value) of yesterday's contract for each symbol. Will have the
same value as close_current_contract unless there was a roll.
roll_*
: n
columns of (0,1) designating whether a roll occurs on the
current date (1) or not (0).
if (FALSE) {
wrangled <- wrangle_contracts_on_oi(futures)
sim_prices <- make_sim_prices_matrix(wrangled)
}