-
Notifications
You must be signed in to change notification settings - Fork 284
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
Bill and bill trade description. #1748
Conversation
marc-henrard
commented
Jun 21, 2018
- Created bill product and bill trade
- Resolved versions
.settlementDateOffset(DaysAdjustment.ofBusinessDays(2, EUTA, BUSINESS_ADJUST)) | ||
.yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build(); | ||
private static final double TOLERANCE_PRICE = 1.0E-8; | ||
|
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.
Om;y one blank line
/** | ||
* A bill. | ||
* <p> | ||
* A bill is a financial instrument that represents a unique fixed payments. |
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.
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"); |
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.
Spelling
* @return the price | ||
*/ | ||
public double priceFromYield(double yield, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate().getUnadjusted()); |
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.
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)) { |
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.
move to BillConvention
|
||
@Override | ||
public BillTrade withPrice(double price) { | ||
return BillTrade.builder().info(info).product(product).quantity(quantity).price(price).build(); |
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.
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 |
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.
Remove comment
* @return the price | ||
*/ | ||
public double priceFromYield(double yield, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate()); |
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.
Logic on convention
*/ | ||
public double yieldFromPrice(double price, LocalDate settlementDate) { | ||
double accrualFactor = dayCount.relativeYearFraction(settlementDate, notional.getDate()); | ||
if (yieldConvention.equals(DISCOUNT)) { |
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.
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 |
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.
Is this right?
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.
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.
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.
Still got singular/plural comment and ofPrice() to do