/**
   * Creates a forward-starting trade based on this convention.
   *
   * <p>This returns a trade based on the specified period and tenor. For example, a period of 3
   * months and a tenor of 5 years creates a swap starting three months after the spot date and
   * maturing 5 years later.
   *
   * <p>The notional is unsigned, with buy/sell determining the direction of the trade. If buying
   * the swap, the floating rate is received from the counterparty, with the fixed rate being paid.
   * If selling the swap, the floating rate is paid to the counterparty, with the fixed rate being
   * received.
   *
   * @param tradeDate the date of the trade
   * @param periodToStart the period between the spot date and the start date
   * @param tenor the tenor of the swap
   * @param buySell the buy/sell flag
   * @param notional the notional amount
   * @param fixedRate the fixed rate, typically derived from the market
   * @return the trade
   */
  public default SwapTrade toTrade(
      LocalDate tradeDate,
      Period periodToStart,
      Tenor tenor,
      BuySell buySell,
      double notional,
      double fixedRate) {

    LocalDate spotValue = calculateSpotDateFromTradeDate(tradeDate);
    LocalDate startDate = spotValue.plus(periodToStart);
    LocalDate endDate = startDate.plus(tenor.getPeriod());
    return toTrade(tradeDate, startDate, endDate, buySell, notional, fixedRate);
  }
Ejemplo n.º 2
0
  /**
   * Creates a trade based on this convention.
   *
   * <p>This returns a trade based on the specified periods. For example, a '2 x 5' FRA has a period
   * to the start date of 2 months and a period to the end date of 5 months
   *
   * <p>The notional is unsigned, with buy/sell determining the direction of the trade. If buying
   * the FRA, the floating rate is received from the counterparty, with the fixed rate being paid.
   * If selling the FRA, the floating rate is paid to the counterparty, with the fixed rate being
   * received.
   *
   * @param tradeDate the date of the trade
   * @param periodToStart the period between the spot date and the start date
   * @param periodToEnd the period between the spot date and the end date
   * @param buySell the buy/sell flag
   * @param notional the notional amount, in the payment currency of the template
   * @param fixedRate the fixed rate, typically derived from the market
   * @return the trade
   */
  public default FraTrade toTrade(
      LocalDate tradeDate,
      Period periodToStart,
      Period periodToEnd,
      BuySell buySell,
      double notional,
      double fixedRate) {

    LocalDate spotValue = calculateSpotDateFromTradeDate(tradeDate);
    LocalDate startDate = spotValue.plus(periodToStart);
    LocalDate endDate = spotValue.plus(periodToEnd);
    return toTrade(tradeDate, startDate, endDate, buySell, notional, fixedRate);
  }
 public void test_toTrade() {
   IborFixingDepositConvention convention =
       ImmutableIborFixingDepositConvention.builder()
           .businessDayAdjustment(BDA_MOD_FOLLOW)
           .currency(EUR)
           .dayCount(ACT_365F)
           .fixingDateOffset(FIXING_ADJ)
           .index(EUR_LIBOR_3M)
           .spotDateOffset(SPOT_ADJ)
           .build();
   LocalDate tradeDate = LocalDate.of(2015, 1, 22);
   Period depositPeriod = Period.ofMonths(3);
   double notional = 1d;
   double fixedRate = 0.045;
   IborFixingDepositTrade trade =
       convention.toTrade(tradeDate, depositPeriod, BUY, notional, fixedRate);
   LocalDate startExpected = SPOT_ADJ.adjust(tradeDate);
   LocalDate endExpected = startExpected.plus(depositPeriod);
   IborFixingDeposit productExpected =
       IborFixingDeposit.builder()
           .businessDayAdjustment(BDA_MOD_FOLLOW)
           .buySell(BUY)
           .currency(EUR)
           .dayCount(ACT_365F)
           .startDate(startExpected)
           .endDate(endExpected)
           .fixedRate(fixedRate)
           .fixingDateOffset(FIXING_ADJ)
           .index(EUR_LIBOR_3M)
           .notional(notional)
           .build();
   TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(tradeDate).build();
   assertEquals(trade.getProduct(), productExpected);
   assertEquals(trade.getTradeInfo(), tradeInfoExpected);
 }
  // -------------------------------------------------------------------------
  @Override
  public TermDepositTrade toTrade(
      LocalDate tradeDate, Period depositPeriod, BuySell buySell, double notional, double rate) {

    LocalDate startDate = getSpotDateOffset().adjust(tradeDate);
    LocalDate endDate = startDate.plus(depositPeriod);
    return toTrade(tradeDate, startDate, endDate, buySell, notional, rate);
  }
Ejemplo n.º 5
0
 /**
  * Set up an on-the-run index represented as a single name CDS (i.e. by CdsAnalytic). The index
  * roll dates (when new indices are issued) are 20 Mar & Sep, and the index is defined to have a
  * maturity that is its nominal tenor plus 3M on issuance, so a 5Y index on the 6-Feb-2014 will
  * have a maturity of 20-Dec-2018 (5Y3M on the issue date of 20-Sep-2013). The accrual start date
  * will be the previous IMM date (before the trade date), business-day adjusted. <b>Note</b> it
  * payment interval is changed from the default of 3M, this will produce a (possibly incorrect)
  * non-standard first coupon.
  *
  * @param tradeDate the trade date
  * @param tenor the nominal length of the index
  * @return a CDS analytic description
  */
 public CdsAnalytic makeCdx(LocalDate tradeDate, Period tenor) {
   ArgChecker.notNull(tradeDate, "tradeDate");
   ArgChecker.notNull(tenor, "tenor");
   LocalDate effectiveDate =
       _businessdayAdjustmentConvention.adjust(ImmDateLogic.getPrevIMMDate(tradeDate), _calendar);
   LocalDate roll = ImmDateLogic.getNextIndexRollDate(tradeDate);
   LocalDate maturity = roll.plus(tenor).minusMonths(3);
   return makeCds(tradeDate, effectiveDate, maturity);
 }
Ejemplo n.º 6
0
 /**
  * Make a CDS with a maturity date the given period on from the next IMM date after the
  * trade-date. The accrual start date will be the previous IMM date (before the trade date).
  * <b>Note</b> it payment interval is changed from the default of 3M, this will produce a
  * (possibly incorrect) non-standard first coupon.
  *
  * @param tradeDate the trade date
  * @param tenor the tenor (length) of the CDS
  * @param makeEffBusDay is the accrual start day business-day adjusted.
  * @return a CDS analytic description
  */
 public CdsAnalytic makeImmCds(LocalDate tradeDate, Period tenor, boolean makeEffBusDay) {
   ArgChecker.notNull(tradeDate, "tradeDate");
   ArgChecker.notNull(tenor, "tenor");
   LocalDate effectiveDate =
       makeEffBusDay
           ? _businessdayAdjustmentConvention.adjust(
               ImmDateLogic.getPrevIMMDate(tradeDate), _calendar)
           : ImmDateLogic.getPrevIMMDate(tradeDate);
   LocalDate nextIMM = ImmDateLogic.getNextIMMDate(tradeDate);
   LocalDate maturity = nextIMM.plus(tenor);
   return makeCds(tradeDate, effectiveDate, maturity);
 }
Ejemplo n.º 7
0
 public void test_trade() {
   TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
   double rate = 0.035;
   MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
   TermDepositTrade trade = node.trade(1d, marketData, REF_DATA);
   LocalDate startDateExpected = PLUS_TWO_DAYS.adjust(VAL_DATE, REF_DATA);
   LocalDate endDateExpected = startDateExpected.plus(DEPOSIT_PERIOD);
   TermDeposit depositExpected =
       TermDeposit.builder()
           .buySell(BuySell.BUY)
           .currency(EUR)
           .dayCount(ACT_360)
           .startDate(startDateExpected)
           .endDate(endDateExpected)
           .notional(1.0d)
           .businessDayAdjustment(BDA_MOD_FOLLOW)
           .rate(rate + SPREAD)
           .build();
   TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(VAL_DATE).build();
   assertEquals(trade.getProduct(), depositExpected);
   assertEquals(trade.getInfo(), tradeInfoExpected);
 }
Ejemplo n.º 8
0
 public void setUp(BigDecimal threshold, LocalDate startDate, Period period) {
   this.threshold = threshold;
   this.startDate = startDate;
   this.endDate = startDate.plus(period);
 }
Ejemplo n.º 9
0
 /**
  * /** A forward starting index starts on some date after today (the trade date). The stepin date
  * and cash settlement date are taken from the forward start date (1 day and 3 working days by
  * default). The maturity (of the index) is taken from the forward-start-date. The index roll
  * dates (when new indices are issued) are 20 Mar & Sep, and the index is defined to have a
  * maturity that is its nominal tenor plus 3M on issuance, so a 5Y index on the 6-Feb-2014 will
  * have a maturity of 20-Dec-2018 (5Y3M on the issue date of 20-Sep-2013). However for a
  * trade-date of 6-Feb-2014, a forward-start-date of 25-Mar-2014 and a tenor of 5Y, the maturity
  * will be 20-Jun-2019.
  *
  * @param tradeDate the trade date (i.e. today)
  * @param forwardStartDate the forward start date
  * @param tenor the tenor (nominal length) of the index at the forwardStartDate
  * @return a CDS analytic description for a forward starting index
  */
 public CdsAnalytic makeForwardStartingCdx(
     LocalDate tradeDate, LocalDate forwardStartDate, Period tenor) {
   LocalDate roll = ImmDateLogic.getNextIndexRollDate(forwardStartDate);
   LocalDate maturity = roll.plus(tenor).minusMonths(3);
   return makeForwardStartingCds(tradeDate, forwardStartDate, maturity);
 }
Ejemplo n.º 10
0
 /**
  * A forward starting CDS starts on some date after today (the trade date). The stepin date and
  * cash settlement date are taken from the forward start date (1 day and 3 working days by
  * default). The period is from the next IMM date after the forward-start-date, so for a
  * trade-date of 13-Feb-2014, a forward-start-date of 25-Mar-2014 and a tenor of 1Y, the maturity
  * will be 20-Jun-2015.
  *
  * @param tradeDate the trade date (i.e. today)
  * @param forwardStartDate the forward start date
  * @param tenor the tenor (length) of the CDS at the forwardStartDate
  * @return a CDS analytic description for a forward starting CDS
  */
 public CdsAnalytic makeForwardStartingImmCds(
     LocalDate tradeDate, LocalDate forwardStartDate, Period tenor) {
   LocalDate nextIMM = ImmDateLogic.getNextIMMDate(forwardStartDate);
   LocalDate maturity = nextIMM.plus(tenor);
   return makeForwardStartingCds(tradeDate, forwardStartDate, maturity);
 }
Ejemplo n.º 11
0
  public MakeReservation() {
    new BorderLayout();

    standardRoom.setMnemonic(KeyEvent.VK_K);
    standardRoom.setActionCommand("Standard Room");
    standardRoom.setSelected(true);

    familyRoom.setMnemonic(KeyEvent.VK_F);
    familyRoom.setActionCommand("Family Room");

    suiteRoom.setMnemonic(KeyEvent.VK_S);
    suiteRoom.setActionCommand("Suite");

    // Add Booking Button
    ImageIcon bookRoomIcon = createImageIcon("images/book.png");
    bookRoom = new JButton("Book Room", bookRoomIcon);
    bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM);
    bookRoom.setHorizontalTextPosition(AbstractButton.CENTER);
    bookRoom.setMnemonic(KeyEvent.VK_M);
    bookRoom.addActionListener(this);
    bookRoom.setActionCommand("book");

    // Group the radio buttons.
    group.add(standardRoom);
    group.add(familyRoom);
    group.add(suiteRoom);

    // Create the labels.
    nameLabel = new JLabel("Name: ");
    amountroomsLabel = new JLabel("How many rooms? ");
    checkoutdateLabel = new JLabel("Check-Out Date: ");
    checkindateLabel = new JLabel("Check-In Date: ");

    // Create the text fields and set them up.
    nameField = new JFormattedTextField();
    nameField.setColumns(10);

    amountroomsField = new JFormattedTextField(new Integer(1));
    amountroomsField.setValue(new Integer(1));
    amountroomsField.setColumns(10);

    // java.util.Date dt_checkin = new java.util.Date();
    LocalDate today = LocalDate.now();
    // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkin = today.toString();
    checkindateField = new JFormattedTextField(currentDate_checkin);
    checkindateField.setColumns(10);

    // java.util.Date dt_checkout = new java.util.Date();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkout = tomorrow.toString();
    checkoutdateField = new JFormattedTextField(currentDate_checkout);
    checkoutdateField.setColumns(10);

    // Tell accessibility tools about label/textfield pairs.
    nameLabel.setLabelFor(nameField);
    amountroomsLabel.setLabelFor(amountroomsField);
    checkoutdateLabel.setLabelFor(checkoutdateField);
    checkindateLabel.setLabelFor(checkindateField);

    // Lay out the labels in a panel.
    JPanel labelPane1 = new JPanel(new GridLayout(0, 1));

    labelPane1.add(amountroomsLabel);

    JPanel labelPane3 = new JPanel(new GridLayout(0, 1));
    labelPane3.add(checkindateLabel);

    JPanel labelPane2 = new JPanel(new GridLayout(0, 1));
    labelPane2.add(checkoutdateLabel);

    JPanel labelPane4 = new JPanel(new GridLayout(0, 1));
    labelPane4.add(nameLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane1 = new JPanel(new GridLayout(0, 1));
    fieldPane1.add(amountroomsField);

    JPanel fieldPane3 = new JPanel(new GridLayout(0, 1));
    fieldPane3.add(checkindateField);

    JPanel fieldPane2 = new JPanel(new GridLayout(0, 1));
    fieldPane2.add(checkoutdateField);

    JPanel fieldPane4 = new JPanel(new GridLayout(0, 1));
    fieldPane4.add(nameField);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(standardRoom);
    radioPanel.add(familyRoom);
    radioPanel.add(suiteRoom);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane1, BorderLayout.LINE_START);
    add(fieldPane1, BorderLayout.LINE_END);
    add(labelPane3, BorderLayout.LINE_START);
    add(fieldPane3, BorderLayout.LINE_END);
    add(labelPane2, BorderLayout.LINE_START);
    add(fieldPane2, BorderLayout.LINE_END);
    add(labelPane4, BorderLayout.LINE_START);
    add(fieldPane4, BorderLayout.LINE_END);

    add(radioPanel, BorderLayout.LINE_END);
    add(bookRoom);
  }