| run_backtest | R Documentation |
Main backtesting engine that simulates portfolio performance over time. Handles position tracking, transaction costs, and performance calculation.
run_backtest(
prices,
weights,
initial_capital = 1e+05,
name = "Strategy",
verbose = FALSE,
stop_loss = NULL,
stop_monitoring_prices = NULL
)
prices |
Price data (data.frame with Date column) |
weights |
Weight matrix from weighting functions |
initial_capital |
Starting capital (default: 100000) |
name |
Strategy name for reporting |
verbose |
Print progress messages (default: FALSE) |
stop_loss |
Optional stop loss percentage as decimal |
stop_monitoring_prices |
Optional daily prices for stop monitoring |
backtest_result object with performance metrics
data("sample_prices_weekly")
momentum <- calc_momentum(sample_prices_weekly, lookback = 12)
selected <- filter_top_n(momentum, n = 10)
weights <- weight_equally(selected)
result <- run_backtest(sample_prices_weekly, weights)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.