summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-10-25 11:34:16 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-10-25 11:34:16 -0400
commit3e994c495065c371c4ee136146bb5dbb6512fa63 (patch)
tree39beb1cdebb7d25bfa117a7af8ac575fbdfc5728
parentd1f5259a5682346e0cb7ad342fe39581999f868c (diff)
downloadpyisda-3e994c495065c371c4ee136146bb5dbb6512fa63.tar.gz
improve docs
-rw-r--r--Makefile4
-rw-r--r--docs/api.rst15
-rw-r--r--pyisda/curve.pyx1
-rw-r--r--pyisda/legs.pyx72
4 files changed, 89 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index fb1c950..08a3604 100644
--- a/Makefile
+++ b/Makefile
@@ -8,5 +8,7 @@ clean:
install:
pip install .
-docs:
+docs: build
make -C docs html
+
+.PHONY: build docs clean
diff --git a/docs/api.rst b/docs/api.rst
index 253ddd5..c87674a 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -1,8 +1,8 @@
PyISDA
======
-:mod:`~pyisda.cdsone` contains the two work horse functions of the library,
-which allow to convert back and forth from upfront to spread
+:mod:`~pyisda.cdsone` contains the two workhorse functions of the library,
+which allow to convert back and forth from upfront to spread.
.. autosummary::
pyisda.cdsone.upfront_charge
@@ -21,3 +21,14 @@ which allow to convert back and forth from upfront to spread
.. automodule:: pyisda.curve
:members:
:undoc-members:
+
+:mod:`~pyisda.legs` contains two types of Legs:
+
+.. autosummary::
+ pyisda.legs.FeeLeg
+ pyisda.legs.ContingentLeg
+
+
+.. automodule:: pyisda.legs
+ :members:
+ :undoc-members:
diff --git a/pyisda/curve.pyx b/pyisda/curve.pyx
index 52ddab7..9e2f2e9 100644
--- a/pyisda/curve.pyx
+++ b/pyisda/curve.pyx
@@ -210,6 +210,7 @@ cdef class SpreadCurve(Curve):
coupon_rates : :class:`array.array` of double
recovery_rate : float
pay_accrued_on_default : bool, optional
+ Default to True
"""
diff --git a/pyisda/legs.pyx b/pyisda/legs.pyx
index 1a66af3..ea19b72 100644
--- a/pyisda/legs.pyx
+++ b/pyisda/legs.pyx
@@ -4,6 +4,17 @@ from cdsone cimport JpmcdsStringToStubMethod, TStubMethod
from curve cimport YieldCurve, SpreadCurve
cdef class ContingentLeg:
+ """
+ Initialize a ContingentLeg.
+
+ Parameters
+ ----------
+ startdate : :class:`datetime.date`
+ end_date : :class:`datetime.date`
+ notional : float
+ protect_start : bool, optional
+ if True, protection starts at beginning of day. Default to True.
+ """
def __cinit__(self, start_date, end_date, double notional,
TBoolean protect_start = True):
@@ -21,6 +32,21 @@ cdef class ContingentLeg:
def pv(self, today, step_in_date, value_date, YieldCurve yc, SpreadCurve sc,
double recovery_rate):
+ """
+ Present Value of the ContingentLeg cashflows.
+
+ Parameters
+ ----------
+ today : :class:`datetime.date`
+ step_in_date : :class:`datetime.date`
+ date at which protection starts (usually `today` + 1)
+ value_date : :class:`datetime.date`
+ date at which cashflows are exchanged (usually `today` + 3 business days)
+ yc : :class:`~pyisda.curve.YieldCurve`
+ sc : :class:`~pyisda.curve.SpreadCurve`
+ recovery_rate : float
+ """
+
cdef TDate today_c = pydate_to_TDate(today)
cdef TDate step_in_date_c = pydate_to_TDate(step_in_date)
cdef TDate value_date_c = pydate_to_TDate(value_date)
@@ -32,7 +58,25 @@ cdef class ContingentLeg:
raise ValueError
cdef class FeeLeg:
+ """
+ Initialize a FeeLeg.
+ Parameters
+ ----------
+ startdate : :class:`datetime.date`
+ date when protection begins. Either start or end of day (depending on
+ `protect_start`)
+ end_date : :class:`datetime.date`
+ date when protection ends (end of day)
+ pay_accrued_on_default : bool
+ Usually set to True
+ notional : float
+ coupon_rate : float
+ payment_dcc : string, optional
+ Default 'ACT/360'
+ protect_start : bool, optional
+ if True, protection starts at beginning of day. Default to True.
+ """
def __cinit__(self, start_date, end_date, TBoolean pay_accrued_on_default,
double notional, double coupon_rate, str payment_dcc = 'ACT/360',
TBoolean protect_start = True):
@@ -57,6 +101,7 @@ cdef class FeeLeg:
raise ValueError
def inspect(self):
+ """convenience method to study the C struct"""
cdef list acc_start_dates = []
cdef list acc_end_dates = []
cdef list pay_dates = []
@@ -71,6 +116,7 @@ cdef class FeeLeg:
@property
def cashflows(self):
+ """Cashflow schedule"""
cdef TCashFlowList* cfl = JpmcdsFeeLegFlows(self._thisptr)
cdef TCashFlow cf
result = []
@@ -81,6 +127,22 @@ cdef class FeeLeg:
def pv(self, today, step_in_date, value_date, YieldCurve yc, SpreadCurve sc,
TBoolean pay_accrued_at_start):
+ """
+ Present Value of FeeLeg cashflows.
+
+ Parameters
+ ----------
+ today : :class:`datetime.date`
+ step_in_date : :class:`datetime.date`
+ date at which protection starts (usually `today` + 1)
+ value_date : :class:`datetime.date`
+ date at which cashflows are exchanged (usually `today` + 3 business days)
+ yc : :class:`~pyisda.curve.YieldCurve`
+ sc : :class:`~pyisda.curve.SpreadCurve`
+ pay_accrued_at_start : bool
+ True means clean
+
+ """
cdef TDate today_c = pydate_to_TDate(today)
cdef TDate step_in_date_c = pydate_to_TDate(step_in_date)
cdef TDate value_date_c = pydate_to_TDate(value_date)
@@ -92,6 +154,16 @@ cdef class FeeLeg:
raise ValueError
def accrued(self, today):
+ """Accrued amount as of today
+
+ Parameters
+ ----------
+ today : :class:`datetime.date`
+
+ Return
+ ------
+ float
+ """
cdef double ai
FeeLegAI(self._thisptr, pydate_to_TDate(today), &ai)
return ai