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
3 changes: 3 additions & 0 deletions QuantLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@
<ClInclude Include="ql\indexes\ibor\kofr.hpp" />
<ClInclude Include="ql\indexes\ibor\libor.hpp" />
<ClInclude Include="ql\indexes\ibor\mosprime.hpp" />
<ClInclude Include="ql\indexes\ibor\noknibor.hpp" />
<ClInclude Include="ql\indexes\ibor\nzdlibor.hpp" />
<ClInclude Include="ql\indexes\ibor\nzocr.hpp" />
<ClInclude Include="ql\indexes\ibor\pribor.hpp" />
Expand Down Expand Up @@ -1048,6 +1049,7 @@
<ClInclude Include="ql\math\interpolations\kernelinterpolation2d.hpp" />
<ClInclude Include="ql\math\interpolations\lagrangeinterpolation.hpp" />
<ClInclude Include="ql\math\interpolations\linearinterpolation.hpp" />
<ClInclude Include="ql\math\interpolations\linearthenflatinterpolation.hpp" />
<ClInclude Include="ql\math\interpolations\loginterpolation.hpp" />
<ClInclude Include="ql\math\interpolations\mixedinterpolation.hpp" />
<ClInclude Include="ql\math\interpolations\multicubicspline.hpp" />
Expand Down Expand Up @@ -1865,6 +1867,7 @@
<ClInclude Include="ql\time\daycounters\actual364.hpp" />
<ClInclude Include="ql\time\daycounters\actual36525.hpp" />
<ClInclude Include="ql\time\daycounters\actual365fixed.hpp" />
<ClInclude Include="ql\time\daycounters\actual365nl.hpp" />
<ClInclude Include="ql\time\daycounters\actual366.hpp" />
<ClInclude Include="ql\time\daycounters\actualactual.hpp" />
<ClInclude Include="ql\time\daycounters\all.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions QuantLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4534,6 +4534,9 @@
<ClInclude Include="ql\time\calendars\serbia.hpp" />
<ClInclude Include="ql\time\calendars\slovenia.hpp" />
<ClInclude Include="ql\time\calendars\croatia.hpp" />
<ClInclude Include="ql\time\daycounters\actual365nl.hpp" />
<ClInclude Include="ql\indexes\ibor\noknibor.hpp" />
<ClInclude Include="ql\math\interpolations\linearthenflatinterpolation.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ql\methods\montecarlo\brownianbridge.cpp">
Expand Down
3 changes: 3 additions & 0 deletions ql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ set(QL_HEADERS
indexes/ibor/kofr.hpp
indexes/ibor/libor.hpp
indexes/ibor/mosprime.hpp
indexes/ibor/noknibor.hpp
indexes/ibor/nzdlibor.hpp
indexes/ibor/nzocr.hpp
indexes/ibor/pribor.hpp
Expand Down Expand Up @@ -1486,6 +1487,7 @@ set(QL_HEADERS
math/interpolations/kernelinterpolation2d.hpp
math/interpolations/lagrangeinterpolation.hpp
math/interpolations/linearinterpolation.hpp
math/interpolations/linearthenflatinterpolation.hpp
math/interpolations/loginterpolation.hpp
math/interpolations/mixedinterpolation.hpp
math/interpolations/multicubicspline.hpp
Expand Down Expand Up @@ -2248,6 +2250,7 @@ set(QL_HEADERS
time/daycounters/actual360.hpp
time/daycounters/actual364.hpp
time/daycounters/actual365fixed.hpp
time/daycounters/actual365nl.hpp
time/daycounters/actual366.hpp
time/daycounters/actual36525.hpp
time/daycounters/actualactual.hpp
Expand Down
1 change: 1 addition & 0 deletions ql/indexes/ibor/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ this_include_HEADERS = \
kofr.hpp \
libor.hpp \
mosprime.hpp \
noknibor.hpp \
nzdlibor.hpp \
nzocr.hpp \
pribor.hpp \
Expand Down
1 change: 1 addition & 0 deletions ql/indexes/ibor/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <ql/indexes/ibor/kofr.hpp>
#include <ql/indexes/ibor/libor.hpp>
#include <ql/indexes/ibor/mosprime.hpp>
#include <ql/indexes/ibor/noknibor.hpp>
#include <ql/indexes/ibor/nzdlibor.hpp>
#include <ql/indexes/ibor/nzocr.hpp>
#include <ql/indexes/ibor/pribor.hpp>
Expand Down
54 changes: 54 additions & 0 deletions ql/indexes/ibor/noknibor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
Copyright (C) 2003, 2004, 2005, 2006 StatPro Italia srl

This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/

QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<https://www.quantlib.org/license.shtml>.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

/*! \file noknibor.hpp
\brief NOK-NIBOR index
*/

#ifndef quantext_noknibor_hpp
#define quantext_noknibor_hpp

#include <ql/currencies/europe.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/time/calendars/norway.hpp>
#include <ql/time/daycounters/actual360.hpp>

namespace QuantLib {

//! NOK-NIBOR index
/*! NOK-NIBOR rate published by Oslo Boers.
See <http://www.oslobors.no/ob_eng>.
https://nore-benchmarks.com/
https://finansfag.no/wp-content/uploads/2024/10/Rentekonvensjon-6.0_engelsk_oppdatert-18.09.2024_final.pdf
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5099269

\remark Using Norway calendar, should be Oslo.

\warning Check roll convention and EOM.
*/
class NOKNibor : public IborIndex {
public:
NOKNibor(const Period &tenor, const Handle<YieldTermStructure> &h = Handle<YieldTermStructure>())
: IborIndex("NOK-NIBOR", tenor, 2, NOKCurrency(), Norway(), ModifiedFollowing, false, Actual360(), h) {}
};

}

#endif
1 change: 1 addition & 0 deletions ql/math/interpolations/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ this_include_HEADERS = \
kernelinterpolation2d.hpp \
lagrangeinterpolation.hpp \
linearinterpolation.hpp \
linearthenflatinterpolation.hpp \
loginterpolation.hpp \
mixedinterpolation.hpp \
multicubicspline.hpp \
Expand Down
1 change: 1 addition & 0 deletions ql/math/interpolations/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <ql/math/interpolations/kernelinterpolation2d.hpp>
#include <ql/math/interpolations/lagrangeinterpolation.hpp>
#include <ql/math/interpolations/linearinterpolation.hpp>
#include <ql/math/interpolations/linearthenflatinterpolation.hpp>
#include <ql/math/interpolations/loginterpolation.hpp>
#include <ql/math/interpolations/mixedinterpolation.hpp>
#include <ql/math/interpolations/multicubicspline.hpp>
Expand Down
88 changes: 88 additions & 0 deletions ql/math/interpolations/cubicinterpolation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,94 @@ namespace QuantLib {

}

class Cubic__FritschButland_nonMonotonic : public Cubic {
public:
Cubic__FritschButland_nonMonotonic()
: Cubic(CubicInterpolation::FritschButland, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__FritschButland_monotonic : public Cubic {
public:
Cubic__FritschButland_monotonic()
: Cubic(CubicInterpolation::FritschButland, true,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__NaturalSpline : public Cubic {
public:
Cubic__NaturalSpline()
: Cubic(CubicInterpolation::Spline, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__Monotonic_NaturalSpline : public Cubic {
public:
Cubic__Monotonic_NaturalSpline()
: Cubic(CubicInterpolation::Spline, true,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__SplineOvershootingMinimization1 : public Cubic {
public:
Cubic__SplineOvershootingMinimization1()
: Cubic(CubicInterpolation::SplineOM1, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__SplineOvershootingMinimization2 : public Cubic {
public:
Cubic__SplineOvershootingMinimization2()
: Cubic(CubicInterpolation::SplineOM2, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__Akima : public Cubic {
public:
Cubic__Akima()
: Cubic(CubicInterpolation::Akima, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__Parabolic : public Cubic {
public:
Cubic__Parabolic()
: Cubic(CubicInterpolation::Parabolic, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__MonotonicParabolic : public Cubic {
public:
Cubic__MonotonicParabolic()
: Cubic(CubicInterpolation::Parabolic, true,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__Kruger : public Cubic {
public:
Cubic__Kruger()
: Cubic(CubicInterpolation::Kruger, false,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

class Cubic__MonotonicKruger : public Cubic {
public:
Cubic__MonotonicKruger()
: Cubic(CubicInterpolation::Kruger, true,
CubicInterpolation::SecondDerivative, 0.0,
CubicInterpolation::SecondDerivative, 0.0) {}
};

}

#endif
120 changes: 120 additions & 0 deletions ql/math/interpolations/linearthenflatinterpolation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
Copyright (C) 2002, 2003, 2008, 2009 Ferdinando Ametrano
Copyright (C) 2004, 2007, 2008 StatPro Italia srl

This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/

QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<https://www.quantlib.org/license.shtml>.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

/*! \file linearthenflatinterpolation.hpp
\brief linear interpolation between discrete points, that after last point becomes flat
*/

#ifndef quantlib_linearthenflat_interpolation_hpp
#define quantlib_linearthenflat_interpolation_hpp

#include <ql/math/interpolation.hpp>
#include <vector>

namespace QuantLib {

namespace detail {
template <class I1, class I2> class LinearThenFlatInterpolationImpl;
}

//! %Linear-then-flat interpolation between discrete points
class LinearThenFlatInterpolation : public Interpolation {
public:
/*! \pre the \f$ x \f$ values must be sorted. */
template <class I1, class I2>
LinearThenFlatInterpolation(const I1& xBegin,
const I1& xEnd,
const I2& yBegin) {
impl_ = ext::shared_ptr<Interpolation::Impl>(new
detail::LinearThenFlatInterpolationImpl<I1, I2>(xBegin, xEnd, yBegin));
impl_->update();
}
};

//! %Linear-then-flat interpolation factory and traits
class LinearThenFlat {
public:
template <class I1, class I2>
Interpolation interpolate(const I1& xBegin,
const I1& xEnd,
const I2& yBegin) const {
return LinearThenFlatInterpolation(xBegin, xEnd, yBegin);
}
static const bool global = false;
static const Size requiredPoints = 2;
};

namespace detail {

template <class I1, class I2>
class LinearThenFlatInterpolationImpl : public Interpolation::templateImpl<I1, I2> {
public:
LinearThenFlatInterpolationImpl(const I1& xBegin,
const I1& xEnd,
const I2& yBegin)
: Interpolation::templateImpl<I1, I2>(xBegin, xEnd, yBegin),
primitiveConst_(xEnd-xBegin), s_(xEnd-xBegin),
primitive_(xEnd-xBegin), n_(xEnd-xBegin) {}
void update() override {
primitiveConst_[0] = 0.0;
for (Size i=1; i<Size(this->xEnd_-this->xBegin_); ++i) {
Real dx = this->xBegin_[i]-this->xBegin_[i-1];
s_[i-1] = (this->yBegin_[i]-this->yBegin_[i-1])/dx;
primitiveConst_[i] = primitiveConst_[i-1]
+ dx*(this->yBegin_[i-1] + 0.5*dx*s_[i-1]);
}
}
Real value(Real x) const override {
if (x >= this->xBegin_[n_-1])
return this->yBegin_[n_-1];
Size i = this->locate(x);
return this->yBegin_[i] + (x-this->xBegin_[i])*s_[i];
}
Real primitive(Real x) const override {
// TODO: fix primitive implementation
if (x >= this->xBegin_[n_-1]) {
Size i = this->locate(x);
Real dx = x-this->xBegin_[i];
return primitive_[i] + dx*this->yBegin_[i];
}
Size i = this->locate(x);
Real dx = x-this->xBegin_[i];
return primitiveConst_[i] + dx*(this->yBegin_[i] + 0.5*dx*s_[i]);
}
Real derivative(Real x) const override {
if (x >= this->xBegin_[n_-1])
return 0.0;
Size i = this->locate(x);
return s_[i];
}
Real secondDerivative(Real) const override {
return 0.0;
}
private:
std::vector<Real> primitiveConst_, s_;
std::vector<Real> primitive_;
Size n_;
};

}

}

#endif
20 changes: 20 additions & 0 deletions ql/termstructures/yield/ratehelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,4 +836,24 @@ namespace QuantLib {
RateHelper::accept(v);
}

GenericRateHelper::GenericRateHelper(const Handle<Quote>& rate,
const Date& settlementDate,
const Date& refDate,
const DayCounter& dayCounter,
const Compounding& comp,
const Frequency& freq,
const bool& extrapolate)
: RelativeDateRateHelper(rate), dayCounter_(dayCounter),
compounding_(comp), frequency_(freq), extrapolate_(extrapolate) {
earliestDate_ = settlementDate;
latestDate_ = refDate;
}

Real GenericRateHelper::impliedQuote() const {
return termStructure_->zeroRate(latestDate_, dayCounter_,
compounding_, frequency_, extrapolate_);
}

void GenericRateHelper::initializeDates() {}

}
Loading
Loading