remove | R Documentation |
remove
methodImplemented for various purposes.
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 removed.
Remove contracts from a portfolio by their respective ContractIDs.
remove(object, what, ...) ## S4 method for signature 'RiskFactorConnector,character' remove(object, what, ...) ## S4 method for signature 'Portfolio,character' remove(object, what, ...)
object |
An object of class |
what |
A single or vector of characters representing the ContractIDs of the contracts to be removed |
... |
add
add
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))) fx <- FxRate() # create an FX-Rate object 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(fx, what=list(MarketObjectCode = "CHF/USD", Data=list(Dates=times,Values=values))) rf <- RFConn() # create a RiskFactorConnector object add(rf,list(yc,ind,fx)) # add all risk factors to the RiskFactorConnector containsID(rf, c("YC_Prim", "CHF_SMI", "YC_2")) remove(rf, "YC_Prim") containsID(rf, c("YC_Prim", "CHF_SMI", "YC_2")) # load contract demo data data(BondPortfolio) # create new portfolio ptf <- Portfolio() # import the portfolio import(ptf, BondPortfolio) # get ContractIDs of the contracts in the get(ptf, "ids") # remove the first contract from the portfolio remove(ptf, get(ptf, "ids")[1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.