Get the current value of a portfolio's holdings
price_portfolio(
portfolio,
connection,
price_type = "close",
percent_decimal_places = 2
)
an extended portfolio object, as returned from load_portfolio_targets()
a backend data connection
which price to use. 'close' is the only supported value at this time.
define the decimal places to round the portfolio percentage weights calculation to
a portfolio object with closing prices which can be passed to solve_portfolio()
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')
}