This function allow us to make changes to a portfolio model using R tooling. An alternative approach would be to edit the yaml file directly.
update_portfolio_model(portfolio_model, element_name, element_content)
an existing portfolio model
the name of the portfolio model element to replace
the new content of the element
a portfolio model
model <- read_portfolio_model(system.file(package='rblncr','extdata/sample_portfolio.yaml'))
update_portfolio_model(model, 'tolerance', list(percent = 10))
#> $name
#> [1] "sample_portfolio"
#>
#> $description
#> [1] "create from function"
#>
#> $cash
#> $cash$percent
#> [1] 5
#>
#>
#> $assets
#> symbol percent
#> 1 AAPL 30
#> 2 GOOG 30
#> 3 VT 30
#> 4 TSLA 5
#>
#> $tolerance
#> $tolerance$percent
#> [1] 10
#>
#>
#> $cooldown
#> $cooldown$days
#> [1] 365
#>
#>
#> $created_at
#> [1] "2022-10-24T11:22:01"
#>
#> $updated_at
#> [1] "2024-03-18T19:53:12"
#>
#> attr(,"class")
#> [1] "portfolio" "list"