summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2020-11-17 17:24:07 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2020-11-17 17:24:07 -0500
commit3b3d53ea09d054c3bd909ae632dded1d3758ea86 (patch)
tree9861fae2c93920bec14ba06207cd63e1bfc4c4a9
parent3be205c245acbeaf1dd8866b59a57638f78bd3a2 (diff)
downloadpyisda-3b3d53ea09d054c3bd909ae632dded1d3758ea86.tar.gz
allow to pass array of dates
-rw-r--r--pyisda/curve.pyx20
1 files changed, 16 insertions, 4 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx
index 1cf7f23..87d613e 100644
--- a/pyisda/curve.pyx
+++ b/pyisda/curve.pyx
@@ -5,7 +5,7 @@ from .date cimport (JpmcdsStringToDateInterval, pydate_to_TDate, dcc, TMonthDayY
JpmcdsDateFromBusDaysOffset, JpmcdsStringToDayCountConv, ACT_360,
BadDay, FOLLOW, MODIFIED, NONE)
from .date import dcc_tostring
-from .date cimport _previous_twentieth, _roll_date
+from .date cimport _previous_twentieth, _roll_date, c_datetime
from .cdsone cimport JpmcdsStringToStubMethod
from .legs cimport (JpmcdsCdsContingentLegMake, JpmcdsCdsFeeLegMake,
JpmcdsContingentLegPV, JpmcdsFeeLegPV, FeeLegAI, JpmcdsFeeLegFree)
@@ -219,10 +219,22 @@ cdef class Curve(object):
-------
float
"""
- cdef const TCurve* curve = get_TCurve(self)
+ cdef:
+ const TCurve* curve = get_TCurve(self)
+ np.ndarray r
+ c_datetime.date d
+ size_t i
+
if d1 is None:
- return JpmcdsForwardZeroPrice(curve, curve.fBaseDate,
- pydate_to_TDate(d2))
+ if isinstance(d2, np.ndarray):
+ r = np.zeros_like(d2)
+ for i, e in enumerate(d2):
+ r[i] = JpmcdsForwardZeroPrice(curve, curve.fBaseDate,
+ pydate_to_TDate(d2[i]))
+ return r
+ else:
+ return JpmcdsForwardZeroPrice(curve, curve.fBaseDate,
+ pydate_to_TDate(d2))
else:
return JpmcdsForwardZeroPrice(curve, pydate_to_TDate(d1),
pydate_to_TDate(d2))