diff options
| author | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-07-06 11:05:46 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-07-06 11:05:46 -0400 |
| commit | e61c2ea1409c9579f6a2020f382db480f58be538 (patch) | |
| tree | 8e98cb1217591de3d96c786c64440ccf4aa8c753 /curve.pyx | |
| parent | cd7c2f612050e692e804b4f51b7180ab540bbc59 (diff) | |
| download | pyisda-e61c2ea1409c9579f6a2020f382db480f58be538.tar.gz | |
add new constructor
Diffstat (limited to 'curve.pyx')
| -rw-r--r-- | curve.pyx | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -1,12 +1,17 @@ from libc.stdlib cimport malloc, free -from curve cimport JpmcdsBuildIRZeroCurve, JpmcdsZeroPrice +from curve cimport (JpmcdsBuildIRZeroCurve, JpmcdsZeroPrice, JpmcdsMakeTCurve, + Basis, CONTINUOUS) from date cimport (JpmcdsStringToDateInterval, pydate_to_TDate, dcc, JpmcdsDateIntervalToFreq, JpmcdsDateFwdThenAdjust, TDate_to_pydate, JpmcdsDateFromBusDaysOffset) from date import dcc_tostring from cdsone cimport JpmcdsStringToStubMethod, TStubMethod + cdef int SUCCESS = 0 +cdef extern from "limits.h": + long LONG_MAX + cpdef public enum BadDay: FOLLOW = <long>'F' PREVIOUS = <long>'P' @@ -135,3 +140,19 @@ cdef class SpreadCurve(Curve): &stub_type, <long>'M', b'NONE') + + @classmethod + def from_flat_hazard(cls, base_date, double rate, Basis basis = CONTINUOUS, + str day_count_conv = 'Actual/365F'): + cdef TDate base_date_c = pydate_to_TDate(base_date) + cdef SpreadCurve sc = cls.__new__(cls) + cdef TDate max_date = LONG_MAX + cdef TDate* dates = <TDate*>malloc(sizeof(TDate)) + + cdef double* rates = <double*>malloc(sizeof(double)) + dates[0] = max_date + rates[0] = rate + + sc._thisptr = JpmcdsMakeTCurve(base_date_c, dates, rates, 1, + <double>basis, dcc(day_count_conv)) + return sc |
