Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions quantlib/_index.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ cdef extern from 'ql/index.hpp' namespace 'QuantLib' nogil:
void addFixings(vector[Date].iterator dBegin, vector[Date].iterator dEnd, vector[Real].iterator vBegin, bool forceOverwrite) except +
TimeSeries[Real] timeSeries()
void clearFixings()
bool hasHistoricalFixing(const Date& fixingDate)
2 changes: 1 addition & 1 deletion quantlib/compounding.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cdef extern from "ql/compounding.hpp" namespace "QuantLib":
cdef extern from "ql/compounding.hpp" namespace "QuantLib" nogil:
cpdef enum Compounding:
Simple = 0
Continuous = 1
Expand Down
1 change: 1 addition & 0 deletions quantlib/compounding.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globals().update(getattr(Compounding, "__members__"))
Empty file.
36 changes: 0 additions & 36 deletions quantlib/experimental/risk/_sensitivityanalysis.pxd

This file was deleted.

110 changes: 0 additions & 110 deletions quantlib/experimental/risk/sensitivityanalysis.pyx

This file was deleted.

6 changes: 4 additions & 2 deletions quantlib/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the license for more details.
"""Abstract base class for indices"""
include 'types.pxi'

from quantlib.types cimport Real
from cpython.datetime cimport PyDate_Check, date_year, date_month, date_day, import_datetime
from libcpp cimport bool
from libcpp.vector cimport vector
Expand Down Expand Up @@ -92,3 +91,6 @@ cdef class Index:

def clear_fixings(self):
self._thisptr.get().clearFixings()

def has_historical_fixing(self, Date d):
return self._thisptr.get().hasHistoricalFixing(d._thisptr)
2 changes: 0 additions & 2 deletions quantlib/indexes/_inflation_index.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
"""

include '../types.pxi'
from libcpp cimport bool
from libcpp.string cimport string

Expand Down Expand Up @@ -58,7 +57,6 @@ cdef extern from 'ql/indexes/inflationindex.hpp' namespace 'QuantLib' nogil:
YoYInflationIndex(const string& familyName,
const Region& region,
bool revised,
bool ratio, # is this one a genuine index or a ratio?
Frequency frequency,
const Period& availabilityLag,
const Currency& currency,
Expand Down
24 changes: 0 additions & 24 deletions quantlib/indexes/index_manager.pyx
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
# cython: c_string_type=unicode, c_string_encoding=ascii
include '../types.pxi'
from libcpp.string cimport string
cimport quantlib.indexes._index_manager as _im
from quantlib.time_series cimport TimeSeries
cimport quantlib._time_series as _ts

cdef class IndexManager:
cdef has_history(self, string name):
_im.IndexManager.instance().hasHistory(name)

@staticmethod
def histories():
return _im.IndexManager.instance().histories()

@staticmethod
def get_history(string name):
cdef TimeSeries ts = TimeSeries.__new__(TimeSeries)
ts._thisptr = _im.IndexManager.instance().getHistory(name)
return ts

@staticmethod
def set_history(string name, TimeSeries ts not None):
_im.IndexManager.instance().setHistory(name, ts._thisptr)

@staticmethod
def clear_history(string name):
_im.IndexManager.instance().clearHistory(name)

@staticmethod
def clear_histories():
_im.IndexManager.instance().clearHistories()
6 changes: 2 additions & 4 deletions quantlib/indexes/inflation/_euhicp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ cdef extern from 'ql/indexes/inflation/euhicp.hpp' namespace 'QuantLib' nogil:
EUHICPXT(const Handle[ZeroInflationTermStructure]& ts)

cdef cppclass YYEUHICP(YoYInflationIndex):
YYEUHICP(bool interpolated,
const Handle[YoYInflationTermStructure]& ts)
YYEUHICP(const Handle[YoYInflationTermStructure]& ts)

cdef cppclass YYEUHICPXT(YoYInflationIndex):
YYEUHICPXT(bool interpolated,
const Handle[YoYInflationTermStructure]& ts)
YYEUHICPXT(const Handle[YoYInflationTermStructure]& ts)
8 changes: 4 additions & 4 deletions quantlib/indexes/inflation/euhicp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ cdef class EUHICPXT(ZeroInflationIndex):
self._thisptr.reset(new _euhicp.EUHICPXT(ts._handle))

cdef class YYEUHICP(YoYInflationIndex):
def __init__(self, bool interpolated, YoYInflationTermStructure ts=YoYInflationTermStructure()):
self._thisptr.reset(new _euhicp.YYEUHICP(interpolated, ts._handle))
def __init__(self, YoYInflationTermStructure ts=YoYInflationTermStructure()):
self._thisptr.reset(new _euhicp.YYEUHICP(ts._handle))

cdef class YYEUHICPXT(YoYInflationIndex):
def __init__(self, bool interpolated, YoYInflationTermStructure ts=YoYInflationTermStructure()):
self._thisptr.reset(new _euhicp.YYEUHICPXT(interpolated, ts._handle))
def __init__(self, YoYInflationTermStructure ts=YoYInflationTermStructure()):
self._thisptr.reset(new _euhicp.YYEUHICPXT(ts._handle))
4 changes: 2 additions & 2 deletions quantlib/indexes/inflation_index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ cdef class ZeroInflationIndex(InflationIndex):

cdef class YoYInflationIndex(ZeroInflationIndex):
def __init__(self, family_name, Region region, bool revised,
bool ratio, Frequency frequency,
Frequency frequency,
Period availability_lag, Currency currency,
YoYInflationTermStructure ts=YoYInflationTermStructure()):

Expand All @@ -115,6 +115,6 @@ cdef class YoYInflationIndex(ZeroInflationIndex):
self._thisptr = shared_ptr[_in.Index](
new _ii.YoYInflationIndex(
c_family_name, deref(region._thisptr), revised,
ratio, frequency,
frequency,
deref(availability_lag._thisptr),
deref(currency._thisptr), ts._handle))
2 changes: 1 addition & 1 deletion quantlib/instruments/_swaption.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cdef extern from 'ql/instruments/swaption.hpp' namespace 'QuantLib':
VolatilityType type,# = ShiftedLognormal,
Real displacement)# = 0.0)
SwapType type() const
const shared_ptr[FixedVsFloatingSwap]& underlyingSwap()
const shared_ptr[FixedVsFloatingSwap]& underlying()
4 changes: 2 additions & 2 deletions quantlib/instruments/swaption.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ cdef class Swaption(Option):
def type(self):
return <SwapType>(self.get_swaption().type())

def underlying_swap(self):
def underlying(self):
cdef FixedVsFloatingSwap instance = FixedVsFloatingSwap.__new__(FixedVsFloatingSwap)
cdef shared_ptr[_fixedvsfloatingswap.FixedVsFloatingSwap] swap = self.get_swaption().underlyingSwap()
cdef shared_ptr[_fixedvsfloatingswap.FixedVsFloatingSwap] swap = self.get_swaption().underlying()
instance._thisptr = static_pointer_cast[_instrument.Instrument](swap)
return instance

Expand Down
6 changes: 3 additions & 3 deletions quantlib/mlab/fixed_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
FixedRateBond
)

from quantlib.compounding import Compounded
from quantlib.compounding import Compounding

from quantlib.pricingengines.bond import DiscountingBondEngine
from quantlib.time.businessdayconvention import (
from quantlib.time.api import (
Unadjusted, ModifiedFollowing, Following)

from quantlib.time.calendars.null_calendar import NullCalendar
Expand Down Expand Up @@ -144,7 +144,7 @@ def _bndprice(bond_yield, coupon_rate, pricing_date, maturity_date,
forward=bond_yield,
calendar=NullCalendar(),
daycounter=cnt_yield,
compounding=Compounded,
compounding=Compounding.Compounded,
frequency=period)

discounting_term_structure.link_to(flat_term_structure)
Expand Down
6 changes: 3 additions & 3 deletions quantlib/mlab/option_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from quantlib.processes.api import BlackScholesMertonProcess
from quantlib.termstructures.yields.api import FlatForward, HandleYieldTermStructure
from quantlib.termstructures.volatility.api import BlackConstantVol
from quantlib.time.api import today, NullCalendar, ActualActual, ISMA
from quantlib.time.api import today, NullCalendar, ActualActual

from quantlib.time.date import (Period, Days)
from quantlib.mlab.util import common_shape, array_call
Expand Down Expand Up @@ -104,7 +104,7 @@ def _blsprice(spot, strike, risk_free_rate, time, volatility,
"""
_spot = SimpleQuote(spot)

daycounter = ActualActual(ISMA)
daycounter = ActualActual(ActualActual.ISMA)
risk_free_ts = HandleYieldTermStructure(FlatForward(today(), risk_free_rate, daycounter))
dividend_ts = HandleYieldTermStructure(FlatForward(today(), dividend, daycounter))
volatility_ts = BlackConstantVol(today(), NullCalendar(),
Expand Down Expand Up @@ -162,7 +162,7 @@ def _blsimpv(price, spot, strike, risk_free_rate, time,
option_type, dividend):

spot = SimpleQuote(spot)
daycounter = ActualActual(ISMA)
daycounter = ActualActual(ActualActual.ISMA)
risk_free_ts = HandleYieldTermStructure(FlatForward(today(), risk_free_rate, daycounter))
dividend_ts = HandleYieldTermStructure(FlatForward(today(), dividend, daycounter))
volatility_ts = BlackConstantVol(today(), NullCalendar(),
Expand Down
2 changes: 1 addition & 1 deletion quantlib/models/calibration_helper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ from quantlib.types cimport Real, Size, Volatility
from quantlib.handle cimport shared_ptr

from quantlib.pricingengines.engine cimport PricingEngine

globals().update(getattr(CalibrationErrorType, "__members__"))

cdef class BlackCalibrationHelper:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cdef extern from 'ql/models/shortrate/calibrationhelpers/swaptionhelper.hpp' nam
VolatilityType type, # = ShiftedLognormal,
Real shift # = 0.0
) except +
shared_ptr[FixedVsFloatingSwap] underlyingSwap()
shared_ptr[FixedVsFloatingSwap] underlying()
shared_ptr[Swaption] swaption()

# this should really be a constructor but cython can't disambiguate the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from quantlib.instruments.fixedvsfloatingswap cimport FixedVsFloatingSwap
from quantlib.instruments.swaption cimport Swaption
from quantlib.time.date cimport Period, Date
from quantlib.quote cimport Quote
from quantlib.models.calibration_helper import RelativePriceError
from quantlib.utilities.null cimport Null

cimport quantlib._quote as _qt
Expand All @@ -42,7 +41,7 @@ cdef class SwaptionHelper(BlackCalibrationHelper):
DayCounter fixed_leg_daycounter not None,
DayCounter floating_leg_daycounter not None,
HandleYieldTermStructure ts not None,
CalibrationErrorType error_type=RelativePriceError,
CalibrationErrorType error_type=CalibrationErrorType.RelativePriceError,
Real strike=Null[Real](),
Real nominal=1.0,
VolatilityType vol_type=VolatilityType.ShiftedLognormal,
Expand Down Expand Up @@ -103,9 +102,9 @@ cdef class SwaptionHelper(BlackCalibrationHelper):
)
)

def underlying_swap(self):
def underlying(self):
cdef FixedVsFloatingSwap swap = FixedVsFloatingSwap.__new__(FixedVsFloatingSwap)
swap._thisptr = (<_sh.SwaptionHelper*>self._thisptr.get()).underlyingSwap()
swap._thisptr = (<_sh.SwaptionHelper*>self._thisptr.get()).underlying()
return swap

def underlying_swaption(self):
Expand Down
Loading