Compute which changes are required to make a current portfolio identical to a portfolio model

solve_portfolio(portfolio_priced, terse = TRUE)

Arguments

portfolio_priced

a portfolio object, as returned from price_portfolio()

terse

TRUE/FALSE should the returned object only contained the information necessary for downstream operations?

Value

a portfolio object which can be passed to constrain_orders()

Examples

if (FALSE) {
t_conn <- alpaca_connect('paper',
                         Sys.getenv("ALPACA_PAPER_KEY"),
                         Sys.getenv("ALPACA_PAPER_SECRET"))
d_conn <- alpaca_connect('data',
                         Sys.getenv("ALPACA_LIVE_KEY"),
                         Sys.getenv("ALPACA_LIVE_SECRET"))

portfolio_model <- read_portfolio_model(system.file(package='rblncr','extdata/sample_portfolio.yaml'))

get_portfolio_current(t_conn) |>
  load_portfolio_targets(portfolio_model) |>
  price_portfolio(connection = d_conn, price_type = 'close') |>
  solve_portfolio()
}