From 1990c15ff0bfeffd442d9be3c3d38df0dbb0b15d Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 6 Jul 2016 12:21:53 -0400 Subject: fix indentation --- curve.pyx | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/curve.pyx b/curve.pyx index b4b61ad..824c8ce 100644 --- a/curve.pyx +++ b/curve.pyx @@ -1,6 +1,6 @@ from libc.stdlib cimport malloc, free from curve cimport (JpmcdsBuildIRZeroCurve, JpmcdsZeroPrice, JpmcdsMakeTCurve, - Basis, CONTINUOUS) + Basis, CONTINUOUS, JpmcdsCleanSpreadCurve) from date cimport (JpmcdsStringToDateInterval, pydate_to_TDate, dcc, JpmcdsDateIntervalToFreq, JpmcdsDateFwdThenAdjust, TDate_to_pydate, JpmcdsDateFromBusDaysOffset) @@ -9,9 +9,6 @@ from cdsone cimport JpmcdsStringToStubMethod, TStubMethod cdef int SUCCESS = 0 -cdef extern from "limits.h": - long LONG_MAX - cpdef public enum BadDay: FOLLOW = 'F' PREVIOUS = 'P' @@ -141,18 +138,18 @@ cdef class SpreadCurve(Curve): '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 = malloc(sizeof(TDate)) - - cdef double* rates = malloc(sizeof(double)) - dates[0] = max_date - rates[0] = rate - - sc._thisptr = JpmcdsMakeTCurve(base_date_c, dates, rates, 1, - basis, dcc(day_count_conv)) - return sc + @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 = 200000 # can go higher but this should be more than enough + cdef TDate* dates = malloc(sizeof(TDate)) + + cdef double* rates = malloc(sizeof(double)) + dates[0] = max_date + rates[0] = rate + + sc._thisptr = JpmcdsMakeTCurve(base_date_c, dates, rates, 1, + basis, dcc(day_count_conv)) + return sc -- cgit v1.2.3-70-g09d2