/** * Gets the notional amount, must be positive. * <p> * The notional expressed here must be positive. * The currency of the notional is specified by {@link #getCurrency()}. * * @return the notional amount */ public double getNotional() { return nominalPayment.getAmount(); }
void recordPayment(Payment pmt) { // Do something common for all subclasses recordAmount(pmt.getAmount()); // Do something special for the credit card subclasses if (pmt instanceof CreditCardPayment) { CreditCardPayment ccPmt = (CreditCardPayment)pmt; recordCreditCardNumber(ccPmt.getCardNumber()); } }
// Summarize EnumMap<PaymentType, Double> totals = new EnumMap<>(PaymentType.class); for (Payment payment : payments) { Double total = totals.get(payment.getType()); total = (total == null ? payment.getAmount() : total.doubleValue() + payment.getAmount()); totals.put(payment.getType(), total); } // Without autoboxing total = Double.valueOf(total == null ? payment.getAmount() : total.doubleValue() + payment.getAmount()); // Get total Double totalObj = totals.get(PaymentType.CASH); double cashTotal = (totalObj != null ? totalObj.doubleValue() : 0d);
@ImmutableValidator private void validate() { if (baseCurrencyPayment.getCurrency().equals(counterCurrencyPayment.getCurrency())) { throw new IllegalArgumentException("Amounts must have different currencies"); } if ((baseCurrencyPayment.getAmount() != 0d || counterCurrencyPayment.getAmount() != 0d) && Math.signum(baseCurrencyPayment.getAmount()) != -Math.signum(counterCurrencyPayment.getAmount())) { throw new IllegalArgumentException("Amounts must have different signs"); } }
/** * Returns the put/call flag. * <p> * This is the put/call for the base currency. * If the amount for the base currency is positive, the option is a call on the base currency (put on counter currency). * If the amount for the base currency is negative, the option is a put on the base currency (call on counter currency). * * @return the put or call */ public PutCall getPutCall() { return underlying.getCounterCurrencyPayment().getAmount() > 0d ? PutCall.PUT : PutCall.CALL; }
@ImmutableValidator private void validate() { if (baseCurrencyPayment.getCurrency().equals(counterCurrencyPayment.getCurrency())) { throw new IllegalArgumentException("Payments must have different currencies"); } if ((baseCurrencyPayment.getAmount() != 0d || counterCurrencyPayment.getAmount() != 0d) && Math.signum(baseCurrencyPayment.getAmount()) != -Math.signum(counterCurrencyPayment.getAmount())) { throw new IllegalArgumentException("Payments must have different signs"); } ArgChecker.inOrderOrEqual(baseCurrencyPayment.getDate(), counterCurrencyPayment.getDate(), "baseCurrencyPayment.date", "counterCurrencyPayment.date"); }
@ImmutablePreBuild private static void preBuild(Builder builder) { if (builder.settlement != null) { ArgChecker.isTrue(builder.quantity * builder.settlement.getAmount() <= 0); // Amount negative for buy } }
/** * Gets the currency amount in which the amount is paid. * <p> * This returns the currency amount whose amount is negative or zero. * * @return the pay currency amount */ public CurrencyAmount getPayCurrencyAmount() { if (baseCurrencyPayment.getAmount() <= 0d) { return baseCurrencyPayment.getValue(); } return counterCurrencyPayment.getValue(); }
private double signedNotional(ResolvedFxVanillaOption option) { return (option.getLongShort().isLong() ? 1d : -1d) * Math.abs(option.getUnderlying().getBaseCurrencyPayment().getAmount()); }
private double signedNotional(ResolvedFxVanillaOption option) { return (option.getLongShort().isLong() ? 1d : -1d) * Math.abs(option.getUnderlying().getBaseCurrencyPayment().getAmount()); }
private double signedNotional(ResolvedFxVanillaOption option) { return (option.getLongShort().isLong() ? 1d : -1d) * Math.abs(option.getUnderlying().getBaseCurrencyPayment().getAmount()); }
private double signedNotional(ResolvedFxVanillaOption option) { return (option.getLongShort().isLong() ? 1d : -1d) * Math.abs(option.getUnderlying().getBaseCurrencyPayment().getAmount()); }
public void test_upfrontPayment() { Payment payment = TRADE_PRICER.upfrontPayment(TRADE); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getAmount(), -NOTIONAL * QUANTITY * DIRTY_PRICE, TOL); assertEquals(payment.getDate(), SETTLEMENT); }
@ImmutableValidator private void validate() { ArgChecker.inOrderNotEqual( nearLeg.getPaymentDate(), farLeg.getPaymentDate(), "nearLeg.paymentDate", "farLeg.paymentDate"); if (!nearLeg.getBaseCurrencyPayment().getCurrency().equals(farLeg.getBaseCurrencyPayment().getCurrency()) || !nearLeg.getCounterCurrencyPayment().getCurrency().equals(farLeg.getCounterCurrencyPayment().getCurrency())) { throw new IllegalArgumentException("Legs must have the same currency pair"); } if (signum(nearLeg.getBaseCurrencyPayment().getAmount()) == signum(farLeg.getBaseCurrencyPayment().getAmount())) { throw new IllegalArgumentException("Legs must have payments flowing in opposite directions"); } }
public void test_upfrontPayment_position() { Payment payment = TRADE_PRICER.upfrontPayment(POSITION); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getAmount(), 0, TOL); assertEquals(payment.getDate(), POSITION.getProduct().getStartDate()); }
/** * Calculates the current of the FX barrier option trade. * * @param trade the option trade * @param valuationDate the valuation date * @return the current cash amount */ public CurrencyAmount currentCash(ResolvedFxSingleBarrierOptionTrade trade, LocalDate valuationDate) { Payment premium = trade.getPremium(); if (premium.getDate().equals(valuationDate)) { return CurrencyAmount.of(premium.getCurrency(), premium.getAmount()); } return CurrencyAmount.of(premium.getCurrency(), 0d); }
/** * Calculates the current of the FX barrier option trade. * * @param trade the option trade * @param valuationDate the valuation date * @return the current cash amount */ public CurrencyAmount currentCash(ResolvedFxSingleBarrierOptionTrade trade, LocalDate valuationDate) { Payment premium = trade.getPremium(); if (premium.getDate().equals(valuationDate)) { return CurrencyAmount.of(premium.getCurrency(), premium.getAmount()); } return CurrencyAmount.of(premium.getCurrency(), 0d); }
/** * Calculates the current of the FX vanilla option trade. * * @param trade the option trade * @param valuationDate the valuation date * @return the current cash amount */ public CurrencyAmount currentCash(ResolvedFxVanillaOptionTrade trade, LocalDate valuationDate) { Payment premium = trade.getPremium(); if (premium.getDate().equals(valuationDate)) { return CurrencyAmount.of(premium.getCurrency(), premium.getAmount()); } return CurrencyAmount.of(premium.getCurrency(), 0d); }