Learn R Programming

PMwR (version 0.11-0)

valuation: Valuation

Description

Valuation of financial objects: map an object into a quantity that is measured in a concrete (typically currency) unit.

Usage

valuation(x, ...)

# S3 method for journal valuation(x, multiplier = 1, cashflow = function(x, …) x$amount * x$price, instrument = function(x, …) "cash", flip.sign = TRUE, …)

# S3 method for position valuation(x, price.table, multiplier = 1, do.sum = FALSE, price.unit, verbose = TRUE, …)

Arguments

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 TRUE (the default), a positive amount gets mapped into a negative cashflow.

price.table

numeric

do.sum

logical: sum over positions

price.unit

a named character vector. Not implemented.

verbose

logical

other arguments passed to methods

Value

depends on the object

Details

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.

References

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

See Also

journal

Examples

Run this code
# NOT RUN {
j <- journal(amount = 10, price = 2)
##    amount  price
## 1      10      2
##
## 1 transaction

valuation(j, instrument = NA)
##    amount  price
## 1     -20      1
##
## 1 transaction
# }

Run the code above in your browser using DataLab