Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

credit pricing engine: MidPointCdsEngine

  • Loading branch information...
commit 54de28220be6c84bee364eecf78a690fe7ed66d2 1 parent 8466ba0
@dpinte dpinte authored
View
18 quantlib/pricingengines/_credit.pxd
@@ -0,0 +1,18 @@
+
+include '../types.pxi'
+
+from quantlib.handle cimport Handle
+from quantlib.termstructures._default_term_structure cimport DefaultProbabilityTermStructure
+from quantlib.termstructures._yield_term_structure cimport YieldTermStructure
+from _pricing_engine cimport PricingEngine
+
+cdef extern from 'ql/pricingengines/credit/midpointcdsengine.hpp' namespace 'QuantLib':
+
+ cdef cppclass MidPointCdsEngine(PricingEngine):
+ MidPointCdsEngine(
+ Handle[DefaultProbabilityTermStructure]&,
+ Real recoveryRate,
+ Handle[YieldTermStructure]& discountCurve,
+ #boost::optional<bool> includeSettlementDateFlows = boost::none);
+ )
+
View
27 quantlib/pricingengines/credit.pyx
@@ -1,19 +1,34 @@
# distutils: language = c++
+from cython.operator cimport dereference as deref
-from quantlib.handle cimport shared_ptr
+from quantlib.handle cimport Handle, shared_ptr
cimport _pricing_engine as _pe
+cimport _credit
+
from engine cimport PricingEngine
-cdef class MiPointCdsEngine(PricingEngine):
+cimport quantlib.termstructures._default_term_structure as _dts
+cimport quantlib.termstructures._yield_term_structure as _yts
+from quantlib.termstructures.credit.piecewise_default_curve cimport PiecewiseDefaultCurve
+from quantlib.termstructures.yields.yield_term_structure cimport YieldTermStructure
+
+cdef class MidPointCdsEngine(PricingEngine):
- def __init__(self): #, PiecewiseDefaultCurve ts, float recovery_rate,
- #YieldTermStructure discount_curve):
+ def __init__(self, PiecewiseDefaultCurve ts, float recovery_rate,
+ YieldTermStructure discount_curve):
"""
- First argument should be a DefaultProbabilityTermStructure. I am using
+ First argument should be a DefaultProbabilityTermStructure. Using
the PiecewiseDefaultCurve at the moment.
"""
+
+ cdef Handle[_dts.DefaultProbabilityTermStructure] handle = \
+ Handle[_dts.DefaultProbabilityTermStructure](deref(ts._thisptr))
+
+ cdef Handle[_yts.YieldTermStructure] yts_handle = \
+ Handle[_yts.YieldTermStructure](deref(discount_curve._thisptr))
+
self._thisptr = new shared_ptr[_pe.PricingEngine](
- #new _credit.MidPointCdsEngine()
+ new _credit.MidPointCdsEngine(handle, recovery_rate, yts_handle)
)
Please sign in to comment.
Something went wrong with that request. Please try again.