summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-02-03 15:29:41 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2017-02-03 15:29:41 -0500
commitee458862e860d87f8388c753f45f6240e45ebbc6 (patch)
tree4ae83d58c73b20180d1e006b40fe5c8bb97746cd
parente45cc3840ca5acff08dc2c266b705a098fdac0c8 (diff)
downloadpyisda-ee458862e860d87f8388c753f45f6240e45ebbc6.tar.gz
try to calibrate with upfronts
-rw-r--r--pyisda/curve.pxd16
-rw-r--r--pyisda/curve.pyx8
-rw-r--r--pyisda/flat_hazard.pyx4
3 files changed, 16 insertions, 12 deletions
diff --git a/pyisda/curve.pxd b/pyisda/curve.pxd
index dadd87b..2ca1030 100644
--- a/pyisda/curve.pxd
+++ b/pyisda/curve.pxd
@@ -33,12 +33,11 @@ cdef extern from "isda/bastypes.h":
double fRate
cdef extern from "isda/cds.h" nogil:
-
- TCurve* JpmcdsCleanSpreadCurve(
+ TCurve* JpmcdsCleanSpreadCurve(
# Risk starts at the end of today
TDate today,
# Interest rate discount curve - assumes flat forward interpolation
- TCurve *discCurve,
+ const TCurve *discCurve,
# Effective date of the benchmark CDS
TDate startDate,
# Step in date of the benchmark CDS
@@ -51,14 +50,15 @@ cdef extern from "isda/cds.h" nogil:
# Array of size nbDate
TDate *endDates,
# Coupon rates for each benchmark instrument. Array of size nbDate
- double *couponRates,
+ const double *couponRates,
+ const double *upfrontRates,
# Flags to denote that we include particular benchmarks. This makes it
# easy for the user to include or exclude benchmarks on a one-by-one
# basis. Can be NULL if all are included. Otherwise an array of size
# nbDate.
- TBoolean *includes,
+ const TBoolean *includes,
# Recovery rate in case of default
- double recoveryRate,
+ const double* recoveryRate,
# Should accrued interest be paid on default. Usually set to TRUE
TBoolean payAccOnDefault,
# Interval between coupon payments. Can be NULL when 3M is assumed
@@ -67,12 +67,12 @@ cdef extern from "isda/cds.h" nogil:
long paymentDcc,
# If the startDate and endDate are not on cycle, then this parameter
# determines location of coupon dates. */
- TStubMethod *stubType,
+ const TStubMethod *stubType,
# Bad day convention for adjusting coupon payment dates. */
long badDayConv,
# Calendar used when adjusting coupon dates. Can be NULL which equals
# a calendar with no holidays and including weekends. */
- char *calendar
+ const char *calendar
)
cdef extern from "isda/tcurve.h" nogil:
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx
index 82d214b..61b12d6 100644
--- a/pyisda/curve.pyx
+++ b/pyisda/curve.pyx
@@ -253,8 +253,9 @@ cdef class SpreadCurve(Curve):
"""
def __init__(self, today, YieldCurve yc, start_date, step_in_date,
- cash_settle_date, list end_dates, double[:] coupon_rates,
- double recovery_rate, int pay_accrued_on_default = True):
+ cash_settle_date, list end_dates,
+ double[:] coupon_rates, double[:] upfront_rates,
+ double[:] recovery_rates, int pay_accrued_on_default = True):
cdef TDate today_c = pydate_to_TDate(today)
cdef TDate step_in_date_c = pydate_to_TDate(step_in_date)
@@ -281,8 +282,9 @@ cdef class SpreadCurve(Curve):
len(end_dates),
end_dates_c,
&coupon_rates[0],
+ &upfront_rates[0],
NULL,
- recovery_rate,
+ &recovery_rates[0],
pay_accrued_on_default,
NULL,
dcc('ACT/360'),
diff --git a/pyisda/flat_hazard.pyx b/pyisda/flat_hazard.pyx
index 01a1748..fc93b1d 100644
--- a/pyisda/flat_hazard.pyx
+++ b/pyisda/flat_hazard.pyx
@@ -49,6 +49,7 @@ def strike_vec(double[:] spreads, YieldCurve yc, trade_date, value_date,
b'NONE',
1) # protect_start = True
cdef size_t i
+ cdef double zero_upfront = 0
for i in range(spreads.shape[0]):
sc = JpmcdsCleanSpreadCurve(trade_date_c,
yc._thisptr,
@@ -58,8 +59,9 @@ def strike_vec(double[:] spreads, YieldCurve yc, trade_date, value_date,
1, # length of end_dates_c
&end_date_c,
&spreads[i],
+ &zero_upfront,
NULL,
- recovery_rate,
+ &recovery_rate,
1, # pay_accrued_on_default True
NULL,
ACT_360, # JPMCDS_ACT_360