{"id":26686455,"url":"https://github.com/dppalomar/portfoliobacktest","last_synced_at":"2025-04-12T16:52:43.786Z","repository":{"id":43701322,"uuid":"148288881","full_name":"dppalomar/portfolioBacktest","owner":"dppalomar","description":"Automated Backtesting of Portfolios over Multiple Datasets","archived":false,"fork":false,"pushed_at":"2022-04-26T01:01:35.000Z","size":131527,"stargazers_count":60,"open_issues_count":3,"forks_count":12,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-26T11:18:54.500Z","etag":null,"topics":["backtesting","financial-markets","portfolio"],"latest_commit_sha":null,"homepage":"https://cran.r-project.org/package=portfolioBacktest","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dppalomar.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-11T08:55:36.000Z","updated_at":"2025-03-14T02:01:14.000Z","dependencies_parsed_at":"2022-08-22T04:00:35.660Z","dependency_job_id":null,"html_url":"https://github.com/dppalomar/portfolioBacktest","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dppalomar%2FportfolioBacktest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dppalomar%2FportfolioBacktest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dppalomar%2FportfolioBacktest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dppalomar%2FportfolioBacktest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dppalomar","download_url":"https://codeload.github.com/dppalomar/portfolioBacktest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248601310,"owners_count":21131608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtesting","financial-markets","portfolio"],"created_at":"2025-03-26T11:19:02.752Z","updated_at":"2025-04-12T16:52:43.757Z","avatar_url":"https://github.com/dppalomar.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nalways_allow_html: yes\noutput:\n  html_document:\n    keep_md: yes\n    variant: markdown_github\n  md_document:\n    variant: markdown_github\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nlibrary(knitr)\nopts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  fig.align = \"center\",\n  fig.retina = 2,\n  out.width = \"75%\",\n  dpi = 96\n)\nknit_hooks$set(pngquant = hook_pngquant)\n```\n\n\n\n# portfolioBacktest\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/portfolioBacktest)](https://CRAN.R-project.org/package=portfolioBacktest)\n[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/portfolioBacktest)](https://CRAN.R-project.org/package=portfolioBacktest)\n[![CRAN Downloads Total](https://cranlogs.r-pkg.org/badges/grand-total/portfolioBacktest?color=brightgreen)](https://CRAN.R-project.org/package=portfolioBacktest)\n\nAutomated backtesting of multiple portfolios over multiple \ndatasets of stock prices in a rolling-window fashion. Intended for \nresearchers and practitioners to backtest a set of different portfolios, \nas well as by a course instructor to assess the students in their portfolio \ndesign in a fully automated and convenient manner, with results conveniently \nformatted in tables and plots. Each portfolio design is easily defined as a\nfunction that takes as input a window of the stock prices and outputs the \nportfolio weights. Multiple portfolios can be easily specified as a list \nof functions or as files in a folder. Multiple datasets can be conveniently \nextracted randomly from different markets, different time periods, and \ndifferent subsets of the stock universe. The results can be later assessed \nand ranked with tables based on a number of performance criteria (e.g., \nexpected return, volatility, Sharpe ratio, drawdown, turnover rate, return \non investment, computational time, etc.), as well as plotted in a number of \nways with nice barplots and boxplots.\n\n\n## Installation\nThe package can be installed from [CRAN](https://CRAN.R-project.org/package=portfolioBacktest) or [GitHub](https://github.com/dppalomar/portfolioBacktest):\n```{r, eval=FALSE}\n# install stable version from CRAN\ninstall.packages(\"portfolioBacktest\")\n\n# install development version from GitHub\ndevtools::install_github(\"dppalomar/portfolioBacktest\")\n```\n\nTo get help:\n```{r, eval=FALSE}\nlibrary(portfolioBacktest)\nhelp(package = \"portfolioBacktest\")\n?portfolioBacktest\n```\n\nTo cite `portfolioBacktest` in publications:\n```{r, eval=FALSE}\ncitation(\"portfolioBacktest\")\n```\n\n\n## Quick Start\nDo the backtest on your own portfolio following few steps:\n\n- **Step 1** - load package \u0026 10 datasets\n```{r, message=FALSE, results=\"hide\"}\nlibrary(portfolioBacktest)\ndata(\"dataset10\")\n```\n- **Step 2** - define your own portfolio\n```{r}\nmy_portfolio \u003c- function(dataset, w_current) {\n  prices \u003c- dataset$adjusted\n  N \u003c- ncol(prices)\n  return(rep(1/N, N))\n}\n```\n- **Step 3** - do backtest\n```{r, message=FALSE, results=\"hide\"}\nbt \u003c- portfolioBacktest(my_portfolio, dataset10)\n```\n- **Step 4** - check your portfolio performance (e.g., median of the 10 individual backtests)\n```{r}\nbacktestSummary(bt)$performance\n```\n\nFor a more detailed explanation on how to use the package with all the features, check the [vignette](https://CRAN.R-project.org/package=portfolioBacktest/vignettes/PortfolioBacktest.html).\n\n\n\n## Package Snapshot\nThis package backtests a list of portfolios over multiple datasets on a rolling-window basis, producing final results as in the following.\n\n- Performance table:\n\n```{r README-table, echo=FALSE, message=FALSE, out.width=\"95%\"}\n#library(portfolioBacktest)\n#load(\"man/figures/bt.RData\")\n#res_sum \u003c- backtestSummary(bt)\n#summaryTable(res_sum, type = \"DT\", order_col = 2, order_dir = \"desc\")\nknitr::include_graphics(\"man/figures/README-table.png\")\n```\n\n\n- Barplot:\n\n```{r README-barplot, echo=FALSE, out.width=\"70%\"}\n#summaryBarPlot(res_sum, measures = c(\"Sharpe ratio\", \"max drawdown\"), type = \"ggplot2\")\nknitr::include_graphics(\"man/figures/README-barplot.png\")\n```\n\n\n- Boxplot:\n\n```{r README-boxplot, echo=FALSE, out.width=\"70%\"}\n#backtestBoxPlot(bt, measure = \"Sharpe ratio\")\nknitr::include_graphics(\"man/figures/README-boxplot.png\")\n```\n\n## Documentation\nFor more detailed information, please check the\n[vignette](https://CRAN.R-project.org/package=portfolioBacktest/vignettes/PortfolioBacktest.html).\n\n\n## Links\nPackage: [CRAN](https://CRAN.R-project.org/package=portfolioBacktest) and [GitHub](https://github.com/dppalomar/portfolioBacktest).\n\nREADME file: [GitHub-readme](https://github.com/dppalomar/portfolioBacktest/blob/master/README.md).\n\nVignette: [CRAN-vignette](https://CRAN.R-project.org/package=portfolioBacktest/vignettes/PortfolioBacktest.html) and [GitHub-vignette](https://htmlpreview.github.io/?https://github.com/dppalomar/portfolioBacktest/blob/master/vignettes/PortfolioBacktest.html).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdppalomar%2Fportfoliobacktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdppalomar%2Fportfoliobacktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdppalomar%2Fportfoliobacktest/lists"}