valuation: Valuation

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/valuation.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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, 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

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.

Value

depends on the object

Note

Very experimental.

Author(s)

Enrico Schumann <[email protected]>

References

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

See Also

journal

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
j <- journal(amount = 10, price = 2)
##    amount  price
## 1      10      2
##
## 1 transaction

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

enricoschumann/PMwR documentation built on Sept. 23, 2018, 5:14 a.m.