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

Alter CSV format for FxSingle #1732

Merged
merged 2 commits into from Jun 13, 2018

Conversation

Projects
None yet
2 participants
@jodastephen
Copy link
Member

jodastephen commented Jun 12, 2018

Provide a more market-focussed version of the CSV

Alter CSV format for FxSingle
Provide a more market-focussed version of the CSV

@jodastephen jodastephen requested a review from Mistuus Jun 12, 2018

@jodastephen jodastephen added this to the v2.0 milestone Jun 12, 2018

FxSingle fx = paymentAdj
.map(adj -> FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate, adj))
.orElse(FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate));
return FxSingleTrade.of(info, fx);

This comment has been minimized.

@Mistuus

Mistuus Jun 13, 2018

Contributor

Would it be better to extract this if branch into its own method for readability?

CurrencyAmount amount = CurrencyAmount.of(currency, buySell.normalize(notional));
FxSingle fx = paymentAdj
.map(adj -> FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate, adj))
.orElse(FxSingle.of(amount, FxRate.of(pair, fxRate), paymentDate));

This comment has been minimized.

@Mistuus

Mistuus Jun 13, 2018

Contributor

Probably not a huge performance gain, but using orElseGet(...) would only get the value lazily instead of computing it every time.

FxSingle fx = paymentAdj
.map(adj -> FxSingle.of(payment1, payment2, adj))
.orElse(FxSingle.of(payment1, payment2));
return FxSingleTrade.of(info, fx);

This comment has been minimized.

@Mistuus

Mistuus Jun 13, 2018

Contributor

Can this if branch be extracted in a method?

* @param nearDate the near value date
* @param farDate the far value date
* @return the FX swap
*/
public static FxSwap ofForwardPoints(
CurrencyAmount amount,
FxRate nearRate,
double forwardPoints,
double decimalForwardPoints,
LocalDate nearDate,
LocalDate farDate) {

Currency currency1 = amount.getCurrency();
ArgChecker.isTrue(
nearRate.getPair().contains(currency1),
Messages.format("Amount and FX rate have a currency in common: {} and {}", amount, nearDate));

This comment has been minimized.

@Mistuus

Mistuus Jun 13, 2018

Contributor

Message should probably be: "Amount and FX rate must have a currency in common: {} and {}",
and shouldn't last parameter be nearRate rather than nearDate?

@jodastephen jodastephen merged commit 9f2c4e4 into master Jun 13, 2018

15 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 No dependency changes
Details
security/snyk - modules/calc/pom.xml No dependency changes
Details
security/snyk - modules/collect/pom.xml No dependency changes
Details
security/snyk - modules/data/pom.xml No dependency changes
Details
security/snyk - modules/loader/pom.xml No dependency changes
Details
security/snyk - modules/market/pom.xml No dependency changes
Details
security/snyk - modules/math/pom.xml No dependency changes
Details
security/snyk - modules/measure/pom.xml No dependency changes
Details
security/snyk - modules/pom.xml No dependency changes
Details
security/snyk - modules/pricer/pom.xml No dependency changes
Details
security/snyk - modules/product/pom.xml No dependency changes
Details
security/snyk - modules/report/pom.xml No dependency changes
Details
security/snyk - pom.xml No dependency changes
Details

@jodastephen jodastephen deleted the topic/fx-single branch Jun 13, 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.