export | R Documentation |
This method allows to export the ACTUS contract events and further results such as discount factors (if computed) or selection criteria (if added) for a portfolio to a flat-file.
export(object, file, sep) ## S4 method for signature 'Portfolio' export(object, file = "./events.txt", sep = ",")
object |
The portfolio whose events and further results to export.
Can be an object of class |
file |
A character containing the file path with name to the target file |
sep |
A character containing the separator to be used when writing the file |
Portfolio
,PortfolioFast
,import
# define analysis data ad <- "2015-01-02T00" # construct portfolio data(BondPortfolio) ptf <- PortfolioFast() import(ptf,BondPortfolio, valuationEngines=TRUE) # construct market model yc <- YieldCurve() 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_EA_AAA", Nodes = list(ReferenceDate = ad, Tenors = tenors, Rates = rates))) cpi <- Index() times <- c("2015-01-01T00", "2016-01-01T00", "2017-01-01T00", "2018-01-01T00", "2019-01-01T00") values <- c(100, 110, 120, 130, 140) set(cpi, what=list( MarketObjectCode = "IND_CPI_EA", Data=list(Dates=times,Values=values))) rf <- RFConn() add(rf, list(yc, cpi)) # assign market model to portfolio set(ptf, rf, valuationEngines=TRUE) # generate and process events generateEvents(ptf, ad0=ad) processEvents(ptf, ad0=ad) # export events to external file export(ptf, file="./temp.txt", sep=";") # ... and import again to check results structure res <- read.table("./temp.txt", sep=";", header=TRUE) str(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.