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
Conversation
590a966
to
1d84f9b
Compare
Provides the ability to load sensitivities in two formats Leniently handles some older formats
1d84f9b
to
994ca59
Compare
* <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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be static
Provides the ability to load sensitivities in two formats
Leniently handles some older formats