Skip to content

Commit 50aea01

Browse files
committed
better docstrings
1 parent 3e96bd4 commit 50aea01

File tree

6 files changed

+87
-34
lines changed

6 files changed

+87
-34
lines changed

quantlib/instrument.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ cdef class Instrument(Observable):
3131
return self._thisptr.get().NPV()
3232

3333
@property
34-
def is_expired(self):
34+
def is_expired(self) -> bool:
35+
"""whether the instrument might ave value greater than zero."""
3536
return self._thisptr.get().isExpired()
3637

3738
@property
3839
def valuation_date(self):
40+
"""the date the net present value refers to.
41+
42+
Returns
43+
-------
44+
valuation_date: :class:`~quantlib.time.date.Date`
45+
"""
3946
return date_from_qldate(self._thisptr.get().valuationDate())

quantlib/instruments/bond.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ cdef class Bond(Instrument):
109109

110110
@property
111111
def cashflows(self):
112-
""" cash flow stream as a Leg """
112+
""" cash flow stream as a :class:`~quantlib.cashflow.Leg`."""
113113
cdef Leg leg = Leg.__new__(Leg)
114114
leg._thisptr = self.as_ptr().cashflows()
115115
return leg

quantlib/option.pxd

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
from quantlib.instrument cimport Instrument
22

3-
cdef extern from 'ql/option.hpp' namespace 'QuantLib::Option':
3+
cdef extern from 'ql/option.hpp' namespace 'QuantLib::Option' nogil:
44
cpdef enum class OptionType "QuantLib::Option::Type":
5-
Put
6-
Call
5+
"""
6+
Attributes
7+
----------
8+
Put
9+
Call
10+
"""
11+
Put
12+
Call
713

814

915

quantlib/pricingengines/forward/replicating_variance_swap_engine.pyx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ from quantlib.pricingengines.engine cimport PricingEngine
99
from ._replicating_variance_swap_engine cimport ReplicatingVarianceSwapEngine as _ReplicatingVarianceSwapEngine
1010

1111
cdef class ReplicatingVarianceSwapEngine(PricingEngine):
12-
"""
13-
Variance-swap pricing engine using replicating cost,
14-
as described in Demeterfi, Derman, Kamal & Zou,
15-
"A Guide to Volatility and Variance Swaps", 1999
16-
17-
Attributes
18-
---------
19-
process : :obj:`GeneralizedBlackScholesProcess`
20-
call_strikes : list of :obj:`Real`
21-
put_strikes : list of :obj:`Real`
22-
dk : Real
23-
5.0
12+
"""Variance-swap pricing engine using replicating cost
13+
14+
as described in [1]_.
15+
16+
Parameters
17+
----------
18+
process : :class:`~quantlib.processes.black_scholes_process.GeneralizedBlackScholesProcess`
19+
call_strikes : list of :obj:`Real`
20+
put_strikes : list of :obj:`Real`
21+
dk : Real, default 5.0
2422
23+
References
24+
----------
25+
.. [1] Demeterfi, Derman, Kamal & Zou, "A Guide to Volatility and Variance Swaps", 1999
2526
2627
"""
2728

quantlib/termstructures/volatility/equityfx/local_vol_surface.pyx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,23 @@ cdef class LocalVolSurface(LocalVolTermStructure):
1313
def __init__(self, BlackVolTermStructure black_ts, HandleYieldTermStructure risk_free_ts, HandleYieldTermStructure dividend_ts, Quote underlying):
1414
""" Local volatility surface derived from a Black vol surface
1515
16-
For details about this implementation refer to [Gat]_.
17-
1816
Parameters
1917
----------
2018
black_ts : BlackVolTermStructure
2119
risk_free_ts : YieldTermStructure
22-
dividend_ts : YieldTermStructure, the dividend term structure.
23-
underlying : Quote, the spot underlying
20+
dividend_ts : YieldTermStructure
21+
the dividend term structure.
22+
underlying : Quote
23+
the spot underlying.
2424
25+
26+
Notes
27+
-----
28+
For details about this implementation refer to [Gat]_.
29+
30+
31+
References
32+
----------
2533
.. [Gat] "Stochastic Volatility and LocalVolatility" in *Case Studies and Financial Modelling Course Notes,* Jim Gatheral, Fall Term, 2003 https://web.math.ku.dk/~rolf/teaching/ctff03/Gatheral.1.pdf
2634
"""
2735
self._thisptr.reset(

quantlib/time/frequency.pxd

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,50 @@ from libcpp.string cimport string
22

33
cdef extern from 'ql/time/frequency.hpp' namespace "QuantLib" nogil:
44
cpdef enum Frequency:
5-
NoFrequency = -1 # null frequency
6-
Once = 0 # only once, e.g., a zero-coupon
7-
Annual = 1 # once a year
8-
Semiannual = 2 # twice a year
9-
EveryFourthMonth = 3 # every fourth month
10-
Quarterly = 4 # every third month
11-
Bimonthly = 6 # every second month
12-
Monthly = 12 # once a month
13-
EveryFourthWeek = 13 # every fourth week
14-
Biweekly = 26 # every second week
15-
Weekly = 52 # once a week
16-
Daily = 365 # once a day
17-
OtherFrequency = 999 # some other unknown frequency
5+
"""Frequency of events
6+
7+
Attributes
8+
----------
9+
NoFrequency
10+
null frequency
11+
Once
12+
only once, e.g., a zero-coupon
13+
Annual
14+
once a year
15+
Semiannual
16+
twice a year
17+
EveryFourthMonth
18+
every fourth month
19+
Quarterly
20+
every third month
21+
Bimonthly
22+
every second month
23+
Monthly
24+
once a month
25+
EveryFourthWeek
26+
every fourth week
27+
Biweekly
28+
every second week
29+
Weekly
30+
once a week
31+
Daily
32+
once a day
33+
OtherFrequency
34+
some other unknown frequency
35+
"""
36+
NoFrequency
37+
Once
38+
Annual
39+
Semiannual
40+
EveryFourthMonth
41+
Quarterly
42+
Bimonthly
43+
Monthly
44+
EveryFourthWeek
45+
Biweekly
46+
Weekly
47+
Daily
48+
OtherFrequency
1849

1950
cdef extern from "<sstream>" namespace "std":
2051
cdef cppclass stringstream:

0 commit comments

Comments
 (0)