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
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: SX L <han...@ho...> - 2020-12-19 09:22:31
|
I am looking at GeneralizedBSProcess. I can understand the usage of Handle<YieldTermStructure>. Say, you wanna switch from LIBOR based discount curve to SOFR based one. You could do "USDDiscount.linkTo(USDSOFRCurve)". However, what's the usage of Handle<Quote>? For cases of SimpleQuote, can we just use SimpleQuote::setValue()? Thanks. |
|
From: <mat...@gm...> - 2020-12-18 08:36:21
|
Hi David, Thank you for your advice. I retried my old (Python) exercise adding a guess for the parameter vector (an optional argument whose existence I missed) and indeed it does help. Kind regards, Matthias From: da...@el... <da...@el...> Sent: Wednesday, 16 December 2020 23:00 To: mat...@gm... Cc: qua...@li... Subject: RE: [Quantlib-users] FittedBondCurve in R Hi Matthias & “Random User”, “That said, I also tried Nelson-Siegel and indeed the exponential splines, but both methods would give me the linear curve you got as well. So I quickly discarded them without much thinking about as to why this kind of “deformation” may have happened.” This same question was asked on Stack Overflow, so I’ll give pretty much the same reply here, which relates specifically to the exponential spline, and why it doesn’t seem to work in the current R wrapper for QuantLib in the low-rate world. See: QuantLib in R: Bond Setup - Stack Overflow <https://stackoverflow.com/questions/65006282/quantlib-in-r-bond-setup> (I’ll do my best with showing the equations in plain text). For the default QuantLib exponential spline fit (which is what you seem to get in R), the discount function is fitted to this form: df(t) = Coeff1.exp(-kappa.t) + Coeff2.exp(-2.kappa.t) + … CoeffN.exp(-N.kappa.t), where N is fixed at 9. So you have 9 Coeffs and 1 kappa as your fit parameters. In addition, the default is to constrain df(0) = 1 (ie PV of 1$ today is 1$ which seems reasonable). This imposes a constraint that: Sum(Coeffs) = 1 So you actually only have 8 independent Coeffs. You can think of kappa as the far-forward overnight rate, as when t gets large df(t) ~ Coeff1.exp(-kappa.t). When I first started using exponential splines for European government curves back in the ‘90s (which dates me terribly), rates were much higher than today, and kappa came out around 3%. Actually we didn’t vary kappa, left it fixed and just varied the coefficients (you find that the fitted curve is pretty insensitive to the choice of kappa within reason). The issue today is rates are close to zero. I don’t know the details of the QL optimization process, but if the routine tries a solution with kappa close (or equal to) zero then it hits a special case. Why? Well if kappa = 0, then the discount function reduces to: df(t) = Coeff1 + Coeff2 + …. Coeff9 But the sum of the Coeffs is constrained to 1. So df(t) = 1 for any variation of the 8 independent coefficients. As a consequence I think the optimization routine considers it has found a solution, since no matter how much it varies the 8 independent Coeffs, the fit doesn’t improve. You can only see this when using the C++ or Python libraries, as they let you inspect the values of the fit parameters. Indeed I went to the trouble of trying to fit the Treasury Curve using the default exponential spline fitting method (see the SO link above), and I got the same results as Matthias: an almost linear yield curve. When you look at the final fit parameters you see that kappa = 0.000. However, the C++/Python libraries allow the user to specify an initial guess for the fit parameters (as well as choosing how to weight each bond in the fit). If you supply a non-zero initial guess for kappa (say 1% or 0.01) then the fitting algorithm doesn’t get stuck and you get a decent fit to the Treasury curve (including bonds with the same maturity), complete with inflection points. Unfortunately the R implementation doesn’t give you access to this approach. Since I was trying to use the exponential spline via QuantLibXL, I dug quite deep into this issue. I’ve submitted a pull request on the QuantLib github which allows a C++ user to fix kappa in the exponential fit (which speeds up the fit), as well as specify how many Coeffs to use. At some point I guess this will find its way to the Python and R interfaces too. So, when it comes to the exponential fit via R, it is not a matter of incorrect day count issues, or bonds with the same maturity. It is that R is not giving access to the finer details of the fitting method, which are needed in this case. I hope this all sounds reasonable, David Sansom From: mat...@gm... <mailto:mat...@gm...> <mat...@gm... <mailto:mat...@gm...> > Sent: Wednesday, 16 December 2020 20:51 To: 'Random User' <qld...@gm... <mailto:qld...@gm...> >; qua...@li... <mailto:qua...@li...> Subject: Re: [Quantlib-users] FittedBondCurve in R Hello “Random User”, Your example made me try out the QuantLib R extension which I never used before. Put your code into a file if someone else wants to try – I believe the attachment may survive distribution in this list. Anyway this will not be the answer you hoped for, but let me share an anecdotal (attempt of) advice. Some while ago I tried to essentially do the same: Fit a curve based on government bonds. My dataset also included several bonds at the same tenor, so the first approach to simply pass the bonds to a function like this (Python code)… ql.PiecewiseLogCubicDiscount(settle_days, calendar, bond_helpers, day_count) …required to filter the dataset to avoid such “collisions”. With that, I got a somewhat bumpy curve with quite some oscillations on the short tenors. So, in order to smoothen that curve, I used the same class you also used, but chose cubic splines instead of exponential, because some paper suggested so. Do not remember which, but not the ones mentioned in the C++ documentation of the regarding class. Well, I did not read them, but I am pretty sure the one I had was way more recent. ql.FittedBondDiscountCurve(settle_days, calendar, bond_helpers, day_count, ql.CubicBSplinesFitting(knots, True), tolerance, iterations) That said, I also tried Nelson-Siegel and indeed the exponential splines, but both methods would give me the linear curve you got as well. So I quickly discarded them without much thinking about as to why this kind of “deformation” may have happened. Speaking of deformation: I had to do some uneducated tweaking for the control knots vector to get suitable results where “suitable results” means: pricing of some benchmark corporate bonds yielded reasonable results. Not sure if there a good universal way to choose those knots, looking again at the C++ code docs: \warning "The results are extremely sensitive to the number and location of the knot points, and there is no optimal way of selecting them." James, J. and N. Webber, "Interest Rate Modelling" John Wiley, 2000, pp. 440. So, all in all not very scientific and more of a fun exercise. But all the same I am, too, interested in more details about this function. Suppose that more data cleansing could help, but I am pretty sure not to have included anything but plain bonds. Regards, Matthias From: Random User <qld...@gm... <mailto:qld...@gm...> > Sent: Wednesday, 2 December 2020 08:59 To: qua...@li... <mailto:qua...@li...> Subject: [Quantlib-users] FittedBondCurve in R Hello all - I'm trying to build a fitted US Treasury curve using FittedBondCurve(). However, my results are odd for two reasons. (1) the shape of the curve is a straight line and not concave as one might expect (2) the yields of the modeled term structure are within a very tight range for the entire curve and well below even the lowest yields in the yield dataset that is being fit (yields being fit are shown in the dataframe below). The only possible issues I can suspect are day count issues in my dateparams (unclear why) or the function being able to fit multiple data points for a single maturity. On this second point, for example, I'm trying to model all outstanding Treasuries, so there are several bonds that sit at the same maturity point (eg. at the 1Y point there could be an originally issued 2Y bond that has aged 1 year along with an originally issued 30Y bond that has aged 29 years etc.). I've included the relatively short code along with the dataset being fit to hopefully ease replication. This is very close to the QuantLib example for the function with the major difference that I'm trying to fit actual bond prices (the df that is referenced is shown in full below). Please let me know if you need more information. Thanks for any help! [[ REMOVED ]] |
|
From: <da...@el...> - 2020-12-16 22:00:43
|
Hi Matthias & “Random User”, “That said, I also tried Nelson-Siegel and indeed the exponential splines, but both methods would give me the linear curve you got as well. So I quickly discarded them without much thinking about as to why this kind of “deformation” may have happened.” This same question was asked on Stack Overflow, so I’ll give pretty much the same reply here, which relates specifically to the exponential spline, and why it doesn’t seem to work in the current R wrapper for QuantLib in the low-rate world. See: QuantLib in R: Bond Setup - Stack Overflow <https://stackoverflow.com/questions/65006282/quantlib-in-r-bond-setup> (I’ll do my best with showing the equations in plain text). For the default QuantLib exponential spline fit (which is what you seem to get in R), the discount function is fitted to this form: df(t) = Coeff1.exp(-kappa.t) + Coeff2.exp(-2.kappa.t) + … CoeffN.exp(-N.kappa.t), where N is fixed at 9. So you have 9 Coeffs and 1 kappa as your fit parameters. In addition, the default is to constrain df(0) = 1 (ie PV of 1$ today is 1$ which seems reasonable). This imposes a constraint that: Sum(Coeffs) = 1 So you actually only have 8 independent Coeffs. You can think of kappa as the far-forward overnight rate, as when t gets large df(t) ~ Coeff1.exp(-kappa.t). When I first started using exponential splines for European government curves back in the ‘90s (which dates me terribly), rates were much higher than today, and kappa came out around 3%. Actually we didn’t vary kappa, left it fixed and just varied the coefficients (you find that the fitted curve is pretty insensitive to the choice of kappa within reason). The issue today is rates are close to zero. I don’t know the details of the QL optimization process, but if the routine tries a solution with kappa close (or equal to) zero then it hits a special case. Why? Well if kappa = 0, then the discount function reduces to: df(t) = Coeff1 + Coeff2 + …. Coeff9 But the sum of the Coeffs is constrained to 1. So df(t) = 1 for any variation of the 8 independent coefficients. As a consequence I think the optimization routine considers it has found a solution, since no matter how much it varies the 8 independent Coeffs, the fit doesn’t improve. You can only see this when using the C++ or Python libraries, as they let you inspect the values of the fit parameters. Indeed I went to the trouble of trying to fit the Treasury Curve using the default exponential spline fitting method (see the SO link above), and I got the same results as Matthias: an almost linear yield curve. When you look at the final fit parameters you see that kappa = 0.000. However, the C++/Python libraries allow the user to specify an initial guess for the fit parameters (as well as choosing how to weight each bond in the fit). If you supply a non-zero initial guess for kappa (say 1% or 0.01) then the fitting algorithm doesn’t get stuck and you get a decent fit to the Treasury curve (including bonds with the same maturity), complete with inflection points. Unfortunately the R implementation doesn’t give you access to this approach. Since I was trying to use the exponential spline via QuantLibXL, I dug quite deep into this issue. I’ve submitted a pull request on the QuantLib github which allows a C++ user to fix kappa in the exponential fit (which speeds up the fit), as well as specify how many Coeffs to use. At some point I guess this will find its way to the Python and R interfaces too. So, when it comes to the exponential fit via R, it is not a matter of incorrect day count issues, or bonds with the same maturity. It is that R is not giving access to the finer details of the fitting method, which are needed in this case. I hope this all sounds reasonable, David Sansom From: mat...@gm... <mat...@gm...> Sent: Wednesday, 16 December 2020 20:51 To: 'Random User' <qld...@gm...>; qua...@li... Subject: Re: [Quantlib-users] FittedBondCurve in R Hello “Random User”, Your example made me try out the QuantLib R extension which I never used before. Put your code into a file if someone else wants to try – I believe the attachment may survive distribution in this list. Anyway this will not be the answer you hoped for, but let me share an anecdotal (attempt of) advice. Some while ago I tried to essentially do the same: Fit a curve based on government bonds. My dataset also included several bonds at the same tenor, so the first approach to simply pass the bonds to a function like this (Python code)… ql.PiecewiseLogCubicDiscount(settle_days, calendar, bond_helpers, day_count) …required to filter the dataset to avoid such “collisions”. With that, I got a somewhat bumpy curve with quite some oscillations on the short tenors. So, in order to smoothen that curve, I used the same class you also used, but chose cubic splines instead of exponential, because some paper suggested so. Do not remember which, but not the ones mentioned in the C++ documentation of the regarding class. Well, I did not read them, but I am pretty sure the one I had was way more recent. ql.FittedBondDiscountCurve(settle_days, calendar, bond_helpers, day_count, ql.CubicBSplinesFitting(knots, True), tolerance, iterations) That said, I also tried Nelson-Siegel and indeed the exponential splines, but both methods would give me the linear curve you got as well. So I quickly discarded them without much thinking about as to why this kind of “deformation” may have happened. Speaking of deformation: I had to do some uneducated tweaking for the control knots vector to get suitable results where “suitable results” means: pricing of some benchmark corporate bonds yielded reasonable results. Not sure if there a good universal way to choose those knots, looking again at the C++ code docs: \warning "The results are extremely sensitive to the number and location of the knot points, and there is no optimal way of selecting them." James, J. and N. Webber, "Interest Rate Modelling" John Wiley, 2000, pp. 440. So, all in all not very scientific and more of a fun exercise. But all the same I am, too, interested in more details about this function. Suppose that more data cleansing could help, but I am pretty sure not to have included anything but plain bonds. Regards, Matthias From: Random User <qld...@gm... <mailto:qld...@gm...> > Sent: Wednesday, 2 December 2020 08:59 To: qua...@li... <mailto:qua...@li...> Subject: [Quantlib-users] FittedBondCurve in R Hello all - I'm trying to build a fitted US Treasury curve using FittedBondCurve(). However, my results are odd for two reasons. (1) the shape of the curve is a straight line and not concave as one might expect (2) the yields of the modeled term structure are within a very tight range for the entire curve and well below even the lowest yields in the yield dataset that is being fit (yields being fit are shown in the dataframe below). The only possible issues I can suspect are day count issues in my dateparams (unclear why) or the function being able to fit multiple data points for a single maturity. On this second point, for example, I'm trying to model all outstanding Treasuries, so there are several bonds that sit at the same maturity point (eg. at the 1Y point there could be an originally issued 2Y bond that has aged 1 year along with an originally issued 30Y bond that has aged 29 years etc.). I've included the relatively short code along with the dataset being fit to hopefully ease replication. This is very close to the QuantLib example for the function with the major difference that I'm trying to fit actual bond prices (the df that is referenced is shown in full below). Please let me know if you need more information. Thanks for any help! [[ REMOVED ]] |
|
From: <mat...@gm...> - 2020-12-16 20:51:16
|
Hello “Random User”,
Your example made me try out the QuantLib R extension which I never used before. Put your code into a file if someone else wants to try – I believe the attachment may survive distribution in this list.
Anyway this will not be the answer you hoped for, but let me share an anecdotal (attempt of) advice.
Some while ago I tried to essentially do the same: Fit a curve based on government bonds. My dataset also included several bonds at the same tenor, so the first approach to simply pass the bonds to a function like this (Python code)…
ql.PiecewiseLogCubicDiscount(settle_days, calendar, bond_helpers, day_count)
…required to filter the dataset to avoid such “collisions”.
With that, I got a somewhat bumpy curve with quite some oscillations on the short tenors. So, in order to smoothen that curve, I used the same class you also used, but chose cubic splines instead of exponential, because some paper suggested so. Do not remember which, but not the ones mentioned in the C++ documentation of the regarding class. Well, I did not read them, but I am pretty sure the one I had was way more recent.
ql.FittedBondDiscountCurve(settle_days,
calendar,
bond_helpers,
day_count,
ql.CubicBSplinesFitting(knots, True),
tolerance,
iterations)
That said, I also tried Nelson-Siegel and indeed the exponential splines, but both methods would give me the linear curve you got as well. So I quickly discarded them without much thinking about as to why this kind of “deformation” may have happened.
Speaking of deformation: I had to do some uneducated tweaking for the control knots vector to get suitable results where “suitable results” means: pricing of some benchmark corporate bonds yielded reasonable results.
Not sure if there a good universal way to choose those knots, looking again at the C++ code docs:
\warning "The results are extremely sensitive to the number
and location of the knot points, and there is no
optimal way of selecting them." James, J. and
N. Webber, "Interest Rate Modelling" John Wiley,
2000, pp. 440.
So, all in all not very scientific and more of a fun exercise. But all the same I am, too, interested in more details about this function. Suppose that more data cleansing could help, but I am pretty sure not to have included anything but plain bonds.
Regards,
Matthias
From: Random User <qld...@gm...>
Sent: Wednesday, 2 December 2020 08:59
To: qua...@li...
Subject: [Quantlib-users] FittedBondCurve in R
Hello all -
I'm trying to build a fitted US Treasury curve using FittedBondCurve(). However, my results are odd for two reasons. (1) the shape of the curve is a straight line and not concave as one might expect (2) the yields of the modeled term structure are within a very tight range for the entire curve and well below even the lowest yields in the yield dataset that is being fit (yields being fit are shown in the dataframe below).
The only possible issues I can suspect are day count issues in my dateparams (unclear why) or the function being able to fit multiple data points for a single maturity. On this second point, for example, I'm trying to model all outstanding Treasuries, so there are several bonds that sit at the same maturity point (eg. at the 1Y point there could be an originally issued 2Y bond that has aged 1 year along with an originally issued 30Y bond that has aged 29 years etc.).
I've included the relatively short code along with the dataset being fit to hopefully ease replication. This is very close to the QuantLib example for the function with the major difference that I'm trying to fit actual bond prices (the df that is referenced is shown in full below). Please let me know if you need more information. Thanks for any help!
[[ REMOVED ]]
|
|
From: Tom A. <tw...@ur...> - 2020-12-15 10:01:48
|
Thanks for the responses, everyone! I am also tempted to interpolate between 1M and 3M, and forget about 2M. I suspect the error from doing that is below the noise floor of the input market data anyway. Worth checking, though! I note that IborCoupon already requests forecast fixings from its index using a method which takes the value and end dates of the accrual period as parameters. I think that would let it use an interpolating index class directly, which means i could use a normal VanillaSwap here. However, it doesn't do that for past fixings - it only passes the fixing date. If i am only interested in pricing fresh (unseasoned) swaps, that would be enough. The interpolating index could throw an exception from its pastFixing method. Or, as you say, i could stuff in dummy values for the past, based on what i know the stub dates are. As long as i don't have two swaps whose stubs started on the same day but are different lenths. Perhaps i would just generate a separate index for each swap. I also wonder if i could handle this by using the existing VanillaSwap and adding a spread. If VanillaSwap uses, say, the 3M Ibor for the stub coupon, i could work out the error in that, as the difference between the 3M fixing and the interpolated fixing, and then somehow turn that into a floating leg spread. This feels like it would be rather hard to get right, as the spread will be smeared out along the discounting curve, whereas the error is concentrated at the start. Also, there's no way to change the spread after the object is created. I suppose there is no great desire to add support for short stubs to QuantLib, because in a few years, the tenor Ibors will be gone, and we will only be trading OISs. Regards, tom On Sat, 12 Dec 2020, Peter Caspers wrote: > I guess a "full" solution supporting both front and back stubs > (requiring projected fixings) could consist of > > - a new curve class taking the Euribor1M and Euribor3M projection > curves as input and giving an interpolated Euribor2M projection curve > as an output (to support the Ibor tenors that are still real, but for > which you can't directly bootstrap a forward curve) > - an interpolated Ibor index class taking two Ibor indices and weights > and managing the interpolation of historical and projected fixings > - an interpolated Ibor coupon class on top of the interpolated Ibor index class > > This is how we handle this anyway. As you say, for historical fixings > you can use a dummy index + coupon and set the fixing value manually. > For projected fixings, you could try to use two coupons (say on > Euribor1M and 3M) for the same accrual period and use their nominals > to interpolate the effective rate. You still have the problem to set > up the Euribor2M projection curve then though. > > It's maybe a bit late to introduce all that to QuantLib though :-) > > Best regards, > Peter > > On Fri, 11 Dec 2020 at 22:35, Mike DelMedico <mik...@gm...> wrote: >> >> Tom, >> >> This has been on my list to tackle for a while. Basically you need to >> build schedules AND (assuming it’s a short front stub) override the >> first cash flow of the swap object using the interpolated fixing from >> your two curves (2m + 3m in this case). Given that 2m is getting the >> axe soon, I think I’ll probably just go with the simpler version of >> interpolating off the 1m and 3m curves and assign the stub fixing that >> way. >> >> Luigi gave me some starting pointers to look at several months ago, let >> me see if I can dig them up and pass them along. I’d be happy to work >> with you on this if you’d like. >> >> >> Regards, >> Mike >> >> >> >> On Fri, Dec 11, 2020 at 15:22 Arkadiy Naumov <ark...@gm...> wrote: >>> >>> Hi Tom, >>> >>> As far as I understand, this is all transparent in QL, in a sense that >>> all you have to is to build a swap with appropriate payments schedule. >>> Nothing special is required for the curve (unless you are really keen >>> on very particular interpolation between very particular points) - a >>> curve is able to generate fixing values for any arbitrary tenor on its >>> own. >>> >>> Sent from my iPhone >>> >>> > On Dec 11, 2020, at 3:32 PM, Tom Anderson <tw...@ur...> wrote: >>> > >>> > Hello, >>> > >>> > Certain difficult people might like to trade swaps whose tenors are not integer multiples of their index tenors. For example, a 26.5 month swap against 3-month LIBOR, which, assuming backward date generation, has a 2.5-month first accrual period. My understanding is that in this case, the cashflow for the first period is determined not by a fixing of 3-month LIBOR, but by linear interpolation between fixings of the closest tenors of LIBOR (2 and 3 month in this example). >>> > >>> > Can i model swaps like this with QuantLib? >>> > >>> > I'm assuming i'll have to build separate curves for the tenors i want to interpolate between, but how do i connect them to a swap? >>> > >>> > Thanks, >>> > tom >>> > >>> > -- >>> > Advertising does not make content free. It merely externalizes the >>> > costs in a way that incentivizes malicious or incompetent players to >>> > build things like Superfish, infect 1 in 20 machines with ad injection >>> > malware, and create sites that require unsafe plugins and take twice as >>> > many resources to load, quite expensive in terms of bandwidth, power, >>> > and stability. -- Monica Chew >>> > >>> > >>> > _______________________________________________ >>> > 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 >> >> _______________________________________________ >> 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 -- If you can't open it, you don't own it -- The Maker's Bill of Rights |
|
From: Philippe H. <phi...@ex...> - 2020-12-12 19:24:40
|
Is there an existing model to build a swap curve with SOFR futures instead of Eurodollar futures? Is the convexity adjustment futures vs forward a similar approach? I believe the daily compounding nature of the SOFR contract may complicate the approach a bit. Philippe Hatstadt -- Broker-Dealer services offered through Exos Securities LLC, member of SIPC <http://www.sipc.org/> / FINRA <http://www.finra.org/> / BrokerCheck <https://brokercheck.finra.org/>/ 2020 Exos, inc. For important disclosures, click here <https://www.exosfinancial.com/general-disclosures>. |
|
From: Peter C. <pca...@gm...> - 2020-12-12 19:08:54
|
Hey Mike, can you use CashFlows::bps() to get the fixed leg BPS and compute the fair rate as fixedRate - SwapNPV / BPS as it is done in VanillaSwap? On Sat, 12 Dec 2020 at 19:11, Mike DelMedico <mik...@gm...> wrote: > > Peter, > > Thanks for sharing the framework, that seems very robust. If I remember correctly I think the biggest hurdle I encountered was getting the fair rate of the swap along with the fixed/floatBPS values given the object wasn’t in the vanilla swap class so the standard methods are not available to call. I’m using python though so that could be part of it if certain methods aren’t exposed via SWIG. > > Thanks, > Mike > > > On Sat, Dec 12, 2020 at 05:14 Peter Caspers <pca...@gm...> wrote: >> >> I guess a "full" solution supporting both front and back stubs >> (requiring projected fixings) could consist of >> >> - a new curve class taking the Euribor1M and Euribor3M projection >> curves as input and giving an interpolated Euribor2M projection curve >> as an output (to support the Ibor tenors that are still real, but for >> which you can't directly bootstrap a forward curve) >> - an interpolated Ibor index class taking two Ibor indices and weights >> and managing the interpolation of historical and projected fixings >> - an interpolated Ibor coupon class on top of the interpolated Ibor index class >> >> This is how we handle this anyway. As you say, for historical fixings >> you can use a dummy index + coupon and set the fixing value manually. >> For projected fixings, you could try to use two coupons (say on >> Euribor1M and 3M) for the same accrual period and use their nominals >> to interpolate the effective rate. You still have the problem to set >> up the Euribor2M projection curve then though. >> >> It's maybe a bit late to introduce all that to QuantLib though :-) >> >> Best regards, >> Peter >> >> On Fri, 11 Dec 2020 at 22:35, Mike DelMedico <mik...@gm...> wrote: >> > >> > Tom, >> > >> > This has been on my list to tackle for a while. Basically you need to build schedules AND (assuming it’s a short front stub) override the first cash flow of the swap object using the interpolated fixing from your two curves (2m + 3m in this case). Given that 2m is getting the axe soon, I think I’ll probably just go with the simpler version of interpolating off the 1m and 3m curves and assign the stub fixing that way. >> > >> > Luigi gave me some starting pointers to look at several months ago, let me see if I can dig them up and pass them along. I’d be happy to work with you on this if you’d like. >> > >> > >> > Regards, >> > Mike >> > >> > >> > >> > On Fri, Dec 11, 2020 at 15:22 Arkadiy Naumov <ark...@gm...> wrote: >> >> >> >> Hi Tom, >> >> >> >> As far as I understand, this is all transparent in QL, in a sense that all you have to is to build a swap with appropriate payments schedule. Nothing special is required for the curve (unless you are really keen on very particular interpolation between very particular points) - a curve is able to generate fixing values for any arbitrary tenor on its own. >> >> >> >> Sent from my iPhone >> >> >> >> > On Dec 11, 2020, at 3:32 PM, Tom Anderson <tw...@ur...> wrote: >> >> > >> >> > Hello, >> >> > >> >> > Certain difficult people might like to trade swaps whose tenors are not integer multiples of their index tenors. For example, a 26.5 month swap against 3-month LIBOR, which, assuming backward date generation, has a 2.5-month first accrual period. My understanding is that in this case, the cashflow for the first period is determined not by a fixing of 3-month LIBOR, but by linear interpolation between fixings of the closest tenors of LIBOR (2 and 3 month in this example). >> >> > >> >> > Can i model swaps like this with QuantLib? >> >> > >> >> > I'm assuming i'll have to build separate curves for the tenors i want to interpolate between, but how do i connect them to a swap? >> >> > >> >> > Thanks, >> >> > tom >> >> > >> >> > -- >> >> > Advertising does not make content free. It merely externalizes the >> >> > costs in a way that incentivizes malicious or incompetent players to >> >> > build things like Superfish, infect 1 in 20 machines with ad injection >> >> > malware, and create sites that require unsafe plugins and take twice as >> >> > many resources to load, quite expensive in terms of bandwidth, power, >> >> > and stability. -- Monica Chew >> >> > >> >> > >> >> > _______________________________________________ >> >> > 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 >> > >> > _______________________________________________ >> > QuantLib-users mailing list >> > Qua...@li... >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Teddy O <tm...@ho...> - 2020-12-12 18:37:01
|
Hi, sorry for the late response, but I finally got this to work. I needed to copy vcruntime140_1.dll from another directory into the windows/system32 folder. Thanks for your help on this. Sent from Outlook<http://aka.ms/weboutlook> ________________________________ From: li cheng <weg...@ho...> Sent: Friday, November 20, 2020 6:14 AM To: Teddy O <tm...@ho...>; Luigi Ballabio <lui...@gm...> Cc: qua...@li... <qua...@li...> Subject: 回复: [Quantlib-users] DLL Load Failed So you may have a check about your PATH config, is c:\windows\system32 is in PATH? Below is my screenshot, all is ok: [cid:image003.jpg@01D6BF47.732C61C0] 发件人: Teddy O <tm...@ho...> 发送时间: 2020年11月19日 8:19 收件人: li cheng <weg...@ho...>; Luigi Ballabio <lui...@gm...> 抄送: qua...@li... 主题: Re: [Quantlib-users] DLL Load Failed yes, it installed _QuantLib.cp38-win_amd64.pyd this time instead of 37. I ran another dependency walker that was supposed to get rid of a bunch of false errors. I'm assuming the issue is this VCRUNTIME140_1.dll, but I also see I have it just below it in windows\system32. [cid:image002.png@01D6BF47.73211720] Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648694290%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Grn4yRTEjc0kHKHlPGsHr6SW1H1p1CXL8lIsHWhLHX8%3D&reserved=0> ________________________________ From: li cheng <weg...@ho...<mailto:weg...@ho...>> Sent: Wednesday, November 18, 2020 8:55 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>>; Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: 回复: [Quantlib-users] DLL Load Failed Could you have a try using Dependency Worker to see the dll linking chain about your *.pyd file. http://dependencywalker.com/<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdependencywalker.com%2F&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648694290%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0WYgmzhcM6zQpcq8NRwV0DopMZTPT%2B1wdKY6YbJDows%3D&reserved=0> The error of missing dlls may caused by missing of vc’s redistribution package. Regards, Cheng 发件人: Teddy O <tm...@ho...<mailto:tm...@ho...>> 发送时间: 2020年11月18日 7:46 收件人: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> 抄送: qua...@li...<mailto:qua...@li...> 主题: Re: [Quantlib-users] DLL Load Failed Still no luck. getting the same error when I uninstall and then reinstall using python -m pip install -U QuantLib and python -m pip install -U QuantLib-python Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648704283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=k6U3c%2FhFGA%2FbAg0fbPdSp3Gji61p1jrfPbeakcZfJQo%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 2:09 PM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed Ok, I see. The DLL you have, _QuantLib.cp37-win_amd64.pyd, is compiled for Python 3.7. You probably have multiple versions of Python installed, and the version of pip you used to install QuantLib was the one for 3.7. Instead of calling pip directly (which might give you the wrong version for the Python you want to use), you can try something like python -m pip install -U QuantLib which will use the pip corresponding to the python you're running. Luigi On Tue, Nov 17, 2020 at 3:03 PM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: When I run it in the powershell it says 64bit. "Import Quantlib" also gives me the same error when I run it here as well. Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information. Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648704283%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=k6U3c%2FhFGA%2FbAg0fbPdSp3Gji61p1jrfPbeakcZfJQo%3D&reserved=0> ________________________________ From: Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>> Sent: Tuesday, November 17, 2020 8:09 AM To: Teddy O <tm...@ho...<mailto:tm...@ho...>> Cc: qua...@li...<mailto:qua...@li...> <qua...@li...<mailto:qua...@li...>> Subject: Re: [Quantlib-users] DLL Load Failed From the file names and paths, it seems you have the 64-bit version of QuantLib installed but spyder is using 32-bit python. May you check that? Luigi On Tue, Nov 17, 2020 at 3:52 AM Teddy O <tm...@ho...<mailto:tm...@ho...>> wrote: I installed quantlib using "pip install QuantLib" and now I'm getting the below error. I'm using windows 10 and Spyder IDE. I don't see any dll file called _QuantLib, only _QuantLib.cp37-win_amd64.pyd. File "C:\Conda\lib\site-packages\QuantLib\QuantLib.py", line 13, in from . import _QuantLib ImportError: DLL load failed: The specified module could not be found. These are my path variables: C:\Conda\python38.zip C:\Conda\DLLs C:\Conda\lib C:\Conda C:\Conda\lib\site-packages C:\Conda\lib\site-packages\win32 C:\Conda\lib\site-packages\win32\lib C:\Conda\lib\site-packages\Pythonwin C:\Conda\lib\site-packages\IPython\extensions C:\Users\name t\.ipython Has anyone experienced a similar problem? Thanks Sent from Outlook<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Faka.ms%2Fweboutlook&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648714277%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Q0w8gWmEh18W%2Bp0ExwTijrWu6togLBd2YmzMJ2wlGjw%3D&reserved=0> _______________________________________________ QuantLib-users mailing list Qua...@li...<mailto:Qua...@li...> https://lists.sourceforge.net/lists/listinfo/quantlib-users<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fquantlib-users&data=04%7C01%7C%7Cd899b521e7ee4eda081208d88c20c4cb%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413419648714277%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=VtsqouqWV%2Bbt5vUzGoifWlwSeUdmUcFXoe5UuBub6N4%3D&reserved=0> |
|
From: Mike D. <mik...@gm...> - 2020-12-12 18:11:35
|
Peter, Thanks for sharing the framework, that seems very robust. If I remember correctly I think the biggest hurdle I encountered was getting the fair rate of the swap along with the fixed/floatBPS values given the object wasn’t in the vanilla swap class so the standard methods are not available to call. I’m using python though so that could be part of it if certain methods aren’t exposed via SWIG. Thanks, Mike On Sat, Dec 12, 2020 at 05:14 Peter Caspers <pca...@gm...> wrote: > I guess a "full" solution supporting both front and back stubs > (requiring projected fixings) could consist of > > - a new curve class taking the Euribor1M and Euribor3M projection > curves as input and giving an interpolated Euribor2M projection curve > as an output (to support the Ibor tenors that are still real, but for > which you can't directly bootstrap a forward curve) > - an interpolated Ibor index class taking two Ibor indices and weights > and managing the interpolation of historical and projected fixings > - an interpolated Ibor coupon class on top of the interpolated Ibor index > class > > This is how we handle this anyway. As you say, for historical fixings > you can use a dummy index + coupon and set the fixing value manually. > For projected fixings, you could try to use two coupons (say on > Euribor1M and 3M) for the same accrual period and use their nominals > to interpolate the effective rate. You still have the problem to set > up the Euribor2M projection curve then though. > > It's maybe a bit late to introduce all that to QuantLib though :-) > > Best regards, > Peter > > On Fri, 11 Dec 2020 at 22:35, Mike DelMedico <mik...@gm...> > wrote: > > > > Tom, > > > > This has been on my list to tackle for a while. Basically you need to > build schedules AND (assuming it’s a short front stub) override the first > cash flow of the swap object using the interpolated fixing from your two > curves (2m + 3m in this case). Given that 2m is getting the axe soon, I > think I’ll probably just go with the simpler version of interpolating off > the 1m and 3m curves and assign the stub fixing that way. > > > > Luigi gave me some starting pointers to look at several months ago, let > me see if I can dig them up and pass them along. I’d be happy to work with > you on this if you’d like. > > > > > > Regards, > > Mike > > > > > > > > On Fri, Dec 11, 2020 at 15:22 Arkadiy Naumov <ark...@gm...> > wrote: > >> > >> Hi Tom, > >> > >> As far as I understand, this is all transparent in QL, in a sense that > all you have to is to build a swap with appropriate payments schedule. > Nothing special is required for the curve (unless you are really keen on > very particular interpolation between very particular points) - a curve is > able to generate fixing values for any arbitrary tenor on its own. > >> > >> Sent from my iPhone > >> > >> > On Dec 11, 2020, at 3:32 PM, Tom Anderson <tw...@ur...> > wrote: > >> > > >> > Hello, > >> > > >> > Certain difficult people might like to trade swaps whose tenors are > not integer multiples of their index tenors. For example, a 26.5 month swap > against 3-month LIBOR, which, assuming backward date generation, has a > 2.5-month first accrual period. My understanding is that in this case, the > cashflow for the first period is determined not by a fixing of 3-month > LIBOR, but by linear interpolation between fixings of the closest tenors of > LIBOR (2 and 3 month in this example). > >> > > >> > Can i model swaps like this with QuantLib? > >> > > >> > I'm assuming i'll have to build separate curves for the tenors i want > to interpolate between, but how do i connect them to a swap? > >> > > >> > Thanks, > >> > tom > >> > > >> > -- > >> > Advertising does not make content free. It merely externalizes the > >> > costs in a way that incentivizes malicious or incompetent players to > >> > build things like Superfish, infect 1 in 20 machines with ad injection > >> > malware, and create sites that require unsafe plugins and take twice > as > >> > many resources to load, quite expensive in terms of bandwidth, power, > >> > and stability. -- Monica Chew > >> > > >> > > >> > _______________________________________________ > >> > 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 > > > > _______________________________________________ > > QuantLib-users mailing list > > Qua...@li... > > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Peter C. <pca...@gm...> - 2020-12-12 11:15:19
|
I guess a "full" solution supporting both front and back stubs (requiring projected fixings) could consist of - a new curve class taking the Euribor1M and Euribor3M projection curves as input and giving an interpolated Euribor2M projection curve as an output (to support the Ibor tenors that are still real, but for which you can't directly bootstrap a forward curve) - an interpolated Ibor index class taking two Ibor indices and weights and managing the interpolation of historical and projected fixings - an interpolated Ibor coupon class on top of the interpolated Ibor index class This is how we handle this anyway. As you say, for historical fixings you can use a dummy index + coupon and set the fixing value manually. For projected fixings, you could try to use two coupons (say on Euribor1M and 3M) for the same accrual period and use their nominals to interpolate the effective rate. You still have the problem to set up the Euribor2M projection curve then though. It's maybe a bit late to introduce all that to QuantLib though :-) Best regards, Peter On Fri, 11 Dec 2020 at 22:35, Mike DelMedico <mik...@gm...> wrote: > > Tom, > > This has been on my list to tackle for a while. Basically you need to build schedules AND (assuming it’s a short front stub) override the first cash flow of the swap object using the interpolated fixing from your two curves (2m + 3m in this case). Given that 2m is getting the axe soon, I think I’ll probably just go with the simpler version of interpolating off the 1m and 3m curves and assign the stub fixing that way. > > Luigi gave me some starting pointers to look at several months ago, let me see if I can dig them up and pass them along. I’d be happy to work with you on this if you’d like. > > > Regards, > Mike > > > > On Fri, Dec 11, 2020 at 15:22 Arkadiy Naumov <ark...@gm...> wrote: >> >> Hi Tom, >> >> As far as I understand, this is all transparent in QL, in a sense that all you have to is to build a swap with appropriate payments schedule. Nothing special is required for the curve (unless you are really keen on very particular interpolation between very particular points) - a curve is able to generate fixing values for any arbitrary tenor on its own. >> >> Sent from my iPhone >> >> > On Dec 11, 2020, at 3:32 PM, Tom Anderson <tw...@ur...> wrote: >> > >> > Hello, >> > >> > Certain difficult people might like to trade swaps whose tenors are not integer multiples of their index tenors. For example, a 26.5 month swap against 3-month LIBOR, which, assuming backward date generation, has a 2.5-month first accrual period. My understanding is that in this case, the cashflow for the first period is determined not by a fixing of 3-month LIBOR, but by linear interpolation between fixings of the closest tenors of LIBOR (2 and 3 month in this example). >> > >> > Can i model swaps like this with QuantLib? >> > >> > I'm assuming i'll have to build separate curves for the tenors i want to interpolate between, but how do i connect them to a swap? >> > >> > Thanks, >> > tom >> > >> > -- >> > Advertising does not make content free. It merely externalizes the >> > costs in a way that incentivizes malicious or incompetent players to >> > build things like Superfish, infect 1 in 20 machines with ad injection >> > malware, and create sites that require unsafe plugins and take twice as >> > many resources to load, quite expensive in terms of bandwidth, power, >> > and stability. -- Monica Chew >> > >> > >> > _______________________________________________ >> > 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 > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Mike D. <mik...@gm...> - 2020-12-11 21:34:48
|
Tom, This has been on my list to tackle for a while. Basically you need to build schedules AND (assuming it’s a short front stub) override the first cash flow of the swap object using the interpolated fixing from your two curves (2m + 3m in this case). Given that 2m is getting the axe soon, I think I’ll probably just go with the simpler version of interpolating off the 1m and 3m curves and assign the stub fixing that way. Luigi gave me some starting pointers to look at several months ago, let me see if I can dig them up and pass them along. I’d be happy to work with you on this if you’d like. Regards, Mike On Fri, Dec 11, 2020 at 15:22 Arkadiy Naumov <ark...@gm...> wrote: > Hi Tom, > > As far as I understand, this is all transparent in QL, in a sense that all > you have to is to build a swap with appropriate payments schedule. Nothing > special is required for the curve (unless you are really keen on very > particular interpolation between very particular points) - a curve is able > to generate fixing values for any arbitrary tenor on its own. > > Sent from my iPhone > > > On Dec 11, 2020, at 3:32 PM, Tom Anderson <tw...@ur...> wrote: > > > > Hello, > > > > Certain difficult people might like to trade swaps whose tenors are not > integer multiples of their index tenors. For example, a 26.5 month swap > against 3-month LIBOR, which, assuming backward date generation, has a > 2.5-month first accrual period. My understanding is that in this case, the > cashflow for the first period is determined not by a fixing of 3-month > LIBOR, but by linear interpolation between fixings of the closest tenors of > LIBOR (2 and 3 month in this example). > > > > Can i model swaps like this with QuantLib? > > > > I'm assuming i'll have to build separate curves for the tenors i want to > interpolate between, but how do i connect them to a swap? > > > > Thanks, > > tom > > > > -- > > Advertising does not make content free. It merely externalizes the > > costs in a way that incentivizes malicious or incompetent players to > > build things like Superfish, infect 1 in 20 machines with ad injection > > malware, and create sites that require unsafe plugins and take twice as > > many resources to load, quite expensive in terms of bandwidth, power, > > and stability. -- Monica Chew > > > > > > _______________________________________________ > > 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: Arkadiy N. <ark...@gm...> - 2020-12-11 21:20:00
|
Hi Tom, As far as I understand, this is all transparent in QL, in a sense that all you have to is to build a swap with appropriate payments schedule. Nothing special is required for the curve (unless you are really keen on very particular interpolation between very particular points) - a curve is able to generate fixing values for any arbitrary tenor on its own. Sent from my iPhone > On Dec 11, 2020, at 3:32 PM, Tom Anderson <tw...@ur...> wrote: > > Hello, > > Certain difficult people might like to trade swaps whose tenors are not integer multiples of their index tenors. For example, a 26.5 month swap against 3-month LIBOR, which, assuming backward date generation, has a 2.5-month first accrual period. My understanding is that in this case, the cashflow for the first period is determined not by a fixing of 3-month LIBOR, but by linear interpolation between fixings of the closest tenors of LIBOR (2 and 3 month in this example). > > Can i model swaps like this with QuantLib? > > I'm assuming i'll have to build separate curves for the tenors i want to interpolate between, but how do i connect them to a swap? > > Thanks, > tom > > -- > Advertising does not make content free. It merely externalizes the > costs in a way that incentivizes malicious or incompetent players to > build things like Superfish, infect 1 in 20 machines with ad injection > malware, and create sites that require unsafe plugins and take twice as > many resources to load, quite expensive in terms of bandwidth, power, > and stability. -- Monica Chew > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Tom A. <tw...@ur...> - 2020-12-11 20:29:54
|
Hello, Certain difficult people might like to trade swaps whose tenors are not integer multiples of their index tenors. For example, a 26.5 month swap against 3-month LIBOR, which, assuming backward date generation, has a 2.5-month first accrual period. My understanding is that in this case, the cashflow for the first period is determined not by a fixing of 3-month LIBOR, but by linear interpolation between fixings of the closest tenors of LIBOR (2 and 3 month in this example). Can i model swaps like this with QuantLib? I'm assuming i'll have to build separate curves for the tenors i want to interpolate between, but how do i connect them to a swap? Thanks, tom -- Advertising does not make content free. It merely externalizes the costs in a way that incentivizes malicious or incompetent players to build things like Superfish, infect 1 in 20 machines with ad injection malware, and create sites that require unsafe plugins and take twice as many resources to load, quite expensive in terms of bandwidth, power, and stability. -- Monica Chew |
|
From: Francois B. <ig...@gm...> - 2020-12-11 16:13:27
|
Hi all, I'm looking for the most appropriate class in QuantLib to model our NCDs. For example, we have an 18M NCD that pays 5-monthly coupons. The market quote determines the value of the coupons, so that if the rate is market quote / rate is 4%, the coupons are 2% each. I can easily model this with the FixedRateBond class, by putting the market quote in as the coupon rate, but the coupons are a vector of type Real. I'm looking for an instrument that accepts the market quote as a Handle<Quote> so that I can benefit from its features. Does such a class and its associated RateHelper class exist yet in QuantLib? And if not, what would be the closest class to use a base when writing the correct implementation? thank you Francois Botha |
|
From: <ben...@ma...> - 2020-12-11 02:19:11
|
I am looking at pricing the extension risk of AT1 bank issued bonds. These are tier 1 bonds that have extension features. These are a bit complex as it boils down to a ‘put’ in to a forward start callable bond. We break up the bond into a * non-callable bond (Quantlib is fine here…. tick!) * puttable ‘callable’ bond * The puttable part has non-economic trigger – i.e. the issuer will ‘put’ the bond, not based on if the forward bond is in the money or not, but based on other considerations such as Tier 1 capital considerations of the bank and the market for refinance. * The callable bond is a bond that settles at the ‘first call date’ and in many instances is perpetual. Coupons are resettable and can be fixed or floating. There is usually a call schedule that typically is based on the coupon dates. Generally these bonds would ultimately be called when the bank or market conditions improve. The puttable part I think will be OK as I an imply the option premium by the difference in the non-call price and the market price of the bond. If I can work out the price of the callable bond, I can then infer back the put option delta (i.e. probability of extending). Looking at the callable bond part – I see that Quantlib can not do callable floaters. This is OK for now, but this will need to be addressed at some point (floaters would dampen the price volatility). But my question is this -what I will need is the CR01 of the extendable bond. In the case I am looking at, the bond has a legal maturity of 2168 and clearly the risk is not all to this date. So to calculate the CR01, I would need to look at the value (and imply a delta) at each lattice node. Is it possible to get details of the lattice? Any help here would be helpful. Happy to entertain other ideas on pricing these. Regards Ben |
|
From: Random U. <qld...@gm...> - 2020-12-02 07:59:58
|
Hello all -
I'm trying to build a fitted US Treasury curve using FittedBondCurve().
However, my results are odd for two reasons. (1) the shape of the curve is
a straight line and not concave as one might expect (2) the yields of the
modeled term structure are within a very tight range for the entire curve
and well below even the lowest yields in the yield dataset that is being
fit (yields being fit are shown in the dataframe below).
The only possible issues I can suspect are day count issues in my
dateparams (unclear why) or the function being able to fit multiple data
points for a single maturity. On this second point, for example, I'm trying
to model all outstanding Treasuries, so there are several bonds that sit at
the same maturity point (eg. at the 1Y point there could be an originally
issued 2Y bond that has aged 1 year along with an originally issued 30Y
bond that has aged 29 years etc.).
I've included the relatively short code along with the dataset being fit to
hopefully ease replication. This is very close to the QuantLib example for
the function with the major difference that I'm trying to fit actual bond
prices (the df that is referenced is shown in full below). Please let me
know if you need more information. Thanks for any help!
### Please load df shown at the bottom of the code before running
df <- df[order(df$YrsToMat),]
row.names(df)<-NULL
YrsToMat <- df$YrsToMat
marketQuotes <- df$Prices
cpn_rates <- df$Coupons
# I used these parameters from the QuantLib cookbook where a Treasury curve
was bootstrapped (page 101) - Treasuries settle T+1 and are Actual/Actual,
but the ActualActual.Bond dayCounter seems to give even worse results.
dateparams <- list(settlementDays=0, period="Semiannual",
dayCounter="Thirty360",
businessDayConvention ="Unadjusted")
curveparams <- list(method="ExponentialSplinesFitting",
origDate = Sys.Date())
curve <- FittedBondCurve(curveparams, YrsToMat, cpn_rates, marketQuotes,
dateparams)
z <- zoo::zoo(curve$table$zeroRates, order.by=curve$table$date)
plot(z)
df = structure(list(ISIN = c("US9128285R78", "US912828G534",
"US912828U659",
"US912828YT13", "US9128285V80", "US912828G872", "US912828U816",
"US912828YZ72", "US9128286C90", "US912828H862", "US912828SF82",
"US912828V723", "US912828Z609", "US9128286H87", "US912828J439",
"US912828W556", "US912828ZA13", "US9128286M72", "US912828J769",
"US912828W895", "US912828ZG82", "US9128286U98", "US912828SV33",
"US912828WZ90", "US912828X471", "US912828ZM50", "US9128286Y11",
"US912828XD79", "US912828XR65", "US912828ZR48", "US9128287C81",
"US912828XG01", "US912828XW50", "US912828ZX16", "US9128282P40",
"US912828XQ82", "US91282CAC55", "US912810EM63", "US912828TJ95",
"US912828YA22", "US9128282S88", "US912828L245", "US912828YF19",
"US91282CAG69", "US9128282W90", "US912828L575", "US912828YK04",
"US91282CAN11", "US912810EN47", "US9128283C28", "US912828M490",
"US912828TY62", "US91282CAR25", "US912828M805", "US912828YW42",
"US91282CAX92", "US912828N308", "US912828Z294", "US912810EP94",
"US9128283U26", "US912828P386", "US912828UN88", "US912828Z864",
"US9128284A52", "US912828P790", "US912828ZD51", "US9128284D91",
"US912828Q293", "US912828ZH65", "US9128284L18", "US912828R283",
"US912828VB32", "US912828ZP81", "US9128284S60", "US912828R697",
"US912828ZU76", "US9128284U17", "US912828S356", "US912828ZY98",
"US912810EQ77", "US912828S927", "US912828VS66", "US912828Y610",
"US91282CAF86", "US9128282D10", "US9128284X55", "US91282CAK71",
"US9128285D82", "US912828T263", "US91282CAP68", "US9128285K26",
"US912828T917", "US912828WE61", "US91282CAW10", "US9128285P13",
"US912828U576", "US9128285U08", "US912828V236", "US9128285Z94",
"US912828B667", "US912828V806", "US9128286G05", "US912828W481",
"US912828W713", "US9128286R69", "US912828WJ58", "US912828X703",
"US912828XT22", "US9128286Z85", "US912828XX34", "US9128282N91",
"US912828D564", "US912828Y875", "US9128282U35", "US912828YE44",
"US9128282Y56", "US912828YH74", "US912810ES34", "US9128283D01",
"US912828G385", "US912828YM69", "US9128283J70", "US912828YV68",
"US9128283P31", "US912828YY08", "US912810ET17", "US9128283V09",
"US912828J272", "US912828Z526", "US9128283Z13", "US912828ZC78",
"US9128284F40", "US912828ZF00", "US9128284M90", "US912828XB14",
"US912828ZL77", "US9128284R87", "US912828ZT04", "US912828XZ81",
"US912828ZW33", "US912810EV62", "US912828K742", "US912828Y792",
"US91282CAB72", "US9128284Z04", "US91282CAJ09", "US9128285C00",
"US91282CAM38", "US9128285J52", "US912828M565", "US91282CAT80",
"US9128285N64", "US91282CAZ41", "US9128285T35", "US912810EW46",
"US9128286A35", "US912828P469", "US9128286F22", "US9128286L99",
"US9128286S43", "US912828R366", "US9128286X38", "US9128287B09",
"US912810EX29", "US9128282A70", "US912828Y958", "US912828YD60",
"US912828YG91", "US912810EY02", "US912828U246", "US912828YQ73",
"US912828YU85", "US912828YX25", "US912810EZ76", "US912828V988",
"US912828Z781", "US912828ZB95", "US912828ZE35", "US912828X885",
"US912828ZN34", "US912828ZS21", "US912828ZV59", "US912810FA17",
"US9128282R06", "US91282CAD39", "US91282CAH43", "US91282CAL54",
"US912810FB99", "US9128283F58", "US91282CAU53", "US91282CAY75",
"US9128283W81", "US9128284N73", "US912810FE39", "US9128284V99",
"US912810FF04", "US9128285M81", "US912810FG86", "US9128286B18",
"US9128286T26", "US912810FJ26", "US912828YB05", "US912828YS30",
"US912828Z948", "US912810FM54", "US912828ZQ64", "US91282CAE12",
"US91282CAV37", "US912810FP85", "US912810FT08", "US912810PT97",
"US912810PU60", "US912810PW27", "US912810PX00", "US912810QA97",
"US912810QB70", "US912810QC53", "US912810QD37", "US912810QE10",
"US912810QH41", "US912810SR05", "US912810QK79", "US912810SQ22",
"US912810QL52", "US912810ST60", "US912810QN19", "US912810QQ40",
"US912810QS06", "US912810QT88", "US912810QU51", "US912810QW18",
"US912810QX90", "US912810QY73", "US912810QZ49", "US912810RB61",
"US912810RC45", "US912810RD28", "US912810RE01", "US912810RG58",
"US912810RH32", "US912810RJ97", "US912810RK60", "US912810RM27",
"US912810RN00", "US912810RP57", "US912810RQ31", "US912810RS96",
"US912810RT79", "US912810RU43", "US912810RV26", "US912810RX81",
"US912810RY64", "US912810RZ30", "US912810SA79", "US912810SC36",
"US912810SD19", "US912810SE91", "US912810SF66", "US912810SH23",
"US912810SJ88", "US912810SK51", "US912810SL35", "US912810SN90",
"US912810SP49", "US912810SS87"), YrsToMat = c(1, 1, 1, 1, 1.08333333333333,
1.08333333333333, 1.08333333333333, 1.08333333333333, 1.16666666666667,
1.16666666666667, 1.16666666666667, 1.16666666666667, 1.16666666666667,
1.25, 1.25, 1.25, 1.25, 1.33333333333333, 1.33333333333333,
1.33333333333333,
1.33333333333333, 1.41666666666667, 1.41666666666667, 1.41666666666667,
1.41666666666667, 1.41666666666667, 1.5, 1.5, 1.5, 1.5, 1.58333333333333,
1.58333333333333, 1.58333333333333, 1.58333333333333, 1.66666666666667,
1.66666666666667, 1.66666666666667, 1.66666666666667, 1.66666666666667,
1.66666666666667, 1.75, 1.75, 1.75, 1.75, 1.83333333333333,
1.83333333333333,
1.83333333333333, 1.83333333333333, 1.91666666666667, 1.91666666666667,
1.91666666666667, 1.91666666666667, 1.91666666666667, 2, 2, 2,
2.08333333333333, 2.08333333333333, 2.16666666666667, 2.16666666666667,
2.16666666666667, 2.16666666666667, 2.16666666666667, 2.25, 2.25,
2.25, 2.33333333333333, 2.33333333333333, 2.33333333333333,
2.41666666666667,
2.41666666666667, 2.41666666666667, 2.41666666666667, 2.5, 2.5,
2.5, 2.58333333333333, 2.58333333333333, 2.58333333333333,
2.66666666666667,
2.66666666666667, 2.66666666666667, 2.66666666666667, 2.66666666666667,
2.75, 2.75, 2.75, 2.83333333333333, 2.83333333333333, 2.83333333333333,
2.91666666666667, 2.91666666666667, 2.91666666666667, 2.91666666666667,
3, 3, 3.08333333333333, 3.08333333333333, 3.16666666666667,
3.16666666666667,
3.16666666666667, 3.25, 3.25, 3.33333333333333, 3.41666666666667,
3.41666666666667, 3.41666666666667, 3.5, 3.58333333333333,
3.58333333333333,
3.66666666666667, 3.66666666666667, 3.66666666666667, 3.75, 3.75,
3.83333333333333, 3.83333333333333, 3.91666666666667, 3.91666666666667,
3.91666666666667, 3.91666666666667, 4, 4, 4.08333333333333,
4.08333333333333,
4.16666666666667, 4.16666666666667, 4.16666666666667, 4.16666666666667,
4.25, 4.25, 4.33333333333333, 4.33333333333333, 4.41666666666667,
4.41666666666667, 4.41666666666667, 4.5, 4.5, 4.58333333333333,
4.58333333333333, 4.66666666666667, 4.66666666666667, 4.66666666666667,
4.66666666666667, 4.75, 4.75, 4.83333333333333, 4.83333333333333,
4.91666666666667, 4.91666666666667, 4.91666666666667, 5, 5,
5.08333333333333,
5.16666666666667, 5.16666666666667, 5.16666666666667, 5.25,
5.33333333333333,
5.41666666666667, 5.41666666666667, 5.5, 5.58333333333333,
5.66666666666667,
5.66666666666667, 5.66666666666667, 5.75, 5.83333333333333,
5.91666666666667,
5.91666666666667, 5.91666666666667, 6, 6.08333333333333, 6.16666666666667,
6.16666666666667, 6.16666666666667, 6.25, 6.33333333333333,
6.41666666666667,
6.41666666666667, 6.5, 6.58333333333333, 6.66666666666667,
6.66666666666667,
6.66666666666667, 6.75, 6.83333333333333, 6.91666666666667,
6.91666666666667,
6.91666666666667, 7, 7.16666666666667, 7.41666666666667, 7.66666666666667,
7.66666666666667, 8, 8, 8.25, 8.25, 8.41666666666667, 8.66666666666667,
8.66666666666667, 9, 9.25, 9.41666666666667, 9.41666666666667,
9.66666666666667, 10, 10.25, 15.25, 16.25, 16.4166666666667,
17.25, 17.4166666666667, 18.25, 18.4166666666667, 18.75, 19,
19.25, 19.5, 19.5, 19.75, 19.75, 20, 20, 20.25, 20.5, 20.75,
21, 21.25, 21.5, 21.75, 22, 22.25, 22.5, 22.75, 23, 23.25, 23.5,
23.75, 24, 24.25, 24.5, 24.75, 25, 25.25, 25.5, 25.75, 26, 26.25,
26.5, 26.75, 27, 27.25, 27.5, 27.75, 28, 28.25, 28.5, 28.75,
29, 29.25, 29.5, 29.75, 30), Coupons = c(0.02625, 0.01875, 0.0175,
0.015, 0.025, 0.02125, 0.02, 0.01625, 0.025, 0.015, 0.02, 0.01875,
0.01375, 0.02375, 0.0175, 0.01875, 0.01125, 0.0225, 0.0175, 0.01875,
0.00375, 0.02125, 0.0175, 0.0175, 0.01875, 0.00125, 0.0175, 0.01875,
0.0175, 0.00125, 0.0175, 0.02125, 0.0175, 0.00125, 0.01875, 0.02,
0.00125, 0.0725, 0.01625, 0.015, 0.01625, 0.01875, 0.015, 0.00125,
0.01875, 0.0175, 0.01375, 0.00125, 0.07625, 0.02, 0.01875, 0.01625,
0.00125, 0.02, 0.01625, 0.00125, 0.02125, 0.015, 0.07125, 0.02375,
0.0175, 0.02, 0.01375, 0.02625, 0.015, 0.005, 0.025, 0.015, 0.0025,
0.0275, 0.01625, 0.0175, 0.00125, 0.0275, 0.01625, 0.0025, 0.02625,
0.01375, 0.00125, 0.0625, 0.0125, 0.025, 0.0275, 0.00125, 0.01375,
0.0275, 0.00125, 0.02875, 0.01375, 0.00125, 0.02875, 0.01625,
0.0275, 0.0025, 0.02875, 0.02125, 0.02625, 0.0225, 0.025, 0.0275,
0.0225, 0.02375, 0.02125, 0.02125, 0.0225, 0.025, 0.02, 0.02,
0.0175, 0.02, 0.02125, 0.02375, 0.0175, 0.01875, 0.0125, 0.02125,
0.015, 0.075, 0.0225, 0.0225, 0.015, 0.02125, 0.015, 0.0225,
0.0175, 0.07625, 0.025, 0.02, 0.01375, 0.0275, 0.01125, 0.02625,
0.005, 0.02875, 0.02125, 0.00375, 0.02875, 0.0025, 0.0275, 0.0025,
0.06875, 0.02, 0.02875, 0.0025, 0.0275, 0.0025, 0.03, 0.0025,
0.03, 0.0225, 0.0025, 0.02875, 0.00375, 0.02625, 0.06, 0.02625,
0.01625, 0.025, 0.0225, 0.02375, 0.01625, 0.02125, 0.01875, 0.0675,
0.015, 0.01875, 0.01375, 0.01625, 0.065, 0.02, 0.01625, 0.01625,
0.0175, 0.06625, 0.0225, 0.015, 0.01125, 0.00625, 0.02375, 0.005,
0.005, 0.005, 0.06375, 0.0225, 0.00375, 0.005, 0.00375, 0.06125,
0.0225, 0.005, 0.00625, 0.0275, 0.02875, 0.055, 0.02875, 0.0525,
0.03125, 0.0525, 0.02625, 0.02375, 0.06125, 0.01625, 0.0175,
0.015, 0.0625, 0.00625, 0.00625, 0.00875, 0.05375, 0.045, 0.0475,
0.05, 0.04375, 0.045, 0.035, 0.0425, 0.045, 0.04375, 0.04625,
0.04375, 0.01125, 0.03875, 0.01125, 0.0425, 0.01375, 0.0475,
0.04375, 0.0375, 0.03125, 0.03125, 0.03, 0.0275, 0.0275, 0.03125,
0.02875, 0.03625, 0.0375, 0.03625, 0.03375, 0.03125, 0.03, 0.025,
0.03, 0.02875, 0.03, 0.025, 0.025, 0.0225, 0.02875, 0.03, 0.03,
0.0275, 0.0275, 0.03, 0.03125, 0.03, 0.03375, 0.03, 0.02875,
0.0225, 0.02375, 0.02, 0.0125, 0.01375, 0.01625), Prices = c(102.5703125,
101.72265625, 101.6015625, 101.36328125, 102.6328125, 102.1328125,
102.00390625, 101.6015625, 102.84375, 101.57421875, 102.26171875,
102.0078125, 101.43359375, 102.85546875, 101.99609375, 102.16015625,
101.23046875, 102.875, 102.125, 102.2890625, 100.3046875, 102.859375,
102.31640625, 102.25390625, 102.4296875, 99.98046875, 102.44140625,
102.5703125, 102.3828125, 99.96484375, 102.5703125, 103.08984375,
102.50390625, 99.94921875, 102.84375, 103.0390625, 99.94140625,
111.8828125, 102.484375, 102.2734375, 102.53125, 102.96484375,
102.36328125, 99.93359375, 103.11328125, 102.89453125, 102.25,
99.93359375, 114.38671875, 103.48828125, 103.25, 102.8359375,
99.921875, 103.63671875, 102.94921875, 99.92578125, 104.046875,
102.8046875, 115.14453125, 104.73828125, 103.40234375, 103.98828125,
102.625, 105.46484375, 102.953125, 100.72265625, 105.375, 103.05859375,
100.15625, 106.16015625, 103.45703125, 103.8125, 99.84375, 106.359375,
103.56640625, 100.140625, 106.24609375, 103.0390625, 99.80859375,
116.2109375, 102.79296875, 106.203125, 106.77734375, 99.7890625,
103.21484375, 106.953125, 99.7734375, 107.515625, 103.30859375,
99.75390625, 107.734375, 104.12109375, 107.48046875, 100.109375,
107.93359375, 105.7109375, 107.37109375, 106.22265625, 107.15625,
108.03515625, 106.375, 106.8984375, 106.08984375, 106.21484375,
106.77734375, 107.69921875, 105.92578125, 106.04296875, 105.27734375,
106.17578125, 106.73046875, 107.73046875, 105.3671875, 105.921875,
103.58203125, 106.96875, 104.578125, 128.28515625, 107.56640625,
107.6484375, 104.65234375, 107.203125, 104.7109375, 107.83203125,
105.78515625, 130.33203125, 108.984375, 106.9375, 104.30078125,
110.16015625, 103.2890625, 109.78125, 100.63671875, 111.02734375,
107.7890625, 100.0703125, 111.18359375, 99.484375, 110.76953125,
99.42578125, 130.01171875, 107.5234375, 111.51171875, 99.375,
111.08203125, 99.34375, 112.43359375, 99.28515625, 112.59765625,
108.99609375, 99.24609375, 112.1484375, 99.8203125, 111.0625,
128.45703125, 111.1953125, 106.08984375, 110.65625, 109.44921875,
110.21875, 106.19921875, 108.94140625, 107.6328125, 135.08984375,
105.59375, 107.68359375, 104.87890625, 106.32421875, 134.97265625,
108.57421875, 106.34765625, 106.3828125, 107.1796875, 136.921875,
110.2734375, 105.66796875, 103.36328125, 100.21484375, 111.2734375,
99.3515625, 99.26953125, 99.2109375, 137.765625, 110.61328125,
98.3125, 99.03125, 98.10546875, 137.24609375, 110.81640625, 98.84765625,
99.640625, 114.51953125, 115.71875, 135.74609375, 116.0078125,
134.7265625, 118.25, 135.58984375, 114.6171875, 112.8125, 144.94140625,
106.765625, 107.9140625, 105.6328125, 149.1015625, 97.59375,
97.3515625, 99.578125, 143.74609375, 146.921875, 152.53125, 156.859375,
148.73046875, 151.16015625, 135.8828125, 148.4296875, 153.0390625,
151.30859375, 156, 151.97265625, 94.7109375, 143.29296875, 94.45703125,
150.3515625, 98.625, 159.8359375, 153.29296875, 141.94921875,
130.609375, 130.9140625, 128.421875, 123.734375, 123.625, 130.94921875,
126.12890625, 140.9765625, 143.6328125, 141.2890625, 136.44921875,
131.53125, 129.0390625, 118.79296875, 129.28125, 126.765625,
129.61328125, 119.00390625, 119.05078125, 113.7109375, 127.30078125,
130.30859375, 130.42578125, 124.89453125, 125.05859375, 130.81640625,
133.80859375, 131.1171875, 140.05859375, 131.4375, 128.640625,
114.03515625, 117.0703125, 108.23046875, 90.32421875, 93.21484375,
99.171875), Yields = c(0.1337081, 0.1362573, 0.133515, 0.1241131,
0.1399032, 0.1407489, 0.135751, 0.1350621, 0.1296603, 0.1416507,
0.1150397, 0.1425034, 0.1380301, 0.1442954, 0.1386738, 0.1313512,
0.1317766, 0.1415287, 0.1430796, 0.1440013, 0.1445889, 0.1504745,
0.1504191, 0.1478758, 0.1479262, 0.1388794, 0.1546924, 0.1494229,
0.150287, 0.1486016, 0.1576033, 0.1612303, 0.1586688, 0.1572704,
0.1592381, 0.1662562, 0.1603484, 0.2453876, 0.1618873, 0.1611249,
0.1677527, 0.1681253, 0.1709984, 0.1632234, 0.1649997, 0.1602392,
0.1664094, 0.1614686, 0.2275633, 0.1688146, 0.1688992, 0.1678715,
0.1660078, 0.1702386, 0.1710206, 0.1623381, 0.1713865, 0.1720528,
0.2235201, 0.1764782, 0.1714474, 0.1834972, 0.1794814, 0.1796261,
0.1785715, 0.1824745, 0.1813703, 0.1806178, 0.1837643, 0.1857355,
0.1859493, 0.1896815, 0.1889451, 0.1905526, 0.1896534, 0.194313,
0.1931176, 0.1917809, 0.198368, 0.2264378, 0.1968473, 0.1961992,
0.1945467, 0.2033451, 0.1980432, 0.2042049, 0.2067191, 0.2047044,
0.1995581, 0.2111883, 0.2066671, 0.2033169, 0.2054688, 0.212789,
0.2132956, 0.2091312, 0.2193078, 0.2191277, 0.2261665, 0.2291516,
0.2244644, 0.2365864, 0.2372155, 0.2465419, 0.2519977, 0.2571519,
0.2530085, 0.2603545, 0.2662295, 0.2637156, 0.275636, 0.2741968,
0.2752424, 0.2822191, 0.286467, 0.2911749, 0.2951612, 0.2928947,
0.301369, 0.3008203, 0.3018345, 0.307993, 0.3115587, 0.3146542,
0.3202659, 0.3459327, 0.3240707, 0.335542, 0.3331675, 0.3348024,
0.3429906, 0.3441309, 0.3514909, 0.3521024, 0.359143, 0.3589054,
0.3626047, 0.3658439, 0.3741231, 0.3766819, 0.4207583, 0.3835824,
0.3804697, 0.3854424, 0.3882631, 0.3898512, 0.395374, 0.3997549,
0.4054119, 0.412211, 0.4052657, 0.4135729, 0.4114041, 0.4200256,
0.4569543, 0.4290136, 0.4393644, 0.4406205, 0.4517372, 0.4599254,
0.4715513, 0.4736518, 0.4858387, 0.4992027, 0.5034059, 0.4966529,
0.511404, 0.5211256, 0.5228673, 0.5340614, 0.5322963, 0.5409351,
0.5469844, 0.5586764, 0.5618671, 0.5625578, 0.5754976, 0.5903231,
0.5911177, 0.6032908, 0.6149554, 0.6226418, 0.6137462, 0.6299625,
0.6341457, 0.6470986, 0.65936, 0.6378036, 0.6554544, 0.6709587,
0.677713, 0.6803971, 0.7054962, 0.7199359, 0.7332262, 0.7434956,
0.7554881, 0.7644571, 0.7813789, 0.8036422, 0.7739499, 0.8178105,
0.8306454, 0.8618547, 0.8354958, 0.8910527, 0.9108458, 0.9194552,
0.8813713, 1.1314021, 1.1783204, 1.1851732, 1.2244673, 1.2326062,
1.2828189, 1.2913256, 1.2968105, 1.3089486, 1.3151415, 1.3324039,
1.437676, 1.3619944, 1.4494158, 1.359794, 1.4546407, 1.3542914,
1.3762002, 1.4069981, 1.4291268, 1.4295199, 1.4529993, 1.4687229,
1.4848191, 1.4836052, 1.4998736, 1.490619, 1.4965878, 1.5089954,
1.5211415, 1.5331939, 1.5447829, 1.5641817, 1.5556365, 1.564367,
1.5622115, 1.5825676, 1.5871687, 1.5973929, 1.5873149, 1.5821889,
1.5869259, 1.6005552, 1.6014668, 1.5984828, 1.5985781, 1.6041773,
1.593257, 1.608535, 1.6153224, 1.6352791, 1.6326895, 1.6439244,
1.6671026, 1.6658406, 1.6601911)), row.names = c(NA, -265L), class =
"data.frame")
|
|
From: <da...@el...> - 2020-12-01 14:36:10
|
Hi everyone, The FittedBondDiscountCurve uses a FittingMethod specific to a curve model. The currently available FittingMethods are: ExponentialSplinesFitting SimplePolynomialFitting NelsonSiegelFitting CubicBSplinesFitting SvenssonFitting and SpreadFittingMethod (which is a helper, and uses one of the other methods). Since I am looking to access these via QuantLibXL, it seems I have two options for the Excel interface: expose separate Excel UDFs for each method (eg qlExponentialSplinesFittedBondDiscountCurve(), qlSimplePolynomialFittedBondDiscountCurve() etc), or have a single qlFittedBondDiscountCurve() function which takes a parameter which identifies what FittingMethod to use, as well as a variable Array of values specific to that FittingMethod. Any thoughts on which is better? If there is to be one function call, then there probably needs to be a separate enumerated type visible to Excel (as we have for other curve methods). It could also (instead?) be an Enum within QuantLib which could be used by a generic discount curve generator that decides the FittingMethod at runtime. I am quite new to the architecture of QL, so not sure the best approach. Best David Sansom |
|
From: <da...@el...> - 2020-12-01 12:56:49
|
Hi Luigi,
I submitted a pull request for the modified ExponentialSplinesFitting class.
While this satisfies my selfish needs, it is not very general. If other FittingMethod’s could benefit from the ability to fix certain parameters, then perhaps a more generalized mechanism could be included in the base class.
I did play with this idea for a member variable for FittingMethod, which would be initialized by the FittingMethod constructor. I am not sure it is the most elegant solution but I was aiming to reduce the speed of access to the variables in the discountFunction() call (as that is called many times). The FitParameterArray class has to be supplied with a variable array that does not go out of scope while the class is being used.
Pseudo-code:
//Fitting will take 6 params, but only the fourth is fixed
Array arrFixed(6, QL_NULL_REAL);
arrFixed[3] = 0.01;
FitParameterArray fpa(arrFixed);
//When needed the variable array is set
Array arrVariable(5, 1,1);
fpa.setVariableArray(&arrVariable);
//The [] operator returns the fixed parameter if it has been set, or the variable parameter if not
for (Size np = 0; np < fpa.size(); np++)
{
cout << "Param " << np << ": " << fpa[np] << endl;
}
Output is:
Param 0: 1
Param 1: 2
Param 2: 3
Param 3: 0.01
Param 4: 4
Param 5: 5
The class that handles the parameters:
class FitParameterArray
{
typedef const Array * ArrayPtr;
typedef std::pair<ArrayPtr *, Size> FitParameterArrayElement;
public:
//No fixed parameters
FitParameterArray(Size count = 0)
:pFixedParams_(&fixedParameters_), pVariableParams_(0)
{
for (Size n = 0; n < count; n++)
parameters_.push_back(FitParameterArrayElement(&pVariableParams_, n));
}
//Some fixed parameters
FitParameterArray(const Array& fixedParameters)
:pFixedParams_(&fixedParameters_), pVariableParams_(0),fixedParameters_(fixedParameters)
{
Size nVariable = 0;
for (Size n = 0; n < fixedParameters.size(); n++)
{
if (fixedParameters[n] == QL_NULL_REAL) //No fixed parameter, use variable
{
parameters_.push_back(FitParameterArrayElement(&pVariableParams_, nVariable++));
}
else
{
parameters_.push_back(FitParameterArrayElement(&pFixedParams_, n));
}
}
}
Size size() const
{
return parameters_.size();
}
Real operator[](Size n) const
{
const FitParameterArrayElement& elt = parameters_[n];
if (*(elt.first) == 0) return QL_NULL_REAL; //Variable parameter array not set
return (*(*elt.first))[elt.second];
}
void setVariableArray(ArrayPtr p)
{
pVariableParams_ = p;
}
private:
ArrayPtr pFixedParams_;
Array fixedParameters_;
ArrayPtr pVariableParams_;
std::vector<FitParameterArrayElement> parameters_;
};
From: Luigi Ballabio <lui...@gm...>
Sent: Friday, 20 November 2020 15:07
To: da...@el...
Cc: QuantLib users <qua...@li...>
Subject: Re: [Quantlib-users] Modifying ExponentialSplinesFitting class for FittedBondDiscountCurve
Hello David,
if you can do so while keeping backward compatibility (e.g., by adding new constructors or giving defaults to new parameters) I'd suggest you modify the existing class.
Thanks,
Luigi
On Fri, Nov 20, 2020 at 2:44 PM <da...@el... <mailto:da...@el...> > wrote:
Hi everyone,
I’ve made some mods for my own use to the ExponentialSplinesFitting class, and before I go ahead and submit a pull request, I’d appreciate some initial feedback.
The form of the discount function for the exponential spline fit is: df(t) = sum( b(i) exp -i.kappa.t ) for i = 1 to N.
Where b(i) and kappa are the variables used to fit the curve.
The current implementation fixes N at 9 (so 9 x b(i) + 1 x kappa = 10 parameters). If the discount factor is constrained to be 1 at time t=0 (which is usually is) then one of the b(i)s is constrained, since at t=0, sum(b(i)) = 1, reducing the total number of independent parameters to 9. In the implementation b(1) is constrained.
>From my experience of using exponential spline fitting over the years, and from what I have read, there is no definitive argument for fixing N=9. Indeed the number chosen can depend on several considerations: the density of bonds across the curve; whether you want to fit the very short end etc. You also find that the value of kappa doesn’t make much difference to the quality of fit as long as it is in the right range. Other implementations fix kappa (it’s akin to the far-forward overnight rate, so something around 1% in the current environment), and then optimize over the b(i)s. If you extrapolate the spline beyond the last bond (which is probably not a great idea) then kappa does have an effect on the shape of that extrapolated part but I feel it is simply an artefact of the fitting.
In my implementation, the number of parameters is a variable and hence a class member, and there is also the option to fix kappa and supply a non-zero value for that fix (kappa = 0 is a special case as it produces df(t) = 1 no matter how much the b(i)s are varied (in the constrained model) ).
Initially I had derived my new class, unimaginatively named ExponentialSplinesFittingN from ExponentialSplinesFitting, but on reflection the inheritance is redundant as I am over-riding every method, so perhaps it should also derive directly from the abstract base FittedBondDiscountCurve::FittingMethod. I am open to suggestions for a decent name!
I wrote it before I had read the QL “style guide” so will need to amend my implantation anyway: hence this is a good moment to hear any thoughts!
Best wishes
David Sansom
_______________________________________________
QuantLib-users mailing list
Qua...@li... <mailto:Qua...@li...>
https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Ngonidzashe F. <ngo...@gm...> - 2020-11-30 18:42:41
|
Hi QuantLib users,
I was looking at a CDS illustration done by Luigu below;
import QuantLib as ql
calendar = ql.TARGET()
todaysDate = ql.Date(15, ql.May, 2007)
ql.Settings.instance().evaluationDate = todaysDate
risk_free_rate = ql.YieldTermStructureHandle(ql.FlatForward(todaysDate, 0.01,
ql.Actual365Fixed()))
# ### CDS parameters
recovery_rate = 0.5
quoted_spreads = [0.0150, 0.0150, 0.0150, 0.0150]
tenors = [ql.Period(3, ql.Months), ql.Period(6, ql.Months), ql.Period(1, ql.
Years), ql.Period(2, ql.Years)]
maturities = [calendar.adjust(todaysDate + x, ql.Following) for x in tenors]
instruments = [
ql.SpreadCdsHelper(
ql.QuoteHandle(ql.SimpleQuote(s)),
tenor,
0,
calendar,
ql.Quarterly,
ql.Following,
ql.DateGeneration.TwentiethIMM,
ql.Actual365Fixed(),
recovery_rate,
risk_free_rate,
)
for s, tenor in zip(quoted_spreads, tenors)
]
hazard_curve = ql.PiecewiseFlatHazardRate(todaysDate, instruments, ql.
Actual365Fixed())
print("Calibrated hazard rate values: ")
for x in hazard_curve.nodes():
print("hazard rate on %s is %.7f" % x)
print("Some survival probability values: ")
print(
"1Y survival probability: %.4g, \n\t\texpected %.4g"
% (hazard_curve.survivalProbability(todaysDate + ql.Period("1Y")), 0.9704)
)
print(
"2Y survival probability: %.4g, \n\t\texpected %.4g"
% (hazard_curve.survivalProbability(todaysDate + ql.Period("2Y")), 0.9418)
)
# ### Reprice instruments
nominal = 1000000.0
probability = ql.DefaultProbabilityTermStructureHandle(hazard_curve)
# We'll create a cds for every maturity:
all_cds = []
for maturity, s in zip(maturities, quoted_spreads):
schedule = ql.Schedule(
todaysDate,
maturity,
ql.Period(ql.Quarterly),
calendar,
ql.Following,
ql.Unadjusted,
ql.DateGeneration.TwentiethIMM,
False,
)
cds = ql.CreditDefaultSwap(ql.Protection.Seller, nominal, s, schedule, ql.
Following, ql.Actual365Fixed())
engine = ql.MidPointCdsEngine(probability, recovery_rate, risk_free_rate)
cds.setPricingEngine(engine)
all_cds.append(cds)
print("Repricing of quoted CDSs employed for calibration: ")
for cds, tenor in zip(all_cds, tenors):
print("%s fair spread: %.7g" % (tenor, cds.fairSpread()))
print(" NPV: %g" % cds.NPV())
print(" default leg: %.7g" % cds.defaultLegNPV())
print(" coupon leg: %.7g" % cds.couponLegNPV())
This illustration already has CDS spreads already defined in the
quoted_spread object such that if you try to determine cds.fairSpread() you
will get what is already in the quotated_spread.
My questions are as follow;
1. If the quoted rates are not defined as in the above code, where do I
adjust to solve for the CDS spread required to have the Expected PV of the
default leg equal to the Expected PV of the coupon leg?
2. If it's possible, how do I print the cashflows of both the default leg
and the coupon leg?
3. Given the CDS spread (or the quoted spread), where do I adjust in the
code to get the value of the CDS at a given valuation date.
Regards,
Ngoni
|
|
From: Luigi B. <lui...@gm...> - 2020-11-29 08:58:03
|
Hello,
the problem is not the negative value per se. By passing [0, -1, 1]
and simple compounding, you're passing a -100% rate for the first year,
which results in the discount at one year being 0. This is what the curve
is rejecting. If you wanted to pass -1%, the correct value is -0.01.
Luigi
On Sun, Nov 29, 2020 at 9:19 AM Daniel Lobo <dan...@gm...> wrote:
> Hi,
>
> It appears like QL is failing to construct a term structure when some
> spot-rates are supplied with Negative value. Below is my calculation -
>
> from QuantLib import *
>
> ZeroCurve([Date(1, 1, 2010), Date(1, 1, 2011), Date(1, 1, 2012)], [0,
> -1, 1],Actual360(), UnitedStates(), Linear(), Simple)
>
> WIth this, the error I obtained as -
>
> File "<stdin>", line 1, in <module>
>
> File "QuantLib.py", line 24534, in __init__
>
> _QuantLib.ZeroCurve_swiginit(self, _QuantLib.new_ZeroCurve(*args))
>
> RuntimeError: positive compound factor required
>
> Your advice on how to handle this situation will be very appreciated.
>
> Thanks for your time.
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Daniel L. <dan...@gm...> - 2020-11-29 08:11:59
|
Hi,
It appears like QL is failing to construct a term structure when some
spot-rates are supplied with Negative value. Below is my calculation -
from QuantLib import *
ZeroCurve([Date(1, 1, 2010), Date(1, 1, 2011), Date(1, 1, 2012)], [0,
-1, 1],Actual360(), UnitedStates(), Linear(), Simple)
WIth this, the error I obtained as -
File "<stdin>", line 1, in <module>
File "QuantLib.py", line 24534, in __init__
_QuantLib.ZeroCurve_swiginit(self, _QuantLib.new_ZeroCurve(*args))
RuntimeError: positive compound factor required
Your advice on how to handle this situation will be very appreciated.
Thanks for your time.
|
|
From: Brian S. <bri...@gm...> - 2020-11-27 18:10:37
|
Many thanks for your reply.
However if I want to estimate the Zero-rate for some arbitrary date
(other than the supplied Nodes), then what method should I use? Below
code to fetch the same generates some error.
>>> spotCurve.zeroRates(Date(1,3,2021))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: zeroRates() takes exactly 1 argument (2 given)
Thanks for your insight.
Regards,
On Fri, 27 Nov 2020 at 14:03, Luigi Ballabio <lui...@gm...> wrote:
>
> Hello,
> you can retrieve them from spotCurve (methods dates(), zeroRates() or nodes()) but not from spotCurveHandle, which only has the interface of the base YieldTermStructure class.
>
> Luigi
>
>
> On Thu, Nov 26, 2020 at 11:38 PM Brian Smith <bri...@gm...> wrote:
>>
>> Hi,
>>
>> Let say I build a term structure like this -
>>
>> from QuantLib import *
>> import math
>>
>> todaysDate = Date(1, 9, 2019)
>> Settings.instance().evaluationDate = todaysDate
>> dayCount = Actual365Fixed()
>> calendar = Canada()
>> interpolation = Linear()
>> compounding = Compounded
>> compoundingFrequency = Continuous
>>
>> spotDates = [todaysDate, todaysDate + Period("6m"), todaysDate +
>> Period("1y"), todaysDate + Period("2y"), todaysDate + Period("3y")]
>> spotRates = [0, 0.061682, 0.066682, 0.067199, 0.067502]
>>
>> spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar,
>> interpolation, compoundingFrequency)
>> spotCurveHandle = YieldTermStructureHandle(spotCurve)
>>
>> Now, from the spotCurveHandle object, I want to extract all Nodes
>> dates and rate information. Ofcourse I can get such information from
>> spotDates and spotRates respectively, however I am looking for some
>> way to extract the same information from the spotCurveHandle itself.
>>
>> Is there any method to do the same?
>>
>> Thanks for your insights.
>>
>>
>> _______________________________________________
>> QuantLib-users mailing list
>> Qua...@li...
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Jack G <jac...@gm...> - 2020-11-27 10:27:32
|
Sorry, ignore me - this change does seem to work (I think I was seeing an OOM error before) I'll make a pull request into SWIG repo with this change once I've tested that it's doing the right thing. On Fri, Nov 27, 2020 at 5:47 PM Jack G <jac...@gm...> wrote: > Luigi, > > Thanks for the pointer. It seems as though the only multi-path generator > that is currently exposed via SWIG is for pseudorandoms only ( > https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/montecarlo.i). > > I have the feeling that I should be adding the following to expose a > multi-path generator for low discrepancy numbers, but for some reason this > is upsetting my SWIG build (the error I get is "gcc: fatal error: Killed > signal terminated program cc1plus" which I usually see when I add something > subtly bad)... am I thinking on the right lines here? > > *%{* > *typedef > QuantLib::MultiPathGenerator<GaussianLowDiscrepancySequenceGenerator>* > * GaussianMultiPathSobolGenerator;* > *%}* > *class GaussianMultiPathSobolGenerator {* > * public:* > * %extend {* > * GaussianMultiPathSobolGenerator(* > * const ext::shared_ptr<StochasticProcess>& process,* > * const std::vector<Time>& times,* > * const GaussianLowDiscrepancySequenceGenerator& > generator,* > * bool brownianBridge = false) {* > * return new GaussianMultiPathSobolGenerator(process,* > * QuantLib::TimeGrid(* > * times.begin(),* > * times.end()),* > * generator,* > * brownianBridge);* > * }* > * }* > * Sample<MultiPath> next() const;* > * Sample<MultiPath> antithetic() const;* > *};* > > Best, > Jack > > On Fri, Nov 27, 2020 at 4:35 PM Luigi Ballabio <lui...@gm...> > wrote: > >> Hello Jack, >> the Heston process is two-dimensional (it models both underlying and >> vol) so you'll need to use a multi-path generator. The error you're >> getting is the generator trying to cast the process to a one-dimensional >> one and failing. >> >> Luigi >> >> >> On Fri, Nov 27, 2020 at 4:13 AM Jack G <jac...@gm...> wrote: >> >>> Dear QL Users, >>> >>> I'm getting a slightly cryptic error when I try to manually generate >>> paths for Heston using LD numbers in Python. >>> >>> It works fine for BS: >>> >>> *import QuantLib as ql* >>> >>> *initialValue = ql.QuoteHandle(ql.SimpleQuote(100))* >>> *sigma = 0.2* >>> >>> *today = ql.Date().todaysDate()* >>> *riskFreeTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.0, >>> ql.Actual365Fixed()))* >>> *dividendTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.0, >>> ql.Actual365Fixed()))* >>> *volTS = ql.BlackVolTermStructureHandle(ql.BlackConstantVol(today, >>> ql.NullCalendar(), sigma, ql.Actual365Fixed()))* >>> *process = ql.BlackScholesProcess(initialValue, riskFreeTS, volTS)* >>> >>> *times = ql.TimeGrid(1, 12)* >>> >>> *rng = ql.UniformLowDiscrepancySequenceGenerator(12)* >>> *seq = ql.GaussianLowDiscrepancySequenceGenerator(rng)* >>> *path_gen = ql.GaussianSobolPathGenerator(process, times, seq, False)* >>> >>> *x = path_gen.next()* >>> >>> >>> However, when I try the same with Heston, I get the following error: " >>> RuntimeError: Boost assertion failed: px != 0" >>> >>> *v0 = 0.09 kappa = 0.8 theta = 0.09 rho = 0.4 sigma = 0.1 process = >>> ql.HestonProcess(riskFreeTS, dividendTS, initialValue, v0, kappa, theta, >>> sigma, rho) times = ql.TimeGrid(1, 12) rng = >>> ql.UniformLowDiscrepancySequenceGenerator(12) seq = >>> ql.GaussianLowDiscrepancySequenceGenerator(rng) path_gen = >>> ql.GaussianSobolPathGenerator(process, times, seq, False) x = >>> path_gen.next()* >>> >>> >>> My working hypothesis is that the rng needs to be dimension 24 instead >>> of 12 because of the second vol process that needs to be simulated, but >>> when I change the dimension to 24 I get the following error: " >>> RuntimeError: sequence generator dimensionality (24) != timeSteps (12)" >>> >>> I've looked through the QuantLib-SWIG code but not got too far... any >>> pointers about how I might deal with this? Or have I done something stupid >>> somewhere? >>> >>> Thanks, >>> Jack >>> >>> >>> _______________________________________________ >>> QuantLib-users mailing list >>> Qua...@li... >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >> |