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
Merged

Alter CSV format for FxSingle #1732

merged 2 commits into from Jun 13, 2018

Conversation

@jodastephen
Copy link
Member

@jodastephen jodastephen commented Jun 12, 2018

Provide a more market-focussed version of the CSV

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);
Copy link
Contributor

@Mistuus Mistuus Jun 13, 2018

Choose a reason for hiding this comment

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

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

Loading

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));
Copy link
Contributor

@Mistuus Mistuus Jun 13, 2018

Choose a reason for hiding this comment

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

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

Loading

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

@Mistuus Mistuus Jun 13, 2018

Choose a reason for hiding this comment

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

Can this if branch be extracted in a method?

Loading

* @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));
Copy link
Contributor

@Mistuus Mistuus Jun 13, 2018

Choose a reason for hiding this comment

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

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?

Loading

@jodastephen jodastephen merged commit 9f2c4e4 into master Jun 13, 2018
15 checks passed
Loading
@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
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants