buildPortfolios: Build a List of Portfolio Specifications (Default Example)

View source: R/buildPortfolios.R

buildPortfoliosR Documentation

Build a List of Portfolio Specifications (Default Example)

Description

This function serves as the default example for the buildPortfolios argument in runMultipleBacktests. It demonstrates how to construct a list of portfolio specifications using portfolio.spec, add.constraint, and add.objective from the PortfolioAnalytics package.

Users are encouraged to write their own portfolio list following the same structure of this function: one input (selected_stocks), one output (a named list of portfolio.spec objects), and pass it to runMultipleBacktests() via the buildPortfolios argument.

Usage

buildPortfolios(selected_stocks)

Arguments

selected_stocks

Character vector. Tickers of the assets to include in the portfolio.

Value

A list of portfolio.spec objects, one per strategy. It is strongly recommended to name each element of the list, as the names are used as labels across all outputs.

See Also

runMultipleBacktests, portfolio.spec, add.constraint, add.objective

Examples

body(buildPortfolios)

PCRA documentation built on July 15, 2026, 9:06 a.m.