vat-methods: Generic method to retrieve the value of a...

valueAtR Documentation

Generic method to retrieve the value of a ForeignExchangeRate,ReferenceIndex object at a certain point in time

Description

ForeignExchangeRate,ReferenceIndex risk factors define the dynamics of the respective risk factor over time. valueAt computes or retrieves the value of this risk factor at a future point in time.

Usage

valueAt(object, at, ...)

## S4 method for signature 'ForeignExchangeRate,character'
valueAt(object, at, ...)

## S4 method for signature 'ReferenceIndex,character'
valueAt(object, at, ...)

Arguments

object

An object of class RiskFactor for which to return it's value at a given point in time

at

The point in time at which to return the value

...

Value

numeric The value of the respective risk factor at the specified point in time

Examples


# create an FX-Rate object
fx <- FxRate() 

# define time stamps and values
times <- c("2015-01-01", "2016-01-01", "2017-01-01", 
           "2018-01-01", "2019-01-01")
values <- c(1.04, 1.05, 1.2, 1.0, 0.9)

# set the MarketObjectCode and TimeSeries
set(fx, what = list(MarketObjectCode = "CHF/USD",
                    TimeSeries = list(Dates=times,Values=values)))  

# get the MarketObjectCode
get(fx, "MarketObjectCode")

# get values of the risk factor at certain times
valueAt(fx, "2016-01-01")
valueAt(fx, c("2016-01-01", "2018-07-01", "2018-07-01"))


wbreymann/FEMS documentation built on Dec. 8, 2022, 9:43 a.m.