Learn R Programming

PCRA (version 1.3.1)

buildPortfolios: 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)

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.

Arguments

selected_stocks

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

See Also

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

Examples

Run this code
body(buildPortfolios)

Run the code above in your browser using DataLab