R/solve_portfolio.R
solve_portfolio.Rd
Compute which changes are required to make a current portfolio identical to a portfolio model
solve_portfolio(portfolio_priced, terse = TRUE)
a portfolio object, as returned from price_portfolio()
TRUE/FALSE should the returned object only contained the information necessary for downstream operations?
a portfolio object which can be passed to constrain_orders()
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()
}