• java.lang.Object

• public final class SensitivityCsvLoader
extends java.lang.Object

The sensitivities are expected to be in a CSV format known to Strata. The parser currently supports two different CSV formats. Columns may occur in any order.

#### Standard format

The following columns are supported:

• 'Id Scheme' (optional) - the name of the scheme that the identifier is unique within, defaulted to 'OG-Sensitivity'.
• 'Id' (optional) - the identifier of the sensitivity, such as 'SENS12345'.
• 'Reference' - a currency, floating rate name, index name or curve name. The standard reference name for a discount curve is the currency, such as 'GBP'. The standard reference name for a forward curve is the index name, such as 'GBP-LIBOR-3M'. Any curve name may be used however, which will be specific to the market data setup.
• 'Sensitivity Type' - defines the type of the sensitivity value, such as 'ZeroRateDelta' or 'ZeroRateGamma'.
• 'Sensitivity Tenor' - the tenor of the bucketed sensitivity, such as '1Y'.
• 'Sensitivity Date' (optional) - the date of the bucketed sensitivity, such as '2018-06-01'.
• 'Currency' (optional) - the currency of each sensitivity value, such as 'GBP'. If omitted, the currency will be implied from the reference, which must start with the currency.
• 'Value' - the sensitivity value

The identifier columns are not normally present as the identifier is completely optional. If present, the values must be repeated for each row that forms part of one sensitivity. If the parser finds a different identifier, it will create a second sensitivity instance.

When parsing the value column, if the cell is empty, the combination of type/reference/tenor/value will not be added to the result, so use an explicit zero to include a zero value.

#### List format

The following columns are supported:

• 'Id Scheme' (optional) - the name of the scheme that the identifier is unique within, defaulted to 'OG-Sensitivity'.
• 'Id' (optional) - the identifier of the sensitivity, such as 'SENS12345'.
• 'Reference' - a currency, floating rate name, index name or curve name. The standard reference name for a discount curve is the currency, such as 'GBP'. The standard reference name for a forward curve is the index name, such as 'GBP-LIBOR-3M'. Any curve name may be used however, which will be specific to the market data setup.
• 'Sensitivity Tenor' - the tenor of the bucketed sensitivity, such as '1Y'.
• 'Sensitivity Date' (optional) - the date of the bucketed sensitivity, such as '2018-06-01'.
• 'Currency' (optional) - the currency of each sensitivity value, such as 'GBP'. If omitted, the currency will be implied from the reference, which must start with the currency.
• one or more sensitivity value columns, the type of the sensitivity is specified by the header name, such as 'ZeroRateDelta'.

The identifier columns are not normally present as the identifier is completely optional. If present, the values must be repeated for each row that forms part of one sensitivity. If the parser finds a different identifier, it will create a second sensitivity instance.

When parsing the value columns, if the cell is empty, the combination of type/reference/tenor/value will not be added to the result, so use an explicit zero to include a zero value.

#### Grid format

The following columns are supported:

• 'Id Scheme' (optional) - the name of the scheme that the identifier is unique within, defaulted to 'OG-Sensitivity'.
• 'Id' (optional) - the identifier of the sensitivity, such as 'SENS12345'.
• 'Sensitivity Type' - defines the type of the sensitivity value, such as 'ZeroRateDelta' or 'ZeroRateGamma'.
• 'Sensitivity Tenor' - the tenor of the bucketed sensitivity, such as '1Y'.
• 'Sensitivity Date' (optional) - the date of the bucketed sensitivity, such as '2018-06-01'.
• 'Currency' (optional) - the currency of each sensitivity value, such as 'GBP'. If omitted, the currency will be implied from the reference, which must start with the currency.
• one or more sensitivity value columns, the reference of the sensitivity is specified by the header name. The reference can be a currency, floating rate name, index name or curve name. The standard reference name for a discount curve is the currency, such as 'GBP'. The standard reference name for a forward curve is the index name, such as 'GBP-LIBOR-3M'. Any curve name may be used however, which will be specific to the market data setup.

The identifier columns are not normally present as the identifier is completely optional. If present, the values must be repeated for each row that forms part of one sensitivity. If the parser finds a different identifier, it will create a second sensitivity instance.

When parsing the value columns, if the cell is empty, the combination of type/reference/tenor/value will not be added to the result, so use an explicit zero to include a zero value.

#### Resolver

The standard resolver will ensure that the sensitivity always has a tenor and implements TenoredParameterMetadata. The resolver can be adjusted to allow date-only metadata (thereby making the 'Sensitivity Tenor' column optional. The resolver can manipulate the tenor and/or curve name that is parsed if desired.
• ### Method Summary

All Methods
Modifier and Type Method Description
boolean isKnownFormat​(com.google.common.io.CharSource charSource)
Checks whether the source is a CSV format sensitivities file.
ValueWithFailures<com.google.common.collect.ListMultimap<java.lang.String,​CurveSensitivities>> load​(java.util.Collection<ResourceLocator> resources)
Loads one or more CSV format sensitivities files.
static SensitivityCsvLoader of​(ReferenceData refData)
Obtains an instance that uses the specified set of reference data.
static SensitivityCsvLoader of​(SensitivityCsvInfoResolver resolver)
Obtains an instance that uses the specified resolver for additional information.
ValueWithFailures<com.google.common.collect.ListMultimap<java.lang.String,​CurveSensitivities>> parse​(java.util.Collection<com.google.common.io.CharSource> charSources)
Parses one or more CSV format position files, returning sensitivities.
static SensitivityCsvLoader standard()
Obtains an instance that uses the standard set of reference data.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Method Detail

• #### standard

public static SensitivityCsvLoader standard()
Obtains an instance that uses the standard set of reference data.
Returns:
• #### of

public static SensitivityCsvLoader of​(ReferenceData refData)
Obtains an instance that uses the specified set of reference data.
Parameters:
refData - the reference data
Returns:
• #### of

public static SensitivityCsvLoader of​(SensitivityCsvInfoResolver resolver)
Obtains an instance that uses the specified resolver for additional information.
Parameters:
resolver - the resolver used to parse additional information
Returns:
• #### isKnownFormat

public boolean isKnownFormat​(com.google.common.io.CharSource charSource)
Checks whether the source is a CSV format sensitivities file.

This parses the headers as CSV and checks that mandatory headers are present.

Parameters:
charSource - the CSV character source to check
Returns:
true if the source is a CSV file with known headers, false otherwise

public ValueWithFailures<com.google.common.collect.ListMultimap<java.lang.String,​CurveSensitivities>> load​(java.util.Collection<ResourceLocator> resources)
Loads one or more CSV format sensitivities files.

In most cases each file contains one sensitivity instance, however the file format is capable of representing any number.

Within a single file and identifier, the same combination of type, reference and tenor must not be repeated. No checks are performed between different input files. It may be useful to merge the sensitivities in the resulting list in a separate step after parsing.

CSV files sometimes contain a Unicode Byte Order Mark. This method uses UnicodeBom to interpret it.

Parameters:
resources - the CSV resources
Returns:
the sensitivities keyed by identifier, parsing errors are captured in the result
• #### parse

public ValueWithFailures<com.google.common.collect.ListMultimap<java.lang.String,​CurveSensitivities>> parse​(java.util.Collection<com.google.common.io.CharSource> charSources)
Parses one or more CSV format position files, returning sensitivities.

The standard way to write sensitivities files is for each file to contain one sensitivity instance. The file format can handle multiple instances per file, where each instance has a separate identifier. Most files will not have the identifier columns, thus the identifier will be the empty string.

The returned multimap is keyed by identifier. The value will contain one entry for each instance. If desired, the results can be reduced using CurveSensitivities.mergedWith(CurveSensitivities) to merge those with the same identifier.

CSV files sometimes contain a Unicode Byte Order Mark. Callers are responsible for handling this, such as by using UnicodeBom.

Parameters:
charSources - the CSV character sources
Returns:
the loaded sensitivities, parsing errors are captured in the result