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: Luigi B. <lui...@gm...> - 2024-01-16 10:31:19
|
Hello,
shallow copy is the C++ default, and I'm afraid we never bothered with
deep copy since most of the time ters structures are passed around by
shared_ptr anyway.
If BASE_TS is your derived class, you can implement a copy constructor.
Otherwise, do you really need a copy to add a spread? As an alternative,
you might pass around your original base term structure and add a constant
spread by means of a class like ZeroSpreadedTermStructure (see
https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerospreadedtermstructure.hpp
).
Hope this helps,
Luigi
On Tue, Jan 2, 2024 at 6:55 AM Wei Li <ttl...@gm...> wrote:
> Dear all,
>
> Happy new year to all!
>
> In our c++ project we are caching our term structures / vol surfaces
> calibrated from real time market data. And during the calculation we need
> to assign different spread values for different trades. For example, for
> TRADE_A, the risk free term structure would be BASE_TS with a constant 0.01
> spread, and for TRADE_B, it would be the same BASE_TS with a constant 0.02
> spread. And we are caching BASE_TS since it makes only sense to us (we have
> our derived classes of YieldTermStructure and VolTermStructure to add the
> spreads, in case you were wondering).
>
> But how can I make a deep copy of BASE_TS and use this copy with arbitrary
> spread values to the calculation? I tried the (default) copy
> constructors of the classes and they are apparently shallow-copied. So how
> can I achieve this? It doesn't need to be the deep copy of the bases, it
> can also be the deep copy of the shared_ptr / handle, as long as it does
> the trick.
>
> Thank you very much!
>
> Cheers,
> Wei
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: GESI L. <ge...@gm...> - 2024-01-13 15:45:22
|
Unsubscribe On Fri, Jan 12, 2024, 5:19 AM <qua...@li...> wrote: > Send QuantLib-users mailing list submissions to > qua...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/quantlib-users > or, via email, send a message with subject or body 'help' to > qua...@li... > > You can reach the person managing the list at > qua...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of QuantLib-users digest..." > Today's Topics: > > 1. Re: Two factor model (Luigi Ballabio) > > > > ---------- Forwarded message ---------- > From: Luigi Ballabio <lui...@gm...> > To: Philippe Hatstadt <phi...@ex...> > Cc: philippe hatstadt <pha...@ma...>, > qua...@li... > Bcc: > Date: Fri, 12 Jan 2024 10:03:59 +0100 > Subject: Re: [Quantlib-users] Two factor model > Hello Philippe, > the G2 model is exported. It can be calibrated in the same way as the > other one-factor models. > > Hope this helps, > Luigi > > > On Tue, Jan 9, 2024 at 4:05 PM Philippe Hatstadt < > phi...@ex...> wrote: > >> Bumping this in case anyone knows. >> >> Regards >> >> Philippe Hatstadt >> +1-203-252-0408 >> >> >> > On Dec 11, 2023, at 11:06 AM, philippe hatstadt <pha...@ma...> >> wrote: >> > >> > Is there any QL 2 factor rate model implementation that has been >> exposed to Python? I am working on a CMBS Pool OAS model and need the >> ability to de-correlate short rates and long rates. >> > But I would also need a calibration module to swaption vols and some >> way to calibrate the correlation parameters to match correlation matrices >> or rate changes by tenors. >> > >> > Please let me know. >> > >> > Regards >> > >> > Philippe Hatstadt >> > +1-203-252-0408 >> > >> >> -- >> >> >> 1370 Broadway, Suite 1450 | New York, NY | 10018 >> >> >> <https://www.exosfinancial.com/> >> <https://www.linkedin.com/company/meetexos/about/> >> >> >> Broker-Dealer >> services offered through Exos Securities LLC, Member SIPC, FINRA. For >> important disclosures including Form CRS and Regulation BI click here >> <https://www.exosfinancial.com/general-disclosures>. >> >> >> >> >> >> Confidentiality >> Notice: The information contained in this email (including attachments) >> is >> only for the personal and confidential use of the sender and recipient >> named above. If the reader is not the intended recipient, you are >> notified >> that you have received this message in error and that any review, >> dissemination, copying or distribution is prohibited. If you have >> received >> this communication in error, please notify the sender immediately by >> e-mail >> and delete or destroy the original message and all copies. >> >> >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Luigi B. <lui...@gm...> - 2024-01-12 09:04:23
|
Hello Philippe,
the G2 model is exported. It can be calibrated in the same way as the
other one-factor models.
Hope this helps,
Luigi
On Tue, Jan 9, 2024 at 4:05 PM Philippe Hatstadt <
phi...@ex...> wrote:
> Bumping this in case anyone knows.
>
> Regards
>
> Philippe Hatstadt
> +1-203-252-0408
>
>
> > On Dec 11, 2023, at 11:06 AM, philippe hatstadt <pha...@ma...>
> wrote:
> >
> > Is there any QL 2 factor rate model implementation that has been
> exposed to Python? I am working on a CMBS Pool OAS model and need the
> ability to de-correlate short rates and long rates.
> > But I would also need a calibration module to swaption vols and some way
> to calibrate the correlation parameters to match correlation matrices or
> rate changes by tenors.
> >
> > Please let me know.
> >
> > Regards
> >
> > Philippe Hatstadt
> > +1-203-252-0408
> >
>
> --
>
>
> 1370 Broadway, Suite 1450 | New York, NY | 10018
>
>
> <https://www.exosfinancial.com/>
> <https://www.linkedin.com/company/meetexos/about/>
>
>
> Broker-Dealer
> services offered through Exos Securities LLC, Member SIPC, FINRA. For
> important disclosures including Form CRS and Regulation BI click here
> <https://www.exosfinancial.com/general-disclosures>.
>
>
>
>
>
> Confidentiality
> Notice: The information contained in this email (including attachments) is
> only for the personal and confidential use of the sender and recipient
> named above. If the reader is not the intended recipient, you are notified
> that you have received this message in error and that any review,
> dissemination, copying or distribution is prohibited. If you have received
> this communication in error, please notify the sender immediately by
> e-mail
> and delete or destroy the original message and all copies.
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Philippe H. <phi...@ex...> - 2024-01-09 15:02:01
|
Bumping this in case anyone knows. Regards Philippe Hatstadt +1-203-252-0408 > On Dec 11, 2023, at 11:06 AM, philippe hatstadt <pha...@ma...> wrote: > > Is there any QL 2 factor rate model implementation that has been exposed to Python? I am working on a CMBS Pool OAS model and need the ability to de-correlate short rates and long rates. > But I would also need a calibration module to swaption vols and some way to calibrate the correlation parameters to match correlation matrices or rate changes by tenors. > > Please let me know. > > Regards > > Philippe Hatstadt > +1-203-252-0408 > -- 1370 Broadway, Suite 1450 | New York, NY | 10018 <https://www.exosfinancial.com/> <https://www.linkedin.com/company/meetexos/about/> Broker-Dealer services offered through Exos Securities LLC, Member SIPC, FINRA. For important disclosures including Form CRS and Regulation BI click here <https://www.exosfinancial.com/general-disclosures>. Confidentiality Notice: The information contained in this email (including attachments) is only for the personal and confidential use of the sender and recipient named above. If the reader is not the intended recipient, you are notified that you have received this message in error and that any review, dissemination, copying or distribution is prohibited. If you have received this communication in error, please notify the sender immediately by e-mail and delete or destroy the original message and all copies. |
|
From: Quant <qua...@gm...> - 2024-01-09 12:23:24
|
Hi Luigi, Thanks for the update. Is it possible to add the Monotone convex (ameliorated) which is the smoothed version on the next updates? From the looks of the Zero and Forward Curves that I obtained, it seems the currently implemented one is the Monotone convex (unameliorated) version which is only using the neighboring nodes. Thanks & regards, On Fri, Jan 5, 2024 at 11:32 AM Luigi Ballabio <lui...@gm...> wrote: > Done in https://github.com/lballabio/QuantLib-SWIG/pull/603. It will be > in version 1.33. > > Luigi > > On Wed, Dec 27, 2023 at 12:02 PM Peter Caspers <pca...@gm...> > wrote: > >> Hi, >> >> what I meant is that we should export >> >> >> export_piecewise_curve(PiecewiseConvexMonotoneForward,ForwardRate,ConvexMonotone); >> >> instead of "PiecewiseConvexMonotoneZero" and use that. >> >> I am not sure if that explains your issues, since I never tried to use >> convex monotone interpolation with the zero yield as the interpolation >> variable. >> >> Thank you >> Peter >> >> On Tue, 26 Dec 2023 at 21:46, Quant <qua...@gm...> wrote: >> > >> > Hi Peter, >> > >> > Thanks for the feedback. The workaround you suggested of avoiding the >> extrapolation of the curve worked and also removing the "Forward Rate" in >> the node_data as the forward rate is not exported in SWIG as you indicated. >> I think it will be helpful if the forward rates can be exported in SWIG as >> well on the next updates. >> > >> > I did 2 plots for the PiecewiseLogCubicDiscount and the >> PiecewiseConvexMonotoneZero for both zero and forward rates curves (tried >> to attach the plots but the email became too large i.e., more than 100KB to >> be posted). The PiecewiseConvexMonotoneZero is not smooth (quite weird >> curve) and I was wondering if the one implemented in QuantLib is the >> "Monotone convex (unameliorated)" described in the Hagan and West Paper as >> the best interpolation method? Is it perhaps possible to add the smoothed >> version of the interpolation on the upcoming updates? Please note that the >> plots below are related to the bootstrapping of government bonds. >> > >> > On a separate note, I tried using PiecewiseConvexMonotoneZero on >> deposits + FRA + Swap Rates bootstrapping and I got the following error; >> > >> > Traceback (most recent call last): >> > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib >> Software/Valuations/Valuation of ZAR IRS/ZAR IRS Valuation 2.py", line 115, >> in <module> >> > zero_rate = curve.zeroRate(date, day_count, ql.Annual).rate() >> > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", >> line 8610, in zeroRate >> > return _QuantLib.YieldTermStructure_zeroRate(self, *args) >> > RuntimeError: 1st iteration: failed at 13th alive instrument, pillar >> May 28th, 2020, maturity May 28th, 2020, reference date February 28th, >> 2019: root not bracketed: f[-1,1] -> [-1.339261e-01,-1.181714e+01] >> > >> > >> > What could be the cause of the error on this one? >> > >> > Thanks and regards, >> > >> > On Mon, Dec 25, 2023 at 8:17 PM Peter Caspers <pca...@gm...> >> wrote: >> >> >> >> Hi, the error is probably generated here >> >> >> >> >> https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerocurve.hpp#L168 >> >> >> >> so a workaround would be to avoid extrapolating the curve. >> >> >> >> In fact I think the convex monotone interpolation was designed to be >> >> applied to forward rates rather than zero yields, see >> >> >> >> https://downloads.dxfeed.com/specifications/dxLibOptions/HaganWest.pdf >> >> >> >> in section 6. But it seems only zero yield is exported as an >> >> interpolation variable in SWIG at the moment >> >> >> >> >> https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/piecewiseyieldcurve.i#L168 >> >> >> >> We should add forward rate here I guess? >> >> >> >> Best >> >> Peter >> >> >> >> On Sun, 24 Dec 2023 at 15:18, Quant <qua...@gm...> wrote: >> >> > >> >> > Hi QuantLib Users, >> >> > >> >> > I am trying to implement the Convex Monotone interpolation as shown >> below; >> >> > >> >> > curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count) >> >> > # curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers, >> day_count) >> >> > # curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count) >> >> > >> >> > # Enable Extrapolation: >> >> > # This line enables extrapolation for the yield curve. >> >> > # Extrapolation allows the curve to provide interest rates or rates >> beyond the observed data points, >> >> > # which can be useful for pricing or risk management purposes. >> >> > curve.enableExtrapolation() >> >> > >> >> > # Print the Zero Rates, Forward Rates and Discount Factors at node >> dates >> >> > # print(pd.DataFrame(curve.nodes())) >> >> > node_data = {'Date': [], >> >> > 'Zero Rates': [], >> >> > 'Forward Rates': [], >> >> > 'Discount Factors': []} >> >> > >> >> > for dt in curve.dates(): >> >> > node_data['Date'].append(dt) >> >> > node_data['Zero Rates'].append(curve.zeroRate(dt, day_count, >> ql.Compounded, ql.Annual).rate()) >> >> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + >> ql.Period(1, ql.Years), day_count, ql.Annual).rate()) >> >> > node_data['Discount Factors'].append(curve.discount(dt)) >> >> > >> >> > node_dataframe = pd.DataFrame(node_data) >> >> > >> >> > And I am getting the following error; >> >> > >> >> > Traceback (most recent call last): >> >> > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib >> Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond >> Bootstrapping 3.py", line 87, in <module> >> >> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + >> ql.Period(1, ql.Years), day_count, ql.Annual).rate()) >> >> > File >> "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line 8617, >> in forwardRate >> >> > return _QuantLib.YieldTermStructure_forwardRate(self, *args) >> >> > RuntimeError: Convex-monotone spline derivative not implemented >> >> > >> >> > Is this a known issue with PiecewiseConvexMonotoneZero or it's an >> error that can be fixed in my code? If it can be fixed where do I need to >> fix? >> >> > >> >> > Thanks & regards, >> >> > _______________________________________________ >> >> > QuantLib-users mailing list >> >> > Qua...@li... >> >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> >> >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > |
|
From: Dirk E. <ed...@de...> - 2024-01-09 04:47:47
|
Looks good in Debian builds as 1.32.99 (usual renaming to allow a.b.c sorting once 1.33.0 is out): https://buildd.debian.org/status/package.php?p=quantlib Dirk -- dirk.eddelbuettel.com | @eddelbuettel | ed...@de... |
|
From: Luigi B. <lui...@gm...> - 2024-01-08 20:50:50
|
Prerelease Python wheels are also available from TestPyPi; use
pip install -i https://test.pypi.org/simple/ QuantLib==1.33rc0
There is also an experimental, no-guarantees nupkg for C#; see
https://int.nugettest.org/packages/QuantLib/1.33.0-rc.
Luigi
On Mon, Jan 8, 2024 at 3:50 PM Luigi Ballabio <lui...@gm...>
wrote:
> Hello everybody,
> I just published sources for a release candidate for 1.33 at <
> https://github.com/lballabio/QuantLib/releases/tag/v1.33rc>. If you have
> some time, please try them out this week or the next and report any
> problems here. Thanks!
>
> Luigi
>
>
|
|
From: Luigi B. <lui...@gm...> - 2024-01-08 14:50:50
|
Hello everybody,
I just published sources for a release candidate for 1.33 at <
https://github.com/lballabio/QuantLib/releases/tag/v1.33rc>. If you have
some time, please try them out this week or the next and report any
problems here. Thanks!
Luigi
|
|
From: Luigi B. <lui...@gm...> - 2024-01-05 09:32:36
|
Done in https://github.com/lballabio/QuantLib-SWIG/pull/603. It will be in version 1.33. Luigi On Wed, Dec 27, 2023 at 12:02 PM Peter Caspers <pca...@gm...> wrote: > Hi, > > what I meant is that we should export > > > export_piecewise_curve(PiecewiseConvexMonotoneForward,ForwardRate,ConvexMonotone); > > instead of "PiecewiseConvexMonotoneZero" and use that. > > I am not sure if that explains your issues, since I never tried to use > convex monotone interpolation with the zero yield as the interpolation > variable. > > Thank you > Peter > > On Tue, 26 Dec 2023 at 21:46, Quant <qua...@gm...> wrote: > > > > Hi Peter, > > > > Thanks for the feedback. The workaround you suggested of avoiding the > extrapolation of the curve worked and also removing the "Forward Rate" in > the node_data as the forward rate is not exported in SWIG as you indicated. > I think it will be helpful if the forward rates can be exported in SWIG as > well on the next updates. > > > > I did 2 plots for the PiecewiseLogCubicDiscount and the > PiecewiseConvexMonotoneZero for both zero and forward rates curves (tried > to attach the plots but the email became too large i.e., more than 100KB to > be posted). The PiecewiseConvexMonotoneZero is not smooth (quite weird > curve) and I was wondering if the one implemented in QuantLib is the > "Monotone convex (unameliorated)" described in the Hagan and West Paper as > the best interpolation method? Is it perhaps possible to add the smoothed > version of the interpolation on the upcoming updates? Please note that the > plots below are related to the bootstrapping of government bonds. > > > > On a separate note, I tried using PiecewiseConvexMonotoneZero on > deposits + FRA + Swap Rates bootstrapping and I got the following error; > > > > Traceback (most recent call last): > > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib > Software/Valuations/Valuation of ZAR IRS/ZAR IRS Valuation 2.py", line 115, > in <module> > > zero_rate = curve.zeroRate(date, day_count, ql.Annual).rate() > > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", > line 8610, in zeroRate > > return _QuantLib.YieldTermStructure_zeroRate(self, *args) > > RuntimeError: 1st iteration: failed at 13th alive instrument, pillar May > 28th, 2020, maturity May 28th, 2020, reference date February 28th, 2019: > root not bracketed: f[-1,1] -> [-1.339261e-01,-1.181714e+01] > > > > > > What could be the cause of the error on this one? > > > > Thanks and regards, > > > > On Mon, Dec 25, 2023 at 8:17 PM Peter Caspers <pca...@gm...> > wrote: > >> > >> Hi, the error is probably generated here > >> > >> > https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerocurve.hpp#L168 > >> > >> so a workaround would be to avoid extrapolating the curve. > >> > >> In fact I think the convex monotone interpolation was designed to be > >> applied to forward rates rather than zero yields, see > >> > >> https://downloads.dxfeed.com/specifications/dxLibOptions/HaganWest.pdf > >> > >> in section 6. But it seems only zero yield is exported as an > >> interpolation variable in SWIG at the moment > >> > >> > https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/piecewiseyieldcurve.i#L168 > >> > >> We should add forward rate here I guess? > >> > >> Best > >> Peter > >> > >> On Sun, 24 Dec 2023 at 15:18, Quant <qua...@gm...> wrote: > >> > > >> > Hi QuantLib Users, > >> > > >> > I am trying to implement the Convex Monotone interpolation as shown > below; > >> > > >> > curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count) > >> > # curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers, > day_count) > >> > # curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count) > >> > > >> > # Enable Extrapolation: > >> > # This line enables extrapolation for the yield curve. > >> > # Extrapolation allows the curve to provide interest rates or rates > beyond the observed data points, > >> > # which can be useful for pricing or risk management purposes. > >> > curve.enableExtrapolation() > >> > > >> > # Print the Zero Rates, Forward Rates and Discount Factors at node > dates > >> > # print(pd.DataFrame(curve.nodes())) > >> > node_data = {'Date': [], > >> > 'Zero Rates': [], > >> > 'Forward Rates': [], > >> > 'Discount Factors': []} > >> > > >> > for dt in curve.dates(): > >> > node_data['Date'].append(dt) > >> > node_data['Zero Rates'].append(curve.zeroRate(dt, day_count, > ql.Compounded, ql.Annual).rate()) > >> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + > ql.Period(1, ql.Years), day_count, ql.Annual).rate()) > >> > node_data['Discount Factors'].append(curve.discount(dt)) > >> > > >> > node_dataframe = pd.DataFrame(node_data) > >> > > >> > And I am getting the following error; > >> > > >> > Traceback (most recent call last): > >> > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib > Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond > Bootstrapping 3.py", line 87, in <module> > >> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + > ql.Period(1, ql.Years), day_count, ql.Annual).rate()) > >> > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", > line 8617, in forwardRate > >> > return _QuantLib.YieldTermStructure_forwardRate(self, *args) > >> > RuntimeError: Convex-monotone spline derivative not implemented > >> > > >> > Is this a known issue with PiecewiseConvexMonotoneZero or it's an > error that can be fixed in my code? If it can be fixed where do I need to > fix? > >> > > >> > Thanks & regards, > >> > _______________________________________________ > >> > QuantLib-users mailing list > >> > Qua...@li... > >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Jan P. <jan...@da...> - 2024-01-03 20:24:17
|
Hello Jonathan, Thank you for your prompt answer and clarification. We will make them running separately as per your suggestion. Best, Jan P. From: Jonathan Sweemer <sw...@gm...> Date: Tuesday, January 2, 2024 at 16:20 To: Jan Pandoscak <jan...@da...> Cc: Efren Belizario <efr...@da...>, Martin Adamec <mar...@da...>, "qua...@li..." <qua...@li...> Subject: [<<EXT>>] Re: [Quantlib-users] multi-threading question Hi Jan, If possible, you should use multiple separate processes instead of multiple threads within a process. QuantLib data structures are not thread-safe. See this link for more details: https://stackoverflow.com/questions/46934259/what-is-the-right-way-to-use-quantlib-from-multiple-threads Regarding the build options, there is one to enable the thread-safe observer pattern, but this is designed mainly to make callbacks safe in garbage-collected languages, not to make the whole library thread-safe. 2024년 1월 3일 (수) 02:50, Jan Pandoscak via QuantLib-users <qua...@li...<mailto:qua...@li...>>님이 작성: Hello QL community, I would like to ask. We are planning a task of manipulating the date for stock option calculations. The intention is to be able to make the process parallel in multiple threads. I have some experience with QL compilation, but I do not have any deep knowledge of it. I’m sysadmin with no trading and a limited Python experience (which we use for calculations). I have seen there are command line options to modify the thread-safety configuration prior the compilation. Can someone advice whether we need to modify the configuration to be able to multithread the tasks or if the default compilation setting would do it just right? Kind regards, Jan Pandoscak System Administrator DataDock Solutions _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Jonathan S. <sw...@gm...> - 2024-01-02 21:20:50
|
Hi Jan, If possible, you should use multiple separate processes instead of multiple threads within a process. QuantLib data structures are not thread-safe. See this link for more details: https://stackoverflow.com/questions/46934259/what-is-the-right-way-to-use-quantlib-from-multiple-threads Regarding the build options, there is one to enable the thread-safe observer pattern, but this is designed mainly to make callbacks safe in garbage-collected languages, not to make the whole library thread-safe. 2024년 1월 3일 (수) 02:50, Jan Pandoscak via QuantLib-users < qua...@li...>님이 작성: > Hello QL community, > > > > I would like to ask. We are planning a task of manipulating the date for > stock option calculations. The intention is to be able to make the process > parallel in multiple threads. I have some experience with QL compilation, > but I do not have any deep knowledge of it. I’m sysadmin with no trading > and a limited Python experience (which we use for calculations). > > > > I have seen there are command line options to modify the thread-safety > configuration prior the compilation. Can someone advice whether we need to > modify the configuration to be able to multithread the tasks or if the > default compilation setting would do it just right? > > > > > > Kind regards, > > > > Jan Pandoscak > > System Administrator > > DataDock Solutions > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Jan P. <jan...@da...> - 2024-01-02 17:46:59
|
Hello QL community, I would like to ask. We are planning a task of manipulating the date for stock option calculations. The intention is to be able to make the process parallel in multiple threads. I have some experience with QL compilation, but I do not have any deep knowledge of it. I’m sysadmin with no trading and a limited Python experience (which we use for calculations). I have seen there are command line options to modify the thread-safety configuration prior the compilation. Can someone advice whether we need to modify the configuration to be able to multithread the tasks or if the default compilation setting would do it just right? Kind regards, Jan Pandoscak System Administrator DataDock Solutions |
|
From: Wei Li <ttl...@gm...> - 2024-01-02 05:52:23
|
Dear all, Happy new year to all! In our c++ project we are caching our term structures / vol surfaces calibrated from real time market data. And during the calculation we need to assign different spread values for different trades. For example, for TRADE_A, the risk free term structure would be BASE_TS with a constant 0.01 spread, and for TRADE_B, it would be the same BASE_TS with a constant 0.02 spread. And we are caching BASE_TS since it makes only sense to us (we have our derived classes of YieldTermStructure and VolTermStructure to add the spreads, in case you were wondering). But how can I make a deep copy of BASE_TS and use this copy with arbitrary spread values to the calculation? I tried the (default) copy constructors of the classes and they are apparently shallow-copied. So how can I achieve this? It doesn't need to be the deep copy of the bases, it can also be the deep copy of the shared_ptr / handle, as long as it does the trick. Thank you very much! Cheers, Wei |
|
From: Francois B. <ig...@gm...> - 2024-01-01 15:36:45
|
Hi Robert, I don't know much about ASX dates, but I can see in the code at https://github.com/lballabio/QuantLib/blob/7dfe04c3797552f8853f0368eb8f7c07ef7051cd/ql/time/asx.cpp#L38 that if the relevant date is not a Friday, it is not considered valid. 13 March 2024 is a Thursday and that's why you're seeing the message. Whether the business logic behind that function is sound... I don't know. regards Francois Botha On Mon, 1 Jan 2024 at 11:28, Robert Chapman <rob...@gm...> wrote: > Has anyone run into this problem? I'm trying to use New Zealand 90 Day > Bank Bill Futures to build a curve. > When I try to create the helper, I'm getting: March 13th, 2024 is not a > valid ASX date > > > > ############################################################### > > # ZBH4 Comdty > > # SFE NZ 90 Day Bank Bill Future Contract (Sydney > Futures Exchange) > > # RuntimeError: March 13th, 2024 is not a valid ASX > date > > helper = ql.FuturesRateHelper(94.46, > > ql.Date(13, 3, 2024), > > ql.Date(), > > ql.Actual365Fixed(), > > 0.0, > > ql.Futures.ASX) > > > > It works for an ASX futures contract: > > > > ############################################################### > > # IRH4 Comdty > > # ASX 90 Day Bank Accepted Bills Future Contract > > # *works fine !* > > helper = ql.FuturesRateHelper(95.720, > > ql.Date(8, 3, 2024), > > ql.Date(), > > ql.Actual365Fixed(), > > 0.0, > > ql.Futures.ASX) > > > > print(f'helper maturity date: {helper.maturityDate()}' > ) > > > ############################################################### > > Do I need to build a custom helper or something? > > > > Robert Chapman > +61 418 693 633 > rob...@gm... > au.linkedin.com/in/robertchapman2095 > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Robert C. <rob...@gm...> - 2024-01-01 09:24:54
|
Has anyone run into this problem? I'm trying to use New Zealand 90 Day
Bank Bill Futures to build a curve.
When I try to create the helper, I'm getting: March 13th, 2024 is not a
valid ASX date
###############################################################
# ZBH4 Comdty
# SFE NZ 90 Day Bank Bill Future Contract (Sydney
Futures Exchange)
# RuntimeError: March 13th, 2024 is not a valid ASX date
helper = ql.FuturesRateHelper(94.46,
ql.Date(13, 3, 2024),
ql.Date(),
ql.Actual365Fixed(),
0.0,
ql.Futures.ASX)
It works for an ASX futures contract:
###############################################################
# IRH4 Comdty
# ASX 90 Day Bank Accepted Bills Future Contract
# *works fine !*
helper = ql.FuturesRateHelper(95.720,
ql.Date(8, 3, 2024),
ql.Date(),
ql.Actual365Fixed(),
0.0,
ql.Futures.ASX)
print(f'helper maturity date: {helper.maturityDate()}')
###############################################################
Do I need to build a custom helper or something?
Robert Chapman
+61 418 693 633
rob...@gm...
au.linkedin.com/in/robertchapman2095
|
|
From: Peter C. <pca...@gm...> - 2023-12-27 10:59:43
|
Hi, what I meant is that we should export export_piecewise_curve(PiecewiseConvexMonotoneForward,ForwardRate,ConvexMonotone); instead of "PiecewiseConvexMonotoneZero" and use that. I am not sure if that explains your issues, since I never tried to use convex monotone interpolation with the zero yield as the interpolation variable. Thank you Peter On Tue, 26 Dec 2023 at 21:46, Quant <qua...@gm...> wrote: > > Hi Peter, > > Thanks for the feedback. The workaround you suggested of avoiding the extrapolation of the curve worked and also removing the "Forward Rate" in the node_data as the forward rate is not exported in SWIG as you indicated. I think it will be helpful if the forward rates can be exported in SWIG as well on the next updates. > > I did 2 plots for the PiecewiseLogCubicDiscount and the PiecewiseConvexMonotoneZero for both zero and forward rates curves (tried to attach the plots but the email became too large i.e., more than 100KB to be posted). The PiecewiseConvexMonotoneZero is not smooth (quite weird curve) and I was wondering if the one implemented in QuantLib is the "Monotone convex (unameliorated)" described in the Hagan and West Paper as the best interpolation method? Is it perhaps possible to add the smoothed version of the interpolation on the upcoming updates? Please note that the plots below are related to the bootstrapping of government bonds. > > On a separate note, I tried using PiecewiseConvexMonotoneZero on deposits + FRA + Swap Rates bootstrapping and I got the following error; > > Traceback (most recent call last): > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib Software/Valuations/Valuation of ZAR IRS/ZAR IRS Valuation 2.py", line 115, in <module> > zero_rate = curve.zeroRate(date, day_count, ql.Annual).rate() > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line 8610, in zeroRate > return _QuantLib.YieldTermStructure_zeroRate(self, *args) > RuntimeError: 1st iteration: failed at 13th alive instrument, pillar May 28th, 2020, maturity May 28th, 2020, reference date February 28th, 2019: root not bracketed: f[-1,1] -> [-1.339261e-01,-1.181714e+01] > > > What could be the cause of the error on this one? > > Thanks and regards, > > On Mon, Dec 25, 2023 at 8:17 PM Peter Caspers <pca...@gm...> wrote: >> >> Hi, the error is probably generated here >> >> https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerocurve.hpp#L168 >> >> so a workaround would be to avoid extrapolating the curve. >> >> In fact I think the convex monotone interpolation was designed to be >> applied to forward rates rather than zero yields, see >> >> https://downloads.dxfeed.com/specifications/dxLibOptions/HaganWest.pdf >> >> in section 6. But it seems only zero yield is exported as an >> interpolation variable in SWIG at the moment >> >> https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/piecewiseyieldcurve.i#L168 >> >> We should add forward rate here I guess? >> >> Best >> Peter >> >> On Sun, 24 Dec 2023 at 15:18, Quant <qua...@gm...> wrote: >> > >> > Hi QuantLib Users, >> > >> > I am trying to implement the Convex Monotone interpolation as shown below; >> > >> > curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count) >> > # curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers, day_count) >> > # curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count) >> > >> > # Enable Extrapolation: >> > # This line enables extrapolation for the yield curve. >> > # Extrapolation allows the curve to provide interest rates or rates beyond the observed data points, >> > # which can be useful for pricing or risk management purposes. >> > curve.enableExtrapolation() >> > >> > # Print the Zero Rates, Forward Rates and Discount Factors at node dates >> > # print(pd.DataFrame(curve.nodes())) >> > node_data = {'Date': [], >> > 'Zero Rates': [], >> > 'Forward Rates': [], >> > 'Discount Factors': []} >> > >> > for dt in curve.dates(): >> > node_data['Date'].append(dt) >> > node_data['Zero Rates'].append(curve.zeroRate(dt, day_count, ql.Compounded, ql.Annual).rate()) >> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + ql.Period(1, ql.Years), day_count, ql.Annual).rate()) >> > node_data['Discount Factors'].append(curve.discount(dt)) >> > >> > node_dataframe = pd.DataFrame(node_data) >> > >> > And I am getting the following error; >> > >> > Traceback (most recent call last): >> > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond Bootstrapping 3.py", line 87, in <module> >> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + ql.Period(1, ql.Years), day_count, ql.Annual).rate()) >> > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line 8617, in forwardRate >> > return _QuantLib.YieldTermStructure_forwardRate(self, *args) >> > RuntimeError: Convex-monotone spline derivative not implemented >> > >> > Is this a known issue with PiecewiseConvexMonotoneZero or it's an error that can be fixed in my code? If it can be fixed where do I need to fix? >> > >> > Thanks & regards, >> > _______________________________________________ >> > QuantLib-users mailing list >> > Qua...@li... >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Quant <qua...@gm...> - 2023-12-26 20:46:25
|
Hi Peter,
Thanks for the feedback. The workaround you suggested of avoiding the
extrapolation of the curve worked and also removing the "Forward Rate" in
the node_data as the forward rate is not exported in SWIG as you indicated.
I think it will be helpful if the forward rates can be exported in SWIG as
well on the next updates.
I did 2 plots for the PiecewiseLogCubicDiscount and the
PiecewiseConvexMonotoneZero for both zero and forward rates curves (tried
to attach the plots but the email became too large i.e., more than 100KB to
be posted). The PiecewiseConvexMonotoneZero is not smooth (quite weird
curve) and I was wondering if the one implemented in QuantLib is the
"Monotone convex (unameliorated)" described in the Hagan and West Paper as
the best interpolation method? Is it perhaps possible to add the smoothed
version of the interpolation on the upcoming updates? Please note that the
plots below are related to the bootstrapping of government bonds.
On a separate note, I tried using PiecewiseConvexMonotoneZero on deposits +
FRA + Swap Rates bootstrapping and I got the following error;
Traceback (most recent call last):
File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib
Software/Valuations/Valuation of ZAR IRS/ZAR IRS Valuation 2.py", line 115,
in <module>
zero_rate = curve.zeroRate(date, day_count, ql.Annual).rate()
File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line
8610, in zeroRate
return _QuantLib.YieldTermStructure_zeroRate(self, *args)
RuntimeError: 1st iteration: failed at 13th alive instrument, pillar May
28th, 2020, maturity May 28th, 2020, reference date February 28th, 2019:
root not bracketed: f[-1,1] -> [-1.339261e-01,-1.181714e+01]
What could be the cause of the error on this one?
Thanks and regards,
On Mon, Dec 25, 2023 at 8:17 PM Peter Caspers <pca...@gm...>
wrote:
> Hi, the error is probably generated here
>
>
> https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerocurve.hpp#L168
>
> so a workaround would be to avoid extrapolating the curve.
>
> In fact I think the convex monotone interpolation was designed to be
> applied to forward rates rather than zero yields, see
>
> https://downloads.dxfeed.com/specifications/dxLibOptions/HaganWest.pdf
>
> in section 6. But it seems only zero yield is exported as an
> interpolation variable in SWIG at the moment
>
>
> https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/piecewiseyieldcurve.i#L168
>
> We should add forward rate here I guess?
>
> Best
> Peter
>
> On Sun, 24 Dec 2023 at 15:18, Quant <qua...@gm...> wrote:
> >
> > Hi QuantLib Users,
> >
> > I am trying to implement the Convex Monotone interpolation as shown
> below;
> >
> > curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count)
> > # curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers,
> day_count)
> > # curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count)
> >
> > # Enable Extrapolation:
> > # This line enables extrapolation for the yield curve.
> > # Extrapolation allows the curve to provide interest rates or rates
> beyond the observed data points,
> > # which can be useful for pricing or risk management purposes.
> > curve.enableExtrapolation()
> >
> > # Print the Zero Rates, Forward Rates and Discount Factors at node dates
> > # print(pd.DataFrame(curve.nodes()))
> > node_data = {'Date': [],
> > 'Zero Rates': [],
> > 'Forward Rates': [],
> > 'Discount Factors': []}
> >
> > for dt in curve.dates():
> > node_data['Date'].append(dt)
> > node_data['Zero Rates'].append(curve.zeroRate(dt, day_count,
> ql.Compounded, ql.Annual).rate())
> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
> ql.Period(1, ql.Years), day_count, ql.Annual).rate())
> > node_data['Discount Factors'].append(curve.discount(dt))
> >
> > node_dataframe = pd.DataFrame(node_data)
> >
> > And I am getting the following error;
> >
> > Traceback (most recent call last):
> > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib
> Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond
> Bootstrapping 3.py", line 87, in <module>
> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
> ql.Period(1, ql.Years), day_count, ql.Annual).rate())
> > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py",
> line 8617, in forwardRate
> > return _QuantLib.YieldTermStructure_forwardRate(self, *args)
> > RuntimeError: Convex-monotone spline derivative not implemented
> >
> > Is this a known issue with PiecewiseConvexMonotoneZero or it's an error
> that can be fixed in my code? If it can be fixed where do I need to fix?
> >
> > Thanks & regards,
> > _______________________________________________
> > QuantLib-users mailing list
> > Qua...@li...
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Quant <qua...@gm...> - 2023-12-26 14:27:05
|
Hi Peter,
Thanks for the feedback. The workaround you suggested of avoiding the
extrapolation of the curve worked and also removing the "Forward Rate" in
the node_data as the forward rate is not exported in SWIG as you indicated.
I think it will be helpful if the forward rates can be exported in SWIG as
well on the next updates.
I have 2 plots for the PiecewiseLogCubicDiscount and the
PiecewiseConvexMonotoneZero for both zero and forward rates curves as
attached below. The PiecewiseConvexMonotoneZero is not smooth (quite weird)
and I was wondering if the one implemented in QuantLib is the "Monotone
convex (unameliorated)" described in the Hagan and West Paper as the best
interpolation method? Is it perhaps possible to add the smoothed version of
the interpolation on the upcoming updates? Please note that the plots below
are related to the bootstrapping of government bonds.
On a separate note, I tried using PiecewiseConvexMonotoneZero on deposits +
FRA + Swap Rates bootstrapping and I got the following error;
Traceback (most recent call last):
File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib
Software/Valuations/Valuation of ZAR IRS/ZAR IRS Valuation 2.py", line
115, in <module>
zero_rate = curve.zeroRate(date, day_count, ql.Annual).rate()
File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py",
line 8610, in zeroRate
return _QuantLib.YieldTermStructure_zeroRate(self, *args)
RuntimeError: 1st iteration: failed at 13th alive instrument, pillar
May 28th, 2020, maturity May 28th, 2020, reference date February 28th,
2019: root not bracketed: f[-1,1] -> [-1.339261e-01,-1.181714e+01]
What could be the cause of the error on this one?
Thanks and regards,
On Mon, Dec 25, 2023 at 8:17 PM Peter Caspers <pca...@gm...>
wrote:
> Hi, the error is probably generated here
>
>
> https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerocurve.hpp#L168
>
> so a workaround would be to avoid extrapolating the curve.
>
> In fact I think the convex monotone interpolation was designed to be
> applied to forward rates rather than zero yields, see
>
> https://downloads.dxfeed.com/specifications/dxLibOptions/HaganWest.pdf
>
> in section 6. But it seems only zero yield is exported as an
> interpolation variable in SWIG at the moment
>
>
> https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/piecewiseyieldcurve.i#L168
>
> We should add forward rate here I guess?
>
> Best
> Peter
>
> On Sun, 24 Dec 2023 at 15:18, Quant <qua...@gm...> wrote:
> >
> > Hi QuantLib Users,
> >
> > I am trying to implement the Convex Monotone interpolation as shown
> below;
> >
> > curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count)
> > # curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers,
> day_count)
> > # curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count)
> >
> > # Enable Extrapolation:
> > # This line enables extrapolation for the yield curve.
> > # Extrapolation allows the curve to provide interest rates or rates
> beyond the observed data points,
> > # which can be useful for pricing or risk management purposes.
> > curve.enableExtrapolation()
> >
> > # Print the Zero Rates, Forward Rates and Discount Factors at node dates
> > # print(pd.DataFrame(curve.nodes()))
> > node_data = {'Date': [],
> > 'Zero Rates': [],
> > 'Forward Rates': [],
> > 'Discount Factors': []}
> >
> > for dt in curve.dates():
> > node_data['Date'].append(dt)
> > node_data['Zero Rates'].append(curve.zeroRate(dt, day_count,
> ql.Compounded, ql.Annual).rate())
> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
> ql.Period(1, ql.Years), day_count, ql.Annual).rate())
> > node_data['Discount Factors'].append(curve.discount(dt))
> >
> > node_dataframe = pd.DataFrame(node_data)
> >
> > And I am getting the following error;
> >
> > Traceback (most recent call last):
> > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib
> Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond
> Bootstrapping 3.py", line 87, in <module>
> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
> ql.Period(1, ql.Years), day_count, ql.Annual).rate())
> > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py",
> line 8617, in forwardRate
> > return _QuantLib.YieldTermStructure_forwardRate(self, *args)
> > RuntimeError: Convex-monotone spline derivative not implemented
> >
> > Is this a known issue with PiecewiseConvexMonotoneZero or it's an error
> that can be fixed in my code? If it can be fixed where do I need to fix?
> >
> > Thanks & regards,
> > _______________________________________________
> > QuantLib-users mailing list
> > Qua...@li...
> > https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Peter C. <pca...@gm...> - 2023-12-25 18:17:57
|
Hi, the error is probably generated here https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yield/zerocurve.hpp#L168 so a workaround would be to avoid extrapolating the curve. In fact I think the convex monotone interpolation was designed to be applied to forward rates rather than zero yields, see https://downloads.dxfeed.com/specifications/dxLibOptions/HaganWest.pdf in section 6. But it seems only zero yield is exported as an interpolation variable in SWIG at the moment https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/piecewiseyieldcurve.i#L168 We should add forward rate here I guess? Best Peter On Sun, 24 Dec 2023 at 15:18, Quant <qua...@gm...> wrote: > > Hi QuantLib Users, > > I am trying to implement the Convex Monotone interpolation as shown below; > > curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count) > # curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers, day_count) > # curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count) > > # Enable Extrapolation: > # This line enables extrapolation for the yield curve. > # Extrapolation allows the curve to provide interest rates or rates beyond the observed data points, > # which can be useful for pricing or risk management purposes. > curve.enableExtrapolation() > > # Print the Zero Rates, Forward Rates and Discount Factors at node dates > # print(pd.DataFrame(curve.nodes())) > node_data = {'Date': [], > 'Zero Rates': [], > 'Forward Rates': [], > 'Discount Factors': []} > > for dt in curve.dates(): > node_data['Date'].append(dt) > node_data['Zero Rates'].append(curve.zeroRate(dt, day_count, ql.Compounded, ql.Annual).rate()) > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + ql.Period(1, ql.Years), day_count, ql.Annual).rate()) > node_data['Discount Factors'].append(curve.discount(dt)) > > node_dataframe = pd.DataFrame(node_data) > > And I am getting the following error; > > Traceback (most recent call last): > File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond Bootstrapping 3.py", line 87, in <module> > node_data['Forward Rates'].append(curve.forwardRate(dt, dt + ql.Period(1, ql.Years), day_count, ql.Annual).rate()) > File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line 8617, in forwardRate > return _QuantLib.YieldTermStructure_forwardRate(self, *args) > RuntimeError: Convex-monotone spline derivative not implemented > > Is this a known issue with PiecewiseConvexMonotoneZero or it's an error that can be fixed in my code? If it can be fixed where do I need to fix? > > Thanks & regards, > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Quant <qua...@gm...> - 2023-12-24 14:16:46
|
Hi QuantLib Users,
I am trying to implement the Convex Monotone interpolation as shown below;
curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count)
# curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers, day_count)
# curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count)
# Enable Extrapolation:
# This line enables extrapolation for the yield curve.
# Extrapolation allows the curve to provide interest rates or rates
beyond the observed data points,
# which can be useful for pricing or risk management purposes.
curve.enableExtrapolation()
# Print the Zero Rates, Forward Rates and Discount Factors at node dates
# print(pd.DataFrame(curve.nodes()))
node_data = {'Date': [],
'Zero Rates': [],
'Forward Rates': [],
'Discount Factors': []}
for dt in curve.dates():
node_data['Date'].append(dt)
node_data['Zero Rates'].append(curve.zeroRate(dt, day_count,
ql.Compounded, ql.Annual).rate())
node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
ql.Period(1, ql.Years), day_count, ql.Annual).rate())
node_data['Discount Factors'].append(curve.discount(dt))
node_dataframe = pd.DataFrame(node_data)
And I am getting the following error;
Traceback (most recent call last):
File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib
Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond
Bootstrapping 3.py", line 87, in <module>
node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
ql.Period(1, ql.Years), day_count, ql.Annual).rate())
File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line
8617, in forwardRate
return _QuantLib.YieldTermStructure_forwardRate(self, *args)
RuntimeError: Convex-monotone spline derivative not implemented
Is this a known issue with PiecewiseConvexMonotoneZero or it's an error
that can be fixed in my code? If it can be fixed where do I need to fix?
Thanks & regards,
|
|
From: Renren D. <dr...@gm...> - 2023-12-23 00:36:04
|
Hi Quantlib Users,
I am very new to QuantLib and its Python interface, so apologies if this
was obvious.
I was trying to figure out how to use ql.SabrSwaptionVolatilityCube, I
can't seem to find a working example on how to work.
Here are the closest I got so far.
many thanks in advance,
thank you
-Renren
optionTenors = ['1y', '2y', '3y']
swapTenors = [ '5Y', '10Y']
normal_vols = [
[50, 60],
[70, 80],
[90, 95]]
normal_vols = [[vol / 10000 for vol in row] for row in normal_vols]
swapTenors = [ql.Period(tenor) for tenor in swapTenors]
optionTenors = [ql.Period(tenor) for tenor in optionTenors]
normal_vols = [[vol / 10000 for vol in row] for row in normal_vols]
calendar = ql.TARGET()
bdc = ql.ModifiedFollowing
dayCounter = ql.ActualActual(1)
swaptionVolMatrix = ql.SwaptionVolatilityMatrix(calendar
, bdc
, optionTenors
, swapTenors
, ql.Matrix(normal_vols)
, dayCounter
, False
, ql.Normal)
swaptionVolHandle = ql.SwaptionVolatilityStructureHandle(swaptionVolMatrix)
strikeSpreads = [ -0.01, 0.0, 0.01]
volSpreads = [
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
[0.5, 0.55, 0.6],
]
###
oisQuote = ql.QuoteHandle(ql.SimpleQuote(0.04))
ytsOis = ql.FlatForward(today, oisQuote, ql.Actual360())
ytsOis.enableExtrapolation()
t0_Ois = ql.YieldTermStructureHandle(ytsOis)
swapIndexBase = ql.EuriborSwapIsdaFixA(ql.Period(1, ql.Years), t0_Ois,
t0_Ois)
shortSwapIndexBase = ql.EuriborSwapIsdaFixA(ql.Period(1, ql.Years), t0_Ois,
t0_Ois)
##
vegaWeightedSmileFit = False
ql.SabrSwaptionVolatilityCube( swaptionVolHandle,
optionTenors,
swapTenors,
strikeSpreads,
volSpreads,
swapIndexBase,
shortSwapIndexBase,
vegaWeightedSmileFit,
[(0.1,0.1,0.1,0.1) ] * 6,
(False, False, False, False),
True
)
|
|
From: Robert C. <rob...@gm...> - 2023-12-21 06:58:59
|
Has anyone run into this problem - I'm trying to use New Zealand 90 Day
Bank Bill Futures to build a curve. (See attached screenshot)
When I try to create the helper, I'm getting: March 13th, 2024 is not a
valid ASX date
###############################################################
# ZBH4 Comdty
# SFE NZ 90 Day Bank Bill Future Contract (Sydney
Futures Exchange)
# RuntimeError: March 13th, 2024 is not a valid ASX date
helper = ql.FuturesRateHelper(94.46,
ql.Date(13, 3, 2024),
ql.Date(),
ql.Actual365Fixed(),
0.0,
ql.Futures.ASX)
It works for an ASX futures contract:
###############################################################
# IRH4 Comdty
# ASX 90 Day Bank Accepted Bills Future Contract
# *works fine !*
helper = ql.FuturesRateHelper(95.720,
ql.Date(8, 3, 2024),
ql.Date(),
ql.Actual365Fixed(),
0.0,
ql.Futures.ASX)
print(f'helper maturity date: {helper.maturityDate()}')
###############################################################
Any ideas ???
Robert Chapman
+61 418 693 633
rob...@gm...
au.linkedin.com/in/robertchapman2095
|
|
From: Philippe H. <phi...@ex...> - 2023-12-18 18:49:56
|
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">That’s the other solution that always works but it’s just more code. It s a bit weird that the instrument level NPV() method cannot take a settle date. Your decisions on how to proceed are going to be driven by how much code you want to so yourself and speed considerations. <br id="lineBreakAtBeginningOfSignature"><div dir="ltr">Regards<div><br></div><div>Philippe Hatstadt</div><div>+1-203-252-0408</div><div><br></div></div><div dir="ltr"><br><blockquote type="cite">On Dec 18, 2023, at 6:24 PM, Quant <qua...@gm...> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Hi Philippe,<div><br></div><div>Thanks for the reply. I kept on researching and I found a workaround of dividing the discount factors from evaluation date to accrual end date by the discount factor from evaluation date to bond settlement date as shown in the code below;</div><div><br></div><div><div style="background-color:rgb(30,31,34);color:rgb(188,190,196)"><pre style="font-family:"JetBrains Mono",monospace">fields = [<span style="color:rgb(106,171,115)">'accrualStartDate'</span>, <span style="color:rgb(106,171,115)">'accrualEndDate'</span>, <span style="color:rgb(106,171,115)">'date'</span>, <span style="color:rgb(106,171,115)">'nominal'</span>, <span style="color:rgb(106,171,115)">'rate'</span>,<br> <span style="color:rgb(106,171,115)">'amount'</span>, <span style="color:rgb(106,171,115)">'accrualDays'</span>, <span style="color:rgb(106,171,115)">'accrualPeriod'</span>]<br>BondCashflows = []<br><span style="color:rgb(207,142,109)">for </span>cf <span style="color:rgb(207,142,109)">in </span><span style="color:rgb(136,136,198)">list</span>(<span style="color:rgb(136,136,198)">map</span>(ql.as_fixed_rate_coupon, bond.cashflows()))[:-<span style="color:rgb(42,172,184)">1</span>]:<br> row = {fld: <span style="color:rgb(136,136,198)">eval</span>(<span style="color:rgb(106,171,115)">f"cf.</span><span style="color:rgb(207,142,109)">{</span>fld<span style="color:rgb(207,142,109)">}</span><span style="color:rgb(106,171,115)">()"</span>) <span style="color:rgb(207,142,109)">for </span>fld <span style="color:rgb(207,142,109)">in </span>fields}<br> row[<span style="color:rgb(106,171,115)">'AccrualPeriod'</span>] = <span style="color:rgb(136,136,198)">round</span>((row[<span style="color:rgb(106,171,115)">'accrualEndDate'</span>] - row[<span style="color:rgb(106,171,115)">'accrualStartDate'</span>]) / <span style="color:rgb(42,172,184)">365</span>, <span style="color:rgb(42,172,184)">4</span>)<br> <span style="color:rgb(207,142,109)">if </span>row[<span style="color:rgb(106,171,115)">'date'</span>] >= today:<br> row[<span style="color:rgb(106,171,115)">'ZeroRate (NPV)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.zeroRate(row[<span style="color:rgb(106,171,115)">'date'</span>], day_count, ql.Compounded, ql.Annual).rate(), <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'ZeroRate (Dirty Price)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.forwardRate(bond.settlementDate(), row[<span style="color:rgb(106,171,115)">'date'</span>], day_count, ql.Compounded, ql.Annual).rate(), <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'DiscFactor (NPV)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.discount(row[<span style="color:rgb(106,171,115)">'date'</span>]), <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'DiscFactor (Dirty Price)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.discount(row[<span style="color:rgb(106,171,115)">'date'</span>]) / curve.discount(bond.settlementDate()), <span style="color:rgb(42,172,184)">9</span>)<br> <span style="color:rgb(207,142,109)">else</span>:<br> row[<span style="color:rgb(106,171,115)">'ZeroRate (NPV)'</span>] = <span style="color:rgb(42,172,184)">0<br></span><span style="color:rgb(42,172,184)"> </span>row[<span style="color:rgb(106,171,115)">'ZeroRate (Dirty Price)'</span>] = <span style="color:rgb(42,172,184)">0<br></span><span style="color:rgb(42,172,184)"> </span>row[<span style="color:rgb(106,171,115)">'DiscFactor (NPV)'</span>] = <span style="color:rgb(42,172,184)">0 </span><span style="color:rgb(122,126,133)"># or any other appropriate handling for dates before today<br></span><span style="color:rgb(122,126,133)"> </span>row[<span style="color:rgb(106,171,115)">'DiscFactor (Dirty Price)'</span>] = <span style="color:rgb(42,172,184)">0 </span><span style="color:rgb(122,126,133)"># or any other appropriate handling for dates before today<br></span><span style="color:rgb(122,126,133)"> </span>row[<span style="color:rgb(106,171,115)">'NPV'</span>] = <span style="color:rgb(136,136,198)">round</span>(row[<span style="color:rgb(106,171,115)">'DiscFactor (NPV)'</span>] * row[<span style="color:rgb(106,171,115)">'amount'</span>], <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'Dirty Price'</span>] = <span style="color:rgb(136,136,198)">round</span>(row[<span style="color:rgb(106,171,115)">'DiscFactor (Dirty Price)'</span>] * row[<span style="color:rgb(106,171,115)">'amount'</span>], <span style="color:rgb(42,172,184)">9</span>)<br> BondCashflows.append(row)<br><br>BondCashflows = pd.DataFrame(BondCashflows)</pre></div></div><div><br></div><div>Hope that makes sense.</div><div><br></div><div>Thanks & regards,</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 17, 2023 at 10:37 PM Philippe Hatstadt <<a href="mailto:phi...@ex...">phi...@ex...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">You could try ql.CashFlows(cashflows, curve_handle, valaution_date) I think. Where valuation date can be the curve evaluation date or anything you want but beware about ex-coupon dates <br id="m_883891212213335717lineBreakAtBeginningOfSignature"><div dir="ltr">Regards<div><br></div><div>Philippe Hatstadt</div><div>+1-203-252-0408</div><div><br></div></div><div dir="ltr"><br><blockquote type="cite">On Dec 17, 2023, at 3:22 PM, Quant <<a href="mailto:qua...@gm..." target="_blank">qua...@gm...</a>> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Hi Quantlib Users,<div><br></div><div>I have bootstrapped the yield curve and I have managed to extract discount factors from this yield curve but the discount factors are referencing from the Evaluation Date. These discount factors are used to calculate the PV of the bond but they can not be used to calculate the Dirty Price of the bond if the Evaluation Date is different from the Bond Settlement Date. How do I extract the Discount Factors from the Bond Settlement Date instead of the Evaluation Date. Hoping that my question is clear.</div><div><br></div><div>Find below a part of the code that I have tried to use to extract the discount factors;</div><div><div style="background-color:rgb(30,31,34);color:rgb(188,190,196)"><pre style="font-family:"JetBrains Mono",monospace">fields = [<span style="color:rgb(106,171,115)">'accrualStartDate'</span>, <span style="color:rgb(106,171,115)">'accrualEndDate'</span>, <span style="color:rgb(106,171,115)">'date'</span>, <span style="color:rgb(106,171,115)">'nominal'</span>, <span style="color:rgb(106,171,115)">'rate'</span>,<br> <span style="color:rgb(106,171,115)">'amount'</span>, <span style="color:rgb(106,171,115)">'accrualDays'</span>, <span style="color:rgb(106,171,115)">'accrualPeriod'</span>]<br>BondCashflows = []<br><span style="color:rgb(207,142,109)">for </span>cf <span style="color:rgb(207,142,109)">in </span><span style="color:rgb(136,136,198)">list</span>(<span style="color:rgb(136,136,198)">map</span>(ql.as_fixed_rate_coupon, bond.cashflows()))[:-<span style="color:rgb(42,172,184)">1</span>]:<br> row = {fld: <span style="color:rgb(136,136,198)">eval</span>(<span style="color:rgb(106,171,115)">f"cf.</span><span style="color:rgb(207,142,109)">{</span>fld<span style="color:rgb(207,142,109)">}</span><span style="color:rgb(106,171,115)">()"</span>) <span style="color:rgb(207,142,109)">for </span>fld <span style="color:rgb(207,142,109)">in </span>fields}<br> row[<span style="color:rgb(106,171,115)">'AccrualPeriod'</span>] = <span style="color:rgb(136,136,198)">round</span>((row[<span style="color:rgb(106,171,115)">'accrualEndDate'</span>] - row[<span style="color:rgb(106,171,115)">'accrualStartDate'</span>]) / <span style="color:rgb(42,172,184)">365</span>, <span style="color:rgb(42,172,184)">4</span>)<br> <span style="color:rgb(207,142,109)">if </span>row[<span style="color:rgb(106,171,115)">'date'</span>] >= today:<br> row[<span style="color:rgb(106,171,115)">'ZeroRate (NPV)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.zeroRate(row[<span style="color:rgb(106,171,115)">'date'</span>], day_count, ql.Compounded, ql.Annual).rate(), <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'ZeroRate (Dirty Price)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.forwardRate(bond.settlementDate(), row[<span style="color:rgb(106,171,115)">'date'</span>], day_count, ql.Compounded, ql.Annual).rate(), <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'DiscFactor (NPV)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.discount(row[<span style="color:rgb(106,171,115)">'date'</span>]), <span style="color:rgb(42,172,184)">9</span>)<br> row[<span style="color:rgb(106,171,115)">'DiscFactor (Dirty Price)'</span>] = <span style="color:rgb(136,136,198)">round</span>(curve.discount(bond.settlementDate(), row[<span style="color:rgb(106,171,115)">'date'</span>]), <span style="color:rgb(42,172,184)">9</span>)<br> <span style="color:rgb(207,142,109)">else</span>:<br> row[<span style="color:rgb(106,171,115)">'ZeroRate (NPV)'</span>] = <span style="color:rgb(42,172,184)">0<br></span><span style="color:rgb(42,172,184)"> </span>row[<span style="color:rgb(106,171,115)">'ZeroRate (Dirty Price)'</span>] = <span style="color:rgb(42,172,184)">0<br></span><span style="color:rgb(42,172,184)"> </span>row[<span style="color:rgb(106,171,115)">'DiscFactor (NPV)'</span>] = <span style="color:rgb(42,172,184)">0 </span><span style="color:rgb(122,126,133)"># or any other appropriate handling for dates before today<br></span><span style="color:rgb(122,126,133)"> </span>row[<span style="color:rgb(106,171,115)">'DiscFactor (Dirty Price)'</span>] = <span style="color:rgb(42,172,184)">0 </span><span style="color:rgb(122,126,133)"># or any other appropriate handling for dates before today<br></span><span style="color:rgb(122,126,133)"> </span>row[<span style="color:rgb(106,171,115)">'NPV'</span>] = <span style="color:rgb(136,136,198)">round</span>(row[<span style="color:rgb(106,171,115)">'DiscFactor (NPV)'</span>] * row[<span style="color:rgb(106,171,115)">'amount'</span>], <span style="color:rgb(42,172,184)">9</span>)<br> BondCashflows.append(row)<br><br>BondCashflows = pd.DataFrame(BondCashflows)<br><br><span style="color:rgb(136,136,198)">print</span>(BondCashflows)</pre></div></div><div><br></div><div>Thanks & regards</div></div>
<span>_______________________________________________</span><br><span>QuantLib-users mailing list</span><br><span><a href="mailto:Qua...@li..." target="_blank">Qua...@li...</a></span><br><span><a href="https://lists.sourceforge.net/lists/listinfo/quantlib-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/quantlib-users</a></span><br></div></blockquote></div>
<br>
<p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">1370 Broadway, Suite 1450 | New York, NY | 10018</span></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><a href="https://www.exosfinancial.com/" target="_blank"><img src="https://exos-website-media.s3.amazonaws.com/Disclosures/img1.jpg" alt="https://www.exosfinancial.com/" data-unique-identifier=""></a> <a href="https://www.linkedin.com/company/meetexos/about/" target="_blank"><img src="https://exos-website-media.s3.amazonaws.com/Disclosures/img3.jpg" alt="https://www.linkedin.com/company/meetexos/about/" data-unique-identifier=""></a> <br></span></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Broker-Dealer services offered through Exos Securities LLC, Member SIPC, FINRA. For important disclosures including Form CRS and Regulation BI click </span><a href="https://www.exosfinancial.com/general-disclosures" target="_blank"><span style="font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">here</span></a>.<br></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:9pt;font-family:Arial;color:rgb(0,0,0);font-weight:700;vertical-align:baseline;white-space:pre-wrap"><br></span></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:9pt;font-family:Arial;color:rgb(0,0,0);font-weight:700;vertical-align:baseline;white-space:pre-wrap">Confidentiality Notice</span><span style="background-color:transparent;font-size:9pt;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap">: The information contained in this email (including attachments) is only for the personal and confidential use of the sender and recipient named above. If the reader is not the intended recipient, you are notified that you have received this message in error and that any review, dissemination, copying or distribution is prohibited. If you have received this communication in error, please notify the sender immediately by e-mail and delete or destroy the original message and all copies. </span><br></p></blockquote></div>
</div></blockquote></body></html>
<br>
<p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">1370 Broadway, Suite 1450 | New York, NY | 10018</span></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><a href="https://www.exosfinancial.com/" target="_blank"><img src="https://exos-website-media.s3.amazonaws.com/Disclosures/img1.jpg" alt="https://www.exosfinancial.com/"></a> <a href="https://www.linkedin.com/company/meetexos/about/" target="_blank"><img src="https://exos-website-media.s3.amazonaws.com/Disclosures/img3.jpg" alt="https://www.linkedin.com/company/meetexos/about/"></a> <br></span></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Broker-Dealer services offered through Exos Securities LLC, Member SIPC, FINRA. For important disclosures including Form CRS and Regulation BI click </span><a href="https://www.exosfinancial.com/general-disclosures" target="_blank"><span style="font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">here</span></a>.<br></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:9pt;font-family:Arial;color:rgb(0,0,0);font-weight:700;vertical-align:baseline;white-space:pre-wrap"><br></span></p><p dir="ltr" style="line-height:1.38;background-color:rgb(239,239,239);margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;font-size:9pt;font-family:Arial;color:rgb(0,0,0);font-weight:700;vertical-align:baseline;white-space:pre-wrap">Confidentiality Notice</span><span style="background-color:transparent;font-size:9pt;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap">: The information contained in this email (including attachments) is only for the personal and confidential use of the sender and recipient named above. If the reader is not the intended recipient, you are notified that you have received this message in error and that any review, dissemination, copying or distribution is prohibited. If you have received this communication in error, please notify the sender immediately by e-mail and delete or destroy the original message and all copies. </span><br></p>
|
|
From: Quant <qua...@gm...> - 2023-12-18 17:23:56
|
Hi Philippe,
Thanks for the reply. I kept on researching and I found a workaround of
dividing the discount factors from evaluation date to accrual end date by
the discount factor from evaluation date to bond settlement date as shown
in the code below;
fields = ['accrualStartDate', 'accrualEndDate', 'date', 'nominal', 'rate',
'amount', 'accrualDays', 'accrualPeriod']
BondCashflows = []
for cf in list(map(ql.as_fixed_rate_coupon, bond.cashflows()))[:-1]:
row = {fld: eval(f"cf.{fld}()") for fld in fields}
row['AccrualPeriod'] = round((row['accrualEndDate'] -
row['accrualStartDate']) / 365, 4)
if row['date'] >= today:
row['ZeroRate (NPV)'] = round(curve.zeroRate(row['date'],
day_count, ql.Compounded, ql.Annual).rate(), 9)
row['ZeroRate (Dirty Price)'] =
round(curve.forwardRate(bond.settlementDate(), row['date'], day_count,
ql.Compounded, ql.Annual).rate(), 9)
row['DiscFactor (NPV)'] = round(curve.discount(row['date']), 9)
row['DiscFactor (Dirty Price)'] =
round(curve.discount(row['date']) /
curve.discount(bond.settlementDate()), 9)
else:
row['ZeroRate (NPV)'] = 0
row['ZeroRate (Dirty Price)'] = 0
row['DiscFactor (NPV)'] = 0 # or any other appropriate
handling for dates before today
row['DiscFactor (Dirty Price)'] = 0 # or any other
appropriate handling for dates before today
row['NPV'] = round(row['DiscFactor (NPV)'] * row['amount'], 9)
row['Dirty Price'] = round(row['DiscFactor (Dirty Price)'] *
row['amount'], 9)
BondCashflows.append(row)
BondCashflows = pd.DataFrame(BondCashflows)
Hope that makes sense.
Thanks & regards,
On Sun, Dec 17, 2023 at 10:37 PM Philippe Hatstadt <
phi...@ex...> wrote:
> You could try ql.CashFlows(cashflows, curve_handle, valaution_date) I
> think. Where valuation date can be the curve evaluation date or anything
> you want but beware about ex-coupon dates
> Regards
>
> Philippe Hatstadt
> +1-203-252-0408
>
>
> On Dec 17, 2023, at 3:22 PM, Quant <qua...@gm...> wrote:
>
>
> Hi Quantlib Users,
>
> I have bootstrapped the yield curve and I have managed to extract discount
> factors from this yield curve but the discount factors are referencing from
> the Evaluation Date. These discount factors are used to calculate the PV of
> the bond but they can not be used to calculate the Dirty Price of the bond
> if the Evaluation Date is different from the Bond Settlement Date. How do I
> extract the Discount Factors from the Bond Settlement Date instead of the
> Evaluation Date. Hoping that my question is clear.
>
> Find below a part of the code that I have tried to use to extract the
> discount factors;
>
> fields = ['accrualStartDate', 'accrualEndDate', 'date', 'nominal', 'rate',
> 'amount', 'accrualDays', 'accrualPeriod']
> BondCashflows = []
> for cf in list(map(ql.as_fixed_rate_coupon, bond.cashflows()))[:-1]:
> row = {fld: eval(f"cf.{fld}()") for fld in fields}
> row['AccrualPeriod'] = round((row['accrualEndDate'] - row['accrualStartDate']) / 365, 4)
> if row['date'] >= today:
> row['ZeroRate (NPV)'] = round(curve.zeroRate(row['date'], day_count, ql.Compounded, ql.Annual).rate(), 9)
> row['ZeroRate (Dirty Price)'] = round(curve.forwardRate(bond.settlementDate(), row['date'], day_count, ql.Compounded, ql.Annual).rate(), 9)
> row['DiscFactor (NPV)'] = round(curve.discount(row['date']), 9)
> row['DiscFactor (Dirty Price)'] = round(curve.discount(bond.settlementDate(), row['date']), 9)
> else:
> row['ZeroRate (NPV)'] = 0
> row['ZeroRate (Dirty Price)'] = 0
> row['DiscFactor (NPV)'] = 0 # or any other appropriate handling for dates before today
> row['DiscFactor (Dirty Price)'] = 0 # or any other appropriate handling for dates before today
> row['NPV'] = round(row['DiscFactor (NPV)'] * row['amount'], 9)
> BondCashflows.append(row)
>
> BondCashflows = pd.DataFrame(BondCashflows)
>
> print(BondCashflows)
>
>
> Thanks & regards
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>
> 1370 Broadway, Suite 1450 | New York, NY | 10018
>
> [image: https://www.exosfinancial.com/] <https://www.exosfinancial.com/> [image:
> https://www.linkedin.com/company/meetexos/about/]
> <https://www.linkedin.com/company/meetexos/about/>
>
> Broker-Dealer services offered through Exos Securities LLC, Member SIPC,
> FINRA. For important disclosures including Form CRS and Regulation BI click
> here <https://www.exosfinancial.com/general-disclosures>.
>
>
> Confidentiality Notice: The information contained in this email
> (including attachments) is only for the personal and confidential use of
> the sender and recipient named above. If the reader is not the intended
> recipient, you are notified that you have received this message in error
> and that any review, dissemination, copying or distribution is prohibited.
> If you have received this communication in error, please notify the sender
> immediately by e-mail and delete or destroy the original message and all
> copies.
>
|
|
From: Chilamakuri, P. <Chi...@eb...> - 2023-12-17 23:36:06
|
OFFICIAL USE
Having issues instantiating a Vanilla swap using ql.VanillaSwap. I read online and tried ql.Actual365Fixed() as well as q.Actual365Fixed(q.Actual365Fixed.Standard). Not sure if the daycounter is the problem or the EUR3M_index. I also tried index_curve_handle and no luck. My goal is to get the par swap rate.
I cannot seem to find a resolution and no idea exactly which argument to ql.ValillaSwap has the problem:
Exception has occurred: TypeError Wrong number or type of arguments for overloaded function 'new_VanillaSwap'. Possible C/C++ prototypes are: VanillaSwap::VanillaSwap(Swap::Type,Real,Schedule const &,Rate,DayCounter const &,Schedule const &,ext::shared_ptr< IborIndex > const &,Spread,DayCounter const &,boost::optional< bool >) VanillaSwap::VanillaSwap(Swap::Type,Real,Schedule const &,Rate,DayCounter const &,Schedule const &,ext::shared_ptr< IborIndex > const &,Spread,DayCounter const &) File "C:\Pavani\aValidations\AMC_SwapSingleCcy_Bermudan\PythonCode\ASwapSingleCcyBermPricer_v2\swap.py", line 136, in get_par_swap_rate ir_swap = ql.VanillaSwap(ql.VanillaSwap.Receiver, notional, fixed_schedule, File
My code below:
def get_par_swap_rate(self, exp_date, market_index: YieldCurve, market_disc: YieldCurve, calendar):
ql_mat_dates = []
maturity_date = exp_date + relativedelta(years=1)
schedule_builder = build_ql_schedule()
fixed_tenor = "1Y"
fixed_calendar = "TAR"
fixed_convention = "MODFOLLOWING"
fixed_schedule = schedule_builder.build_schedule(exp_date,
maturity_date,
fixed_tenor,
fixed_calendar,
fixed_convention,
fixed_convention,
date_generation = ql.DateGeneration.Forward,
end_of_month = False)
floating_tenor = "3M"
floating_calendar = "TAR"
floating_convention = "MODFOLLOWING"
floating_schedule = schedule_builder.build_schedule(exp_date,
maturity_date,
floating_tenor,
floating_calendar,
floating_convention,
floating_convention,
date_generation = ql.DateGeneration.Forward,
end_of_month = False)
notional = 50000000
currency = 'EUR'
fixed_rate = 0.00192
# fixed_rate = 0.025
fixed_leg_daycount = ql.Actual365Fixed()
float_spread = -0.0033
float_leg_daycount = ql.Actual360()
startDateList = exp_date.year, exp_date.month, exp_date.day
# parse python datetime.date into QuantLib date format
ql_start_date = ql.Date(startDateList[2], startDateList[1], startDateList[0])
# set up index_curve in QuantLib
index_tenors = market_index.tenors
for tnr in index_tenors:
period = ql.Period(tnr, ql.Days)
ql_mat_date = ql_start_date + period
ql_mat_dates.append(ql_mat_date)
index_rates = market_index.rates
ql_day_count = ql.Actual365Fixed(ql.Actual365Fixed.Standard)
ql_calendar = ql.TARGET()
interpolation = ql.Linear()
compounding = ql.Compounded
compounding_frequency = ql.Daily
index_term_structure = ql.ZeroCurve( ql_mat_dates, index_rates, ql_day_count,
ql_calendar, interpolation,
compounding, compounding_frequency)
index_curve_handle = ql.YieldTermStructureHandle(index_term_structure)
# set up index_curve in QuantLib
ql_mat_dates.clear()
discount_tenors = market_disc.tenors
for tnr in discount_tenors:
period = ql.Period(tnr, ql.Days)
ql_mat_date = ql_start_date + period
ql_mat_dates.append(ql_mat_date)
disc_curve_rates = market_disc.rates
ql_day_count = ql.Actual365Fixed(ql.Actual365Fixed.Standard)
ql_calendar = ql.TARGET()
interpolation = ql.Linear()
compounding = ql.Compounded
compounding_frequency = ql.Daily
disc_term_structure = ql.ZeroCurve(ql_mat_dates, disc_curve_rates, ql_day_count,
ql_calendar, interpolation,
compounding, compounding_frequency)
disc_curve_handle = ql.YieldTermStructureHandle(disc_term_structure)
EUR3M_index = ql.Euribor3M(index_curve_handle)
libor3M_index = ql.USDLibor(ql.Period(3, ql.Months), index_curve_handle)
#swap = ql.VanillaSwap(
# ql.VanillaSwap.Payer, 10000.0,
# fixed_schedule, 0.02, ql.Thirty360(ql.Thirty360.BondBasis),
# floating_schedule, index, 0.0, ql.Actual360()
# )
ir_swap = ql.VanillaSwap(ql.VanillaSwap.Receiver, notional, fixed_schedule,
fixed_rate, fixed_leg_daycount, floating_schedule,
EUR3M_index, float_spread, float_leg_daycount)
swap_engine = ql.DiscountingSwapEngine(disc_curve_handle)
ir_swap.setPricingEngine(swap_engine)
par_swap_rate = ir_swap.fairRate()
return par_swap_rate
Best Regards,
Pav
Phone: +44(0)7769003342
OFFICIAL USE
To learn more about EBRD classifications, visit www.ebrd.com/ic<http://www.ebrd.com/ic>
______________________________________________________________
This message may contain privileged information. If you have received this message by mistake, please keep it confidential and return it to the sender.
Although we have taken steps to minimise the risk of transmitting software viruses, the EBRD accepts no liability for any loss or damage caused by computer viruses and would advise you to carry out your own virus checks.
The contents of this e-mail do not necessarily represent the views of the EBRD.
|