001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (https://www.swig.org).
003 * Version 4.1.1
004 *
005 * Do not make changes to this file unless you know what you are doing - modify
006 * the SWIG interface file instead.
007 * ----------------------------------------------------------------------------- */
008
009package org.quantlib;
010
011public class CreditDefaultSwap extends Instrument implements org.quantlib.helpers.QuantLibJNIHelpers.AutoCloseable {
012  private transient long swigCPtr;
013  private transient boolean swigCMemOwnDerived;
014
015  protected CreditDefaultSwap(long cPtr, boolean cMemoryOwn) {
016    super(QuantLibJNI.CreditDefaultSwap_SWIGSmartPtrUpcast(cPtr), true);
017    swigCMemOwnDerived = cMemoryOwn;
018    swigCPtr = cPtr;
019  }
020
021  protected static long getCPtr(CreditDefaultSwap obj) {
022    return (obj == null) ? 0 : obj.swigCPtr;
023  }
024
025  protected void swigSetCMemOwn(boolean own) {
026    swigCMemOwnDerived = own;
027    super.swigSetCMemOwn(own);
028  }
029
030  @SuppressWarnings("deprecation")
031  protected void finalize() {
032    delete();
033  }
034
035  public synchronized void delete() {
036    if (swigCPtr != 0) {
037      if (swigCMemOwnDerived) {
038        swigCMemOwnDerived = false;
039        QuantLibJNI.delete_CreditDefaultSwap(swigCPtr);
040      }
041      swigCPtr = 0;
042    }
043    super.delete();
044  }
045
046  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Claim claim, DayCounter lastPeriodDayCounter, boolean rebatesAccrual, Date tradeDate, long cashSettlementDays) {
047    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_0(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter, rebatesAccrual, Date.getCPtr(tradeDate), tradeDate, cashSettlementDays), true);
048  }
049
050  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Claim claim, DayCounter lastPeriodDayCounter, boolean rebatesAccrual, Date tradeDate) {
051    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_1(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter, rebatesAccrual, Date.getCPtr(tradeDate), tradeDate), true);
052  }
053
054  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Claim claim, DayCounter lastPeriodDayCounter, boolean rebatesAccrual) {
055    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_2(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter, rebatesAccrual), true);
056  }
057
058  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Claim claim, DayCounter lastPeriodDayCounter) {
059    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_3(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter), true);
060  }
061
062  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Claim claim) {
063    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_4(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Claim.getCPtr(claim), claim), true);
064  }
065
066  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart) {
067    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_5(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart), true);
068  }
069
070  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime) {
071    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_6(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime), true);
072  }
073
074  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual) {
075    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_7(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual), true);
076  }
077
078  public CreditDefaultSwap(Protection.Side side, double notional, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter) {
079    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_8(side.swigValue(), notional, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter), true);
080  }
081
082  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Date upfrontDate, Claim claim, DayCounter lastPeriodDayCounter, boolean rebatesAccrual, Date tradeDate, long cashSettlementDays) {
083    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_9(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Date.getCPtr(upfrontDate), upfrontDate, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter, rebatesAccrual, Date.getCPtr(tradeDate), tradeDate, cashSettlementDays), true);
084  }
085
086  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Date upfrontDate, Claim claim, DayCounter lastPeriodDayCounter, boolean rebatesAccrual, Date tradeDate) {
087    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_10(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Date.getCPtr(upfrontDate), upfrontDate, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter, rebatesAccrual, Date.getCPtr(tradeDate), tradeDate), true);
088  }
089
090  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Date upfrontDate, Claim claim, DayCounter lastPeriodDayCounter, boolean rebatesAccrual) {
091    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_11(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Date.getCPtr(upfrontDate), upfrontDate, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter, rebatesAccrual), true);
092  }
093
094  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Date upfrontDate, Claim claim, DayCounter lastPeriodDayCounter) {
095    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_12(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Date.getCPtr(upfrontDate), upfrontDate, Claim.getCPtr(claim), claim, DayCounter.getCPtr(lastPeriodDayCounter), lastPeriodDayCounter), true);
096  }
097
098  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Date upfrontDate, Claim claim) {
099    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_13(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Date.getCPtr(upfrontDate), upfrontDate, Claim.getCPtr(claim), claim), true);
100  }
101
102  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart, Date upfrontDate) {
103    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_14(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart, Date.getCPtr(upfrontDate), upfrontDate), true);
104  }
105
106  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime, Date protectionStart) {
107    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_15(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime, Date.getCPtr(protectionStart), protectionStart), true);
108  }
109
110  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual, boolean paysAtDefaultTime) {
111    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_16(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual, paysAtDefaultTime), true);
112  }
113
114  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter, boolean settlesAccrual) {
115    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_17(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter, settlesAccrual), true);
116  }
117
118  public CreditDefaultSwap(Protection.Side side, double notional, double upfront, double spread, Schedule schedule, BusinessDayConvention paymentConvention, DayCounter dayCounter) {
119    this(QuantLibJNI.new_CreditDefaultSwap__SWIG_18(side.swigValue(), notional, upfront, spread, Schedule.getCPtr(schedule), schedule, paymentConvention.swigValue(), DayCounter.getCPtr(dayCounter), dayCounter), true);
120  }
121
122  public Protection.Side side() {
123    return Protection.Side.swigToEnum(QuantLibJNI.CreditDefaultSwap_side(swigCPtr, this));
124  }
125
126  public double notional() {
127    return QuantLibJNI.CreditDefaultSwap_notional(swigCPtr, this);
128  }
129
130  public double runningSpread() {
131    return QuantLibJNI.CreditDefaultSwap_runningSpread(swigCPtr, this);
132  }
133
134  public double upfront() {
135    return QuantLibJNI.CreditDefaultSwap_upfront(swigCPtr, this);
136  }
137
138  public boolean settlesAccrual() {
139    return QuantLibJNI.CreditDefaultSwap_settlesAccrual(swigCPtr, this);
140  }
141
142  public boolean paysAtDefaultTime() {
143    return QuantLibJNI.CreditDefaultSwap_paysAtDefaultTime(swigCPtr, this);
144  }
145
146  public Leg coupons() {
147    return new Leg(QuantLibJNI.CreditDefaultSwap_coupons(swigCPtr, this), true);
148  }
149
150  public Date protectionStartDate() {
151    return new Date(QuantLibJNI.CreditDefaultSwap_protectionStartDate(swigCPtr, this), false);
152  }
153
154  public Date protectionEndDate() {
155    return new Date(QuantLibJNI.CreditDefaultSwap_protectionEndDate(swigCPtr, this), false);
156  }
157
158  public boolean rebatesAccrual() {
159    return QuantLibJNI.CreditDefaultSwap_rebatesAccrual(swigCPtr, this);
160  }
161
162  public CashFlow upfrontPayment() {
163    long cPtr = QuantLibJNI.CreditDefaultSwap_upfrontPayment(swigCPtr, this);
164    return (cPtr == 0) ? null : new CashFlow(cPtr, true);
165  }
166
167  public CashFlow accrualRebate() {
168    long cPtr = QuantLibJNI.CreditDefaultSwap_accrualRebate(swigCPtr, this);
169    return (cPtr == 0) ? null : new CashFlow(cPtr, true);
170  }
171
172  public Date tradeDate() {
173    return new Date(QuantLibJNI.CreditDefaultSwap_tradeDate(swigCPtr, this), false);
174  }
175
176  public long cashSettlementDays() {
177    return QuantLibJNI.CreditDefaultSwap_cashSettlementDays(swigCPtr, this);
178  }
179
180  public double fairUpfront() {
181    return QuantLibJNI.CreditDefaultSwap_fairUpfront(swigCPtr, this);
182  }
183
184  public double fairSpread() {
185    return QuantLibJNI.CreditDefaultSwap_fairSpread(swigCPtr, this);
186  }
187
188  public double couponLegBPS() {
189    return QuantLibJNI.CreditDefaultSwap_couponLegBPS(swigCPtr, this);
190  }
191
192  public double upfrontBPS() {
193    return QuantLibJNI.CreditDefaultSwap_upfrontBPS(swigCPtr, this);
194  }
195
196  public double couponLegNPV() {
197    return QuantLibJNI.CreditDefaultSwap_couponLegNPV(swigCPtr, this);
198  }
199
200  public double defaultLegNPV() {
201    return QuantLibJNI.CreditDefaultSwap_defaultLegNPV(swigCPtr, this);
202  }
203
204  public double upfrontNPV() {
205    return QuantLibJNI.CreditDefaultSwap_upfrontNPV(swigCPtr, this);
206  }
207
208  public double accrualRebateNPV() {
209    return QuantLibJNI.CreditDefaultSwap_accrualRebateNPV(swigCPtr, this);
210  }
211
212  public double impliedHazardRate(double targetNPV, YieldTermStructureHandle discountCurve, DayCounter dayCounter, double recoveryRate, double accuracy, CreditDefaultSwap.PricingModel model) {
213    return QuantLibJNI.CreditDefaultSwap_impliedHazardRate__SWIG_0(swigCPtr, this, targetNPV, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve, DayCounter.getCPtr(dayCounter), dayCounter, recoveryRate, accuracy, model.swigValue());
214  }
215
216  public double impliedHazardRate(double targetNPV, YieldTermStructureHandle discountCurve, DayCounter dayCounter, double recoveryRate, double accuracy) {
217    return QuantLibJNI.CreditDefaultSwap_impliedHazardRate__SWIG_1(swigCPtr, this, targetNPV, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve, DayCounter.getCPtr(dayCounter), dayCounter, recoveryRate, accuracy);
218  }
219
220  public double impliedHazardRate(double targetNPV, YieldTermStructureHandle discountCurve, DayCounter dayCounter, double recoveryRate) {
221    return QuantLibJNI.CreditDefaultSwap_impliedHazardRate__SWIG_2(swigCPtr, this, targetNPV, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve, DayCounter.getCPtr(dayCounter), dayCounter, recoveryRate);
222  }
223
224  public double impliedHazardRate(double targetNPV, YieldTermStructureHandle discountCurve, DayCounter dayCounter) {
225    return QuantLibJNI.CreditDefaultSwap_impliedHazardRate__SWIG_3(swigCPtr, this, targetNPV, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve, DayCounter.getCPtr(dayCounter), dayCounter);
226  }
227
228  public double conventionalSpread(double conventionalRecovery, YieldTermStructureHandle discountCurve, DayCounter dayCounter, CreditDefaultSwap.PricingModel model) {
229    return QuantLibJNI.CreditDefaultSwap_conventionalSpread__SWIG_0(swigCPtr, this, conventionalRecovery, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve, DayCounter.getCPtr(dayCounter), dayCounter, model.swigValue());
230  }
231
232  public double conventionalSpread(double conventionalRecovery, YieldTermStructureHandle discountCurve, DayCounter dayCounter) {
233    return QuantLibJNI.CreditDefaultSwap_conventionalSpread__SWIG_1(swigCPtr, this, conventionalRecovery, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve, DayCounter.getCPtr(dayCounter), dayCounter);
234  }
235
236  public final static class PricingModel {
237    public final static CreditDefaultSwap.PricingModel Midpoint = new CreditDefaultSwap.PricingModel("Midpoint");
238    public final static CreditDefaultSwap.PricingModel ISDA = new CreditDefaultSwap.PricingModel("ISDA");
239
240    public final int swigValue() {
241      return swigValue;
242    }
243
244    public String toString() {
245      return swigName;
246    }
247
248    public static PricingModel swigToEnum(int swigValue) {
249      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
250        return swigValues[swigValue];
251      for (int i = 0; i < swigValues.length; i++)
252        if (swigValues[i].swigValue == swigValue)
253          return swigValues[i];
254      throw new IllegalArgumentException("No enum " + PricingModel.class + " with value " + swigValue);
255    }
256
257    private PricingModel(String swigName) {
258      this.swigName = swigName;
259      this.swigValue = swigNext++;
260    }
261
262    private PricingModel(String swigName, int swigValue) {
263      this.swigName = swigName;
264      this.swigValue = swigValue;
265      swigNext = swigValue+1;
266    }
267
268    private PricingModel(String swigName, PricingModel swigEnum) {
269      this.swigName = swigName;
270      this.swigValue = swigEnum.swigValue;
271      swigNext = this.swigValue+1;
272    }
273
274    private static PricingModel[] swigValues = { Midpoint, ISDA };
275    private static int swigNext = 0;
276    private final int swigValue;
277    private final String swigName;
278  }
279
280}