An R6 class for performing Monte Carlo simulations on financial time series data. This class provides methods for data preparation, simulation execution, and result visualization.
Details
The MonteCarlo class uses historical price data to calculate volatility and perform Monte Carlo simulations for future price movements. It leverages the C++ implementation of the Monte Carlo algorithm for efficiency.
Public fields
data
A data.table containing the historical price data.
simulation_results
A data.table containing the results of the Monte Carlo simulation.
end_prices
A data.table containing the final prices from each simulation path.
log_historical
Logical. Whether to use log returns for historical volatility calculation.
number_sims
Integer. The number of simulation paths to generate.
project_days
Integer. The number of days to project into the future.
start_date
POSIXct. The start date for the simulation (last date of historical data).
verbose
Logical. Whether to print progress messages.
Methods
Method new()
Create a new MonteCarlo object.
Usage
MonteCarlo$new(
dt,
log_historical = FALSE,
number_sims = 1000,
project_days = 30,
verbose = FALSE
)
Arguments
dt
A data.table containing historical price data.
log_historical
Logical. Whether to use log returns for historical volatility calculation.
number_sims
Integer. The number of simulation paths to generate.
project_days
Integer. The number of days to project into the future.
verbose
Logical. Whether to print progress messages.