Skip to content

portfolioBacktest

Automated Backtesting of Portfolios over Multiple Datasets

v0.4.2 · May 18, 2026 · GPL-3

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

CRAN

779

Last 30 days

4098th

2.4K

Last 90 days

11.4K

Last year

Trend: -3.8% (30d vs prior 30d)

r2u CRAN

20

Last 30 days

45

Last 90 days

157

Last year

Trend: -16.7% (30d vs prior 30d)

autoCRAN

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

13 OK
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
WARNING r-devel-linux-x86_64-debian-gcc

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
Archived
May 18, 2026
ERROR 13 OK · 0 NOTE · 0 WARNING · 1 ERROR · 0 FAILURE Apr 12, 2026
ERROR r-devel-linux-x86_64-fedora-gcc

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
OK 14 OK · 0 NOTE · 0 WARNING · 0 ERROR · 0 FAILURE Mar 10, 2026

Reverse Dependencies (1)

Dependency Network

Dependencies Reverse dependencies digest evaluate ggplot2 pbapply PerformanceAnalytics quadprog quantmod R.utils rlang xts zoo riskParityPortfolio portfolioBacktest

Version History

12 tracked
new 0.4.2 May 18, 2026
removed 0.4.1 May 18, 2026
new 0.4.1 Mar 10, 2026
updated 0.4.1 ← 0.3.1 diff Apr 21, 2022
updated 0.3.1 ← 0.3.0 diff Oct 16, 2021
updated 0.3.0 ← 0.2.3 diff Sep 20, 2021
updated 0.2.3 ← 0.2.2 diff Jan 11, 2021
updated 0.2.2 ← 0.2.1 diff Aug 2, 2020
updated 0.2.1 ← 0.2.0 diff Oct 6, 2019
updated 0.2.0 ← 0.1.1 diff Aug 22, 2019
updated 0.1.1 ← 0.1.0 diff Jul 5, 2019
new 0.1.0 Jun 18, 2019