Skip to content

Commit 6fe752d

Browse files
This commit adds and improves numpydoc-style docstrings to the quantlib/termstructures/yields directory.
The following classes have been documented: - `FlatForward` - `ForwardSpreadedTermStructure` - `ImpliedTermStructure` The docstrings now use fully qualified type hints to support documentation generation and cross-referencing. The `Parameters` sections have been moved to the class docstrings for consistency.
1 parent da4daa7 commit 6fe752d

File tree

5 files changed

+41
-48
lines changed

5 files changed

+41
-48
lines changed

quantlib/quotes/futuresconvadjustmentquote.pyx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ from quantlib.indexes.ibor_index cimport IborIndex
66
cimport quantlib.indexes._ibor_index as _ii
77

88
cdef class FuturesConvAdjustmentQuote(Quote):
9-
"""Quote for the futures-convexity adjustment of an index.
10-
11-
Parameters
12-
----------
13-
index : :class:`~quantlib.indexes.ibor_index.IborIndex`
14-
The underlying IBOR index.
15-
futures_date_or_code : :class:`~quantlib.time.date.Date` or str
16-
The futures date or IMM code.
17-
futures_quote : :class:`~quantlib.quote.Quote`
18-
The quote for the futures contract.
19-
volatility : :class:`~quantlib.quote.Quote`
20-
The volatility quote.
21-
mean_reversion : :class:`~quantlib.quote.Quote`
22-
The mean-reversion quote.
23-
"""
249
def __init__(self, IborIndex index, futures_date_or_code,
2510
Quote futures_quote,
2611
Quote volatility,
@@ -51,20 +36,16 @@ cdef class FuturesConvAdjustmentQuote(Quote):
5136

5237
@property
5338
def futures_value(self):
54-
"""The value of the futures quote."""
5539
return self.as_ptr().futuresValue()
5640

5741
@property
5842
def volatility(self):
59-
"""The volatility of the quote."""
6043
return self.as_ptr().volatility()
6144

6245
@property
6346
def mean_reversion(self):
64-
"""The mean reversion of the quote."""
6547
return self.as_ptr().meanReversion()
6648

6749
@property
6850
def imm_date(self):
69-
"""The IMM date of the futures contract."""
7051
return _pydate_from_qldate(self.as_ptr().immDate())

quantlib/quotes/simplequote.pyx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ from quantlib.utilities.null cimport Null
44
from . cimport _simplequote as _sq
55

66
cdef class SimpleQuote(Quote):
7-
"""Market element returning a stored value.
8-
9-
Parameters
10-
----------
11-
value : float, optional
12-
The value of the quote. Defaults to a null value.
13-
"""
147
def __init__(self, Real value=Null[Real]()):
8+
""" Market element returning a stored value"""
159
self._thisptr.reset(new _sq.SimpleQuote(value))
1610

1711
def __str__(self):
@@ -27,13 +21,11 @@ cdef class SimpleQuote(Quote):
2721
return "SimpleQuote()"
2822

2923
property value:
30-
"""The value of the quote."""
3124
def __get__(self):
3225
return self._thisptr.get().value()
3326

3427
def __set__(self, double value):
3528
(<_sq.SimpleQuote*>self._thisptr.get()).setValue(value)
3629

3730
def reset(self):
38-
"""Resets the quote to a null value."""
3931
(<_sq.SimpleQuote*>self._thisptr.get()).reset()

quantlib/termstructures/yields/flat_forward.pyx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ from quantlib.quote cimport Quote
2121

2222

2323
cdef class FlatForward(YieldTermStructure):
24-
""" Flat interest-rate curve
24+
"""Flat interest-rate curve.
25+
26+
This class creates a flat forward rate term structure.
2527
2628
Parameters
2729
----------
28-
refererence_date : :class:`~quantlib.time.date.Date` or None
29-
Reference date used by the curve. If None, the user must provide the
30-
settlement days.
31-
forward : :class:`~quantlib.quote.Quote` | float
32-
The forward value used by the curve.
30+
reference_date : :class:`~quantlib.time.date.Date`, optional
31+
The reference date for the curve.
32+
forward : :class:`~quantlib.quote.Quote` or float
33+
The forward rate.
3334
daycounter : :class:`~quantlib.time.daycounter.DayCounter`
34-
The day counter used by the curve.
35-
settlement_days : int
36-
The settlement days used by this curve. If a reference date is given,
37-
this parameter is not used.
38-
calendar : :class:`~quantlib.time.calendar.Calendar`
39-
The calendar used by the curve if created with the settlement days.
40-
compounding : :class:`~quantlib.compounding.Compounding`, default Compounding.Continuous
41-
The type of compounding used by this curve.
42-
frequency : :class:`~quantlib.time.frequency.Frequency`, default `Annual`
43-
The frequency used by this curve.
35+
The day counter for the curve.
36+
settlement_days : int, optional
37+
The number of settlement days, used if `reference_date` is not provided.
38+
calendar : :class:`~quantlib.time.calendar.Calendar`, optional
39+
The calendar for settlement days, used if `reference_date` is not provided.
40+
compounding : :class:`~quantlib.compounding.Compounding`, optional
41+
The compounding convention. Defaults to `Continuous`.
42+
frequency : :class:`~quantlib.time.frequency.Frequency`, optional
43+
The compounding frequency. Defaults to `Annual`.
4444
"""
4545

4646

quantlib/termstructures/yields/forward_spreaded_term_structure.pyx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ from ..yield_term_structure cimport YieldTermStructure
55
from quantlib.quote cimport Quote
66

77
cdef class ForwardSpreadedTermStructure(YieldTermStructure):
8-
"""
9-
Constructor Inputs:
10-
1. YieldTermStructure
11-
2. Quote
8+
"""Term structure with an added spread on the instantaneous forward rate.
9+
10+
This term structure remains linked to the original structure; any changes
11+
in the latter will be reflected in this structure.
1212
13+
Parameters
14+
----------
15+
yts : :class:`~quantlib.termstructures.yield_term_structure.HandleYieldTermStructure`
16+
The handle to the original yield term structure.
17+
spread : :class:`~quantlib.quote.Quote`
18+
The spread to be added to the forward rate.
1319
"""
1420
def __init__(self, HandleYieldTermStructure yts not None, Quote spread not None):
1521

quantlib/termstructures/yields/implied_term_structure.pyx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ from quantlib.handle cimport HandleYieldTermStructure
33
from quantlib.time.date cimport Date
44

55
cdef class ImpliedTermStructure(YieldTermStructure):
6+
"""Implied term structure at a given date in the future.
7+
8+
The given date will be the implied reference date.
9+
10+
This term structure will remain linked to the original structure; any
11+
changes in the latter will be reflected in this structure as well.
12+
13+
Parameters
14+
----------
15+
h : :class:`~quantlib.termstructures.yield_term_structure.HandleYieldTermStructure`
16+
The handle to the original yield term structure.
17+
reference_date : :class:`~quantlib.time.date.Date`
18+
The new reference date for the implied curve.
19+
"""
620
def __init__(self, HandleYieldTermStructure h not None,
721
Date reference_date not None):
822

0 commit comments

Comments
 (0)