imprt-methods: import portfolios of contracts from a source of contract data

importR Documentation

import portfolios of contracts from a source of contract data

Description

This method allows to import ACTUS contracts from a data source and append the contracts to an R-portfolio.

Usage

import(object, source, ...)

## S4 method for signature 'Portfolio,data.frame'
import(object, source, ...)

## S4 method for signature 'Portfolio,character'
import(object, source, ...)

Arguments

object

The portfolio where to append the imported contracts. Can be an object of class Portfolio or PortfolioFast.

source

The data source where ACTUS contract data is imported from. This can be a data.frame or a character string with the full filename of the file from which the data is read.

...

Additional parameters can be a character 'sheet' giving the name of the sheet to import when loading from Excel, character 'sep' specifying the separator when loading from text-file, or boolean 'valuationEngines' for all data sources.

Details

Parameter object contains the portfolio to which to append the imported contracts. Note that existing contracts in the portfolio are not removed. Yet, in case of object being a PortfolioFast, existing contracts with same 'ContractID' than newly imported contracts are overwritten.

The data source must contain ACTUS contract data in a table format with column names indicating the ACTUS contract attribute using official attribute long-names (cf. www.projectactus.org). Currently, three data formats are supported:

  • R-data.frame

  • MS Excel 'xls' files

  • flat-files such as 'txt' or 'csv'

If the data is in flat-file format, parameter source contains the path to the file. Further, additional parameters 'sheet' or 'sep' may be used.

The contract data can be extended with additional parameters specifying a valuation engine and its parameters for every contract. The format for such parameters is as follows:

  • 'Valuation_[engine]'

  • 'Valuation_[par1]'

  • 'Valuation_[par2]'

  • ...

where '[engine]' specifies the type of valuation engine (currently supported are 'Discounting', 'MultiCurrencyDiscounting', 'CapitalAssetPricingModel') and '[par1]', ... refer to parameters to the specific type of valuation engine:

  • Discounting: 'RiskFactorObjectLink', 'dc.spread'

  • MultiCurrencyDiscounting: 'CurrencyPair', 'TargetCurrency', 'Currency1', 'Currency2', 'Spread1', 'Spread2', 'InterestRateModelObjectLink1', 'InterestRateModelObjectLink2'

  • CapitalAssetPricingModel: 'IndexObjectLink', 'RiskFreeRatesObjectLink', 'MarketValueObserved', 'ModelAlpha', 'ModelBeta', 'StatusDate'

Further, any number of selection criteria for aggregation purposes can be added using the following format: 'Selection_[criteria]' where '[criteria]' refers to the specific criteria e.g. 'LineOfBusiness'. Notice that the selection criteria are added to the results table of a PortfolioFast only.

Value

a data.frame containing all the exceptions which were thrown

See Also

Portfolio,PortfolioFast,export

Examples

# define analysis data
ad <- "2015-01-02T00"

# load demo portfolio data
data(BondPortfolio)

# check data structure
# (note the format of certain column headers, 
# e.g. Valuation_XX, or Selection_XX)
str(BondPortfolio)

# now create portfolio structure and import demo data
# as portfolio
ptf <- PortfolioFast()
import(ptf,BondPortfolio, valuationEngines=TRUE)

# check portfolio
ptf
get(ptf, what="ids")


wbreymann/FEMS documentation built on May 6, 2024, 2:19 p.m.