Learn R Programming

PMwR (version 0.11-0)

unit_prices: Compute Prices for Portfolio Based on Units

Description

Compute prices for a portfolio based on outstanding shares.

Usage

unit_prices(NAV, cashflows,
            initial.price = 100, initial.shares = 0,
            cf.included = FALSE)

Arguments

NAV

a dataframe of two columns: timestamp and net asset value

cashflows

a data.frame of two or three columns: timestamp, cashflow and (optionally) an id

initial.price

initial price

initial.shares

number of outstanding shares for first NAV

cf.included

logical

Value

A data.frame

timestamp

NAV

total NAV

price

NAV per share

shares

outstanding shares before cashflows, used for valuation

cashflow

external cashflows

new_shares

shares add/subtracted

total_shares

total outstanding shares after cashflows

NAV_after_cf

total NAV after cashflows

Details

The function may be used to compute the returns for a portfolio with external cashflows, i.e. what is usually called time-weighted returns.

Valuation (i.e. the computation of the NAV) must take place before external cashflows. Fairness suggests that: what price would you give an external investor if you had not valued the positions? And even if fairness mattered not: suppose we traded on a specific day, had a positive PL, and ended the day in cash. We could then not differentiate any more between a cash increase because of an external inflow and a cash increase because of a profitable trade.

References

Schumann, E. (2018) Portfolio Management with R. http://enricoschumann.net/PMwR/

See Also

returns, pl

Examples

Run this code
# NOT RUN {
NAV <- data.frame(timestamp = seq(as.Date("2017-1-1"),
                                  as.Date("2017-1-10"),
                                  by = "1 day"),
                  NAV = c(0,101:104,205:209))

cf <- data.frame(timestamp = c(as.Date("2017-1-1"),
                               as.Date("2017-1-5")),
                 cashflow = c(100, 100))

unit_prices(NAV, cf)

# }

Run the code above in your browser using DataLab