summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2023-01-25 23:31:21 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2023-01-25 23:31:21 -0500
commit6bb86980f7b924b322c8a38b60ecdf44e9b6f1af (patch)
tree160d195ad04d1433ccc2036cffbb65f91544f0e9
parent846daaf8a1f3090965a2606a7933ad0e6f71aa6e (diff)
downloadpyisda-6bb86980f7b924b322c8a38b60ecdf44e9b6f1af.tar.gz
make cal_file a C++ string
-rw-r--r--pyisda/credit_index.pxd2
-rw-r--r--pyisda/credit_index.pyx16
-rw-r--r--pyisda/legs.pxd2
3 files changed, 10 insertions, 10 deletions
diff --git a/pyisda/credit_index.pxd b/pyisda/credit_index.pxd
index 1a07a6f..e355eb8 100644
--- a/pyisda/credit_index.pxd
+++ b/pyisda/credit_index.pxd
@@ -20,7 +20,7 @@ cdef class CreditIndex(CurveList):
cdef vector[TDate] _maturities
cdef TContingentLeg** contingent_legs
cdef TFeeLeg** fee_legs
- cdef readonly char[30] cal_file
+ cdef readonly string cal_file
cdef copy(CurveList orig, CurveList copy)
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx
index 57cd48c..861a103 100644
--- a/pyisda/credit_index.pyx
+++ b/pyisda/credit_index.pyx
@@ -257,7 +257,7 @@ cdef class CreditIndex(CurveList):
cdef size_t i
cdef pair[TContingentLeg_ptr, TFeeLeg_ptr] r
for i in range(self._maturities.size()):
- r = get_legs(self._maturities[i], self._start_date, self.cal_file)
+ r = get_legs(self._maturities[i], self._start_date, self.cal_file.c_str())
self.contingent_legs[i] = r.first
self.fee_legs[i] = r.second
@@ -300,14 +300,14 @@ cdef class CreditIndex(CurveList):
copy.fee_legs[i] = <TFeeLeg*>malloc(sizeof(TFeeLeg))
fee_leg_copy(fl, copy.fee_legs[i])
- strcpy(copy.cal_file, self.cal_file)
+ copy.cal_file = self.cal_file
memo[id(self)] = copy
return copy
def __reduce__(self):
return (self.__class__,
(self.start_date, self.maturities, self.curves,
- TDate_to_pydate(self.base_date), self.cal_file))
+ TDate_to_pydate(self.base_date), self.cal_file.c_str()))
def __hash__(self):
cdef:
@@ -402,7 +402,7 @@ cdef class CreditIndex(CurveList):
int i = get_maturity_index(maturity_c, self._maturities)
if i == -1:
- legs = get_legs(maturity_c, self._start_date, self.cal_file)
+ legs = get_legs(maturity_c, self._start_date, self.cal_file.c_str())
else:
legs.first = self.contingent_legs[i]
legs.second = self.fee_legs[i]
@@ -448,7 +448,7 @@ cdef class CreditIndex(CurveList):
i = get_maturity_index(maturity_c, self._maturities)
if i == -1:
legs = get_legs(maturity_c,
- self._start_date, self.cal_file)
+ self._start_date, self.cal_file.c_str())
else:
legs.first = self.contingent_legs[i]
legs.second = self.fee_legs[i]
@@ -463,7 +463,7 @@ cdef class CreditIndex(CurveList):
i = get_maturity_index(maturity_c, self._maturities)
if i == -1:
legs = get_legs(maturity_c,
- self._start_date, self.cal_file)
+ self._start_date, self.cal_file.c_str())
else:
legs.first = self.contingent_legs[i]
legs.second = self.fee_legs[i]
@@ -581,7 +581,7 @@ cdef class CreditIndex(CurveList):
self._maturities[i] = pydate_to_TDate(val[i])
free(self.contingent_legs[i])
JpmcdsFeeLegFree(self.fee_legs[i])
- r = get_legs(self._maturities[i], self._start_date, self.cal_file)
+ r = get_legs(self._maturities[i], self._start_date, self.cal_file.c_str())
self.contingent_legs[i] = r.first
self.fee_legs[i] = r.second
@@ -844,7 +844,7 @@ cdef inline int get_maturity_index(TDate maturity, const vector[TDate]& maturiti
return i
cdef pair[TContingentLeg_ptr, TFeeLeg_ptr] get_legs(TDate maturity,
- TDate start_date, char* cal) nogil:
+ TDate start_date, const char* cal) nogil:
cdef:
pair[TContingentLeg_ptr, TFeeLeg_ptr] r
TStubMethod stub_type
diff --git a/pyisda/legs.pxd b/pyisda/legs.pxd
index bd35530..6a31c17 100644
--- a/pyisda/legs.pxd
+++ b/pyisda/legs.pxd
@@ -70,7 +70,7 @@ cdef extern from "isda/cds.h" nogil:
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,
# Should protection include the start date */
TBoolean protectStart)