summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/curve.pyx68
1 files changed, 65 insertions, 3 deletions
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx
index d5bb5ff..7a7ce05 100644
--- a/pyisda/curve.pyx
+++ b/pyisda/curve.pyx
@@ -21,6 +21,14 @@ cdef class Curve:
JpmcdsFreeTCurve(self._thisptr)
def inspect(self):
+ """ method to inspect the content of the C struct
+
+ Returns
+ -------
+ dict
+ contains `base_date`, `basis`, `day_count_counvention` and `data`
+ """
+
return {'base_date': TDate_to_pydate(self._thisptr.fBaseDate),
'basis': self._thisptr.fBasis,
'day_count_convention': dcc_tostring(self._thisptr.fDayCountConv),
@@ -34,15 +42,38 @@ cdef fArray_to_list(TRatePt* fArray, int fNumItems):
return l
cdef class YieldCurve(Curve):
+ """ Initialize a yield curve from a list of zero coupon rates
+
+ Parameters
+ ----------
+ types : str
+ string containing only the letters 'M' (for Money Market ) and
+ 'S' (for swaps) to describe the type of quotes
+ periods : list of str
+ Describe the maturity of each instrument (Example: ['3M', '2Y'])
+ rates: array.array
+ Array of double containing the quotes
+ mm_dcc : str
+ Day count convention for the money market instrument.
+ fixed_swap_period : str
+ Period of the fixed leg of the swap.
+ float_swap_period : str
+ Period of the floating leg of the swap.
+ fixed_swap_dcc : str
+ Day count convention for the fixed leg of the swap.
+ float_swap_dcc : str
+ Day count convention for the floating leg of the swap.
+ bad_day_conv : int
+ Business day convention.
+ .. warning:: Instruments need to be sorted by tenor!
+
+ """
def __init__(self, date, str types,
list periods, double[:] rates,
str mm_dcc, str fixed_swap_period, str float_swap_period,
str fixed_swap_dcc, str float_swap_dcc, BadDay bad_day_conv):
- """ Initialize a yield curve from a list of zero coupon rates
- instruments need to be sorted by tenor
- """
cdef:
double fixed_freq
double float_freq
@@ -118,6 +149,22 @@ cdef class YieldCurve(Curve):
return [TDate_to_pydate(self._dates[i]) for i in range(self._ninstr)]
cdef class SpreadCurve(Curve):
+ """
+ Initialize a SpreadCurve from a list of spreads and maturity.
+
+ Parameters
+ ----------
+ today : datetime.date
+ yc : :class:`~pyisda.curve.YieldCurve`
+ start_date : datetime.date
+ step_in_date : datetime.date
+ cash_settle_date: :class:`datetime.date`
+ end_dates : list of :class:`datetime.date`
+ coupon_rates : :class:`array.array` of double
+ recovery_rate : float
+ pay_accrued_on_default : bool, optional
+
+ """
def __init__(self, today, YieldCurve yc, start_date, step_in_date,
cash_settle_date, list end_dates, double[:] coupon_rates,
@@ -158,6 +205,21 @@ cdef class SpreadCurve(Curve):
@classmethod
def from_flat_hazard(cls, base_date, double rate, Basis basis = CONTINUOUS,
str day_count_conv = 'Actual/365F'):
+ """
+ Alternative constructor for flat hazard rate Curve.
+
+ Parameters
+ ----------
+ base_date : datetime.date
+ Starting date of the curve
+ rate : float
+ Flat hazard rate.
+ basis : int, optional
+ Default to :data:`CONTINUOUS`
+ day_count_cont : str, optional
+ Default to '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