Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSV loader for sensitivities #1816

Merged
merged 2 commits into from Oct 16, 2018
Merged

Add CSV loader for sensitivities #1816

merged 2 commits into from Oct 16, 2018

Conversation

jodastephen
Copy link
Member

Provides the ability to load sensitivities in two formats
Leniently handles some older formats

Provides the ability to load sensitivities in two formats
Leniently handles some older formats
* <ul>
* <li>'Id Scheme' (optional) - the name of the scheme that the identifier is unique within, defaulted to 'OG-Sensitivity'.
* <li>'Id' (optional) - the identifier of the sensitivity, such as 'SENS12345'.
* <li>'Reference - a currency, floating rate name, index name or curve name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing '

* <li>'Sensitivity Date' (optional) - the date of the bucketed sensitivity, such as '2018-06-01'.
* <li>'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.
* <li>one or more sensitivity value columns, the reference of the sensitivity is specified by the header name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the doc seems odd? Starts talking about references again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You either have a reference column and flexible types, or a type column and flexible references.

* 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.
* <li>'Sensitivity Tenor' - the tenor of the bucketed sensitivity, such as '1Y'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(optional) too - perhaps worth a note about requiring one of either Tenor or Date

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to document the historic behaviour. Tenor is required unless the resolver says otherwise, so I cover that in the resolver section.

if (csv.containsHeader(REFERENCE_HEADER) || csv.containsHeader(TYPE_HEADER)) {
return true;
} else {
return csv.headers().stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be return csv.headers().stream().anyMatch(header -> knownReference(header));

* @param charSource the CSV character source to check
* @return true if the source is a CSV file with known headers, false otherwise
*/
public boolean isKnownFormat(CharSource charSource) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be static - what's the strata convention/rule on this? (I usually encourage static where possible in the OG lambda stack)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but this matches other CSV parsers in Strata, and allows future expansion where the resolver is used when determining the format.


//-------------------------------------------------------------------------
// parses the currency as a column or from the reference
private Currency parseCurrency(CsvRow row, CurveName reference) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be static too

}

// checks if the identifier in the row matches the previous one
private boolean matchId(CsvRow row, String id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be static

@jodastephen jodastephen merged commit a5c8b34 into master Oct 16, 2018
@jodastephen jodastephen deleted the topic/sens-loader branch October 16, 2018 11:55
@jodastephen jodastephen added this to the v2.1 milestone Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants