R/portfolio_objects.R
add_model_prediction.Rd
Add model prediction to returnPrediction S3 object
add_model_prediction(
return_prediction,
model_function,
config,
new_predictions
)
Add model prediction to this object
Name of the prediction (model) function
Configuration for the model
Tibble with stock_id, date, and prediction columns
returnPrediction S3 object with added model prediction
if (FALSE) {
# Assuming 'return_prediction' has been initialized and contains actual returns
# Sample new prediction data
new_predictions <- tibble::tibble(
stock_id = 1:100,
date = seq.Date(Sys.Date(), by = "day", length.out = 100),
prediction = runif(100) # Example prediction values
)
# Model function and config for demonstration
model_function <- "xgb_pred" # Placeholder for your model function
config <- list(max_depth = 4, eta = 0.1) # Example configuration
# Adding the new model predictions
rp <- add_model_prediction(rp, model_function, config, new_predictions)
print(rp$predictions)
print(rp$errors)
print(rp$models)
}