Get the current value of a portfolio's holdings

price_portfolio(
  portfolio,
  connection,
  price_type = "close",
  percent_decimal_places = 2
)

Arguments

portfolio

an extended portfolio object, as returned from load_portfolio_targets()

connection

a backend data connection

price_type

which price to use. 'close' is the only supported value at this time.

percent_decimal_places

define the decimal places to round the portfolio percentage weights calculation to

Value

a portfolio object with closing prices which can be passed to solve_portfolio()

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')
}