| | 47 | |
|---|
| | 48 | public FixedRateBond(int settlementDays, Calendar calendar, |
|---|
| | 49 | double faceAmount, |
|---|
| | 50 | Date startDate, |
|---|
| | 51 | Date maturityDate, |
|---|
| | 52 | Period tenor, |
|---|
| | 53 | List<double> coupons, |
|---|
| | 54 | DayCounter accrualDayCounter, |
|---|
| | 55 | BusinessDayConvention accrualConvention, |
|---|
| | 56 | BusinessDayConvention paymentConvention, |
|---|
| | 57 | double redemption, |
|---|
| | 58 | Date issueDate, |
|---|
| | 59 | Date stubDate, |
|---|
| | 60 | DateGeneration.Rule rule, |
|---|
| | 61 | bool endOfMonth) |
|---|
| | 62 | : base(settlementDays, calendar, faceAmount, maturityDate, issueDate) { |
|---|
| | 63 | |
|---|
| | 64 | frequency_ = tenor.frequency(); |
|---|
| | 65 | dayCounter_ = accrualDayCounter; |
|---|
| | 66 | |
|---|
| | 67 | maturityDate_ = maturityDate; |
|---|
| | 68 | |
|---|
| | 69 | Date firstDate, nextToLastDate; |
|---|
| | 70 | switch (rule) { |
|---|
| | 71 | case DateGeneration.Rule.Backward: |
|---|
| | 72 | firstDate = null; |
|---|
| | 73 | nextToLastDate = stubDate; |
|---|
| | 74 | break; |
|---|
| | 75 | case DateGeneration.Rule.Forward: |
|---|
| | 76 | firstDate = stubDate; |
|---|
| | 77 | nextToLastDate = null; |
|---|
| | 78 | break; |
|---|
| | 79 | case DateGeneration.Rule.Zero: |
|---|
| | 80 | case DateGeneration.Rule.ThirdWednesday: |
|---|
| | 81 | case DateGeneration.Rule.Twentieth: |
|---|
| | 82 | case DateGeneration.Rule.TwentiethIMM: |
|---|
| | 83 | throw new ApplicationException("stub date (" + stubDate + ") not allowed with " + rule + " DateGeneration::Rule"); |
|---|
| | 84 | default: |
|---|
| | 85 | throw new ApplicationException("unknown DateGeneration::Rule (" + rule + ")"); |
|---|
| | 86 | } |
|---|
| | 87 | |
|---|
| | 88 | Schedule schedule = new Schedule(startDate, maturityDate_, tenor, |
|---|
| | 89 | calendar_, accrualConvention, accrualConvention, |
|---|
| | 90 | rule, endOfMonth, |
|---|
| | 91 | firstDate, nextToLastDate); |
|---|
| | 92 | |
|---|
| | 93 | cashflows_ = new FixedRateLeg(schedule, accrualDayCounter) |
|---|
| | 94 | .withNotionals(faceAmount_) |
|---|
| | 95 | .withCouponRates(coupons) |
|---|
| | 96 | .withPaymentAdjustment(paymentConvention) |
|---|
| | 97 | .value(); |
|---|
| | 98 | |
|---|
| | 99 | Date redemptionDate = calendar_.adjust(maturityDate_, paymentConvention); |
|---|
| | 100 | cashflows_.Add(new SimpleCashFlow(faceAmount_*redemption/100.0, redemptionDate)); |
|---|
| | 101 | } |
|---|