diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2023-02-01 12:53:27 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2023-02-01 12:53:27 -0500 |
| commit | 4334cf909f16376dd4d58bdd5f227aad43028ef3 (patch) | |
| tree | 8cec2c114312c89b9339f7dea6324f00fe048f5c | |
| parent | 1db8c8a1fa2ecb90236d1b27dbc9805c448869e2 (diff) | |
| download | pyisda-4334cf909f16376dd4d58bdd5f227aad43028ef3.tar.gz | |
use calendar more
| -rw-r--r-- | pyisda/cdsone.pxd | 4 | ||||
| -rw-r--r-- | pyisda/date.pyx | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/pyisda/cdsone.pxd b/pyisda/cdsone.pxd index dd8c3cc..3d372dc 100644 --- a/pyisda/cdsone.pxd +++ b/pyisda/cdsone.pxd @@ -19,8 +19,8 @@ cdef extern from "isda/cdsone.h" nogil: TStubMethod* stubType, long accrueDCC, long badDayConv, - char* calendar, - TCurve* discCurve, + const char* calendar, + const TCurve* discCurve, double oneSpread, double recoveryRate, TBoolean payAccruedAtStart, diff --git a/pyisda/date.pyx b/pyisda/date.pyx index 8b3db83..395d3b6 100644 --- a/pyisda/date.pyx +++ b/pyisda/date.pyx @@ -199,7 +199,7 @@ def roll_date(d, tenor): def default_accrual(trade_date, edd, start_date, end_date, double notional, - double coupon_rate): + double coupon_rate, str calendar): cdef: TDate trade_date_c = pydate_to_TDate(trade_date) TDate edd_c = pydate_to_TDate(edd) @@ -209,6 +209,7 @@ def default_accrual(trade_date, edd, start_date, end_date, double notional, TStubMethod stub int accrual_days double default_accrual + const char* c_cal = calendar if JpmcdsStringToStubMethod(b"f/s", &stub) != SUCCESS: raise ValueError("can't convert stub") @@ -226,16 +227,17 @@ def default_accrual(trade_date, edd, start_date, end_date, double notional, coupon_rate, ACT_360, FOLLOW, - b"None", + c_cal, &accrual_days, &default_accrual) != SUCCESS: raise ValueError("failed to compute default accrual") return accrual_days, default_accrual -def add_bus_days(from_date: datetime.date, int offset): +def add_bus_days(from_date: datetime.date, int offset, str calendar="NONE"): cdef: TDate from_date_c = pydate_to_TDate(from_date) TDate result + const char* c_cal = calendar - JpmcdsDateFromBusDaysOffset(from_date_c, offset, b"None", &result) + JpmcdsDateFromBusDaysOffset(from_date_c, offset, c_cal, &result) return TDate_to_pydate(result) |
