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

Conversation

Projects
None yet
2 participants
@jodastephen
Copy link
Member

jodastephen commented Oct 12, 2018

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

@jodastephen jodastephen requested a review from headphonejack Oct 12, 2018

@jodastephen jodastephen force-pushed the topic/sens-loader branch 2 times, most recently from 590a966 to 1d84f9b Oct 12, 2018

Add CSV loader for sensitivities
Provides the ability to load sensitivities in two formats
Leniently handles some older formats

@jodastephen jodastephen force-pushed the topic/sens-loader branch from 1d84f9b to 994ca59 Oct 15, 2018

* <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.

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

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.

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

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

This comment has been minimized.

Copy link
@jodastephen

jodastephen Oct 16, 2018

Author Member

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'.

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

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

This comment has been minimized.

Copy link
@jodastephen

jodastephen Oct 16, 2018

Author Member

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()

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

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) {

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

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

This comment has been minimized.

Copy link
@jodastephen

jodastephen Oct 16, 2018

Author Member

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) {

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

can be static too

}

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

This comment has been minimized.

Copy link
@headphonejack

headphonejack Oct 16, 2018

Contributor

can be static

@jodastephen jodastephen merged commit a5c8b34 into master Oct 16, 2018

14 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
security/snyk - modules/basics/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/calc/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/collect/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/data/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/loader/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/market/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/math/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/measure/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/pricer/pom.xml (OpenGamma) No new issues
Details
security/snyk - modules/report/pom.xml (OpenGamma) No new issues
Details
security/snyk - pom.xml (OpenGamma) No new issues
Details

@jodastephen jodastephen deleted the topic/sens-loader branch Oct 16, 2018

@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
You can’t perform that action at this time.