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

Bill and bill trade description. #1748

Merged
merged 3 commits into from
Jun 28, 2018
Merged

Bill and bill trade description. #1748

merged 3 commits into from
Jun 28, 2018

Conversation

marc-henrard
Copy link
Contributor

  • 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;

Copy link
Member

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.
Copy link
Member

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

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

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)) {
Copy link
Member

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

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
Copy link
Member

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

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)) {
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

Is this right?

Copy link
Contributor Author

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.

Copy link
Member

@jodastephen jodastephen left a 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

@jodastephen jodastephen merged commit f9a068f into master Jun 28, 2018
@jodastephen jodastephen deleted the topic/bill-trade branch June 28, 2018 09:03
@jodastephen jodastephen added this to the v2.0 milestone Jul 5, 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
Development

Successfully merging this pull request may close these issues.

2 participants