Skip to content

Commit

Permalink
Merge pull request #326 from thrasibule/deprecated
Browse files Browse the repository at this point in the history
Deprecated
  • Loading branch information
thrasibule authored Jul 31, 2024
2 parents 5ac50cf + 90892dd commit ab650eb
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 189 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on: [push, pull_request]
jobs:
build:
name: Build and test
runs-on: ubuntu-22.04 # required for latest QuantLib
runs-on: ubuntu-24.04 # required for latest QuantLib
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11']

steps:
- name: install dependencies
Expand All @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -48,28 +48,28 @@ jobs:
# Publish built docs to gh-pages branch.
- name: Checkout documentation branch
if: matrix.python-version == '3.10'
uses: actions/checkout@v2
if: matrix.python-version == '3.11'
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
persist-credentials: false

- name: Build docs
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.11'
run: |
pip install sphinx nbsphinx scikit-learn ipython
sudo apt-get install pandoc texlive texlive-latex-extra dvipng
make docs
- uses: actions/upload-artifact@v2
if: (matrix.python-version == '3.10') && (github.event_name == 'pull_request')
if: (matrix.python-version == '3.11') && (github.event_name == 'pull_request')
with:
name: "doc_${{ github.event.pull_request.number }}"
path: docs/build/html

- name: Move docs over
if: (matrix.python-version == '3.10') && (github.event_name == 'push')
if: (matrix.python-version == '3.11') && (github.event_name == 'push')
run: |
ls
cp -r docs/build/html/* gh-pages/
Expand All @@ -82,7 +82,7 @@ jobs:
# that.
- name: Push changes
if: (matrix.python-version == '3.10') && (github.event_name== 'push')
if: (matrix.python-version == '3.11') && (github.event_name== 'push')
uses: ad-m/github-push-action@master
with:
branch: gh-pages
Expand Down
10 changes: 3 additions & 7 deletions quantlib/indexes/_inflation_index.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ from quantlib.currency._currency cimport Currency
from quantlib.indexes._region cimport Region
from quantlib.handle cimport shared_ptr, Handle
from quantlib.time._period cimport Period, Frequency
from quantlib.time._date cimport Date

cimport quantlib.termstructures._inflation_term_structure as _its

cdef extern from 'ql/indexes/inflationindex.hpp' namespace 'QuantLib':
cdef extern from 'ql/indexes/inflationindex.hpp' namespace 'QuantLib' nogil:

cdef cppclass CPI:
enum InterpolationType:
Expand All @@ -28,40 +29,35 @@ cdef extern from 'ql/indexes/inflationindex.hpp' namespace 'QuantLib':
Linear

cdef cppclass InflationIndex(Index):
InflationIndex()
InflationIndex(string& familyName,
Region& region,
bool revised,
bool interpolated,
Frequency frequency,
Period& availabilitiyLag,
Currency& currency) except +
string familyName()
Region region()
bool revised()
bool interpolated()
Frequency frequency()
Period availabilityLag()
Currency currency()


cdef cppclass ZeroInflationIndex(Index):
ZeroInflationIndex()
ZeroInflationIndex(string& familyName,
Region& region,
bool revised,
bool interpolated,
Frequency frequency,
Period& availabilitiyLag,
Currency& currency,
Handle[_its.ZeroInflationTermStructure]& h) except +
Handle[_its.ZeroInflationTermStructure] zeroInflationTermStructure()
Date lastFixingDate()

cdef cppclass YoYInflationIndex(InflationIndex):
YoYInflationIndex(const string& familyName,
const Region& region,
bool revised,
bool interpolated,
bool ratio, # is this one a genuine index or a ratio?
Frequency frequency,
const Period& availabilityLag,
Expand Down
17 changes: 17 additions & 0 deletions quantlib/indexes/inflation/_aucpi.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from libcpp cimport bool
from .._inflation_index cimport ZeroInflationIndex, YoYInflationIndex
from quantlib.handle cimport Handle
from quantlib.termstructures._inflation_term_structure cimport ZeroInflationTermStructure, YoYInflationTermStructure
from quantlib.time.frequency cimport Frequency


cdef extern from 'ql/indexes/inflation/aucpi.hpp' namespace 'QuantLib' nogil:
cdef cppclass AUCPI(ZeroInflationIndex):
AUCPI(Frequency frequency,
bool revised,
const Handle[ZeroInflationTermStructure]& ts)

YYAUCPI(Frequency frequency,
bool revised,
bool interpolated,
const Handle[YoYInflationTermStructure]& ts)
19 changes: 19 additions & 0 deletions quantlib/indexes/inflation/_euhicp.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from libcpp cimport bool
from .._inflation_index cimport ZeroInflationIndex, YoYInflationIndex
from quantlib.handle cimport Handle
from quantlib.termstructures._inflation_term_structure cimport ZeroInflationTermStructure, YoYInflationTermStructure

cdef extern from 'ql/indexes/inflation/euhicp.hpp' namespace 'QuantLib' nogil:
cdef cppclass EUHICP(ZeroInflationIndex):
EUHICP(const Handle[ZeroInflationTermStructure]& ts)

cdef cppclass EUHICPXT(ZeroInflationIndex):
EUHICPXT(const Handle[ZeroInflationTermStructure]& ts)

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

cdef cppclass YYEUHICPXT(YoYInflationIndex):
YYEUHICPXT(bool interpolated,
const Handle[YoYInflationTermStructure]& ts)
7 changes: 7 additions & 0 deletions quantlib/indexes/inflation/_ukrpi.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .._inflation_index cimport ZeroInflationIndex
from quantlib.handle cimport Handle
from quantlib.termstructures._inflation_term_structure cimport ZeroInflationTermStructure

cdef extern from 'ql/indexes/inflation/ukrpi.hpp' namespace 'QuantLib' nogil:
cdef cppclass UKRPI(ZeroInflationIndex):
UKRPI(const Handle[ZeroInflationTermStructure]& ts)
Empty file.
7 changes: 7 additions & 0 deletions quantlib/indexes/inflation/aucpi.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from quantlib.indexes.inflation_index cimport ZeroInflationIndex, YoYInflationIndex

cdef class AUCPI(ZeroInflationIndex):
pass

cdef class YYAUCPI(YoYInflationIndex):
pass
11 changes: 11 additions & 0 deletions quantlib/indexes/inflation/aucpi.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from libcpp cimport bool
from . cimport _aucpi
from quantlib.time.frequency cimport Frequency
from quantlib.termstructures.inflation_term_structure cimport ZeroInflationTermStructure

cdef class AUCPI(ZeroInflationIndex):
def __init__(self,
Frequency frequency,
bool revised,
ZeroInflationTermStructure ts=ZeroInflationTermStructure()):
self._thisptr.reset(new _aucpi.AUCPI(frequency, revised, ts._handle))
18 changes: 0 additions & 18 deletions quantlib/indexes/inflation/australia.pyx

This file was deleted.

13 changes: 13 additions & 0 deletions quantlib/indexes/inflation/euhicp.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from quantlib.indexes.inflation_index cimport ZeroInflationIndex, YoYInflationIndex

cdef class EUHICP(ZeroInflationIndex):
pass

cdef class EUHICPXT(ZeroInflationIndex):
pass

cdef class YYEUHICP(YoYInflationIndex):
pass

cdef class YYEUHICPXT(YoYInflationIndex):
pass
41 changes: 9 additions & 32 deletions quantlib/indexes/inflation/euhicp.pyx
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
from . cimport _euhicp
from libcpp cimport bool

from quantlib.currency.api import EURCurrency
from quantlib.indexes.regions import EURegion
from quantlib.indexes.inflation_index cimport (
ZeroInflationIndex, YoYInflationIndex)
from quantlib.time.frequency cimport Monthly
from quantlib.time._period cimport Months
from quantlib.time.date cimport Period
from quantlib.termstructures.inflation_term_structure cimport (
ZeroInflationTermStructure, YoYInflationTermStructure)

cdef class EUHICP(ZeroInflationIndex):
def __init__(self, bool interpolated,
ZeroInflationTermStructure ts=ZeroInflationTermStructure()):

super().__init__("HICP", EURegion(), False,
interpolated, Monthly, Period(1, Months),
EURCurrency(), ts)
def __init__(self, ZeroInflationTermStructure ts=ZeroInflationTermStructure()):
self._thisptr.reset(new _euhicp.EUHICP(ts._handle))


cdef class EUHICPXT(ZeroInflationIndex):
def __init__(self, bool interpolated,
ZeroInflationTermStructure ts=ZeroInflationTermStructure()):

super().__init__("HICPXT", EURegion(), False,
interpolated, Monthly, Period(1, Months),
EURCurrency(), ts)
def __init__(self, ZeroInflationTermStructure ts=ZeroInflationTermStructure()):
self._thisptr.reset(new _euhicp.EUHICPXT(ts._handle))

cdef class YYEUHICP(YoYInflationIndex):
def __init__(self, bool interpolated,
YoYInflationTermStructure ts=YoYInflationTermStructure()):

super().__init__("YY_HICP", EURegion(), False,
interpolated, Monthly, Period(1, Months),
EURCurrency(), ts)
def __init__(self, bool interpolated, YoYInflationTermStructure ts=YoYInflationTermStructure()):
self._thisptr.reset(new _euhicp.YYEUHICP(interpolated, ts._handle))

cdef class YYEUHICPXT(YoYInflationIndex):
def __init__(self, bool interpolated,
YoYInflationTermStructure ts=YoYInflationTermStructure()):

super().__init__("YY_HICPXT", EURegion(), False,
interpolated, Monthly, Period(1, Months),
EURCurrency(), ts)
def __init__(self, bool interpolated, YoYInflationTermStructure ts=YoYInflationTermStructure()):
self._thisptr.reset(new _euhicp.YYEUHICPXT(interpolated, ts._handle))
4 changes: 4 additions & 0 deletions quantlib/indexes/inflation/ukrpi.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from quantlib.indexes.inflation_index cimport ZeroInflationIndex

cdef class UKRPI(ZeroInflationIndex):
pass
15 changes: 3 additions & 12 deletions quantlib/indexes/inflation/ukrpi.pyx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
from libcpp cimport bool
from . cimport _ukrpi

from quantlib.currency.api import GBPCurrency
from quantlib.indexes.regions import UKRegion
from quantlib.time.date cimport Period
from quantlib.time.date import Months
from quantlib.time.frequency cimport Monthly
from quantlib.indexes.inflation_index cimport ZeroInflationIndex
from quantlib.termstructures.inflation_term_structure \
cimport ZeroInflationTermStructure

cdef class UKRPI(ZeroInflationIndex):
def __init__(self, bool interpolated,
ZeroInflationTermStructure ts=ZeroInflationTermStructure()):

super().__init__("RPI", UKRegion(), False,
interpolated, Monthly, Period(1, Months),
GBPCurrency(), ts)
def __init__(self, ZeroInflationTermStructure ts=ZeroInflationTermStructure()):
self._thisptr.reset(new _ukrpi.UKRPI(ts._handle))
20 changes: 10 additions & 10 deletions quantlib/indexes/inflation_index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from libcpp cimport bool
from libcpp.string cimport string

from quantlib.index cimport Index
from quantlib.time.date cimport Period, period_from_qlperiod
from quantlib.time.date cimport Period, period_from_qlperiod, date_from_qldate
from quantlib.time.frequency cimport Frequency
from quantlib.indexes.region cimport Region

Expand Down Expand Up @@ -61,11 +61,6 @@ cdef class InflationIndex(Index):
c._thisptr = new _cu.Currency(ref.currency())
return c

@property
def interpolated(self):
cdef _ii.InflationIndex* ref = <_ii.InflationIndex*>self._thisptr.get()
return ref.interpolated()

@property
def region(self):
cdef _ii.InflationIndex* ref = <_ii.InflationIndex*>self._thisptr.get()
Expand All @@ -77,7 +72,6 @@ cdef class ZeroInflationIndex(InflationIndex):
def __init__(self, str family_name,
Region region,
bool revised,
bool interpolated,
Frequency frequency,
Period availabilityLag,
Currency currency,
Expand All @@ -91,7 +85,6 @@ cdef class ZeroInflationIndex(InflationIndex):
c_family_name,
deref(region._thisptr),
revised,
interpolated,
frequency,
deref(availabilityLag._thisptr),
deref(currency._thisptr),
Expand All @@ -104,9 +97,16 @@ cdef class ZeroInflationIndex(InflationIndex):
(<_ii.ZeroInflationIndex*>(self._thisptr.get())).
zeroInflationTermStructure().currentLink())

@property
def last_fixing_date(self):
return date_from_qldate(
(<_ii.ZeroInflationIndex*>(self._thisptr.get())).lastFixingDate()
)


cdef class YoYInflationIndex(ZeroInflationIndex):
def __init__(self, family_name, Region region, bool revised,
bool interpolated, bool ratio, Frequency frequency,
bool ratio, 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,
interpolated, ratio, frequency,
ratio, frequency,
deref(availability_lag._thisptr),
deref(currency._thisptr), ts._handle))
2 changes: 1 addition & 1 deletion quantlib/termstructures/_inflation_term_structure.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ from quantlib.termstructures._yield_term_structure cimport YieldTermStructure
from quantlib.termstructures.inflation._seasonality cimport Seasonality


cdef extern from 'ql/termstructures/inflationtermstructure.hpp' namespace 'QuantLib':
cdef extern from 'ql/termstructures/inflationtermstructure.hpp' namespace 'QuantLib' nogil:

cdef cppclass InflationTermStructure:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ from quantlib.time._date cimport Date
from quantlib.time._daycounter cimport DayCounter
from quantlib.time._calendar cimport Calendar
from quantlib.time._period cimport Frequency, Period
from quantlib.handle cimport Handle
from quantlib.handle cimport Handle, shared_ptr
from ._seasonality cimport Seasonality

cdef extern from 'ql/termstructures/inflation/interpolatedzeroinflationcurve.hpp' namespace 'QuantLib':
cdef extern from 'ql/termstructures/inflation/interpolatedzeroinflationcurve.hpp' namespace 'QuantLib' nogil:
cdef cppclass InterpolatedZeroInflationCurve[T](ZeroInflationTermStructure):
InterpolatedZeroInflationCurve(const Date& referenceDate,
const Calendar& calendar,
const DayCounter& dayCounter,
const Period& lag,
vector[Date]& dates,
vector[Rate]& rates,
Frequency frequency,
const vector[Date]& dates,
vector[Rate]& rates) #should be const here
DayCounter dayCounter,
shared_ptr[Seasonality] seasonality)
vector[Date]& dates()
vector[Real]& data()
vector[Rate]& rates()
Loading

0 comments on commit ab650eb

Please sign in to comment.