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
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Michael (D. portal) <mi...@da...> - 2021-08-29 21:55:21
|
Hi All, I am looking for an algo to calculate option-market-implied probabilities of interest rates moves derived from the premiums of interest rate swaptions. E.g. market-implied probabilities from the prices of swaptions on 10-year-swap rates. What is the market-implied probability that 10Y swap rate will increase 25, 50, 75 bps, etc? Thanks, Michael |
|
From: Peter C. <pca...@gm...> - 2021-08-29 13:43:52
|
Hi Suhas,
you should use OISRateHelper or AverageOISRateHelper instead of
SwapRateHelper for SOFR swaps: The latter class builds a swap with
daily payments. SOFR swaps have annual payments instead. The former
two classes build such swaps with a compounded or averaged rate.
Best Regards
Peter
On Sat, 28 Aug 2021 at 22:13, Suhas Ghorpadkar <suh...@gm...> wrote:
>
> While building SOFR curve for discounting, I am noticing that creating SwapRateHelper gets progressively slower. Below is my test case and the output. There is also comparison with USDLibor 3M where I do not see this behavior. I wonder if I am doing something wrong in creating Sofr index. Any help is appreciated.
> Thanks.
>
> #include <catch.hpp>
> #include <ql/indexes/ibor/sofr.hpp>
> #include <ql/indexes/ibor/usdlibor.hpp>
> #include <ql/instruments/forwardrateagreement.hpp>
> #include <ql/instruments/makevanillaswap.hpp>
> #include <ql/termstructures/yield/ratehelpers.hpp>
> #include <ql/utilities/dataparsers.hpp>
> #include <string>
> #include <iostream>
>
> using namespace QuantLib;
>
> TEST_CASE("sofr curvebuilder build test") {
>
> Settings::instance().evaluationDate() = Date(16,August,2021);
>
> std::vector<std::string> periods {"1M","2M","3M","4M","5M","6M","9M","1Y",
> "18M","2Y","3Y","4Y","5Y","7Y","10Y","12Y",
> "15Y","20Y","25Y","30Y","40Y","50Y"};
> Calendar swapcalendar = UnitedStates(UnitedStates::Market::FederalReserve);
> Frequency frequency = Frequency::Annual;
> DayCounter fDayCount = Actual360();
> std::vector<ext::shared_ptr<RateHelper>> sofrhelpers,liborhelpers;
> sofrhelpers.reserve(22);liborhelpers.reserve(22);
> ext::shared_ptr<Sofr> sofr(new Sofr());
> ext::shared_ptr<IborIndex> usdlibor = ext::make_shared<USDLibor>(Period(3, Months));
>
> for (auto& period_str : periods){
>
> Period period = PeriodParser::parse(period_str);
>
> ext::shared_ptr<SimpleQuote> s = ext::make_shared<SimpleQuote>(0.05 / 100.0);
> auto start = std::chrono::steady_clock::now(); //START
> std::shared_ptr<SwapRateHelper> helper = std::make_shared<SwapRateHelper>(Handle<Quote>(s), period, swapcalendar,
> frequency, BusinessDayConvention::ModifiedFollowing,
> fDayCount, sofr);
> auto end = std::chrono::steady_clock::now(); //STOP
> std::cout << period << " sofrhelper took : " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms" << std::endl;
> sofrhelpers.emplace_back(helper);
> }
> REQUIRE(sofrhelpers.size()==22);
>
> std::cout << "====================================" << std::endl;
>
> for (auto& period_str : periods){
>
> Period period = PeriodParser::parse(period_str);
>
> ext::shared_ptr<SimpleQuote> s = ext::make_shared<SimpleQuote>(0.05 / 100.0);
> auto start = std::chrono::steady_clock::now(); //START
> std::shared_ptr<SwapRateHelper> helper = std::make_shared<SwapRateHelper>(Handle<Quote>(s), period, swapcalendar,
> frequency, BusinessDayConvention::ModifiedFollowing,
> fDayCount, usdlibor);
> auto end = std::chrono::steady_clock::now(); //STOP
> std::cout << period << " liborhelper took : " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms" << std::endl;
> liborhelpers.emplace_back(helper);
> }
> REQUIRE(liborhelpers.size()==22);
>
> }
>
> 1M sofrhelper took : 0 ms
> 2M sofrhelper took : 0 ms
> 3M sofrhelper took : 1 ms
> 4M sofrhelper took : 0 ms
> 5M sofrhelper took : 1 ms
> 6M sofrhelper took : 1 ms
> 9M sofrhelper took : 1 ms
> 1Y sofrhelper took : 2 ms
> 1Y6M sofrhelper took : 4 ms
> 2Y sofrhelper took : 5 ms
> 3Y sofrhelper took : 12 ms
> 4Y sofrhelper took : 15 ms
> 5Y sofrhelper took : 21 ms
> 7Y sofrhelper took : 34 ms
> 10Y sofrhelper took : 65 ms
> 12Y sofrhelper took : 85 ms
> 15Y sofrhelper took : 115 ms
> 20Y sofrhelper took : 211 ms
> 25Y sofrhelper took : 326 ms
> 30Y sofrhelper took : 451 ms
> 40Y sofrhelper took : 728 ms
> 50Y sofrhelper took : 1112 ms
> ====================================
> 1M liborhelper took : 0 ms
> 2M liborhelper took : 0 ms
> 3M liborhelper took : 0 ms
> 4M liborhelper took : 0 ms
> 5M liborhelper took : 0 ms
> 6M liborhelper took : 0 ms
> 9M liborhelper took : 0 ms
> 1Y liborhelper took : 0 ms
> 1Y6M liborhelper took : 0 ms
> 2Y liborhelper took : 0 ms
> 3Y liborhelper took : 0 ms
> 4Y liborhelper took : 0 ms
> 5Y liborhelper took : 0 ms
> 7Y liborhelper took : 0 ms
> 10Y liborhelper took : 0 ms
> 12Y liborhelper took : 0 ms
> 15Y liborhelper took : 0 ms
> 20Y liborhelper took : 1 ms
> 25Y liborhelper took : 1 ms
> 30Y liborhelper took : 1 ms
> 40Y liborhelper took : 1 ms
> 50Y liborhelper took : 2 ms
> ===============================================================================
> All tests passed (2 assertions in 1 test case)
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Suhas G. <suh...@gm...> - 2021-08-28 20:12:49
|
While building SOFR curve for discounting, I am noticing that creating
SwapRateHelper gets progressively slower. Below is my test case and the
output. There is also comparison with USDLibor 3M where I do not see this
behavior. I wonder if I am doing something wrong in creating Sofr index.
Any help is appreciated.
Thanks.
#include <catch.hpp>
#include <ql/indexes/ibor/sofr.hpp>
#include <ql/indexes/ibor/usdlibor.hpp>
#include <ql/instruments/forwardrateagreement.hpp>
#include <ql/instruments/makevanillaswap.hpp>
#include <ql/termstructures/yield/ratehelpers.hpp>
#include <ql/utilities/dataparsers.hpp>
#include <string>
#include <iostream>
using namespace QuantLib;
TEST_CASE("sofr curvebuilder build test") {
Settings::instance().evaluationDate() = Date(16,August,2021);
std::vector<std::string> periods {"1M","2M","3M","4M","5M","6M","9M","1Y",
"18M","2Y","3Y","4Y","5Y","7Y","10Y","12Y",
"15Y","20Y","25Y","30Y","40Y","50Y"};
Calendar swapcalendar = UnitedStates(UnitedStates::Market::FederalReserve);
Frequency frequency = Frequency::Annual;
DayCounter fDayCount = Actual360();
std::vector<ext::shared_ptr<RateHelper>> sofrhelpers,liborhelpers;
sofrhelpers.reserve(22);liborhelpers.reserve(22);
ext::shared_ptr<Sofr> sofr(new Sofr());
ext::shared_ptr<IborIndex> usdlibor =
ext::make_shared<USDLibor>(Period(3, Months));
for (auto& period_str : periods){
Period period = PeriodParser::parse(period_str);
ext::shared_ptr<SimpleQuote> s =
ext::make_shared<SimpleQuote>(0.05 / 100.0);
auto start = std::chrono::steady_clock::now(); //START
std::shared_ptr<SwapRateHelper> helper =
std::make_shared<SwapRateHelper>(Handle<Quote>(s), period,
swapcalendar,
frequency, BusinessDayConvention::ModifiedFollowing,
fDayCount, sofr);
auto end = std::chrono::steady_clock::now(); //STOP
std::cout << period << " sofrhelper took : " <<
std::chrono::duration_cast<std::chrono::milliseconds>(end -
start).count() << " ms" << std::endl;
sofrhelpers.emplace_back(helper);
}
REQUIRE(sofrhelpers.size()==22);
std::cout << "====================================" << std::endl;
for (auto& period_str : periods){
Period period = PeriodParser::parse(period_str);
ext::shared_ptr<SimpleQuote> s =
ext::make_shared<SimpleQuote>(0.05 / 100.0);
auto start = std::chrono::steady_clock::now(); //START
std::shared_ptr<SwapRateHelper> helper =
std::make_shared<SwapRateHelper>(Handle<Quote>(s), period,
swapcalendar,
frequency, BusinessDayConvention::ModifiedFollowing,
fDayCount, usdlibor);
auto end = std::chrono::steady_clock::now(); //STOP
std::cout << period << " liborhelper took : " <<
std::chrono::duration_cast<std::chrono::milliseconds>(end -
start).count() << " ms" << std::endl;
liborhelpers.emplace_back(helper);
}
REQUIRE(liborhelpers.size()==22);
}
1M sofrhelper took : 0 ms
2M sofrhelper took : 0 ms
3M sofrhelper took : 1 ms
4M sofrhelper took : 0 ms
5M sofrhelper took : 1 ms
6M sofrhelper took : 1 ms
9M sofrhelper took : 1 ms
1Y sofrhelper took : 2 ms
1Y6M sofrhelper took : 4 ms
2Y sofrhelper took : 5 ms
3Y sofrhelper took : 12 ms
4Y sofrhelper took : 15 ms
5Y sofrhelper took : 21 ms
7Y sofrhelper took : 34 ms
10Y sofrhelper took : 65 ms
12Y sofrhelper took : 85 ms
15Y sofrhelper took : 115 ms
20Y sofrhelper took : 211 ms
25Y sofrhelper took : 326 ms
30Y sofrhelper took : 451 ms
40Y sofrhelper took : 728 ms
50Y sofrhelper took : 1112 ms
====================================
1M liborhelper took : 0 ms
2M liborhelper took : 0 ms
3M liborhelper took : 0 ms
4M liborhelper took : 0 ms
5M liborhelper took : 0 ms
6M liborhelper took : 0 ms
9M liborhelper took : 0 ms
1Y liborhelper took : 0 ms
1Y6M liborhelper took : 0 ms
2Y liborhelper took : 0 ms
3Y liborhelper took : 0 ms
4Y liborhelper took : 0 ms
5Y liborhelper took : 0 ms
7Y liborhelper took : 0 ms
10Y liborhelper took : 0 ms
12Y liborhelper took : 0 ms
15Y liborhelper took : 0 ms
20Y liborhelper took : 1 ms
25Y liborhelper took : 1 ms
30Y liborhelper took : 1 ms
40Y liborhelper took : 1 ms
50Y liborhelper took : 2 ms
===============================================================================
All tests passed (2 assertions in 1 test case)
|
|
From: Christofer B. <bog...@gm...> - 2021-08-24 18:28:28
|
Hi, CME publishes SOFR rates for 3 different terms as available in https://www.cmegroup.com/market-data/cme-group-benchmark-administration/term-sofr.html Is there any way I can derive SOFR for non standard term (e.g. 4 months) using given terms (i.e. 1, 3, and 6 months), with QL? Any pointer will be highly appreciated. |
|
From: Luigi B. <lui...@gm...> - 2021-08-24 08:36:44
|
Hello,
they are coupons, as you would expect; but the swap interface allows
for more types, so it returns them as their base class CashFlow instead.
If you want to access the derived class interface, you can downcast them
with:
coupons = [ ql.as_floating_rate_coupon(cf) for cf in sw2.floatingLeg() ]
Corresponding functions exist for other classes (e.g.,
ql.as_fixed_rate_coupon). You can look for them in <
https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/cashflows.i>.
If you pass to any of these functions a coupon that can't be converted
(e.g., a floating-rate coupon to as_fixed_rate_coupon or the redemption of
a bond to as_floating_rate_coupon) you'll get None as the return value.
Hope this helps,
Luigi
On Mon, Aug 9, 2021 at 10:22 PM Gorazd Brumen <gor...@gm...>
wrote:
> Hi all,
>
> I'm new to the list, and have the following question: Why are elements
> of VanillaSwap leg CashFlow type, and not Coupon type? (please see
> below)
>
> Best regards,
> Gorazd
>
> In [11]: sw2
> Out[11]: <QuantLib.QuantLib.VanillaSwap; proxy of <Swig Object of type
> 'boost::shared_ptr< VanillaSwap > *' at 0x7f48a03c7780> >
>
> In [10]: list(sw2.floatingLeg())
> Out[10]:
> [<QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863cf0> >,
> <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863e40> >,
> <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863f00> >,
> <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863870> >]
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Miguel A. T. M. <mig...@gm...> - 2021-08-19 14:52:04
|
Hi I’m new to Quantlib. I have run the example 3 of CDS that reproduces the example of the OpenGamma paper “Pricing and Risk Management of CDS”. When comparing the paper with the output of Quantlib I see that the reproduced yield curve is the same but the credit curve it is not. In fact, the maturity dates of the SpreadCdsHelper are not the IMM dates but the next day, even considering for weekend effects. I have tried changing the DateGenerator and model in the construction of the cdshelpers but have not replicated the expected maturity dates (IMM adjusted for weekend calendar and following business date). Even when directly using the constructed credit curve with the Maturity dates (of table 13) the survival probabilities in quantlib do not coincide. . [image: image.png] Thanks Miguel |
|
From: <lev...@gm...> - 2021-08-14 18:03:44
|
Hi everyone, I have noticed that there is a cross currency basis swap rate helper added to the Quantlib new release and it is also included in the ratehelpers test cases in the Python implementation . However, I could not find the instrument cross currency basis swap. I assume the helper is added to bootstrap a cross currency basis curve, but what about pricing the instrument itself? is there a way to do this? Thanks in advance, Levan |
|
From: Conrad C. <con...@gm...> - 2021-08-14 15:45:38
|
Hello,
Please note I am new to quantitative finance and more so to stochastic
calculus.
I have what should be a relatively simple problem using the *Vasicek*
model for estimating future parameters of the short rate.
dr(t)=0.2(0.05−r(t))dt+0.1dW(t),r(0)=5%,
where W(t)W(t)is a standard Brownian motion under the *objective
probability measure* P\mathbb{P}.
I am trying to calculate the expected value of short rate, the standard
deviation and the probability of having a negative short rate all at t = 1.
I have successfully calculated the standard deviation/volatility but
cannot seem to get the other two values.
I know the parameters of the process have to be modified via Girsanov
Theorem but how exactly does that change the expressions for the
*analytical* and *simulated* short rate?
Is it sufficient to just assume the market price of interest rate risk
is -1.2 and reducing the drift term accordingly?
Below are the methods I am currently using to predict the short rate
over the time interval and estimate future values.
*(Simulated)
*
*for t in range(1, M + 1):**
*
* xh[t] = xh[t - 1] + kappa * ((theta - sigma/kappa) - xh[t - 1]) *dt
+ sigma * np.standard_normal(I)*
*(Analytical)
*
*temp1 = np.exp(-self.kappa*(dt))
temp2 = (self.sigma**2) * (1 - temp1**2) / (2*self.kappa)
result = np.mean(self.r0*temp1 + (self.theta -
self.sigma/self.kappa)*(1-temp1) +
np.sqrt(temp2)*npr.standard_normal(1000))*
I also used the code below attempting to do the same using Quantlib but
am not sure exactly how to go about extracting the relevant parameters.
All the examples I have seen involve calibrating such short-rate models
using historic market data but this is not the case for my problem.
**
*today = ql.Date().todaysDate()
# ql.Settings.instance().evaluationDate = today
# crv = ql.ZeroCurve([today, settlement], [0.05, 0.05], ql.Actual365Fixed())
crv = ql.FlatForward(today, 0.05, ql.Actual365Fixed())
yts = ql.YieldTermStructureHandle(crv)
vol = ql.QuoteHandle(ql.SimpleQuote(0.1))
model = ql.Vasicek(r0=0.05, a=0.2, b=0.05, sigma=0.1)
engine = ql.BlackCallableFixedRateBondEngine(vol, yts)*
Thanks,
Conrad
|
|
From: jian Xu <jia...@gm...> - 2021-08-13 18:07:45
|
Wow, thank you very much, Luigi, Matthias, and Conrad. This is very informative. I have never thought about providing schedule in the day_count constructor, and never thought about the additivity of year fraction. Thanks a lot! On Fri, Aug 13, 2021 at 12:07 PM <mat...@gm...> wrote: > > Hi Luigi, > > > > Indeed, it helps – interesting “edge case”. > > > > Thank you, > > > > Matthias > > > > From: Luigi Ballabio <lui...@gm...> > Sent: Friday, 13 August, 2021 19:03 > To: mat...@gm... > Cc: jian Xu <jia...@gm...>; QuantLib users <qua...@li...> > Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow? > > > > Hi Matthias, > > unfortunately the 30/360 day counter is not additive. For instance, in the example in this thread the settlement date is 2021/10/05, the first coupon pays on 2021/12/31, and the second coupon pays on 2022/06/30. When calculating the discount factor for the second coupon, the manual approach calculates the time between settlement and payment date as > > > > day_count.yearFraction(ql.Date(5,10,2021), ql.Date(30,6,2022)) > > > > which gives T = 0.73611111; instead, the dirtyPrice method calculates it, as it iterates over the coupons, as > > > > day_count.yearFraction(ql.Date(5,10,2021), ql.Date(31,12,2021)) + day_count.yearFraction(ql.Date(31,12,2021), ql.Date(30,6,2022)) > > > > which gives T = 0.23888888 + 0.5 = 0.73888888. The difference in time results in a difference in discount. > > > > I'm not sure which one is best, but the second one seems to have the correct accrual time for the coupon. > > > > Hope this helps, > > Luigi > > > > > > > > On Fri, Aug 13, 2021 at 4:28 PM <mat...@gm...> wrote: > > Out of curiosity – hijacking the original question somewhat: > > > > Does any reason come to mind why > > > > day_count = ql.Thirty360(Thirty360.BondBasis) > > > > would give different values? > > > > dirtyPrice(): 103.48181611062914 > > “manual” discounting: 103.48174390787119 > > > > > > > > From: Luigi Ballabio <lui...@gm...> > Sent: Friday, 13 August, 2021 16:20 > To: mat...@gm... > Cc: jian Xu <jia...@gm...>; QuantLib users <qua...@li...> > Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow? > > > > Hello, > > > > to work correctly, act/act(ISMA) needs to know the reference period for a given coupon. The bond has the information and knows how to pass it, but the InterestRate object doesn't. To fix that, you can pass the bond schedule when you build the day counter, as in: > > > > day_count = ql.ActualActual(ql.ActualActual.ISMA, schedule) > > > > so the day counter itself has the information. Using this day counter should give you the same result in both cases. > > > > Luigi > > > > > > > > On Fri, Aug 13, 2021 at 4:15 PM <mat...@gm...> wrote: > > On first glance, I was also wondering about the impact of the reference period, see https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715 > > But being thrown off by a difference in NPVs when using ql.Thirty360(Thirty360.BondBasis). Not quite clear about that one. > > > -----Original Message----- > From: jian Xu <jia...@gm...> > Sent: Friday, 13 August, 2021 15:53 > To: QuantLib users <qua...@li...> > Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow? > > One thing I noticed is that if I set "day_count" to ql.ActualActual() instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price matches the npv exactly. This is very strange. The "day_count" > variable is consistently used in the bond's constructor, dirtyPrice(), and InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty price and the npv to be different? Am I missing something? > > On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm...> wrote: > > > > Hi, > > I saw some difference between a bond's dirty price and the discounted > > cashflow to the settlement date. Cannot figure out why. > > > > For example, in the following code, the dirty price is 103.4815, while > > my discounted cashflow is 103.4674, why? Thanks a lot. > > > > =============================== > > import QuantLib as ql > > > > ## setup the security > > schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018), > > terminationDate = ql.Date(30, 6, 2023), > > tenor = ql.Period(2), > > calendar = > > ql.UnitedStates(ql.UnitedStates.GovernmentBond), > > convention = ql.Unadjusted, > > terminalDateConvention=ql.Unadjusted, > > rule = ql.DateGeneration.Backward, > > endOfMonth = True) > > > > day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market > > convention, not the QuantLib default !!! > > face = 100 > > redemption = 100 > > issue_date = ql.Date(2, 7, 2018) > > days_settle = 1 > > coupon = 2.625/100 > > payment_convention = ql.Unadjusted > > bond = ql.FixedRateBond(days_settle, > > face, > > schedule, > > [coupon], > > day_count, > > payment_convention, > > redemption, > > issue_date) > > > > ## Dirty price > > settle_date = ql.Date(5, 10, 2021) > > yld = 0.01 > > freq = ql.Semiannual > > print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq, > > settle_date)) > > > > ## my discount cash flow > > disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) npv = 0 > > for cf in bond.cashflows(): > > if cf.date() < settle_date: > > continue > > df = disc.discountFactor(settle_date, cf.date()) > > npv += cf.amount() * df > > print(npv) > > > _______________________________________________ > 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: <mat...@gm...> - 2021-08-13 17:07:14
|
Hi Luigi,
Indeed, it helps – interesting “edge case”.
Thank you,
Matthias
From: Luigi Ballabio <lui...@gm...>
Sent: Friday, 13 August, 2021 19:03
To: mat...@gm...
Cc: jian Xu <jia...@gm...>; QuantLib users <qua...@li...>
Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow?
Hi Matthias,
unfortunately the 30/360 day counter is not additive. For instance, in the example in this thread the settlement date is 2021/10/05, the first coupon pays on 2021/12/31, and the second coupon pays on 2022/06/30. When calculating the discount factor for the second coupon, the manual approach calculates the time between settlement and payment date as
day_count.yearFraction(ql.Date(5,10,2021), ql.Date(30,6,2022))
which gives T = 0.73611111; instead, the dirtyPrice method calculates it, as it iterates over the coupons, as
day_count.yearFraction(ql.Date(5,10,2021), ql.Date(31,12,2021)) + day_count.yearFraction(ql.Date(31,12,2021), ql.Date(30,6,2022))
which gives T = 0.23888888 + 0.5 = 0.73888888. The difference in time results in a difference in discount.
I'm not sure which one is best, but the second one seems to have the correct accrual time for the coupon.
Hope this helps,
Luigi
On Fri, Aug 13, 2021 at 4:28 PM <mat...@gm... <mailto:mat...@gm...> > wrote:
Out of curiosity – hijacking the original question somewhat:
Does any reason come to mind why
day_count = ql.Thirty360(Thirty360.BondBasis)
would give different values?
dirtyPrice(): 103.48181611062914
“manual” discounting: 103.48174390787119
From: Luigi Ballabio <lui...@gm... <mailto:lui...@gm...> >
Sent: Friday, 13 August, 2021 16:20
To: mat...@gm... <mailto:mat...@gm...>
Cc: jian Xu <jia...@gm... <mailto:jia...@gm...> >; QuantLib users <qua...@li... <mailto:qua...@li...> >
Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow?
Hello,
to work correctly, act/act(ISMA) needs to know the reference period for a given coupon. The bond has the information and knows how to pass it, but the InterestRate object doesn't. To fix that, you can pass the bond schedule when you build the day counter, as in:
day_count = ql.ActualActual(ql.ActualActual.ISMA, schedule)
so the day counter itself has the information. Using this day counter should give you the same result in both cases.
Luigi
On Fri, Aug 13, 2021 at 4:15 PM <mat...@gm... <mailto:mat...@gm...> > wrote:
On first glance, I was also wondering about the impact of the reference period, see https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715
But being thrown off by a difference in NPVs when using ql.Thirty360(Thirty360.BondBasis). Not quite clear about that one.
-----Original Message-----
From: jian Xu <jia...@gm... <mailto:jia...@gm...> >
Sent: Friday, 13 August, 2021 15:53
To: QuantLib users <qua...@li... <mailto:qua...@li...> >
Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow?
One thing I noticed is that if I set "day_count" to ql.ActualActual() instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price matches the npv exactly. This is very strange. The "day_count"
variable is consistently used in the bond's constructor, dirtyPrice(), and InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty price and the npv to be different? Am I missing something?
On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm... <mailto:jia...@gm...> > wrote:
>
> Hi,
> I saw some difference between a bond's dirty price and the discounted
> cashflow to the settlement date. Cannot figure out why.
>
> For example, in the following code, the dirty price is 103.4815, while
> my discounted cashflow is 103.4674, why? Thanks a lot.
>
> ===============================
> import QuantLib as ql
>
> ## setup the security
> schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018),
> terminationDate = ql.Date(30, 6, 2023),
> tenor = ql.Period(2),
> calendar =
> ql.UnitedStates(ql.UnitedStates.GovernmentBond),
> convention = ql.Unadjusted,
> terminalDateConvention=ql.Unadjusted,
> rule = ql.DateGeneration.Backward,
> endOfMonth = True)
>
> day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market
> convention, not the QuantLib default !!!
> face = 100
> redemption = 100
> issue_date = ql.Date(2, 7, 2018)
> days_settle = 1
> coupon = 2.625/100
> payment_convention = ql.Unadjusted
> bond = ql.FixedRateBond(days_settle,
> face,
> schedule,
> [coupon],
> day_count,
> payment_convention,
> redemption,
> issue_date)
>
> ## Dirty price
> settle_date = ql.Date(5, 10, 2021)
> yld = 0.01
> freq = ql.Semiannual
> print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq,
> settle_date))
>
> ## my discount cash flow
> disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) npv = 0
> for cf in bond.cashflows():
> if cf.date() < settle_date:
> continue
> df = disc.discountFactor(settle_date, cf.date())
> npv += cf.amount() * df
> print(npv)
_______________________________________________
QuantLib-users mailing list
Qua...@li... <mailto:Qua...@li...>
https://lists.sourceforge.net/lists/listinfo/quantlib-users
_______________________________________________
QuantLib-users mailing list
Qua...@li... <mailto:Qua...@li...>
https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Luigi B. <lui...@gm...> - 2021-08-13 17:03:47
|
Hi Matthias,
unfortunately the 30/360 day counter is not additive. For instance, in
the example in this thread the settlement date is 2021/10/05, the first
coupon pays on 2021/12/31, and the second coupon pays on 2022/06/30. When
calculating the discount factor for the second coupon, the manual approach
calculates the time between settlement and payment date as
day_count.yearFraction(ql.Date(5,10,2021), ql.Date(30,6,2022))
which gives T = 0.73611111; instead, the dirtyPrice method calculates it,
as it iterates over the coupons, as
day_count.yearFraction(ql.Date(5,10,2021), ql.Date(31,12,2021)) +
day_count.yearFraction(ql.Date(31,12,2021), ql.Date(30,6,2022))
which gives T = 0.23888888 + 0.5 = 0.73888888. The difference in time
results in a difference in discount.
I'm not sure which one is best, but the second one seems to have the
correct accrual time for the coupon.
Hope this helps,
Luigi
On Fri, Aug 13, 2021 at 4:28 PM <mat...@gm...> wrote:
> Out of curiosity – hijacking the original question somewhat:
>
>
>
> Does any reason come to mind why
>
>
>
> day_count = ql.Thirty360(Thirty360.BondBasis)
>
>
>
> would give different values?
>
>
>
> dirtyPrice(): 103.48181611062914
>
> “manual” discounting: 103.48174390787119
>
>
>
>
>
>
>
> *From:* Luigi Ballabio <lui...@gm...>
> *Sent:* Friday, 13 August, 2021 16:20
> *To:* mat...@gm...
> *Cc:* jian Xu <jia...@gm...>; QuantLib users <
> qua...@li...>
> *Subject:* Re: [Quantlib-users] Bond dirty price different from
> discounted cashflow?
>
>
>
> Hello,
>
>
>
> to work correctly, act/act(ISMA) needs to know the reference period for a
> given coupon. The bond has the information and knows how to pass it,
> but the InterestRate object doesn't. To fix that, you can pass the bond
> schedule when you build the day counter, as in:
>
>
>
> day_count = ql.ActualActual(ql.ActualActual.ISMA, schedule)
>
>
>
> so the day counter itself has the information. Using this day counter
> should give you the same result in both cases.
>
>
>
> Luigi
>
>
>
>
>
>
>
> On Fri, Aug 13, 2021 at 4:15 PM <mat...@gm...> wrote:
>
> On first glance, I was also wondering about the impact of the reference
> period, see
> https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715
>
> But being thrown off by a difference in NPVs when using
> ql.Thirty360(Thirty360.BondBasis). Not quite clear about that one.
>
>
> -----Original Message-----
> From: jian Xu <jia...@gm...>
> Sent: Friday, 13 August, 2021 15:53
> To: QuantLib users <qua...@li...>
> Subject: Re: [Quantlib-users] Bond dirty price different from discounted
> cashflow?
>
> One thing I noticed is that if I set "day_count" to ql.ActualActual()
> instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price
> matches the npv exactly. This is very strange. The "day_count"
> variable is consistently used in the bond's constructor, dirtyPrice(), and
> InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty
> price and the npv to be different? Am I missing something?
>
> On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm...> wrote:
> >
> > Hi,
> > I saw some difference between a bond's dirty price and the discounted
> > cashflow to the settlement date. Cannot figure out why.
> >
> > For example, in the following code, the dirty price is 103.4815, while
> > my discounted cashflow is 103.4674, why? Thanks a lot.
> >
> > ===============================
> > import QuantLib as ql
> >
> > ## setup the security
> > schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018),
> > terminationDate = ql.Date(30, 6, 2023),
> > tenor = ql.Period(2),
> > calendar =
> > ql.UnitedStates(ql.UnitedStates.GovernmentBond),
> > convention = ql.Unadjusted,
> > terminalDateConvention=ql.Unadjusted,
> > rule = ql.DateGeneration.Backward,
> > endOfMonth = True)
> >
> > day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market
> > convention, not the QuantLib default !!!
> > face = 100
> > redemption = 100
> > issue_date = ql.Date(2, 7, 2018)
> > days_settle = 1
> > coupon = 2.625/100
> > payment_convention = ql.Unadjusted
> > bond = ql.FixedRateBond(days_settle,
> > face,
> > schedule,
> > [coupon],
> > day_count,
> > payment_convention,
> > redemption,
> > issue_date)
> >
> > ## Dirty price
> > settle_date = ql.Date(5, 10, 2021)
> > yld = 0.01
> > freq = ql.Semiannual
> > print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq,
> > settle_date))
> >
> > ## my discount cash flow
> > disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) npv = 0
> > for cf in bond.cashflows():
> > if cf.date() < settle_date:
> > continue
> > df = disc.discountFactor(settle_date, cf.date())
> > npv += cf.amount() * df
> > print(npv)
>
>
> _______________________________________________
> 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: <mat...@gm...> - 2021-08-13 14:29:00
|
Out of curiosity – hijacking the original question somewhat:
Does any reason come to mind why
day_count = ql.Thirty360(Thirty360.BondBasis)
would give different values?
dirtyPrice(): 103.48181611062914
“manual” discounting: 103.48174390787119
From: Luigi Ballabio <lui...@gm...>
Sent: Friday, 13 August, 2021 16:20
To: mat...@gm...
Cc: jian Xu <jia...@gm...>; QuantLib users <qua...@li...>
Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow?
Hello,
to work correctly, act/act(ISMA) needs to know the reference period for a given coupon. The bond has the information and knows how to pass it, but the InterestRate object doesn't. To fix that, you can pass the bond schedule when you build the day counter, as in:
day_count = ql.ActualActual(ql.ActualActual.ISMA, schedule)
so the day counter itself has the information. Using this day counter should give you the same result in both cases.
Luigi
On Fri, Aug 13, 2021 at 4:15 PM <mat...@gm... <mailto:mat...@gm...> > wrote:
On first glance, I was also wondering about the impact of the reference period, see https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715
But being thrown off by a difference in NPVs when using ql.Thirty360(Thirty360.BondBasis). Not quite clear about that one.
-----Original Message-----
From: jian Xu <jia...@gm... <mailto:jia...@gm...> >
Sent: Friday, 13 August, 2021 15:53
To: QuantLib users <qua...@li... <mailto:qua...@li...> >
Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow?
One thing I noticed is that if I set "day_count" to ql.ActualActual() instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price matches the npv exactly. This is very strange. The "day_count"
variable is consistently used in the bond's constructor, dirtyPrice(), and InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty price and the npv to be different? Am I missing something?
On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm... <mailto:jia...@gm...> > wrote:
>
> Hi,
> I saw some difference between a bond's dirty price and the discounted
> cashflow to the settlement date. Cannot figure out why.
>
> For example, in the following code, the dirty price is 103.4815, while
> my discounted cashflow is 103.4674, why? Thanks a lot.
>
> ===============================
> import QuantLib as ql
>
> ## setup the security
> schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018),
> terminationDate = ql.Date(30, 6, 2023),
> tenor = ql.Period(2),
> calendar =
> ql.UnitedStates(ql.UnitedStates.GovernmentBond),
> convention = ql.Unadjusted,
> terminalDateConvention=ql.Unadjusted,
> rule = ql.DateGeneration.Backward,
> endOfMonth = True)
>
> day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market
> convention, not the QuantLib default !!!
> face = 100
> redemption = 100
> issue_date = ql.Date(2, 7, 2018)
> days_settle = 1
> coupon = 2.625/100
> payment_convention = ql.Unadjusted
> bond = ql.FixedRateBond(days_settle,
> face,
> schedule,
> [coupon],
> day_count,
> payment_convention,
> redemption,
> issue_date)
>
> ## Dirty price
> settle_date = ql.Date(5, 10, 2021)
> yld = 0.01
> freq = ql.Semiannual
> print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq,
> settle_date))
>
> ## my discount cash flow
> disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) npv = 0
> for cf in bond.cashflows():
> if cf.date() < settle_date:
> continue
> df = disc.discountFactor(settle_date, cf.date())
> npv += cf.amount() * df
> print(npv)
_______________________________________________
QuantLib-users mailing list
Qua...@li... <mailto:Qua...@li...>
https://lists.sourceforge.net/lists/listinfo/quantlib-users
_______________________________________________
QuantLib-users mailing list
Qua...@li... <mailto:Qua...@li...>
https://lists.sourceforge.net/lists/listinfo/quantlib-users
|
|
From: Luigi B. <lui...@gm...> - 2021-08-13 14:20:14
|
Hello,
to work correctly, act/act(ISMA) needs to know the reference period for a
given coupon. The bond has the information and knows how to pass it,
but the InterestRate object doesn't. To fix that, you can pass the bond
schedule when you build the day counter, as in:
day_count = ql.ActualActual(ql.ActualActual.ISMA, schedule)
so the day counter itself has the information. Using this day counter
should give you the same result in both cases.
Luigi
On Fri, Aug 13, 2021 at 4:15 PM <mat...@gm...> wrote:
> On first glance, I was also wondering about the impact of the reference
> period, see
> https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715
>
> But being thrown off by a difference in NPVs when using
> ql.Thirty360(Thirty360.BondBasis). Not quite clear about that one.
>
>
> -----Original Message-----
> From: jian Xu <jia...@gm...>
> Sent: Friday, 13 August, 2021 15:53
> To: QuantLib users <qua...@li...>
> Subject: Re: [Quantlib-users] Bond dirty price different from discounted
> cashflow?
>
> One thing I noticed is that if I set "day_count" to ql.ActualActual()
> instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price
> matches the npv exactly. This is very strange. The "day_count"
> variable is consistently used in the bond's constructor, dirtyPrice(), and
> InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty
> price and the npv to be different? Am I missing something?
>
> On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm...> wrote:
> >
> > Hi,
> > I saw some difference between a bond's dirty price and the discounted
> > cashflow to the settlement date. Cannot figure out why.
> >
> > For example, in the following code, the dirty price is 103.4815, while
> > my discounted cashflow is 103.4674, why? Thanks a lot.
> >
> > ===============================
> > import QuantLib as ql
> >
> > ## setup the security
> > schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018),
> > terminationDate = ql.Date(30, 6, 2023),
> > tenor = ql.Period(2),
> > calendar =
> > ql.UnitedStates(ql.UnitedStates.GovernmentBond),
> > convention = ql.Unadjusted,
> > terminalDateConvention=ql.Unadjusted,
> > rule = ql.DateGeneration.Backward,
> > endOfMonth = True)
> >
> > day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market
> > convention, not the QuantLib default !!!
> > face = 100
> > redemption = 100
> > issue_date = ql.Date(2, 7, 2018)
> > days_settle = 1
> > coupon = 2.625/100
> > payment_convention = ql.Unadjusted
> > bond = ql.FixedRateBond(days_settle,
> > face,
> > schedule,
> > [coupon],
> > day_count,
> > payment_convention,
> > redemption,
> > issue_date)
> >
> > ## Dirty price
> > settle_date = ql.Date(5, 10, 2021)
> > yld = 0.01
> > freq = ql.Semiannual
> > print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq,
> > settle_date))
> >
> > ## my discount cash flow
> > disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) npv = 0
> > for cf in bond.cashflows():
> > if cf.date() < settle_date:
> > continue
> > df = disc.discountFactor(settle_date, cf.date())
> > npv += cf.amount() * df
> > print(npv)
>
>
> _______________________________________________
> 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: Conrad C. <con...@gm...> - 2021-08-13 14:17:24
|
Hi Jian, The content in this link should provide some clarity to your inquiry. https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715 <https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715> Regards, Conrad Cole https://www.linkedin.com/in/conradcole/ <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttps-3A__www.linkedin.com_in_conradcole_%26d%3DDwMFaQ%26c%3Dj-EkbjBYwkAB4f8ZbVn1Fw%26r%3DgdVyBBPVWs13utXwz8gnZm_nAAP9QAdSnii2IJqmorA%26m%3DBB5ue-rDsok8MXDHSKztDytEfiZR8fiFaU16zeBpTCg%26s%3D0G2tyRZA_g1nxUpHxp-orprHIXmcHhxldPFnQ7y4rXA%26e%3D&data=04%7C01%7Chyman%40adobe.com%7C271ab0ec50a940c1bcf008d931b3c0a7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637595470360539602%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=SPf8o8QVSS8Eurt2suoBz3Rx5QskZBA7NK9crCvTu2c%3D&reserved=0> https://github.com/darnoceloc <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttps-3A__github.com_darnoceloc%26d%3DDwMFaQ%26c%3Dj-EkbjBYwkAB4f8ZbVn1Fw%26r%3DgdVyBBPVWs13utXwz8gnZm_nAAP9QAdSnii2IJqmorA%26m%3DBB5ue-rDsok8MXDHSKztDytEfiZR8fiFaU16zeBpTCg%26s%3DN5brSSbSQne5QmmF2BkZBY7Pc-1us2Kn_UJGgM6In4w%26e%3D&data=04%7C01%7Chyman%40adobe.com%7C271ab0ec50a940c1bcf008d931b3c0a7%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637595470360549598%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=uTDE4OAmMOM5JclPtkAz5gZrd0laAxb2T1hb%2FEqArgc%3D&reserved=0> On 8/13/21 9:52 AM, jian Xu wrote: > One thing I noticed is that if I set "day_count" to ql.ActualActual() > instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price > matches the npv exactly. This is very strange. The "day_count" > variable is consistently used in the bond's constructor, dirtyPrice(), > and InterestRate's constructor. Why would ql.ActualActual.ISMA > causing dirty price and the npv to be different? Am I missing > something? > > On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm...> wrote: >> Hi, >> I saw some difference between a bond's dirty price and the discounted >> cashflow to the settlement date. Cannot figure out why. >> >> For example, in the following code, the dirty price is 103.4815, while >> my discounted cashflow is 103.4674, why? Thanks a lot. >> >> =============================== >> import QuantLib as ql >> >> ## setup the security >> schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018), >> terminationDate = ql.Date(30, 6, 2023), >> tenor = ql.Period(2), >> calendar = >> ql.UnitedStates(ql.UnitedStates.GovernmentBond), >> convention = ql.Unadjusted, >> terminalDateConvention=ql.Unadjusted, >> rule = ql.DateGeneration.Backward, >> endOfMonth = True) >> >> day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market >> convention, not the QuantLib default !!! >> face = 100 >> redemption = 100 >> issue_date = ql.Date(2, 7, 2018) >> days_settle = 1 >> coupon = 2.625/100 >> payment_convention = ql.Unadjusted >> bond = ql.FixedRateBond(days_settle, >> face, >> schedule, >> [coupon], >> day_count, >> payment_convention, >> redemption, >> issue_date) >> >> ## Dirty price >> settle_date = ql.Date(5, 10, 2021) >> yld = 0.01 >> freq = ql.Semiannual >> print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq, settle_date)) >> >> ## my discount cash flow >> disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) >> npv = 0 >> for cf in bond.cashflows(): >> if cf.date() < settle_date: >> continue >> df = disc.discountFactor(settle_date, cf.date()) >> npv += cf.amount() * df >> print(npv) > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: <mat...@gm...> - 2021-08-13 14:12:30
|
On first glance, I was also wondering about the impact of the reference period, see https://quant.stackexchange.com/questions/12707/pricing-a-fixedratebond-in-quantlib-yield-vs-termstructure/12715#12715 But being thrown off by a difference in NPVs when using ql.Thirty360(Thirty360.BondBasis). Not quite clear about that one. -----Original Message----- From: jian Xu <jia...@gm...> Sent: Friday, 13 August, 2021 15:53 To: QuantLib users <qua...@li...> Subject: Re: [Quantlib-users] Bond dirty price different from discounted cashflow? One thing I noticed is that if I set "day_count" to ql.ActualActual() instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price matches the npv exactly. This is very strange. The "day_count" variable is consistently used in the bond's constructor, dirtyPrice(), and InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty price and the npv to be different? Am I missing something? On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm...> wrote: > > Hi, > I saw some difference between a bond's dirty price and the discounted > cashflow to the settlement date. Cannot figure out why. > > For example, in the following code, the dirty price is 103.4815, while > my discounted cashflow is 103.4674, why? Thanks a lot. > > =============================== > import QuantLib as ql > > ## setup the security > schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018), > terminationDate = ql.Date(30, 6, 2023), > tenor = ql.Period(2), > calendar = > ql.UnitedStates(ql.UnitedStates.GovernmentBond), > convention = ql.Unadjusted, > terminalDateConvention=ql.Unadjusted, > rule = ql.DateGeneration.Backward, > endOfMonth = True) > > day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market > convention, not the QuantLib default !!! > face = 100 > redemption = 100 > issue_date = ql.Date(2, 7, 2018) > days_settle = 1 > coupon = 2.625/100 > payment_convention = ql.Unadjusted > bond = ql.FixedRateBond(days_settle, > face, > schedule, > [coupon], > day_count, > payment_convention, > redemption, > issue_date) > > ## Dirty price > settle_date = ql.Date(5, 10, 2021) > yld = 0.01 > freq = ql.Semiannual > print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq, > settle_date)) > > ## my discount cash flow > disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) npv = 0 > for cf in bond.cashflows(): > if cf.date() < settle_date: > continue > df = disc.discountFactor(settle_date, cf.date()) > npv += cf.amount() * df > print(npv) _______________________________________________ QuantLib-users mailing list Qua...@li... https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: jian Xu <jia...@gm...> - 2021-08-13 13:53:15
|
One thing I noticed is that if I set "day_count" to ql.ActualActual() instead of ql.ActualActual(ql.ActualActual.ISMA), then the dirty price matches the npv exactly. This is very strange. The "day_count" variable is consistently used in the bond's constructor, dirtyPrice(), and InterestRate's constructor. Why would ql.ActualActual.ISMA causing dirty price and the npv to be different? Am I missing something? On Fri, Aug 13, 2021 at 7:57 AM jian Xu <jia...@gm...> wrote: > > Hi, > I saw some difference between a bond's dirty price and the discounted > cashflow to the settlement date. Cannot figure out why. > > For example, in the following code, the dirty price is 103.4815, while > my discounted cashflow is 103.4674, why? Thanks a lot. > > =============================== > import QuantLib as ql > > ## setup the security > schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018), > terminationDate = ql.Date(30, 6, 2023), > tenor = ql.Period(2), > calendar = > ql.UnitedStates(ql.UnitedStates.GovernmentBond), > convention = ql.Unadjusted, > terminalDateConvention=ql.Unadjusted, > rule = ql.DateGeneration.Backward, > endOfMonth = True) > > day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market > convention, not the QuantLib default !!! > face = 100 > redemption = 100 > issue_date = ql.Date(2, 7, 2018) > days_settle = 1 > coupon = 2.625/100 > payment_convention = ql.Unadjusted > bond = ql.FixedRateBond(days_settle, > face, > schedule, > [coupon], > day_count, > payment_convention, > redemption, > issue_date) > > ## Dirty price > settle_date = ql.Date(5, 10, 2021) > yld = 0.01 > freq = ql.Semiannual > print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq, settle_date)) > > ## my discount cash flow > disc = ql.InterestRate(yld, day_count, ql.Compounded, freq) > npv = 0 > for cf in bond.cashflows(): > if cf.date() < settle_date: > continue > df = disc.discountFactor(settle_date, cf.date()) > npv += cf.amount() * df > print(npv) |
|
From: jian Xu <jia...@gm...> - 2021-08-13 12:57:28
|
Hi,
I saw some difference between a bond's dirty price and the discounted
cashflow to the settlement date. Cannot figure out why.
For example, in the following code, the dirty price is 103.4815, while
my discounted cashflow is 103.4674, why? Thanks a lot.
===============================
import QuantLib as ql
## setup the security
schedule = ql.MakeSchedule(effectiveDate = ql.Date(30, 6, 2018),
terminationDate = ql.Date(30, 6, 2023),
tenor = ql.Period(2),
calendar =
ql.UnitedStates(ql.UnitedStates.GovernmentBond),
convention = ql.Unadjusted,
terminalDateConvention=ql.Unadjusted,
rule = ql.DateGeneration.Backward,
endOfMonth = True)
day_count = ql.ActualActual(ql.ActualActual.ISMA) # US market
convention, not the QuantLib default !!!
face = 100
redemption = 100
issue_date = ql.Date(2, 7, 2018)
days_settle = 1
coupon = 2.625/100
payment_convention = ql.Unadjusted
bond = ql.FixedRateBond(days_settle,
face,
schedule,
[coupon],
day_count,
payment_convention,
redemption,
issue_date)
## Dirty price
settle_date = ql.Date(5, 10, 2021)
yld = 0.01
freq = ql.Semiannual
print(bond.dirtyPrice(yld, day_count, ql.Compounded, freq, settle_date))
## my discount cash flow
disc = ql.InterestRate(yld, day_count, ql.Compounded, freq)
npv = 0
for cf in bond.cashflows():
if cf.date() < settle_date:
continue
df = disc.discountFactor(settle_date, cf.date())
npv += cf.amount() * df
print(npv)
|
|
From: Miguel T. M. <mig...@bc...> - 2021-08-09 23:02:47
|
Hi I’m new to Quantlib. I have run the example 3 of CDS that reproduces the example of the OpenGamma paper “Pricing and Risk Management of CDS”. When comparing the paper with the output of Quantlib I see that the reproduced yield curve is the same but the credit curve it is not. In fact, the maturity dates of the SpreadCdsHelper are not the IMM dates but the next day, even considering for weekend effects. I have tried changing the DateGenerator and model in the construction of the cdshelpers but have not replicated the expected maturity dates (IMM adjusted for weekend calendar and following business date). Even when directly using the constructed credit curve with the Maturity dates (of table 13) the survival probabilities in quantlib do not coincide. . [cid:image001.png@01D78D28.FCEAE620] [cid:image002.png@01D78D28.FCEAE620] Thanks Miguel El sistema de correo electrónico del Banco de Crédito BCP está destinado únicamente para fines del negocio, cualquier otro uso contraviene las políticas del Banco. Toda la información del negocio contenida en este mensaje es confidencial y de uso exclusivo del Banco de Crédito BCP. Su divulgación, copia y/o adulteración están prohibidas y sólo debe ser conocida por la persona a quien se dirige este mensaje. Si Ud. ha recibido este mensaje por error por favor proceda a eliminarlo y notificar al remitente. El sistema de correo electrónico del Banco de Crédito BCP está destinado únicamente para fines del negocio, cualquier otro uso contraviene las políticas del Banco. Toda la información del negocio contenida en este mensaje es confidencial y de uso exclusivo del Banco de Crédito BCP. Su divulgación, copia y/o adulteración están prohibidas y sólo debe ser conocida por la persona a quien se dirige este mensaje. Si Ud. ha recibido este mensaje por error por favor proceda a eliminarlo y notificar al remitente. |
|
From: Gorazd B. <gor...@gm...> - 2021-08-09 20:19:06
|
Hi all, I'm new to the list, and have the following question: Why are elements of VanillaSwap leg CashFlow type, and not Coupon type? (please see below) Best regards, Gorazd In [11]: sw2 Out[11]: <QuantLib.QuantLib.VanillaSwap; proxy of <Swig Object of type 'boost::shared_ptr< VanillaSwap > *' at 0x7f48a03c7780> > In [10]: list(sw2.floatingLeg()) Out[10]: [<QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type 'boost::shared_ptr< CashFlow > *' at 0x7f4895863cf0> >, <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type 'boost::shared_ptr< CashFlow > *' at 0x7f4895863e40> >, <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type 'boost::shared_ptr< CashFlow > *' at 0x7f4895863f00> >, <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type 'boost::shared_ptr< CashFlow > *' at 0x7f4895863870> >] |
|
From: Luigi B. <lui...@gm...> - 2021-08-02 15:49:59
|
Hello Philippe,
PartialTimeBarrierOption is not exported in SWIG. May you open an
issue at <https://github.com/lballabio/QuantLib-SWIG/issues>?
Luigi
On Fri, Jul 30, 2021 at 5:34 PM Philippe Hatstadt <
phi...@ex...> wrote:
> I found a C++ implementation in Quantlib asper the link below:
>
> https://rkapl123.github.io/QLAnnotatedSource/d8/d44/partialtimebarrieroption_8hpp_source.html
> However, I don't seem to be able to find a Python interface in the Python
> QL library.
> Does anyone know the status?
>
> 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/>/ 2021 Exos, inc. For important
> disclosures, click here
> <https://www.exosfinancial.com/general-disclosures>.
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Philippe H. <phi...@ex...> - 2021-07-30 15:32:06
|
I found a C++ implementation in Quantlib asper the link below: https://rkapl123.github.io/QLAnnotatedSource/d8/d44/partialtimebarrieroption_8hpp_source.html However, I don't seem to be able to find a Python interface in the Python QL library. Does anyone know the status? 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/>/ 2021 Exos, inc. For important disclosures, click here <https://www.exosfinancial.com/general-disclosures>. |
|
From: Philippe H. <phi...@ex...> - 2021-07-29 14:51:47
|
I am trying to price an up and out American single barrier rebate call option with the caveat that in order to be triggered, the stock price would need to continuously exceed the barrier for more than say 4 weeks in a row. I am using the existing ql.BarrierOption(), but this is based on the first touch of the barrier for both the knocking out of the option as well as triggering the payment of the rebate. To keep it simple, I used the ql.BlackScholesMertonProcess(), and ql.BinomialBarrierEngine(), with the 'crr' method, but that's not a requirement. So my questions are as follows: 1. Is there an existing engine that can handle my request, and is there a barrier option model that can utilize it? 2. If not, how complex would it be to modify the 'crr' (or whichever would be more appropriate) engine/method at the C++ level to handle my request? Regards 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/>/ 2021 Exos, inc. For important disclosures, click here <https://www.exosfinancial.com/general-disclosures>. |
|
From: David D. <nh...@gm...> - 2021-07-26 13:51:27
|
Just replace: callability_price = ql.CallabilityPrice(call_price, ql.CallabilityPrice.Clean) with: callability_price = ql.BondPrice(call_price, ql.BondPrice.Clean) On Mon, 26 Jul 2021 at 14:40, Philippe Hatstadt < phi...@ex...> wrote: > Thanks. However, I am getting an error as below: > > > AttributeError: module 'QuantLib' has no attribute 'CallabilityPrice' > > > Philippe Hatstadt > > > On Mon, Jul 26, 2021 at 9:23 AM David Duarte <nh...@gm...> wrote: > >> Yes, here is an example: >> >> >> http://gouthamanbalaraman.com/blog/value-convertible-bond-quantlib-python.html >> >> On Mon, 26 Jul 2021 at 14:19, Philippe Hatstadt < >> phi...@ex...> wrote: >> >>> Does QL have a convertible bond model of any sort? Looking for something >>> simple enough, not making markets so approximate would be good enough. >>> >>> 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/>/ 2021 Exos, inc. For important >>> disclosures, click here >>> <https://www.exosfinancial.com/general-disclosures>. >>> >>> >>> _______________________________________________ >>> QuantLib-users mailing list >>> Qua...@li... >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >> > > > 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/>/ 2021 Exos, inc. For important > disclosures, click here > <https://www.exosfinancial.com/general-disclosures>. > > > |
|
From: Philippe H. <phi...@ex...> - 2021-07-26 13:40:48
|
Thanks. However, I am getting an error as below: AttributeError: module 'QuantLib' has no attribute 'CallabilityPrice' Philippe Hatstadt On Mon, Jul 26, 2021 at 9:23 AM David Duarte <nh...@gm...> wrote: > Yes, here is an example: > > > http://gouthamanbalaraman.com/blog/value-convertible-bond-quantlib-python.html > > On Mon, 26 Jul 2021 at 14:19, Philippe Hatstadt < > phi...@ex...> wrote: > >> Does QL have a convertible bond model of any sort? Looking for something >> simple enough, not making markets so approximate would be good enough. >> >> 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/>/ 2021 Exos, inc. For important >> disclosures, click here >> <https://www.exosfinancial.com/general-disclosures>. >> >> >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > -- 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/>/ 2021 Exos, inc. For important disclosures, click here <https://www.exosfinancial.com/general-disclosures>. |
|
From: David D. <nh...@gm...> - 2021-07-26 13:23:47
|
Yes, here is an example: http://gouthamanbalaraman.com/blog/value-convertible-bond-quantlib-python.html On Mon, 26 Jul 2021 at 14:19, Philippe Hatstadt < phi...@ex...> wrote: > Does QL have a convertible bond model of any sort? Looking for something > simple enough, not making markets so approximate would be good enough. > > 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/>/ 2021 Exos, inc. For important > disclosures, click here > <https://www.exosfinancial.com/general-disclosures>. > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |