portfolioBacktest
Automated Backtesting of Portfolios over Multiple Datasets
Description
Automated backtesting of multiple portfolios over multiple datasets of stock prices in a rolling-window fashion. Intended for researchers and practitioners to backtest a set of different portfolios, as well as by a course instructor to assess the students in their portfolio design in a fully automated and convenient manner, with results conveniently formatted in tables and plots. Each portfolio design is easily defined as a function that takes as input a window of the stock prices and outputs the portfolio weights. Multiple portfolios can be easily specified as a list of functions or as files in a folder. Multiple datasets can be conveniently extracted randomly from different markets, different time periods, and different subsets of the stock universe. The results can be later assessed and ranked with tables based on a number of performance criteria (e.g., expected return, volatility, Sharpe ratio, drawdown, turnover rate, return on investment, computational time, etc.), as well as plotted in a number of ways with nice barplots and boxplots. See Chapter 8 (Portfolio Backtesting) of the book: Daniel P. Palomar, "Portfolio Optimization: Theory and Application", Cambridge University Press, 2025.
Downloads
779
Last 30 days
4098th
2.4K
Last 90 days
11.4K
Last year
Trend: -3.8% (30d vs prior 30d)
20
Last 30 days
45
Last 90 days
157
Last year
Trend: -16.7% (30d vs prior 30d)
4
Last 7 days
14
Last 30 days
2
All-time
autoCRAN-only: this name is served only by autoCRAN, so the count is exact.
CRAN Check Status
Show all 13 flavors
| Flavor | Status |
|---|---|
| r-devel-linux-x86_64-debian-clang | OK |
| r-devel-linux-x86_64-debian-gcc | OK |
| r-devel-linux-x86_64-fedora-clang | OK |
| r-devel-linux-x86_64-fedora-gcc | OK |
| r-devel-windows-x86_64 | OK |
| r-oldrel-macos-arm64 | OK |
| r-oldrel-macos-x86_64 | OK |
| r-oldrel-windows-x86_64 | OK |
| r-patched-linux-x86_64 | OK |
| r-release-linux-x86_64 | OK |
| r-release-macos-arm64 | OK |
| r-release-macos-x86_64 | OK |
| r-release-windows-x86_64 | OK |
Check History
OK 13 OK · 0 NOTE · 0 WARNING · 0 ERROR · 0 FAILURE Jun 8, 2026
WARNING 12 OK · 0 NOTE · 1 WARNING · 0 ERROR · 0 FAILURE Jun 7, 2026
for unstated dependencies in examples
Warning in file(out, "wt") : cannot open file '/tmp/RtmpITzZD0/file35210b4f368b0/stockDataDownload.R': No space left on device Error in file(out, "wt") : cannot open the connection Execution halted
OK 13 OK · 0 NOTE · 0 WARNING · 0 ERROR · 0 FAILURE May 24, 2026
ERROR 13 OK · 0 NOTE · 0 WARNING · 1 ERROR · 0 FAILURE Apr 12, 2026
tests
Running ‘testthat.R’ [160s/386s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(testthat)
> library(portfolioBacktest)
>
> test_check("portfolioBacktest")
Saving _problems/test-portfolioBacktest-73.R
Saving _p
...[truncated]...
cs and base R ──
Expected `bt_next_period$Uniform$`dataset 1`$w_bop` to be equivalent to `PerfAnal_next_day$BOP.Weight`.
Numeric: lengths (158, 198) differ
[ FAIL 7 | WARN 2 | SKIP 0 | PASS 61 ]
Error:
! Test failures.
Execution halted