Valuation
Valuation of financial objects: map an object into a quantity that is measured in a concrete (typically currency) unit.
valuation(x, ...) ## S3 method for class 'journal' valuation(x, multiplier = 1, cashflow = function(x, ...) x$amount * x$price, instrument = function(x, ...) "cash", flip.sign = TRUE, ...) ## S3 method for class 'position' valuation(x, vprice, multiplier = 1, do.sum = FALSE, price.unit, use.names = FALSE, verbose = TRUE, do.warn = TRUE, ...)
x |
an object |
multiplier |
a numeric vector, typically with named elements |
cashflow |
either a numeric vector or a function that takes on argument (a journal) and transforms it into a numeric vector |
instrument |
either a character vector or a function that takes on argument (a journal) and transforms it into a character vector |
flip.sign |
logical. If |
vprice |
numeric: a matrix whose elements
correspond to those in |
do.sum |
logical: sum over positions |
use.names |
logical: use names of |
price.unit |
a named character vector. Not implemented. |
verbose |
logical |
do.warn |
logical |
... |
other arguments passed to methods |
valuation
is a generic function. Its
semantics suggest that an object (e.g. a financial
instrument or a position) is mapped into a concrete
quantity (such as an amount of some currency).
The journal
method transforms the
transactions in a journal into amounts of currency
(e.g, a sale of 100 shares of a company is
transformed into the value of these 100 shares).
The position
method takes a position
and returns the value (in currency units) of the
position.
depends on the object: for journals, a journal
Very experimental.
Enrico Schumann <es@enricoschumann.net>
Schumann, E. (2020) Portfolio Management with R. http://enricoschumann.net/R/packages/PMwR/
## valuing a JOURNAL j <- journal(amount = 10, price = 2) ## amount price ## 1 10 2 ## ## 1 transaction valuation(j, instrument = NA) ## amount price ## 1 -20 1 ## ## 1 transaction ## valuing a POSITION pos <- position(c(AMZN = -10, MSFT = 200)) ### contructing a price table: ### ==> P[i, j] must correspond to pos[i, j] P <- array(c(2200, 170), dim = c(1, 2)) colnames(P) <- instrument(pos) valuation(pos, vprice = P) ## AMZN MSFT ## [1,] -22000 34000 ### contructing a price table, alternative: ### a named vector ### ==> only works when there is only a single timestamp valuation(pos, vprice = c(MSFT = 170, AMZN = 2200)) all.equal(valuation(pos, vprice = P), valuation(pos, vprice = c(MSFT = 170, AMZN = 2200)))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.