get | R Documentation |
Implemented e.g. for ContractModel
where
get
returns the value of defined contract term(s) or
for RiskFactor
, ValuationModel
,
and whatever object of this package that is carrying
parameters.
Note that argument what
has to refer to the exact
names of the terms or parameters to retrieve. Whenever
possible, the method converts the values to an R data
format before returning. However, some terms (e.g.
DayCountConvention for a PrincipalAtMaturity) cannot be
converted why the Java reference is returned.
Each element of the what
parameter is expected to
point to an element in the RiskFactorConnector
by
their 'keys'. All elements that can be found in
RiskFactorConnector
are returned.
Allows to retrieve certain information of a portfolio. In
particular, this is a convenience function to access the
Reference Class's fields. Further, using what='size'
the number of contracts in the Portfolio is returned, for
what='ids'
a vector of ContractID
ContractTerms
of the contracts is returned, and if what=[ContractID]
with [ContractID]
the ContractID of a particular
contract in the portfolio then the respective contract is
returned.
A convenience-wrapper to access values of the fields of a
PortfolioTree
.
get(object, what, ...)
## S4 method for signature 'ContractModel,character'
get(object, what)
## S4 method for signature 'RiskFactorConnector,character'
get(object, what)
## S4 method for signature 'ContractType,character'
get(object, what)
## S4 method for signature 'YieldCurve,character'
get(object, what, ...)
## S4 method for signature 'DiscountingEngine,character'
get(object, what)
## S4 method for signature 'EventSeries,character'
get(object, what)
## S4 method for signature 'Portfolio,character'
get(object, what, ...)
## S4 method for signature 'CAPMEngine,character'
get(object, what)
## S4 method for signature 'DynamicYieldCurve,character'
get(object, what, ...)
## S4 method for signature 'ForeignExchangeRate,character'
get(object, what, ...)
## S4 method for signature 'PortfolioTree,character'
get(object, what)
## S4 method for signature 'ReferenceIndex,character'
get(object, what, ...)
object |
A |
what |
A character (-vector) specifying the names of fields to return values for |
... |
A single element or vector of elements representing the values of the requested terms
an object of class RiskFactor
with
'MarketObjectCode'=what
parameter
The respective field or other information element
A list of values of the specified fields
terms,set
add, remove
set
set
pam = Pam()
terms(pam) # get all term names
get(pam, what="NotionalPrincipal") # return value is numeric
get(pam, what="DayCountConvention") # Java reference is returned
yc <- YieldCurve() # create a YieldCurve object
tenors <- c("1W", "1M", "6M", "1Y", "2Y", "5Y")
rates <- c(0.001, 0.0015, 0.002, 0.01, 0.02, 0.03)
set(yc, what = list(MarketObjectCode = "YC_Prim",
Nodes = list(ReferenceDate = "2015-01-01",
Tenors = tenors, Rates = rates)))
ind <- Index() # create a ReferenceIndex object
times <- c("2015-01-01", "2016-01-01", "2017-01-01", "2018-01-01",
"2019-01-01")
values <- c(100, 110, 120, 130, 140)
set(ind, what=list(MarketObjectCode = "CHF_SMI",
Data=list(Dates=times,Values=values)))
rf <- RFConn() # create a RiskFactorConnector object
add(rf,list(yc,ind)) # add all risk factors to the RiskFactorConnector
get(rf, "YC_Prim")
# define analysis data
ad <- "2015-01-02T00"
# construct portfolio
data(BondPortfolio)
ptf <- Portfolio()
import(ptf,BondPortfolio, valuationEngines=TRUE)
# retrieve list of contracts
class(get(ptf, what="contracts"))
# retrieve portfolio size (number of contracts)
get(ptf, what="size")
# retrieve ids of contracts in portfolio
get(ptf, what="ids")
# retrieve contract with specific id
get(ptf, what="110")
tree=Tree()
get(tree,what="leafs")
set(tree, what=list(leafs=list(L1=c(1001,1002),L2=c(1003,1004))))
get(tree,what="leafs")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.