Bill and bill trade description. #1748
Merged
Conversation
Contributor
marc-henrard
commented
Jun 21, 2018
|
.settlementDateOffset(DaysAdjustment.ofBusinessDays(2, EUTA, BUSINESS_ADJUST)) | ||
.yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build(); | ||
private static final double TOLERANCE_PRICE = 1.0E-8; | ||
|
jodastephen
Jun 27, 2018
Member
Om;y one blank line
Om;y one blank line
/** | ||
* A bill. | ||
* <p> | ||
* A bill is a financial instrument that represents a unique fixed payments. |
jodastephen
Jun 27, 2018
Member
singular/plural
singular/plural
@ImmutableValidator | ||
private void validate() { | ||
ArgChecker.isTrue(settlementDateOffset.getDays() >= 0, "The settlement date offset must be non-negative"); | ||
ArgChecker.isTrue(notional.getAmount() > 0, "Notionanl must be strictly positve"); |
jodastephen
Jun 27, 2018
Member
Spelling
Spelling
* @return the price | ||
*/ | ||
public double priceFromYield(double yield, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate().getUnadjusted()); |
jodastephen
Jun 27, 2018
Member
The logic below should move onto BillConvention
(taking accrualFactor)
The logic below should move onto BillConvention
(taking accrualFactor)
*/ | ||
public double yieldFromPrice(double price, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate().getUnadjusted()); | ||
if (yieldConvention.equals(DISCOUNT)) { |
jodastephen
Jun 27, 2018
Member
move to BillConvention
move to BillConvention
|
||
@Override | ||
public BillTrade withPrice(double price) { | ||
return BillTrade.builder().info(info).product(product).quantity(quantity).price(price).build(); |
jodastephen
Jun 27, 2018
Member
return new BillTrade(...)
return new BillTrade(...)
* The notional payment of the bill notional, the amount must be positive. | ||
*/ | ||
@PropertyDefinition(validate = "notNull") | ||
private final Payment notional; // Change to payment |
jodastephen
Jun 27, 2018
Member
Remove comment
Remove comment
* @return the price | ||
*/ | ||
public double priceFromYield(double yield, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate()); |
jodastephen
Jun 27, 2018
Member
Logic on convention
Logic on convention
*/ | ||
public double yieldFromPrice(double price, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate()); | ||
if (yieldConvention.equals(DISCOUNT)) { |
jodastephen
Jun 27, 2018
Member
Logic on convention
Logic on convention
@ImmutablePreBuild | ||
private static void preBuild(Builder builder) { | ||
if (builder.settlement != null) { | ||
ArgChecker.isTrue(builder.quantity * builder.settlement.getAmount() <= 0); // Amount negative for buy |
jodastephen
Jun 27, 2018
Member
Is this right?
Is this right?
marc-henrard
Jun 27, 2018
Author
Contributor
When buying, quantity > 0 and amount is paid and so < 0. This is to check that the user does not get confused on the signs.
When buying, quantity > 0 and amount is paid and so < 0. This is to check that the user does not get confused on the signs.
Still got singular/plural comment and ofPrice() to do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.