You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(60) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(18) |
Feb
(4) |
Mar
(6) |
Apr
(2) |
May
|
Jun
(12) |
Jul
(48) |
Aug
(6) |
Sep
(3) |
Oct
(24) |
Nov
(15) |
Dec
(18) |
| 2002 |
Jan
(39) |
Feb
(12) |
Mar
(80) |
Apr
(72) |
May
(46) |
Jun
(27) |
Jul
(23) |
Aug
(34) |
Sep
(65) |
Oct
(71) |
Nov
(19) |
Dec
(14) |
| 2003 |
Jan
(44) |
Feb
(59) |
Mar
(18) |
Apr
(62) |
May
(54) |
Jun
(27) |
Jul
(46) |
Aug
(15) |
Sep
(44) |
Oct
(36) |
Nov
(19) |
Dec
(12) |
| 2004 |
Jan
(26) |
Feb
(33) |
Mar
(47) |
Apr
(63) |
May
(36) |
Jun
(65) |
Jul
(80) |
Aug
(163) |
Sep
(65) |
Oct
(39) |
Nov
(36) |
Dec
(39) |
| 2005 |
Jan
(97) |
Feb
(78) |
Mar
(64) |
Apr
(64) |
May
(48) |
Jun
(55) |
Jul
(89) |
Aug
(57) |
Sep
(51) |
Oct
(111) |
Nov
(86) |
Dec
(76) |
| 2006 |
Jan
(84) |
Feb
(103) |
Mar
(143) |
Apr
(92) |
May
(55) |
Jun
(58) |
Jul
(71) |
Aug
(57) |
Sep
(74) |
Oct
(59) |
Nov
(8) |
Dec
(32) |
| 2007 |
Jan
(60) |
Feb
(40) |
Mar
(50) |
Apr
(26) |
May
(61) |
Jun
(120) |
Jul
(119) |
Aug
(48) |
Sep
(121) |
Oct
(66) |
Nov
(103) |
Dec
(43) |
| 2008 |
Jan
(60) |
Feb
(109) |
Mar
(92) |
Apr
(106) |
May
(82) |
Jun
(59) |
Jul
(67) |
Aug
(118) |
Sep
(131) |
Oct
(56) |
Nov
(37) |
Dec
(69) |
| 2009 |
Jan
(75) |
Feb
(76) |
Mar
(103) |
Apr
(78) |
May
(61) |
Jun
(35) |
Jul
(66) |
Aug
(69) |
Sep
(166) |
Oct
(46) |
Nov
(72) |
Dec
(65) |
| 2010 |
Jan
(48) |
Feb
(57) |
Mar
(93) |
Apr
(85) |
May
(123) |
Jun
(82) |
Jul
(98) |
Aug
(121) |
Sep
(146) |
Oct
(86) |
Nov
(72) |
Dec
(34) |
| 2011 |
Jan
(96) |
Feb
(55) |
Mar
(73) |
Apr
(57) |
May
(33) |
Jun
(74) |
Jul
(89) |
Aug
(71) |
Sep
(103) |
Oct
(76) |
Nov
(52) |
Dec
(61) |
| 2012 |
Jan
(48) |
Feb
(54) |
Mar
(78) |
Apr
(60) |
May
(75) |
Jun
(59) |
Jul
(33) |
Aug
(66) |
Sep
(43) |
Oct
(46) |
Nov
(75) |
Dec
(51) |
| 2013 |
Jan
(112) |
Feb
(72) |
Mar
(49) |
Apr
(48) |
May
(42) |
Jun
(44) |
Jul
(80) |
Aug
(19) |
Sep
(33) |
Oct
(37) |
Nov
(38) |
Dec
(98) |
| 2014 |
Jan
(113) |
Feb
(93) |
Mar
(49) |
Apr
(106) |
May
(97) |
Jun
(155) |
Jul
(87) |
Aug
(127) |
Sep
(85) |
Oct
(48) |
Nov
(41) |
Dec
(37) |
| 2015 |
Jan
(34) |
Feb
(50) |
Mar
(104) |
Apr
(80) |
May
(82) |
Jun
(66) |
Jul
(41) |
Aug
(84) |
Sep
(37) |
Oct
(65) |
Nov
(83) |
Dec
(52) |
| 2016 |
Jan
(68) |
Feb
(35) |
Mar
(42) |
Apr
(35) |
May
(54) |
Jun
(75) |
Jul
(45) |
Aug
(52) |
Sep
(60) |
Oct
(52) |
Nov
(36) |
Dec
(64) |
| 2017 |
Jan
(92) |
Feb
(59) |
Mar
(35) |
Apr
(53) |
May
(83) |
Jun
(43) |
Jul
(65) |
Aug
(68) |
Sep
(46) |
Oct
(75) |
Nov
(40) |
Dec
(49) |
| 2018 |
Jan
(68) |
Feb
(54) |
Mar
(48) |
Apr
(58) |
May
(51) |
Jun
(44) |
Jul
(40) |
Aug
(68) |
Sep
(35) |
Oct
(15) |
Nov
(7) |
Dec
(37) |
| 2019 |
Jan
(43) |
Feb
(7) |
Mar
(22) |
Apr
(21) |
May
(31) |
Jun
(39) |
Jul
(73) |
Aug
(45) |
Sep
(47) |
Oct
(89) |
Nov
(19) |
Dec
(69) |
| 2020 |
Jan
(52) |
Feb
(63) |
Mar
(45) |
Apr
(59) |
May
(42) |
Jun
(57) |
Jul
(30) |
Aug
(29) |
Sep
(75) |
Oct
(64) |
Nov
(96) |
Dec
(22) |
| 2021 |
Jan
(14) |
Feb
(24) |
Mar
(35) |
Apr
(58) |
May
(36) |
Jun
(15) |
Jul
(18) |
Aug
(31) |
Sep
(30) |
Oct
(33) |
Nov
(27) |
Dec
(16) |
| 2022 |
Jan
(35) |
Feb
(22) |
Mar
(14) |
Apr
(20) |
May
(44) |
Jun
(53) |
Jul
(25) |
Aug
(56) |
Sep
(11) |
Oct
(47) |
Nov
(22) |
Dec
(36) |
| 2023 |
Jan
(30) |
Feb
(17) |
Mar
(31) |
Apr
(48) |
May
(31) |
Jun
(7) |
Jul
(25) |
Aug
(26) |
Sep
(61) |
Oct
(66) |
Nov
(19) |
Dec
(21) |
| 2024 |
Jan
(37) |
Feb
(29) |
Mar
(26) |
Apr
(26) |
May
(34) |
Jun
(9) |
Jul
(27) |
Aug
(13) |
Sep
(15) |
Oct
(25) |
Nov
(13) |
Dec
(8) |
| 2025 |
Jan
(13) |
Feb
(1) |
Mar
(16) |
Apr
(17) |
May
(8) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(6) |
Oct
(15) |
Nov
(6) |
Dec
|
| 2026 |
Jan
(6) |
Feb
(4) |
Mar
(20) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jonathan S. <sw...@gm...> - 2023-05-24 20:42:12
|
Hi Marius, This was reported on GitHub here: https://github.com/lballabio/QuantLib/issues/1675 Your options are 1) download from the master branch instead of the 1.30 tag, 2) manually apply the fix linked in the issue above, or 3) install using automake instead of CMake. 2023년 5월 25일 (목) 02:32, Marius Räsener <mar...@fi...>님이 작성: > Hey everybody, > > I’m trying to get a working docker image to finally run some Python code > which uses QuantLib. > > Dockerfile: > > ``` > FROM python:slim > > RUN apt-get update \ > && apt-get install -y \ > curl \ > build-essential \ > libboost-all-dev \ > cmake \ > ninja-build > > RUN curl -L > https://github.com/lballabio/QuantLib/releases/download/QuantLib-v1.30/QuantLib-1.30.tar.gz > --output QuantLib-1.30.tar.gz \ > && tar xzf QuantLib-1.30.tar.gz \ > && rm QuantLib-1.30.tar.gz > ``` > > then I just run an instance and continue manually (to run have a faster > trial and error loop) > > docker build --ssh default . -f Dockerfile -t foo > > and > > docker run -it --rm foo bash > > inside the container I do the following: > > cd QuantLib-1.30/build > cmake .. -G Ninja -D CMAKE_BUILD_TYPE=Release > ninja > ninja install > > Now, at `ninja install` I run into the following issue, and it seems I > can’t find anything useful in the internetz. > > . > . > . > -- Installing: /usr/local/include/ql/currencies/all.hpp > -- Installing: /usr/local/include/ql/experimental/all.hpp > CMake Error at ql/cmake_install.cmake:5243 (file): > file INSTALL cannot find > "/QuantLib-1.30/build/ql/experimental/amortizingbonds/all.hpp": No such > file or directory. > Call Stack (most recent call first): > cmake_install.cmake:47 (include) > > > FAILED: CMakeFiles/install.util > cd /QuantLib-1.30/build && /usr/bin/cmake -P cmake_install.cmake > ninja: build stopped: subcommand failed. > > Can someone point me into the right direction? > > Disclaimer: I actually work at this from a ops perspective and I don’t > really know what QuantLib is doing or any other details about it :) > > Thx in advance and have a nice day, > Marius > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Marius R. <mar...@fi...> - 2023-05-24 17:28:54
|
Hey everybody,
I’m trying to get a working docker image to finally run some Python code which uses QuantLib.
Dockerfile:
```
FROM python:slim
RUN apt-get update \
&& apt-get install -y \
curl \
build-essential \
libboost-all-dev \
cmake \
ninja-build
RUN curl -L https://github.com/lballabio/QuantLib/releases/download/QuantLib-v1.30/QuantLib-1.30.tar.gz --output QuantLib-1.30.tar.gz \
&& tar xzf QuantLib-1.30.tar.gz \
&& rm QuantLib-1.30.tar.gz
```
then I just run an instance and continue manually (to run have a faster trial and error loop)
docker build --ssh default . -f Dockerfile -t foo
and
docker run -it --rm foo bash
inside the container I do the following:
cd QuantLib-1.30/build
cmake .. -G Ninja -D CMAKE_BUILD_TYPE=Release
ninja
ninja install
Now, at `ninja install` I run into the following issue, and it seems I can’t find anything useful in the internetz.
.
.
.
-- Installing: /usr/local/include/ql/currencies/all.hpp
-- Installing: /usr/local/include/ql/experimental/all.hpp
CMake Error at ql/cmake_install.cmake:5243 (file):
file INSTALL cannot find
"/QuantLib-1.30/build/ql/experimental/amortizingbonds/all.hpp": No such
file or directory.
Call Stack (most recent call first):
cmake_install.cmake:47 (include)
FAILED: CMakeFiles/install.util
cd /QuantLib-1.30/build && /usr/bin/cmake -P cmake_install.cmake
ninja: build stopped: subcommand failed.
Can someone point me into the right direction?
Disclaimer: I actually work at this from a ops perspective and I don’t really know what QuantLib is doing or any other details about it :)
Thx in advance and have a nice day,
Marius |
|
From: Donghee S. <dh7...@gm...> - 2023-05-23 23:09:35
|
Dear Luigi, Thanks for your reply! I will use your valuable QuantLib faithfully!! Thanks again! Donghee On Mon, May 22, 2023 at 10:30 PM Luigi Ballabio <lui...@gm...> wrote: > Hello Donghee, > hard to say without seeing exactly how you modified the library > files. My suggestion is to use the QuantLib sources unchanged (because > they're known to build correctly) and to either qualify types with the > QuantLib namespace in your application or use "using namespace QuantLib". > This will also help you when you upgrade the version of QuantLib you're > using, since you won't have to modify the namespace all over again. > > Hope this helps, > Luigi > > > On Tue, May 16, 2023 at 1:57 AM Donghee Shim <dh7...@gm...> wrote: > >> Dear all of experts! >> >> My previous colleague had developed some programs for evaluating >> non-standard financial products (not included in QuantLib) using QuantLib >> with a test-suite approach! He named these code as analyticresolver. I’m >> trying to include a simple fixedratebond code to this analyticresolver for >> my training exercise. When I built with Cmake , errors (Days, Months, Years >> are not declared) occurred at both instruments/bond.cpp and >> time/daycounter/actualactual.cpp. When I included time/all.hpp at >> corresponding instruments/bond.hpp and time/daycounter/actualactual.hpp, >> the same errors occurred. (I changed the namespace QuantLib as >> anlyticsolver for every code files.) >> >> >> >> To eliminate the error stating that the variables were not declared, I >> resorted to a workaround by modifying Days, Months, and Years to 2, 4, and >> 8 respectively, and completed the library build. >> >> My application fixedratebond.cpp including the corresponding header files >> bond.hpp and actualactual.hpp files, also using the builted library at link >> phase, runs successfully. >> >> >> >> But these ridiculous modification are not normal, How can I fix this >> problem? >> >> >> >> Thanks!!! >> >> >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > |
|
From: Luigi B. <lui...@gm...> - 2023-05-22 14:27:08
|
Hello Lukasz,
I think you're probably right, the derivative should include that
factor. This said, as Francois mentioned, the "can't bracket" message is
probably raised before the solver starts using the derivative; it's still
checking that the minimum and maximum value for the yield bracket the
solution, that is, that one gives a negative error and the other gives a
positive one, otherwise the solution can't be found in that range. We'd
have the same message even if we used a solver (e.g. Brent) that doesn't
require the derivative.
I guess the workaround in C++ would be to use the overload of the
BondFunctions::yield method that takes an explicit solver (so you can avoid
Newton) and to pass an explicit xMin and xMax so your range can extend over
1376%.
Would you be so kind as to open an issue on GitHub so we can check and fix
the derivative? Thanks!
Luigi
On Mon, May 22, 2023 at 3:41 PM Lukasz Skowronek <
luk...@su...> wrote:
> Hi,
>
> Could anyone here comment on the non-inclusion of
>
> * CashFlows.npv(bond.cashflows(),...
>
> in the derivative of the npv function, as I described
>
> (in lenght, I admit) in my email some time ago?
>
> QuantLib does not seem to include this factor,
>
> but for Newton method to work for my example (independently),
>
> I needed to define the derivative with the additional
>
> CashFlows.npv factor included.
>
> Am I missing some important point or reading QuantLib
>
> code incorrectly?
>
> Best regards,
>
> Łukasz
>
>
> On 8.05.2023 10:48, Lukasz Skowronek wrote:
>
> *Warning: This message originated from outside the organization. Use
> caution when following links or opening attachments.*
>
> Hi,
>
> My name is Lukasz and I'm currently working on a small summary screen for
> various bonds
>
> that uses QuantLib under the hood.
>
> I got an error report from our testers for the following inputs:
> request.CouponPaymentsPerYear = 1;
> request.Coupon = 0.0;
> request.RedemptionPrice = 100.0;
> request.CleanPrice = 1376.0;
> request.FaceValue = 1000.0;
>
> ...
> request.ExpirationDate = new DateTime(2024, 6, 27);
> request.InvestmentDate = new DateTime(2023, 2, 9);
>
> In short, this input corresponds to a zero coupon bond priced extremely
> high (at 1376%).
>
> The error I'm getting says the solver cannot bracket the root of the
> target function.
>
> After shifting the dot in the clean price by one decimal place, I get the
> code to work
>
> as expected. Still, even if the testers did not intend to challenge my
> code with
>
> bonds priced at a 85% markup (that is, -85% yield), I would expect the
> solver to
>
> find the root for the original input.
>
> Digging into QuantLib's source code, I traced a few pieces related to how
> yield
>
> calculation is really done:
>
> In *bondfunctions.cpp (line 360):*
>
> Rate BondFunctions::yield(const Bond& bond, ...
>
> in *bondfunctions.hpp (line 160):*
>
> static Rate yield(const Solver& solver, ...
>
> in *cashflows.hpp (line 276):*
>
> static Rate yield(const Solver& solver, ...
>
> IrrFinder objFunction(leg, npv, dayCounter, compounding,
> frequency, includeSettlementDateFlows,
> settlementDate, npvDate);
> return solver.solve(objFunction, accuracy, guess, guess/10.0);
>
> and finally, in *cashflows.cpp (line 728):*
>
> CashFlows::IrrFinder::IrrFinder(const Leg& leg, ...
>
> Real CashFlows::IrrFinder::operator()(Rate y) const {
> InterestRate yield(y, dayCounter_, compounding_, frequency_);
> Real *NPV = CashFlows::npv(leg_, yield,*
> * includeSettlementDateFlows_,*
> * settlementDate_, npvDate_);*
> return *npv_ - NPV*;
> }
>
> Real CashFlows::IrrFinder::derivative(Rate y) const {
> InterestRate yield(y, dayCounter_, compounding_, frequency_);
> return *modifiedDuration(leg_, yield,*
> * includeSettlementDateFlows_,*
> * settlementDate_, npvDate_)*;
> }
>
> Is this target function + derivative correct?
>
> What worked on my side, when simulating the Newton method for finding the
> root
>
> separately, was:
> double f(double rate) {
> InterestRate ir = new InterestRate(rate, dayCounter, Compounding.
> Compounded, frequency);
> return (cleanPrice + bond.accruedAmount(investmentDate)) * bond.notional(
> investmentDate) / 100.0 -
> CashFlows.npv(bond.cashflows(), ir, false, investmentDate, investmentDate);
>
> }
> // <-- target function
> double d(double rate) {
> InterestRate ir = new InterestRate(rate, dayCounter, Compounding.
> Compounded, frequency);
> return CashFlows.modifiedDuration(bond.cashflows(), ir, false,
> investmentDate, investmentDate) * CashFlows.npv(bond.cashflows(), ir,
> false, investmentDate, investmentDate);
> }
> // <-- derivative
> (this is C# code that has QLNet as dependency)
>
> Hence, there is an additional multiplication by CashFlows.npv(..., which
> plays well with the
>
> definition of modified duration as -dPdy / P
>
> There does not seem to be a similar factor in QuantLib.
>
> Am I mistaken? Is the multiplication by NPV in the derivative handled some
> other way?
>
> Best regards,
>
> Lukasz Skowronek
>
>
>
>
> _______________________________________________
> QuantLib-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Lukasz S. <luk...@su...> - 2023-05-22 13:38:15
|
Hi,
Could anyone here comment on the non-inclusion of
*CashFlows.npv(bond.cashflows(),...
in the derivative of the npv function, as I described
(in lenght, I admit) in my email some time ago?
QuantLib does not seem to include this factor,
but for Newton method to work for my example (independently),
I needed to define the derivative with the additional
CashFlows.npv factor included.
Am I missing some important point or reading QuantLib
code incorrectly?
Best regards,
Łukasz
On 8.05.2023 10:48, Lukasz Skowronek wrote:
>
> *Warning: This message originated from outside the organization. Use
> caution when following links or opening attachments.*
>
> Hi,
>
> My name is Lukasz and I'm currently working on a small summary screen
> for various bonds
>
> that uses QuantLib under the hood.
>
> I got an error report from our testers for the following inputs:
>
> request.CouponPaymentsPerYear=1;
> request.Coupon=0.0;
> request.RedemptionPrice=100.0;
> request.CleanPrice=1376.0;
> request.FaceValue=1000.0;
>
> ...
>
> request.ExpirationDate=newDateTime(2024, 6, 27);
> request.InvestmentDate=newDateTime(2023, 2, 9);
>
> In short, this input corresponds to a zero coupon bond priced
> extremely high (at 1376%).
>
> The error I'm getting says the solver cannot bracket the root of the
> target function.
>
> After shifting the dot in the clean price by one decimal place, I get
> the code to work
>
> as expected. Still, even if the testers did not intend to challenge my
> code with
>
> bonds priced at a 85% markup (that is, -85% yield), I would expect the
> solver to
>
> find the root for the original input.
>
> Digging into QuantLib's source code, I traced a few pieces related to
> how yield
>
> calculation is really done:
>
> In *bondfunctions.cpp (line 360):*
>
> Rate BondFunctions::yield(const Bond& bond, ...
>
> in *bondfunctions.hpp (line 160):*
>
> static Rate yield(const Solver& solver, ...
>
> in *cashflows.hpp (line 276):*
>
> static Rate yield(const Solver& solver, ...
>
> IrrFinder objFunction(leg, npv, dayCounter, compounding,
> frequency, includeSettlementDateFlows,
> settlementDate, npvDate);
> return solver.solve(objFunction, accuracy, guess, guess/10.0);
>
> and finally, in *cashflows.cpp (line 728):*
>
> CashFlows::IrrFinder::IrrFinder(const Leg& leg, ...
>
> Real CashFlows::IrrFinder::operator()(Rate y) const {
> InterestRate yield(y, dayCounter_, compounding_, frequency_);
> Real *NPV = CashFlows::npv(leg_, yield,**
> **includeSettlementDateFlows_,**
> ** settlementDate_, npvDate_);*
> return *npv_ - NPV*;
> }
>
> Real CashFlows::IrrFinder::derivative(Rate y) const {
> InterestRate yield(y, dayCounter_, compounding_, frequency_);
> return *modifiedDuration(leg_, yield,**
> **includeSettlementDateFlows_,**
> ** settlementDate_, npvDate_)*;
> }
>
> Is this target function + derivative correct?
>
> What worked on my side, when simulating the Newton method for finding
> the root
>
> separately, was:
>
> doublef(doublerate) {
> InterestRateir=newInterestRate(rate, dayCounter,
> Compounding.Compounded, frequency);
> return(cleanPrice+bond.accruedAmount(investmentDate))
> *bond.notional(investmentDate) /100.0-
> CashFlows.npv(bond.cashflows(), ir, false, investmentDate,
> investmentDate);
> }
> // <-- target function
> doubled(doublerate) {
> InterestRateir=newInterestRate(rate, dayCounter,
> Compounding.Compounded, frequency);
> returnCashFlows.modifiedDuration(bond.cashflows(), ir, false,
> investmentDate, investmentDate) *CashFlows.npv(bond.cashflows(), ir,
> false, investmentDate, investmentDate);
> }
> // <-- derivative
> (this is C# code that has QLNet as dependency)
>
> Hence, there is an additional multiplication by CashFlows.npv(...,
> which plays well with the
>
> definition of modified duration as -dPdy / P
>
> There does not seem to be a similar factor in QuantLib.
>
> Am I mistaken? Is the multiplication by NPV in the derivative handled
> some other way?
>
> Best regards,
>
> Lukasz Skowronek
>
>
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Luigi B. <lui...@gm...> - 2023-05-22 13:30:21
|
Hello Donghee,
hard to say without seeing exactly how you modified the library files.
My suggestion is to use the QuantLib sources unchanged (because they're
known to build correctly) and to either qualify types with the QuantLib
namespace in your application or use "using namespace QuantLib". This will
also help you when you upgrade the version of QuantLib you're using, since
you won't have to modify the namespace all over again.
Hope this helps,
Luigi
On Tue, May 16, 2023 at 1:57 AM Donghee Shim <dh7...@gm...> wrote:
> Dear all of experts!
>
> My previous colleague had developed some programs for evaluating
> non-standard financial products (not included in QuantLib) using QuantLib
> with a test-suite approach! He named these code as analyticresolver. I’m
> trying to include a simple fixedratebond code to this analyticresolver for
> my training exercise. When I built with Cmake , errors (Days, Months, Years
> are not declared) occurred at both instruments/bond.cpp and
> time/daycounter/actualactual.cpp. When I included time/all.hpp at
> corresponding instruments/bond.hpp and time/daycounter/actualactual.hpp,
> the same errors occurred. (I changed the namespace QuantLib as
> anlyticsolver for every code files.)
>
>
>
> To eliminate the error stating that the variables were not declared, I
> resorted to a workaround by modifying Days, Months, and Years to 2, 4, and
> 8 respectively, and completed the library build.
>
> My application fixedratebond.cpp including the corresponding header files
> bond.hpp and actualactual.hpp files, also using the builted library at link
> phase, runs successfully.
>
>
>
> But these ridiculous modification are not normal, How can I fix this
> problem?
>
>
>
> Thanks!!!
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Luigi B. <lui...@gm...> - 2023-05-22 13:21:00
|
Hello Dagur,
you probably need a more recent version of QuantLib; that check was
removed in version 1.29. In the meantime, I wrote some actual code in
Python and I published it at <
https://www.implementingquantlib.com/2023/05/pik-bonds.html>.
Luigi
On Fri, May 19, 2023 at 4:00 PM Dagur Gunnarsson <da...@ko...> wrote:
> Thank you for your reply,
>
> I still get an error due to the increasing notionals
>
> terminate called after throwing an instance of 'QuantLib::Error'
> what(): increasing coupon notionals
> Aborted (core dumped)
>
> I use the bond = new Bond(0, calendar_, interestFromDate_, coupons);
> Where coupons is QuantLib::Leg coupons; and the coupons added as in the
> pseudo-code example.
>
> regards
> Dagur G
>
> On Thu, Apr 27, 2023 at 3:42 PM Luigi Ballabio <lui...@gm...>
> wrote:
>
>> For a fixed-rate bullet bond, I'd try building the coupons manually, as
>> in (pseudo-code, not tested, take with a grain of salt):
>>
>> Leg coupons;
>> coupons.push_back(ext::make_shared<FixedRateCoupon>(date[0], 100,
>> ...));
>> for (each other coupon) {
>> const auto& last = coupons.back();
>> coupons.push_back(ext::make_shared<FixedRateCoupon>(date[1],
>> last->nominal() + last->amount(), ...)
>> }
>>
>> once you have all of them, you can pass them to the proper Bond
>> constructor:
>>
>> auto bond = ext::make_shared<Bond>(settlementDays, calendar,
>> issueDate, coupons);
>>
>> Due to the increasing notionals, the constructor will add negative
>> payments at each coupon date that represent adding amount to the notional
>> and will cancel out the coupon payments.
>>
>> Let me know if this works for you.
>>
>> Luigi
>>
>>
>>
>> On Mon, Apr 17, 2023 at 5:20 PM Dagur Gunnarsson <da...@ko...> wrote:
>>
>>> Hello,
>>>
>>> Is there any way to define a BulletLoan, Bond in QuantLib such that the
>>> coupon payments add to the notional each period?
>>>
>>> First the notional is 100.0
>>> then 103.5 .etc. until maturity.
>>>
>>> -Dagur
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> Qua...@li...
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>
|
|
From: Dagur G. <da...@ko...> - 2023-05-19 14:26:42
|
Thank you for your reply,
I still get an error due to the increasing notionals
terminate called after throwing an instance of 'QuantLib::Error'
what(): increasing coupon notionals
Aborted (core dumped)
I use the bond = new Bond(0, calendar_, interestFromDate_, coupons);
Where coupons is QuantLib::Leg coupons; and the coupons added as in the
pseudo-code example.
regards
Dagur G
On Thu, Apr 27, 2023 at 3:42 PM Luigi Ballabio <lui...@gm...>
wrote:
> For a fixed-rate bullet bond, I'd try building the coupons manually, as in
> (pseudo-code, not tested, take with a grain of salt):
>
> Leg coupons;
> coupons.push_back(ext::make_shared<FixedRateCoupon>(date[0], 100,
> ...));
> for (each other coupon) {
> const auto& last = coupons.back();
> coupons.push_back(ext::make_shared<FixedRateCoupon>(date[1],
> last->nominal() + last->amount(), ...)
> }
>
> once you have all of them, you can pass them to the proper Bond
> constructor:
>
> auto bond = ext::make_shared<Bond>(settlementDays, calendar,
> issueDate, coupons);
>
> Due to the increasing notionals, the constructor will add negative
> payments at each coupon date that represent adding amount to the notional
> and will cancel out the coupon payments.
>
> Let me know if this works for you.
>
> Luigi
>
>
>
> On Mon, Apr 17, 2023 at 5:20 PM Dagur Gunnarsson <da...@ko...> wrote:
>
>> Hello,
>>
>> Is there any way to define a BulletLoan, Bond in QuantLib such that the
>> coupon payments add to the notional each period?
>>
>> First the notional is 100.0
>> then 103.5 .etc. until maturity.
>>
>> -Dagur
>> _______________________________________________
>> QuantLib-users mailing list
>> Qua...@li...
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
|
|
From: Cay C. O. <cay...@fr...> - 2023-05-18 12:05:19
|
Dear Shim, Thanks for using QuantLib. So it is common wisdom that you should never change a dependent library, unless - on the very rare occasion - you are forced to. I don't think this is the case here. So please don't change the QuantLib code (benefitting you as well as your employer), and maybe start reading one book about basic programming practices. Or take a course. Or watch a YouTube video. Or... It certainly wouldn't hurt. Best regards, Cay On 15.05.23 17:05, Donghee Shim wrote: > > Dear all of experts! > > My previous colleague had developed some programs for evaluating > non-standard financial products (not included in QuantLib) using > QuantLib with a test-suite approach! He named these code as > analyticresolver. I’m trying to include a simple fixedratebond code to > this analyticresolver for my training exercise. When I built with > Cmake , errors (Days, Months, Years are not declared) occurred at both > instruments/bond.cpp and time/daycounter/actualactual.cpp. When I > included time/all.hpp at corresponding instruments/bond.hpp and > time/daycounter/actualactual.hpp, the same errors occurred. (I changed > the namespace QuantLib as anlyticsolver for every code files.) > > How can I fix this problem? > > Thanks!!! > |
|
From: Donghee S. <dh7...@gm...> - 2023-05-16 05:12:36
|
Dear Sweemer, Thanks for your kind comments. The errors occurred during the Built of the library. (In this built, both bond.cpp and actualactual.cpp must be included) To eliminate the error stating that the variables were not declared, I resorted to a workaround by modifying Days, Months, and Years to 2, 4, and 8 respectively, and completed the library build. And my application fixedratebond.cpp including the corresponding header files bond.hpp and actualactual.hpp files, using the linked library, runs successfully. But these modification is not normal, How can I fix this problem? Thanks again!!! Best Regards! Donghee Shim On Tue, May 16, 2023 at 5:52 AM Jonathan Sweemer <sw...@gm...> wrote: > Hi Donghee, > > Are you modifying the QuantLib source files directly? If so, then that’s > not the usual way to use the library. Usually what you should do is build > the library first, and then use that in your project by including the > headers and linking with it. > > If that’s not what you’re doing then I’ll need to see the complete build > log to provide more help. > > By the way, did you know that QuantLib is also available in python? It > might be faster to prototype your training exercise in python if you > haven’t tried yet. > > 2023년 5월 16일 (화) 00:08, Donghee Shim <dh7...@gm...>님이 작성: > >> Dear all of experts! >> >> My previous colleague had developed some programs for evaluating >> non-standard financial products (not included in QuantLib) using QuantLib >> with a test-suite approach! He named these code as analyticresolver. I’m >> trying to include a simple fixedratebond code to this analyticresolver for >> my training exercise. When I built with Cmake , errors (Days, Months, Years >> are not declared) occurred at both instruments/bond.cpp and >> time/daycounter/actualactual.cpp. When I included time/all.hpp at >> corresponding instruments/bond.hpp and time/daycounter/actualactual.hpp, >> the same errors occurred. (I changed the namespace QuantLib as >> anlyticsolver for every code files.) >> >> How can I fix this problem? >> >> Thanks!!! >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > |
|
From: Donghee S. <dh7...@gm...> - 2023-05-15 23:54:44
|
Dear all of experts! My previous colleague had developed some programs for evaluating non-standard financial products (not included in QuantLib) using QuantLib with a test-suite approach! He named these code as analyticresolver. I’m trying to include a simple fixedratebond code to this analyticresolver for my training exercise. When I built with Cmake , errors (Days, Months, Years are not declared) occurred at both instruments/bond.cpp and time/daycounter/actualactual.cpp. When I included time/all.hpp at corresponding instruments/bond.hpp and time/daycounter/actualactual.hpp, the same errors occurred. (I changed the namespace QuantLib as anlyticsolver for every code files.) To eliminate the error stating that the variables were not declared, I resorted to a workaround by modifying Days, Months, and Years to 2, 4, and 8 respectively, and completed the library build. My application fixedratebond.cpp including the corresponding header files bond.hpp and actualactual.hpp files, also using the builted library at link phase, runs successfully. But these ridiculous modification are not normal, How can I fix this problem? Thanks!!! |
|
From: Jonathan S. <sw...@gm...> - 2023-05-15 20:52:43
|
Hi Donghee, Are you modifying the QuantLib source files directly? If so, then that’s not the usual way to use the library. Usually what you should do is build the library first, and then use that in your project by including the headers and linking with it. If that’s not what you’re doing then I’ll need to see the complete build log to provide more help. By the way, did you know that QuantLib is also available in python? It might be faster to prototype your training exercise in python if you haven’t tried yet. 2023년 5월 16일 (화) 00:08, Donghee Shim <dh7...@gm...>님이 작성: > Dear all of experts! > > My previous colleague had developed some programs for evaluating > non-standard financial products (not included in QuantLib) using QuantLib > with a test-suite approach! He named these code as analyticresolver. I’m > trying to include a simple fixedratebond code to this analyticresolver for > my training exercise. When I built with Cmake , errors (Days, Months, Years > are not declared) occurred at both instruments/bond.cpp and > time/daycounter/actualactual.cpp. When I included time/all.hpp at > corresponding instruments/bond.hpp and time/daycounter/actualactual.hpp, > the same errors occurred. (I changed the namespace QuantLib as > anlyticsolver for every code files.) > > How can I fix this problem? > > Thanks!!! > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Donghee S. <dh7...@gm...> - 2023-05-15 15:05:23
|
Dear all of experts! My previous colleague had developed some programs for evaluating non-standard financial products (not included in QuantLib) using QuantLib with a test-suite approach! He named these code as analyticresolver. I’m trying to include a simple fixedratebond code to this analyticresolver for my training exercise. When I built with Cmake , errors (Days, Months, Years are not declared) occurred at both instruments/bond.cpp and time/daycounter/actualactual.cpp. When I included time/all.hpp at corresponding instruments/bond.hpp and time/daycounter/actualactual.hpp, the same errors occurred. (I changed the namespace QuantLib as anlyticsolver for every code files.) How can I fix this problem? Thanks!!! |
|
From: Peter C. <pca...@gm...> - 2023-05-12 10:09:16
|
Hi Kostas, I believe there is no support in QuantLib as of now. There is an open dev branch for swaptions. We have added support for RFR caps and swaptions in ORE, following the approach in Lyashenko / Mercurio. https://github.com/OpenSourceRisk/Engine/blob/master/QuantExt/qle/cashflows/blackovernightindexedcouponpricer.cpp#L58 For the time being you might look into using the ORE library "QuantExt" in conjunction with our ORE QuantLib fork. I am aware that both the additional library and the modified QuantLib fork are not the ideal solution and we aim at consolidating everything into the original QuantLib, but I fear it is not realistic that this happens in the short term. BTW help from the community is greatly appreciated here, as we see it in the case of RFR swaptions. However we want to make sure that both QuantLib and ORE work on the new code after such a migration, i.e. the task is not done when the functionality is added to QuantLib, it has to be removed from QuantExt and dependencies in the other ORE libraries have to be updated as well. Thank you Peter On Wed, 10 May 2023 at 14:02, kmylonakis via QuantLib-users <qua...@li...> wrote: > > Hello dear community, > > Excuse me if the below is very naive, but I am a not so experienced QuantLib user. > > Based on my understanding the library can't handle at the moment RFR Caps/Floors and swaptions. Or am I missing something? I am searching if the decay function is applied to IR options when RFR rates are as underlying i.e. an adjustment similar to the one suggested by Lyashenko & Mercurio 2019. > > Thank you very much in advance, > Kostas > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: kmylonakis <kmy...@pr...> - 2023-05-10 12:00:20
|
Hello dear community, Excuse me if the below is very naive, but I am a not so experienced QuantLib user. Based on my understanding the library can't handle at the moment RFR Caps/Floors and swaptions. Or am I missing something? I am searching if the decay function is applied to IR options when RFR rates are as underlying i.e. an adjustment similar to the one suggested by Lyashenko & Mercurio 2019. Thank you very much in advance, Kostas |
|
From: Capt'n V. <vr...@ho...> - 2023-05-08 18:22:45
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="auto"><div class="gmail_quote" dir="auto"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font face="Calibri" size="2"><span style="font-size:11pt"><div>Hi All,</div> <div> </div> <div>I’m trying to construct an yield curve using <a href="https://quantlib-python-docs.readthedocs.io/en/latest/thelpers.html?highlight=FixedRateBondHelper"><font color="blue"><u>FixedRateBondHelper</u></font></a> on real US treasury data and following this example <a href="https://quant.stackexchange.com/questions/54526/parameter-in-fixedratebondhelper-of-quantlib"><font color="blue"><u>https://quant.stackexchange.com/questions/54526/parameter-in-fixedratebondhelper-of-quantlib</u></font></a>. Here is my reproducible code: </div> <div> </div> <div>`from QuantLib import *</div> <div>from pandas import DataFrame</div> <div>import numpy as np</div> <div>import matplotlib.pyplot as plt</div> <div> </div> <div>calc_date = ql.Date(5, 5, 2023)</div> <div>Settings.instance().evaluationDate = calc_date</div> <div> </div> <div>calendar = UnitedStates(UnitedStates.GovernmentBond)</div> <div>business_convention = Unadjusted</div> <div>day_count = ql.ActualActual(ql.ActualActual.Bond)</div> <div>end_of_month = True</div> <div>settlement_days = 1</div> <div>face_amount = 100</div> <div>coupon_frequency = Period(Semiannual)</div> <div> </div> <div> </div> <div>data = [</div> <div> ('31-08-2021', '31-08-2023', 0.125, 98.43537),</div> <div> ('30-09-2021', '30-09-2023', 0.25, 98.13213),</div> <div> ('01-11-2021', '31-10-2023', 0.375, 97.82426),</div> <div> ('30-11-2021', '30-11-2023', 0.5, 97.56833),</div> <div> ('31-12-2021', '31-12-2023', 0.75, 97.36831),</div> <div> ('31-01-2022', '31-01-2024', 0.875, 97.16839),</div> <div> ('28-02-2022', '29-02-2024', 1.5, 97.35896),</div> <div> ('31-03-2022', '31-03-2024', 2.25, 97.79973),</div> <div> ('02-05-2022', '30-04-2024', 2.5, 97.88095),</div> <div> ('31-05-2022', '31-05-2024', 2.5, 97.77523),</div> <div> ('30-06-2022', '30-06-2024', 3.0, 98.2304),</div> <div> ('01-08-2022', '31-07-2024', 3.0, 98.21679),</div> <div> ('31-08-2022', '31-08-2024', 3.25, 98.53124),</div> <div> ('30-09-2022', '30-09-2024', 4.25, 99.87726),</div> <div> ('31-10-2022', '31-10-2024', 4.375, 100.14486),</div> <div> ('30-11-2022', '30-11-2024', 4.5, 100.42819),</div> <div> ('03-01-2023', '31-12-2024', 4.25, 100.1332),</div> <div> ('31-01-2023', '31-01-2025', 4.125, 100.0258),</div> <div> ('28-02-2023', '28-02-2025', 4.625, 101.04361),</div> <div> ('15-03-2022', '15-03-2025', 1.75, 95.98058),</div> <div> </div> <div> ]</div> <div>helpers = []</div> <div> </div> <div>for issue_date, maturity, coupon, price in data:</div> <div> price = ql.QuoteHandle(ql.SimpleQuote(price))</div> <div> issue_date = ql.Date(issue_date, '%d-%m-%Y')</div> <div> maturity = ql.Date(maturity, '%d-%m-%Y')</div> <div> schedule = ql.MakeSchedule(issue_date, maturity, ql.Period(ql.Semiannual))</div> <div> helper = ql.FixedRateBondHelper(price, 2, 100, schedule, [coupon / 100], day_count)</div> <div> helpers.append(helper)</div> <div>yc = ql.PiecewiseLogCubicDiscount(calc_date, helpers, day_count) `</div> <div> </div> <div>which follows the example. However, I’m getting the following error when trying `yc.nodes()`:</div> <div>`RuntimeError: 1st iteration: failed at 20th alive instrument, pillar March 15th, 2025, maturity March 15th, 2025, reference date May 5th, 2023: invalid range: xMin_ (0.930502) >= xMax_ (0.930502)’ . The 19<font size="1"><span style="font-size:7.3pt"><sup>th</sup></span></font> and 20<font size="1"><span style="font-size:7.3pt"><sup>th</sup></span></font> treasuries (CUSIPs <font face="Calibri">91282CGN</font><font face="Calibri"> and </font></div> <div> <font face="Calibri">91282CED</font><font face="Calibri"> </font>yield 4.019113 and 4.02135 respectively? </div> <div> </div> <div>Thank you for your help in advance,</div> <div>Greg</div></span></font></blockquote></div></div> |
|
From: Luigi B. <lui...@gm...> - 2023-05-08 14:40:29
|
Hello everybody,
in the `YoYInflationIndex` class, we have a `ratio` parameter that
tells us whether or not the index is the actual year-on-year ratio of an
underlying CPI index. I see the `ratio=true` case as the "usual" case, but
I don't really see how the `ratio=false` case would work—do indexes exist
which are published as a supposedly year-to-year index, but are independent
of an underlying index? And in that case, what does year-on-year even mean?
Do you have any examples?
Thanks,
Luigi
|
|
From: Lukasz S. <luk...@su...> - 2023-05-08 11:08:59
|
Hi Francois, Thank you for the quick reply. I guess my problem is simpler that you assumed. I'm just using the BondFunctions function 'yield' with a constant yield (a single number / rate; not a non-trivial forward curve). So, my question is just if the Newton procedure for finding yield of a bond gets correct inputs, because I ran into problems when trying to simply replicate the formulas I seem to find in the C++ QuantLib source code available in the web - the npv derivative seems to be modifiedDuration there, without multiplication of the result by npv, which seems wrong. But I may be mistaken. Best regards, Łukasz On 8.05.2023 11:47, Francois Botha wrote: > > *Warning: This message originated from outside the organization. Use > caution when following links or opening attachments.* > > Hi Lukasz, > > Just to note that QLNet is an independent C# port of Quantlib (the C++ > version). > > That said, I'm guessing you're bootstrapping either on Zero or > Forwards rates and the default implementations of these have rates set > to a maximum of 300% ( > https://github.com/amaggiulli/QLNet/blob/d3b709a76098d5765b11da83d0217786b118bd58/src/QLNet/Termstructures/Yield/Bootstraptraits.cs#L100 > and > https://github.com/amaggiulli/QLNet/blob/d3b709a76098d5765b11da83d0217786b118bd58/src/QLNet/Termstructures/Yield/Bootstraptraits.cs#L179). > > The implementation in Quantlib original is similar. I just briefly > glanced at the code and saw some branching related to the > QL_NEGATIVE_RATES preprocessor directive, which might be relevant. Try > enabling that directive. If that fails, you can implement your own > class that implements ITraits<YieldTermStructure> but removes the 300% > cap. I've had to use a variation of the last solution, but with my own > constraints, which in the end worked for me. > > Maybe someone else here has better suggestions. > > regards > Francois Botha > > > On Mon, 8 May 2023 at 11:10, Lukasz Skowronek > <luk...@su...> wrote: > > Hi, > > My name is Lukasz and I'm currently working on a small summary > screen for various bonds > > that uses QuantLib under the hood. > > I got an error report from our testers for the following inputs: > > request.CouponPaymentsPerYear=1; > request.Coupon=0.0; > request.RedemptionPrice=100.0; > request.CleanPrice=1376.0; > request.FaceValue=1000.0; > > ... > > request.ExpirationDate=newDateTime(2024, 6, 27); > request.InvestmentDate=newDateTime(2023, 2, 9); > > In short, this input corresponds to a zero coupon bond priced > extremely high (at 1376%). > > The error I'm getting says the solver cannot bracket the root of > the target function. > > After shifting the dot in the clean price by one decimal place, I > get the code to work > > as expected. Still, even if the testers did not intend to > challenge my code with > > bonds priced at a 85% markup (that is, -85% yield), I would expect > the solver to > > find the root for the original input. > > Digging into QuantLib's source code, I traced a few pieces related > to how yield > > calculation is really done: > > In *bondfunctions.cpp (line 360):* > > Rate BondFunctions::yield(const Bond& bond, ... > > in *bondfunctions.hpp (line 160):* > > static Rate yield(const Solver& solver, ... > > in *cashflows.hpp (line 276):* > > static Rate yield(const Solver& solver, ... > > IrrFinder objFunction(leg, npv, dayCounter, compounding, > frequency, > includeSettlementDateFlows, > settlementDate, npvDate); > return solver.solve(objFunction, accuracy, guess, > guess/10.0); > > and finally, in *cashflows.cpp (line 728):* > > CashFlows::IrrFinder::IrrFinder(const Leg& leg, ... > > Real CashFlows::IrrFinder::operator()(Rate y) const { > InterestRate yield(y, dayCounter_, compounding_, frequency_); > Real *NPV = CashFlows::npv(leg_, yield,** > **includeSettlementDateFlows_,** > ** settlementDate_, npvDate_);* > return *npv_ - NPV*; > } > > Real CashFlows::IrrFinder::derivative(Rate y) const { > InterestRate yield(y, dayCounter_, compounding_, frequency_); > return *modifiedDuration(leg_, yield,** > **includeSettlementDateFlows_,** > ** settlementDate_, npvDate_)*; > } > > Is this target function + derivative correct? > > What worked on my side, when simulating the Newton method for > finding the root > > separately, was: > > doublef(doublerate) { > InterestRateir=newInterestRate(rate, dayCounter, > Compounding.Compounded, frequency); > return(cleanPrice+bond.accruedAmount(investmentDate)) > *bond.notional(investmentDate) /100.0- > CashFlows.npv(bond.cashflows(), ir, false, investmentDate, > investmentDate); > } > // <-- target function > doubled(doublerate) { > InterestRateir=newInterestRate(rate, dayCounter, > Compounding.Compounded, frequency); > returnCashFlows.modifiedDuration(bond.cashflows(), ir, false, > investmentDate, investmentDate) *CashFlows.npv(bond.cashflows(), > ir, false, investmentDate, investmentDate); > } > // <-- derivative > (this is C# code that has QLNet as dependency) > > Hence, there is an additional multiplication by CashFlows.npv(..., > which plays well with the > > definition of modified duration as -dPdy / P > > There does not seem to be a similar factor in QuantLib. > > Am I mistaken? Is the multiplication by NPV in the derivative > handled some other way? > > Best regards, > > Lukasz Skowronek > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Francois B. <ig...@gm...> - 2023-05-08 09:47:57
|
Hi Lukasz, Just to note that QLNet is an independent C# port of Quantlib (the C++ version). That said, I'm guessing you're bootstrapping either on Zero or Forwards rates and the default implementations of these have rates set to a maximum of 300% ( https://github.com/amaggiulli/QLNet/blob/d3b709a76098d5765b11da83d0217786b118bd58/src/QLNet/Termstructures/Yield/Bootstraptraits.cs#L100 and https://github.com/amaggiulli/QLNet/blob/d3b709a76098d5765b11da83d0217786b118bd58/src/QLNet/Termstructures/Yield/Bootstraptraits.cs#L179 ). The implementation in Quantlib original is similar. I just briefly glanced at the code and saw some branching related to the QL_NEGATIVE_RATES preprocessor directive, which might be relevant. Try enabling that directive. If that fails, you can implement your own class that implements ITraits<YieldTermStructure> but removes the 300% cap. I've had to use a variation of the last solution, but with my own constraints, which in the end worked for me. Maybe someone else here has better suggestions. regards Francois Botha On Mon, 8 May 2023 at 11:10, Lukasz Skowronek < luk...@su...> wrote: > Hi, > > My name is Lukasz and I'm currently working on a small summary screen for > various bonds > > that uses QuantLib under the hood. > > I got an error report from our testers for the following inputs: > request.CouponPaymentsPerYear = 1; > request.Coupon = 0.0; > request.RedemptionPrice = 100.0; > request.CleanPrice = 1376.0; > request.FaceValue = 1000.0; > > ... > request.ExpirationDate = new DateTime(2024, 6, 27); > request.InvestmentDate = new DateTime(2023, 2, 9); > > In short, this input corresponds to a zero coupon bond priced extremely > high (at 1376%). > > The error I'm getting says the solver cannot bracket the root of the > target function. > > After shifting the dot in the clean price by one decimal place, I get the > code to work > > as expected. Still, even if the testers did not intend to challenge my > code with > > bonds priced at a 85% markup (that is, -85% yield), I would expect the > solver to > > find the root for the original input. > > Digging into QuantLib's source code, I traced a few pieces related to how > yield > > calculation is really done: > > In *bondfunctions.cpp (line 360):* > > Rate BondFunctions::yield(const Bond& bond, ... > > in *bondfunctions.hpp (line 160):* > > static Rate yield(const Solver& solver, ... > > in *cashflows.hpp (line 276):* > > static Rate yield(const Solver& solver, ... > > IrrFinder objFunction(leg, npv, dayCounter, compounding, > frequency, includeSettlementDateFlows, > settlementDate, npvDate); > return solver.solve(objFunction, accuracy, guess, guess/10.0); > > and finally, in *cashflows.cpp (line 728):* > > CashFlows::IrrFinder::IrrFinder(const Leg& leg, ... > > Real CashFlows::IrrFinder::operator()(Rate y) const { > InterestRate yield(y, dayCounter_, compounding_, frequency_); > Real *NPV = CashFlows::npv(leg_, yield,* > * includeSettlementDateFlows_,* > * settlementDate_, npvDate_);* > return *npv_ - NPV*; > } > > Real CashFlows::IrrFinder::derivative(Rate y) const { > InterestRate yield(y, dayCounter_, compounding_, frequency_); > return *modifiedDuration(leg_, yield,* > * includeSettlementDateFlows_,* > * settlementDate_, npvDate_)*; > } > > Is this target function + derivative correct? > > What worked on my side, when simulating the Newton method for finding the > root > > separately, was: > double f(double rate) { > InterestRate ir = new InterestRate(rate, dayCounter, Compounding. > Compounded, frequency); > return (cleanPrice + bond.accruedAmount(investmentDate)) * bond.notional( > investmentDate) / 100.0 - > CashFlows.npv(bond.cashflows(), ir, false, investmentDate, investmentDate); > > } > // <-- target function > double d(double rate) { > InterestRate ir = new InterestRate(rate, dayCounter, Compounding. > Compounded, frequency); > return CashFlows.modifiedDuration(bond.cashflows(), ir, false, > investmentDate, investmentDate) * CashFlows.npv(bond.cashflows(), ir, > false, investmentDate, investmentDate); > } > // <-- derivative > (this is C# code that has QLNet as dependency) > > Hence, there is an additional multiplication by CashFlows.npv(..., which > plays well with the > > definition of modified duration as -dPdy / P > > There does not seem to be a similar factor in QuantLib. > > Am I mistaken? Is the multiplication by NPV in the derivative handled some > other way? > > Best regards, > > Lukasz Skowronek > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Lukasz S. <luk...@su...> - 2023-05-08 09:06:50
|
Hi,
My name is Lukasz and I'm currently working on a small summary screen
for various bonds
that uses QuantLib under the hood.
I got an error report from our testers for the following inputs:
request.CouponPaymentsPerYear=1;
request.Coupon=0.0;
request.RedemptionPrice=100.0;
request.CleanPrice=1376.0;
request.FaceValue=1000.0;
...
request.ExpirationDate=newDateTime(2024, 6, 27);
request.InvestmentDate=newDateTime(2023, 2, 9);
In short, this input corresponds to a zero coupon bond priced extremely
high (at 1376%).
The error I'm getting says the solver cannot bracket the root of the
target function.
After shifting the dot in the clean price by one decimal place, I get
the code to work
as expected. Still, even if the testers did not intend to challenge my
code with
bonds priced at a 85% markup (that is, -85% yield), I would expect the
solver to
find the root for the original input.
Digging into QuantLib's source code, I traced a few pieces related to
how yield
calculation is really done:
In *bondfunctions.cpp (line 360):*
Rate BondFunctions::yield(const Bond& bond, ...
in *bondfunctions.hpp (line 160):*
static Rate yield(const Solver& solver, ...
in *cashflows.hpp (line 276):*
static Rate yield(const Solver& solver, ...
IrrFinder objFunction(leg, npv, dayCounter, compounding,
frequency, includeSettlementDateFlows,
settlementDate, npvDate);
return solver.solve(objFunction, accuracy, guess, guess/10.0);
and finally, in *cashflows.cpp (line 728):*
CashFlows::IrrFinder::IrrFinder(const Leg& leg, ...
Real CashFlows::IrrFinder::operator()(Rate y) const {
InterestRate yield(y, dayCounter_, compounding_, frequency_);
Real *NPV = CashFlows::npv(leg_, yield,**
**includeSettlementDateFlows_,**
** settlementDate_, npvDate_);*
return *npv_ - NPV*;
}
Real CashFlows::IrrFinder::derivative(Rate y) const {
InterestRate yield(y, dayCounter_, compounding_, frequency_);
return *modifiedDuration(leg_, yield,**
**includeSettlementDateFlows_,**
** settlementDate_, npvDate_)*;
}
Is this target function + derivative correct?
What worked on my side, when simulating the Newton method for finding
the root
separately, was:
doublef(doublerate) {
InterestRateir=newInterestRate(rate, dayCounter, Compounding.Compounded,
frequency);
return(cleanPrice+bond.accruedAmount(investmentDate))
*bond.notional(investmentDate) /100.0-
CashFlows.npv(bond.cashflows(), ir, false, investmentDate, investmentDate);
}
// <-- target function
doubled(doublerate) {
InterestRateir=newInterestRate(rate, dayCounter, Compounding.Compounded,
frequency);
returnCashFlows.modifiedDuration(bond.cashflows(), ir, false,
investmentDate, investmentDate) *CashFlows.npv(bond.cashflows(), ir,
false, investmentDate, investmentDate);
}
// <-- derivative
(this is C# code that has QLNet as dependency)
Hence, there is an additional multiplication by CashFlows.npv(..., which
plays well with the
definition of modified duration as -dPdy / P
There does not seem to be a similar factor in QuantLib.
Am I mistaken? Is the multiplication by NPV in the derivative handled
some other way?
Best regards,
Lukasz Skowronek
|
|
From: Serhat G. <ki...@gm...> - 2023-05-05 18:00:06
|
Hi everyone, I am wondering if there is a method to factor in the counterparty default risk in CDS pricing when the side is "ql.Protection.Buyer". Perhaps, there could be an approach such as default correlation or embedding it into the spread. Do you have any thoughts on this? Regards, Serhat |
|
From: Luigi B. <lui...@gm...> - 2023-04-27 15:57:32
|
Is that a probability curve you're bootstrapping? If so, it seems that even with probability of default = 1 (the second bound in f[2.22045e-16,1]) the pricer can't get the sign of the NPV to change (the two values in [1.165963e+00,3.797374e-01] are the NPVs at the bounds). I don't see a workaround here... Luigi On Thu, Apr 27, 2023 at 12:06 PM Ben Watson <ben...@ma...> wrote: > I know that this topic has come up before. In this case, there is nothing > specifically wrong with the code – the same bit of code works for 350+ CDS > curves. > > > > This issues is that the CASINO GUICHARDPERRACHON looks like it is about to > default. The 6m CDS spread is 11659. The root solver is failing. > > > > My question is… is there anything that could be done to control the root > solver in this case? i.e. adjust the tolerance or some other work around? > > > > Date Ticker ShortName > RedCode Tier > Ccy DocClause Spread6m Spread1y > Spread2y Spread3y Spread4y > Spread5y Spread7y Spread10y > > 2023-04-24 GROUPE CASINO GUICHARDPERRACHON > FG554O SNRFOR EUR MM14 > 1.16596253 1.22492036 1.06136462 > 0.98585902 0.93722387 0.90058129 > 0.84189616 0.78298615 > > > > 1st iteration: failed at 1st alive instrument, pillar December 20th, 2023, > maturity December 20th, 2023, reference date April 26th, 2023: root not > bracketed: f[2.22045e-16,1] -> [1.165963e+00,3.797374e-01] > > > |
|
From: Luigi B. <lui...@gm...> - 2023-04-27 15:42:51
|
For a fixed-rate bullet bond, I'd try building the coupons manually, as in
(pseudo-code, not tested, take with a grain of salt):
Leg coupons;
coupons.push_back(ext::make_shared<FixedRateCoupon>(date[0], 100, ...));
for (each other coupon) {
const auto& last = coupons.back();
coupons.push_back(ext::make_shared<FixedRateCoupon>(date[1],
last->nominal() + last->amount(), ...)
}
once you have all of them, you can pass them to the proper Bond constructor:
auto bond = ext::make_shared<Bond>(settlementDays, calendar, issueDate,
coupons);
Due to the increasing notionals, the constructor will add negative payments
at each coupon date that represent adding amount to the notional and will
cancel out the coupon payments.
Let me know if this works for you.
Luigi
On Mon, Apr 17, 2023 at 5:20 PM Dagur Gunnarsson <da...@ko...> wrote:
> Hello,
>
> Is there any way to define a BulletLoan, Bond in QuantLib such that the
> coupon payments add to the notional each period?
>
> First the notional is 100.0
> then 103.5 .etc. until maturity.
>
> -Dagur
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Ben W. <ben...@ma...> - 2023-04-27 10:12:15
|
I know that this topic has come up before. In this case, there is nothing specifically wrong with the code – the same bit of code works for 350+ CDS curves. This issues is that the CASINO GUICHARDPERRACHON looks like it is about to default. The 6m CDS spread is 11659. The root solver is failing. My question is… is there anything that could be done to control the root solver in this case? i.e. adjust the tolerance or some other work around? Date Ticker ShortName RedCode Tier Ccy DocClause Spread6m Spread1y Spread2y Spread3y Spread4y Spread5y Spread7y Spread10y 2023-04-24 GROUPE CASINO GUICHARDPERRACHON FG554O SNRFOR EUR MM14 1.16596253 1.22492036 1.06136462 0.98585902 0.93722387 0.90058129 0.84189616 0.78298615 1st iteration: failed at 1st alive instrument, pillar December 20th, 2023, maturity December 20th, 2023, reference date April 26th, 2023: root not bracketed: f[2.22045e-16,1] -> [1.165963e+00,3.797374e-01] |
|
From: Ngonidzashe F. <ngo...@gm...> - 2023-04-25 16:05:14
|
Hi, The ‘AmortizingFixedBond’ class works fine thanks. Regards On Mon, 24 Apr 2023 at 10:54, Luigi Ballabio <lui...@gm...> wrote: > Or you can use the `AmortizingFixedRateBond` class (see > https://github.com/lballabio/QuantLib/blob/master/ql/instruments/bonds/amortizingfixedratebond.hpp > ). > > Luigi > > > On Mon, Apr 24, 2023 at 12:35 AM Ben Watson < > ben...@ma...> wrote: > >> I would suggest that you build the bond from the cashflows… The bond >> cashflows >> >> i.e. >> >> bond=ql.Bond(int(self.settlementDays), self.local_calendar, self. >> start_date,self.bond_cashflows) >> >> >> >> the cashflows can be with FixedRate leg or FloatingRate Leg; >> >> >> >> ql.FixedRateLeg(schedule=self.extended_dates_schedule,dayCount = >> fixedDayCount,nominals = [self.redemption],couponRates=self.extended_cpns >> ) >> > >> >> >> >> >> >> >> >> *From:* Ngonidzashe Fungura <ngo...@gm...> >> *Sent:* Monday, April 24, 2023 1:24 AM >> *To:* QuantLib users <qua...@li...> >> *Subject:* [Quantlib-users] Fixed Coupon Bond with 3 equal redemptions >> of capital >> >> >> >> Hi All, >> >> >> >> I have a valuation of a fixed coupon bond below and I need help with the >> following; >> >> 1. The repayment of the capital shall be made in three equal amounts >> on the following dates: 30 April 2030, 30 April 2031, 30 April 2032. One >> third of the nominal value of the loan will be redeemed on the above >> mentioned dates, after which no further interest will accrue on the >> redeemed portion. >> 2. Extraction of the following values (i) nominal value, (ii) cash >> flows (i.e., coupon and redeemed capital), (iii) payment date, (iv) accrual >> start date, (v) accrual end date, (vi) accrual period, (vii) discount >> factor and (vii) PV of cash flows >> >> *Valuation* >> >> >> import QuantLib as ql >> >> calc_date = ql.Date(30, 6, 2022) >> ql.Settings.instance().evaluationDate = calc_date >> spot_dates = [ql.Date(30,6,2022), ql.Date(1,7,2022), >> ql.Date(4,7,2022), ql.Date(7,7,2022), >> ql.Date(29,7,2022), ql.Date(31,8,2022), >> ql.Date(30,9,2022), ql.Date(30,12,2022), >> ql.Date(31,3,2023), ql.Date(30,6,2023), >> ql.Date(28,6,2024), ql.Date(30,6,2025), >> ql.Date(30,6,2026), ql.Date(30,6,2027), >> ql.Date(30,6,2028), ql.Date(29,6,2029), >> ql.Date(28,6,2030), ql.Date(30,6,2031), >> ql.Date(30,6,2032), ql.Date(30,6,2034), >> ql.Date(30,6,2037), ql.Date(30,6,2042), >> ql.Date(28,6,2047), ql.Date(28,6,2052)] >> spot_rates = [0.000000, 0.046757, 0.047312, 0.047849, >> 0.049859, 0.049461, 0.051026, 0.063041, >> 0.069505, 0.074170, 0.074904, 0.079587, >> 0.082547, 0.085506, 0.088410, 0.091284, >> 0.093731, 0.095888, 0.097472, 0.099379, >> 0.100715, 0.100591, 0.099606, 0.097955] >> day_count = ql.Thirty360() >> calendar = ql.UnitedStates() >> interpolation = ql.Linear() >> compounding = ql.Compounded >> compounding_frequency = ql.Annual >> spot_curve = ql.ZeroCurve(spot_dates, spot_rates, day_count, calendar, >> interpolation, compounding, compounding_frequency) >> spot_curve_handle = ql.YieldTermStructureHandle(spot_curve) >> >> issue_date = ql.Date(30, 4, 2022) >> maturity_date = ql.Date(30, 4, 2032) >> tenor = ql.Period(ql.Semiannual) >> calendar = ql.SouthAfrica() >> business_convention = ql.Unadjusted >> date_generation = ql.DateGeneration.Backward >> month_end = False >> schedule = ql.Schedule(issue_date, maturity_date, tenor, >> calendar, business_convention, >> business_convention, date_generation, >> month_end) >> >> # Let us print the schedule to check if it is in agreement with what we expect it to be. >> print("Payment dates: ",list(schedule)) >> >> # Now that we have the schedule, we can create the FixedRateBond object. >> coupon_rate = 0.105 >> coupons = [coupon_rate] >> settlement_days = 0 >> face_value = 100 >> fixed_rate_bond = ql.FixedRateBond(settlement_days,face_value,schedule,coupons,day_count) >> >> bond_engine = ql.DiscountingBondEngine(spot_curve_handle) >> fixed_rate_bond.setPricingEngine(bond_engine) >> >> print("NPV of Bond:",round(fixed_rate_bond.NPV(),2)) >> >> print("Clean Bond Price:",round(fixed_rate_bond.cleanPrice(),2)) >> >> print('Accrual start date:', ql.BondFunctions.accrualStartDate(fixed_rate_bond)) >> >> print('Accrual end date:', ql.BondFunctions.accrualEndDate(fixed_rate_bond)) >> >> print('Number of days between accrual start date and accrual end date:', >> day_count.dayCount(ql.BondFunctions.accrualStartDate(fixed_rate_bond), >> ql.BondFunctions.accrualEndDate(fixed_rate_bond))) >> >> print('Accrued days:', ql.BondFunctions.accruedDays(fixed_rate_bond)) >> >> print("Accrued Amount:",round(fixed_rate_bond.accruedAmount(),2)) >> >> print("Dirty Bond Price:",round(fixed_rate_bond.dirtyPrice(),2)) >> >> print("Bond yield:",round(fixed_rate_bond.bondYield(day_count,compounding,compounding_frequency),5)) >> >> print("Day Count:",fixed_rate_bond.dayCounter()) >> >> print("Settlement Date:",fixed_rate_bond.settlementDate()) >> >> for c in fixed_rate_bond.cashflows(): >> print('%20s %12f' % (c.date(), c.amount())) >> >> Thanks >> >> >> > _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > -- Kind regards, Ngoni Fungura Mobile: +27(0)644126086 |