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
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Peter C. <pca...@gm...> - 2020-10-25 13:09:36
|
Hi Brian, a and alpha refer to the same variable, namely the reversion speed of the model, we should probably make the documentation clearer here. The parameter theta(t) on the other hand is automatically calibrated to the initial rate curve, i.e. you can not (don't need to) specify this parameter explicitly. Best Regards Peter Peter On Sun, 25 Oct 2020 at 09:46, Brian Smith <bri...@gm...> wrote: > > Hi, > > I am confused about the definition of the Black Karasinski Class > implemented in Quantlib. > > The reference is available in > https://rkapl123.github.io/QLAnnotatedSource/d4/d58/class_quant_lib_1_1_black_karasinski.html > > As per this documentation, the constructor of this class takes a > parameter called "a" which is defaulted at 0.1 > > But in this same documentation, the actual process is defined as - > > \[ d\ln r_t = (\theta(t) - \alpha \ln r_t)dt + \sigma dW_t, \] > > Can you please help me understand what is the relation between a and > {theta, alpha} in above two forms of specification? > > Thanks for your time. Regards > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: Peter C. <pca...@gm...> - 2020-10-25 13:08:34
|
Hi Philippe, the Jamshidian engine uses a) discount bond prices conditional on the state of the model (i.e. the short rate in the case of the Hull-White model) and b) zero bond option prices in the model to come up with a model swaption price. It retrieves this information via the discountBond() and discountBondOption() methods in the OneFactorAffineModel interface. The methods account for the adjustment term theta(t) in the Hull-White model SDE already, there is nothing that the engine needs to do in addition to that. I don't know if that answers your question? The HullWhiteProcess also takes into account the adjustment to the initial curve already. To see that you can look into the implementation of HullWhiteProcess::drift() https://github.com/lballabio/QuantLib/blob/master/ql/processes/hullwhiteprocess.cpp#L38 which coincides with e.g. Brigo Mercurio, Interest Rate Models, Theory and Practice, Formulas (3.33) and (3.34) observing that in this context https://github.com/lballabio/QuantLib/blob/master/ql/processes/ornsteinuhlenbeckprocess.hpp#L90 level_ is zero, speed_ is the Hull-White mean reversion parameter and x stands for the short rate at time t. Does that make sense? Thanks, Peter On Sun, 25 Oct 2020 at 12:47, philippe hatstadt via QuantLib-users <qua...@li...> wrote: > > Is there any information about how the Jamshidian engine does the drift adjustment to match the initial curve for the Hull White model? > If I want to use the QL HW Process in a MC model, I assume II have to do the drift adjustment myself, or is there existing QL functionality to do that? > > Regards > > Philippe Hatstadt > +1-203-252-0408 > https://www.linkedin.com/in/philippe-hatstadt > > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: philippe h. <pha...@ma...> - 2020-10-25 11:45:18
|
Is there any information about how the Jamshidian engine does the drift adjustment to match the initial curve for the Hull White model? If I want to use the QL HW Process in a MC model, I assume II have to do the drift adjustment myself, or is there existing QL functionality to do that? Regards Philippe Hatstadt +1-203-252-0408 https://www.linkedin.com/in/philippe-hatstadt |
|
From: Brian S. <bri...@gm...> - 2020-10-25 08:44:45
|
Hi, I am confused about the definition of the Black Karasinski Class implemented in Quantlib. The reference is available in https://rkapl123.github.io/QLAnnotatedSource/d4/d58/class_quant_lib_1_1_black_karasinski.html As per this documentation, the constructor of this class takes a parameter called "a" which is defaulted at 0.1 But in this same documentation, the actual process is defined as - \[ d\ln r_t = (\theta(t) - \alpha \ln r_t)dt + \sigma dW_t, \] Can you please help me understand what is the relation between a and {theta, alpha} in above two forms of specification? Thanks for your time. Regards |
|
From: Eric E. <eri...@re...> - 2020-10-22 10:41:21
|
Dear Jack, Not all QuantLib functionality has been exported to QuantLibXL. I would describe my efforts as mantainer as hovering around the level of barely keeping the project alive. I aim to get a 1.20 release out. I do merge the pull requests that I receive. Kind Regards, Eric On 10/21/20 9:38 AM, Jack G wrote: > Dear Eric and QuantLibXL users, > > I've been experimenting with QuantLibXL a little bit recently and had > a couple of questions regarding it... > > 1) the qlGeneralizedBlackScholesProcess() class seems to only accept > doubles for the rate and dividend arguments (as opposed to > termstructures in QL)* > > 2) I can't see any other spot/vol processes (eg. Heston) implemented > in the wrapper yet > > I'm not a heavy excel user but my use-case here is that it's quite > nice as a demonstration aid to have excel in one window and the > C++/Python in another if the API is consistent to show how you build > the same items in each. > > Is the add-on being actively worked on at the moment? Are pull > requests being merged, and is the correct repo the one below? > > Thanks, > Jack > > References for GeneralizedBlackScholesProcess: > https://www.quantlib.org/quantlibxl/func_processes.html#qlGeneralizedBlackScholesProcess > https://github.com/eehlers/QuantLibAddin-Old/blob/a891cc372429be11cc44bb4ac99931aefc548066/QuantLibAddin/qlo/processes.cpp > > On Tue, Oct 20, 2020 at 8:41 PM Eric Ehlers <eri...@re... > <mailto:eri...@re...>> wrote: > > Hi All, > > I have generated a preliminary build of QuantLibXL version 1.20: > > https://bintray.com/quantlib/prerelease/QuantLibXL/1.20_prerelease#files > > In the coming days I will respond to all of the outstanding pull > requests and queries that I have received, and then I will produce a > final release candidate. > > Kind Regards, > Eric > > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > <mailto:Qua...@li...> > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Jack G <jac...@gm...> - 2020-10-21 07:39:24
|
Dear Eric and QuantLibXL users, I've been experimenting with QuantLibXL a little bit recently and had a couple of questions regarding it... 1) the qlGeneralizedBlackScholesProcess() class seems to only accept doubles for the rate and dividend arguments (as opposed to termstructures in QL)* 2) I can't see any other spot/vol processes (eg. Heston) implemented in the wrapper yet I'm not a heavy excel user but my use-case here is that it's quite nice as a demonstration aid to have excel in one window and the C++/Python in another if the API is consistent to show how you build the same items in each. Is the add-on being actively worked on at the moment? Are pull requests being merged, and is the correct repo the one below? Thanks, Jack References for GeneralizedBlackScholesProcess: https://www.quantlib.org/quantlibxl/func_processes.html#qlGeneralizedBlackScholesProcess https://github.com/eehlers/QuantLibAddin-Old/blob/a891cc372429be11cc44bb4ac99931aefc548066/QuantLibAddin/qlo/processes.cpp On Tue, Oct 20, 2020 at 8:41 PM Eric Ehlers <eri...@re...> wrote: > Hi All, > > I have generated a preliminary build of QuantLibXL version 1.20: > > https://bintray.com/quantlib/prerelease/QuantLibXL/1.20_prerelease#files > > In the coming days I will respond to all of the outstanding pull > requests and queries that I have received, and then I will produce a > final release candidate. > > Kind Regards, > Eric > > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: <mat...@gm...> - 2020-10-20 16:08:01
|
Hello, Maybe this one: https://www.ad-co.com/analytics_valuation#OASSub I remember a proof-of-concept I created some time ago which went fairly well, but my involvement was more on the technical side, so I cannot really judge the quality of the model. It is “fairly” compatible with QL in that it is a C library ;) Free or libre as QL it is not. Best regards, Matthias From: Philippe Hatstadt <phi...@ex...> Sent: Tuesday, 20 October 2020 15:16 To: QuantLib users <Qua...@li...> Subject: [Quantlib-users] Mortgage analytics compatible with QL / Python API Are there any 3rd party analytics vendors specialized in MBS? In particular, I'd be interested in both cash flow modeling and OAS, the latter requiring a stochastic rate model. For a number of reasons, I'd like such a vendor to be somehow compatible with QL although it's not 100% clear what that even means, short of being based on QL an open source, which probably doesn't exist. Philippe Hatstadt Brokerage services offered through Exos Securities LLC, member of <http://www.sipc.org/> SIPC / <http://www.finra.org/> FINRA. For important disclosures, <https://www.exosfinancial.com/disclosures> click here. |
|
From: Philippe H. <phi...@ex...> - 2020-10-20 13:16:38
|
Are there any 3rd party analytics vendors specialized in MBS? In particular, I'd be interested in both cash flow modeling and OAS, the latter requiring a stochastic rate model. For a number of reasons, I'd like such a vendor to be somehow compatible with QL although it's not 100% clear what that even means, short of being based on QL an open source, which probably doesn't exist. Philippe Hatstadt -- Brokerage services offered through Exos Securities LLC, member of SIPC <http://www.sipc.org/> / FINRA <http://www.finra.org/>. For important disclosures, click here <https://www.exosfinancial.com/disclosures>. |
|
From: Eric E. <eri...@re...> - 2020-10-20 12:41:07
|
Hi All, I have generated a preliminary build of QuantLibXL version 1.20: https://bintray.com/quantlib/prerelease/QuantLibXL/1.20_prerelease#files In the coming days I will respond to all of the outstanding pull requests and queries that I have received, and then I will produce a final release candidate. Kind Regards, Eric |
|
From: Luigi B. <lui...@gm...> - 2020-10-19 08:43:28
|
That's correct - with a floor, we need some kind of volatility model for the rates in order to forecast the coupon amount. You can see an example at < https://quantlib-python-docs.readthedocs.io/en/latest/cashflows.html#blackiborcouponpricer>; in your case, in which you don't build the leg directly, you would use something like ql.setCouponPricer(bond.cashflows(), pricer) instead, but the idea is the same. Luigi On Sat, Sep 19, 2020 at 12:18 AM Arkadiy Naumov <ark...@gm...> wrote: > This isn't based on any research (I didn't actually look at the code to > confirm), but from a naive perspective - once you add a floor, you can no > longer use the discounted cash flows engine to value this bond, since it > has an embedded option. Unless of course there is something built into the > engine just for this case (i.e. it assumes zero volatility or something of > that nature). > > On Sun, Sep 6, 2020 at 4:49 PM Sumit Sengupta <su...@mo...> > wrote: > >> Hi all, >> >> I am trying to price a Floating rate note (as per the quantlib python cookbook). >> >> It seems to fail whenever I put a *floor = [0], * with the error... >> >> Traceback (most recent call last): >> File "C:/Users/sumit/.PyCharm2018.3/config/scratches/scratch_48.py", line 88, in calc_bond_price >> return (bond.cleanPrice() - price)**2 >> File "C:\Users\sumit\Anaconda3\envs\msq-360-plus\lib\site-packages\QuantLib\QuantLib.py", line 16229, in cleanPrice >> return _QuantLib.Bond_cleanPrice(self, *args) >> RuntimeError: pricer not set >> >> Note that it fails when I try to fit a discount margin spread over my discount rate curve >> >> *My code is as below....* >> >> forecast_curve = ql.RelinkableYieldTermStructureHandle() >> discount_curve = ql.RelinkableYieldTermStructureHandle() >> >> term_structure_handle, index = generate_swaps_market_data() >> index.addFixing(ql.Date(16, 7, 2020), 0/100) >> >> forecast_curve.linkTo(ql.ZeroSpreadedTermStructure(term_structure_handle, ql.QuoteHandle(ql.SimpleQuote(0.)))) >> >> issue_date = ql.Date(19, 1, 2001) >> maturity_date = ql.Date(19, 1, 2031) >> >> schedule = ql.Schedule(issue_date, maturity_date,ql.Period(ql.Quarterly), ql.TARGET(), >> ql.Following, ql.Following,ql.DateGeneration.Backward, False) >> >> bond = ql.FloatingRateBond(settlementDays = 2,faceAmount = 100,schedule = schedule, >> index = index,paymentDayCounter = ql.Actual360(), >> paymentConvention = ql.Following, fixingDays = index.fixingDays(),gearings = [], >> spreads = [0.3/10000],caps= [],*floors = [0]*,inArrears = False,redemption = 100.0,issueDate = issue_date >> ) >> >> bond.setPricingEngine(ql.DiscountingBondEngine(discount_curve)) >> >> DM = ql.SimpleQuote(0.0) >> discount_curve.linkTo(ql.ZeroSpreadedTermStructure(forecast_curve,ql.QuoteHandle(DM))) >> >> price=88.466 >> >> def calc_bond_price(param): >> s = param[0] >> DM.setValue(s) >> return (bond.cleanPrice() - price)**2 >> >> x0=0.0003 >> bounds=[[-1000, 1000]] >> res = minimize(calc_bond_price, x0, bounds=bounds) >> print(f"DM:{res.x[0]*10000}") >> >> DM.setValue(res.x[0]) >> print(f"clean price:{bond.cleanPrice()}") >> >> >> -- >> Mosaic Smart Data >> >> mobile +44 (0)7961839363 >> su...@mo... >> 25 Finsbury Circus ▫ EC2M 7EE ▫ London ▫ United Kingdom >> www.mosaicsmartdata.com >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: Luigi B. <lui...@gm...> - 2020-10-19 08:11:23
|
Hello Brian,
by spot_rates = [0.1, 0.13, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.7, 1.4, 1.6,
2, 2, 4] do you mean 0.1%, 0.13% and so on?
If so, that should be spot_rates = [0.001, 0.0013, 0.001, 0.001, 0.001,
0.001, 0.001, 0.001, 0.007, 0.014, 0.016, 0.02, 0.02, 0.04].
As it is, you're passing 10%, 13% etc., which throws the computation off.
Hope this helps,
Luigi
On Fri, Oct 2, 2020 at 8:51 PM Brian Smith <bri...@gm...>
wrote:
> Hi,
>
> I was performing european and american valuation of the same Swaption
> contract as follows. I found that both NPV values are quite big, and
> they are surprisingly equal. Below is my implementation -
>
> from QuantLib import *
> import datetime
> import numpy as np
> import pandas as pd
>
> calc_date = Date(23, 12, 2013)
> Settings.instance().evaluationDate = calc_date
> spot_dates = [calc_date + Period("1d"), calc_date + Period("2w"),
> calc_date + Period("1m"), calc_date + Period("2m"), calc_date +
> Period("3m"), calc_date + Period("6m"), calc_date + Period("1y"),
> calc_date + Period("2y"), calc_date + Period("3y"), calc_date +
> Period("4y"), calc_date + Period("5y"), calc_date + Period("8y"),
> calc_date + Period("10y"), calc_date + Period("30y")]
> spot_rates = [0.1, 0.13, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.7, 1.4, 1.6, 2,
> 2, 4]
> us_calendar = UnitedStates()
> zero_curve = ZeroCurve(spot_dates, spot_rates, Actual365Fixed(),
> us_calendar, Linear(), Compounded, Annual)
> termStructure = YieldTermStructureHandle(zero_curve)
> swap = VanillaSwap(VanillaSwap.Payer,
> 100,
> Schedule(Date(1, 12, 2014) + Period("6m"),
> Date(1, 12, 2019), Period(6, Months), us_calendar, Unadjusted,
> Unadjusted, DateGeneration.Forward, False),
> 3/100,
> Thirty360(Thirty360.BondBasis),
> Schedule(Date(1, 12, 2014) + Period("6m"),
> Date(1, 12, 2019), Period(6, Months), us_calendar, Unadjusted,
> Unadjusted, DateGeneration.Forward, False),
> USDLibor(Period(6, Months), termStructure),
> 0.0,
> USDLibor(Period(6, Months),
> termStructure).dayCounter()
> )
>
> exercised = EuropeanExercise(Date(1, 12, 2014))
> atmswaption = Swaption(swap, exercised)
>
> atmswaption.setPricingEngine(TreeSwaptionEngine(BlackKarasinski(termStructure),
> 3000)); print(atmswaption.NPV())
>
> exercised = AmericanExercise(Date(1, 3, 2014), Date(1, 12, 2014))
> atmswaption = Swaption(swap, exercised)
>
> atmswaption.setPricingEngine(TreeSwaptionEngine(BlackKarasinski(termStructure),
> 3000)); print(atmswaption.NPV())
>
> Is there any reason why they are so close? Your pointer will be very
> helpful.
>
> Many thanks,
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: isilay e. <ero...@gm...> - 2020-10-16 08:54:32
|
Hi to all,
lgnore my latest question,
Thank you, my calculaton was wrong, it's working now,
Thank you David
Regards
On 15 Oct 2020 Thu at 16:06 isilay erol <ero...@gm...> wrote:
> I have one more question
>
> After connecting the index to the zero curve, when calculating the fwd
> curve, I see that query divides the fwd curve by “2”.
>
> While calculating the fwd rate, the difference between two consecutive
> dates in the bond's forward cash flows is taken into account.
>
> Dividing the calculated fwd ratio by two again will cause decrease the
> ratio again.
>
> ( I guess It should not divide it again), what am I missing?
>
> On 15 Oct 2020 Thu at 11:33 isilay erol <ero...@gm...> wrote:
>
>>
>> Thanks for your warning David, after that
>> I will post my questions in a relevant email,
>> And thanks for your help
>>
>> Regards
>>
>> On 12 Oct 2020 Mon at 17:20 isilay erol <ero...@gm...> wrote:
>>
>>> Dear David I get it now, thank you
>>>
>>> Well then, if I revise my question as follows;
>>>
>>> Without linking to Euribor or libor index, if I load the zero yield
>>> curves of these indexes into python with their tenors
>>>
>>> What if I create forward cash flows by obtaining forward rates for
>>> floatİng products from these zero coupon curves?
>>>
>>> David, you had a suggestion for me, but I didn't quite understand this
>>> solution.
>>>
>>> Thanks for your help and answers,
>>>
>>>
>>> On 12 Oct 2020 Mon at 16:24 David Duarte <nh...@gm...> wrote:
>>>
>>>> Hi,
>>>>
>>>> You seem to be misinterpreting what this line does:
>>>>
>>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>>
>>>> It does create that named index and you check that like this for
>>>> example: ql.IndexManager.instance().histories()
>>>>
>>>> But it is not a method/attribute/class of QuantLib so you should use it
>>>> as:
>>>>
>>>> index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, 12 Oct 2020 at 14:15, isilay erol <ero...@gm...>
>>>> wrote:
>>>>
>>>>> hello, if I wanted to create an index from my own zero curve for TL
>>>>> and I wanted to link it in floating bon, I got an error like this.
>>>>>
>>>>>
>>>>>
>>>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>>>
>>>>>
>>>>>
>>>>> Error message:
>>>>>
>>>>> “AttributeError: module 'QuantLib' has no attribute 'MyIndex6M'
>>>>>
>>>>>
>>>>>
>>>>> import QuantLib as ql
>>>>>
>>>>> from pandas import DataFrame
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> dates = [
>>>>>
>>>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017',
>>>>> '29.09.2017', '30.12.2017',
>>>>>
>>>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>>>
>>>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025',
>>>>> '30.12.2026']
>>>>>
>>>>>
>>>>>
>>>>> zeros = [
>>>>>
>>>>> 0.000000,0.0693795966991162,
>>>>> 0.0759095626003495,0.0841499536866119, 0.0904620831158592,
>>>>> 0.0951565316374134, 0.103938304795234,
>>>>>
>>>>> 0.106710404148259, 0.107861984374564,
>>>>>
>>>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>>>
>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>
>>>>> dayCounter = ql.Actual360()
>>>>>
>>>>>
>>>>>
>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>
>>>>>
>>>>>
>>>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>>>
>>>>>
>>>>>
>>>>> print(ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360()))
>>>>>
>>>>>
>>>>>
>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>
>>>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>>>
>>>>> ql.Period('6m'))
>>>>>
>>>>> index=ql.MyIndex6M(yts)
>>>>>
>>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>>>
>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.MyIndex(yts),
>>>>>
>>>>> ql.Actual360())
>>>>>
>>>>> On 9 Oct 2020 Fri at 15:28 isilay erol <ero...@gm...> wrote:
>>>>>
>>>>>> Dear David,
>>>>>>
>>>>>>
>>>>>>
>>>>>> First of all, thank you for your detailed answer.
>>>>>>
>>>>>>
>>>>>>
>>>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True) query worked
>>>>>>
>>>>>> But I couldn’t solve my other problem.
>>>>>>
>>>>>> I may not be able to express myself or understand your example.
>>>>>>
>>>>>> I will explain below what I did step by step;
>>>>>>
>>>>>> · firstly, I put dates and rates on Anaconda python (this
>>>>>> zero yield curve)
>>>>>>
>>>>>> · Secondly, I determined evaluation date, I changed the date
>>>>>> format.
>>>>>>
>>>>>> · Then it was created as a zero coupon curve "zCurve".
>>>>>>
>>>>>> · After this stage, building the floating rate bond object
>>>>>> and inspect the rate on the cashflows;
>>>>>>
>>>>>> · There is no problem with the following two lines;
>>>>>>
>>>>>> § yts = ql.YieldTermStructureHandle (zCurve)
>>>>>>
>>>>>> § schedule = ql.MakeSchedule (ql.Date (15,6,2020), ql.Date
>>>>>> (15,6,2021), ql.Period ('6m'))
>>>>>>
>>>>>>
>>>>>>
>>>>>> but when I delete “ql.Euribor6M (yts)“in the index section and
>>>>>> replace it with yts.linkTo (zCurve), the error message is occured
>>>>>>
>>>>>> Briefly, I want to make the index statement independent from Euribor
>>>>>> or Libor and tie it to my zero coupon yield curve.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Also in the next step, my goal is to remove the following
>>>>>> "ql.Euribor6M (yts)" statement and not to use it in the same way in the
>>>>>> query (I think this will be fixed automatically if I can fulfill my request
>>>>>> above.)
>>>>>>
>>>>>> bond = ql.FloatingRateBond (2,100, program, ql.Euribor6M (yts),
>>>>>>
>>>>>> ql.Actual360 ())
>>>>>>
>>>>>>
>>>>>>
>>>>>> As a result, what should I substitute for ql.Euribor6M (yts) in the
>>>>>> query below?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank you very much,
>>>>>>
>>>>>>
>>>>>>
>>>>>> import QuantLib as ql
>>>>>>
>>>>>> from pandas import DataFrame
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> dates = [
>>>>>>
>>>>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017',
>>>>>> '29.09.2017', '30.12.2017',
>>>>>>
>>>>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>>>>
>>>>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025',
>>>>>> '30.12.2026']
>>>>>>
>>>>>>
>>>>>>
>>>>>> zeros = [
>>>>>>
>>>>>> 0.000000,0.0693795966991162,
>>>>>> 0.0759095626003495,0.0841499536866119, 0.0904620831158592,
>>>>>> 0.0951565316374134, 0.103938304795234,
>>>>>>
>>>>>> 0.106710404148259, 0.107861984374564,
>>>>>>
>>>>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>>>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>>>>
>>>>>>
>>>>>>
>>>>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>>>>
>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>
>>>>>> dayCounter = ql.Actual360()
>>>>>>
>>>>>>
>>>>>>
>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>>
>>>>>>
>>>>>>
>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>
>>>>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>>>>
>>>>>> ql.Period('6m'))
>>>>>>
>>>>>> index = ql.Euribor6M(yts)
>>>>>>
>>>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>>>>
>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>
>>>>>> ql.Actual360())
>>>>>>
>>>>>>
>>>>>>
>>>>>> dates = [ c.date() for c in bond.cashflows() ]
>>>>>>
>>>>>> cfs = [ c.amount() for c in bond.cashflows() ]
>>>>>>
>>>>>> DataFrame(list(zip(dates, cfs)),
>>>>>>
>>>>>> columns = ('date','amount'),
>>>>>>
>>>>>> index = range(1,len(dates)+1))
>>>>>>
>>>>>> On 9 Oct 2020 Fri at 11:19 David Duarte <nh...@gm...> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> You can either clear the fixings or use the optional boolean third
>>>>>>> parameter on the addFixing method to explicitly overwrite the existing
>>>>>>> value:
>>>>>>>
>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003, True)
>>>>>>>
>>>>>>>
>>>>>>> On the other question, the parameter for the index is a
>>>>>>> YieldTermStructureHandle and you can create one and then link to whichever
>>>>>>> curve you wish to use.
>>>>>>> Maybe this simple example will help you understand:
>>>>>>>
>>>>>>> yts = ql.RelinkableYieldTermStructureHandle()
>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>
>>>>>>> crv1 = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
>>>>>>> yts.linkTo(crv1)
>>>>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>>>>
>>>>>>> crv2 = ql.FlatForward(2, ql.TARGET(), 0.02, ql.Actual360())
>>>>>>> yts.linkTo(crv2)
>>>>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Fri, 9 Oct 2020 at 08:38, isilay erol <ero...@gm...>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> As you said "index.clearFixings ()" command worked. Thank you very
>>>>>>>> much.
>>>>>>>>
>>>>>>>> Well, there is one more basic point that I cannot understand. How
>>>>>>>> can I link the index directly to my index curve?
>>>>>>>>
>>>>>>>> In all the examples I saw on the internet like in the following
>>>>>>>> ones,
>>>>>>>>
>>>>>>>> "index = ql.Euribor6M ()"
>>>>>>>>
>>>>>>>> "index = ql.Euribor3M ()"
>>>>>>>>
>>>>>>>> or I saw the Libor version of this.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Actually, my zero coupon should be an index curve, right?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> In my query how can I create the bridge between my index and index
>>>>>>>> curve zCurve?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> (the part I would like to change: index = ql.Euribor6M(yts))
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Thank you very much for your help,
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> import QuantLib as ql
>>>>>>>>
>>>>>>>> from pandas import DataFrame
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> dates = [
>>>>>>>>
>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>> '10-02-2020',
>>>>>>>>
>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>
>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>> '09-11-2020',
>>>>>>>>
>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> zeros = [
>>>>>>>>
>>>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>>>> 0.002146,
>>>>>>>>
>>>>>>>> 0.002355, 0.002534,
>>>>>>>>
>>>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>>>> 0.004549,
>>>>>>>>
>>>>>>>> 0.003148, 0.004040]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>
>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>
>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(),
>>>>>>>> ql.TARGET())
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> #To get the forward rates, you can use the "forwardRate" method
>>>>>>>> from the curve:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>
>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>
>>>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>
>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>
>>>>>>>> print(fwd)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> #or build the floating rate bond object and inspect the rate on the
>>>>>>>> cashflows:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>>>
>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>>
>>>>>>>> ql.Period('6m'))
>>>>>>>>
>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>
>>>>>>>> index.clearFixings()
>>>>>>>>
>>>>>>>> index.addFixing(ql.Date(6,ql.August,2014), 0.05)
>>>>>>>>
>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>
>>>>>>>> ql.Actual360())
>>>>>>>>
>>>>>>>>
>>>>>>>> On 9 Oct 2020 Fri at 10:11 Francois Botha <ig...@gm...> wrote:
>>>>>>>>
>>>>>>>>> So the error message states that you have already added the fixing.
>>>>>>>>>
>>>>>>>>> I'm unsure whether the Python interface for index.addFixing
>>>>>>>>> provides a parameter to optionally overwrite any existing indices. If so,
>>>>>>>>> try that. Alternatively, there should be something like
>>>>>>>>> index.clearFixings() which you can call first before adding new fixings.
>>>>>>>>>
>>>>>>>>> regards
>>>>>>>>>
>>>>>>>>> Francois Botha
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, 9 Oct 2020 at 08:58, isilay erol <ero...@gm...>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Hello again,
>>>>>>>>>>
>>>>>>>>>> I want to ask one more question;
>>>>>>>>>>
>>>>>>>>>> I want set a past fixing for the current latest coupon (which,
>>>>>>>>>> having fixed in the past, can’t be forecast).
>>>>>>>>>>
>>>>>>>>>> The forecasting of floating bond cashflow should be start
>>>>>>>>>> generate from this latest repring coupon rate.
>>>>>>>>>>
>>>>>>>>>> That’s why I heve added the following querry only to see what
>>>>>>>>>> will happen;
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> “index.addFixing(ql.Date(6,ql.March,2019), 0.003)”
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Bu I have the folowing error message;
>>>>>>>>>>
>>>>>>>>>> Am I thinking wrongly?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>
>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> dates = [
>>>>>>>>>>
>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>> '10-02-2020',
>>>>>>>>>>
>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>
>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>> '09-11-2020',
>>>>>>>>>>
>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> zeros = [
>>>>>>>>>>
>>>>>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>>>>>> 0.002146,
>>>>>>>>>>
>>>>>>>>>> 0.002355, 0.002534,
>>>>>>>>>>
>>>>>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>>>>>> 0.004549,
>>>>>>>>>>
>>>>>>>>>> 0.003148, 0.004040]
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>
>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>
>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(),
>>>>>>>>>> ql.TARGET())
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>
>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>
>>>>>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>
>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>
>>>>>>>>>> print(fwd)
>>>>>>>>>>
>>>>>>>>>> 0.005623856615195155
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>>>>>
>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>>>>
>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>
>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>
>>>>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>>>>
>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>
>>>>>>>>>> ql.Actual360())
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> File "<ipython-input-61-ec28b13dc284>", line 5, in <module>
>>>>>>>>>>
>>>>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> File "C:\Anaconda3\lib\site-packages\QuantLib\QuantLib.py",
>>>>>>>>>> line 5475, in addFixing
>>>>>>>>>>
>>>>>>>>>> return _QuantLib.Index_addFixing(self, fixingDate, fixing,
>>>>>>>>>> forceOverwrite)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> RuntimeError: At least one duplicated fixing provided: March 6th,
>>>>>>>>>> 2019, 0.003 while 0.002 value is already present
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Best regards,
>>>>>>>>>>
>>>>>>>>>> On 8 Oct 2020 Thu at 17:20 isilay erol <ero...@gm...>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> Thank you very much Luigi an David.
>>>>>>>>>>>
>>>>>>>>>>> On 8 Oct 2020 Thu at 16:32 Luigi Ballabio <
>>>>>>>>>>> lui...@gm...> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> If you use ql.ZeroCurve instead of ql.DiscountCurve you can
>>>>>>>>>>>> input zero rates directly and get a curve that you can use in the exact
>>>>>>>>>>>> same way.
>>>>>>>>>>>>
>>>>>>>>>>>> Luigi
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, Oct 8, 2020 at 3:13 PM isilay erol <
>>>>>>>>>>>> ero...@gm...> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Dear David,
>>>>>>>>>>>>>
>>>>>>>>>>>>> You are right, the discount factors are increasing,
>>>>>>>>>>>>>
>>>>>>>>>>>>> this indicates that the curve is negative.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Your sample helped me a lot, thank you very much.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I need to make my calculation from the zero coupon yield curve
>>>>>>>>>>>>> itself,
>>>>>>>>>>>>>
>>>>>>>>>>>>> not the discount factor. At this point,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I will try to move forward using the formula of the discount
>>>>>>>>>>>>> factor calculation from zero coupon.
>>>>>>>>>>>>>
>>>>>>>>>>>>> If you already have a Python example of this conversion, I
>>>>>>>>>>>>> would be very happy if you could share it with me.
>>>>>>>>>>>>>
>>>>>>>>>>>>> If not, I will try to derive it.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks again
>>>>>>>>>>>>>
>>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On 8 Oct 2020 Thu at 15:39 David Duarte <nh...@gm...>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> That is correct. The rates in EUR are negative.
>>>>>>>>>>>>>> Notice the discount factors are above 1
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, 8 Oct 2020, 13:10 isilay erol, <ero...@gm...>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Dear David,
>>>>>>>>>>>>>>> I'm working on Anaconda Python,
>>>>>>>>>>>>>>> Thank you for your help,
>>>>>>>>>>>>>>> When I ran your query,
>>>>>>>>>>>>>>> I got negative fwd rates and negative fwd cash flows, am I
>>>>>>>>>>>>>>> missing something?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> You can see my results in the following:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>>>> '10-02-2020',
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>>>> '09-11-2020',
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>>>> 1.001941, 1.002146,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1.002355, 1.002534,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>>>> 1.004146, 1.004549,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1.003148, 0.999840]
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> -0.0019082224391586688
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>>>> ql.Date(15,6,2021),
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule,
>>>>>>>>>>>>>>> ql.Euribor6M(yts),
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> June 15th, 2020 -0.00190201607110241
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> December 15th, 2020 -0.001253382120767248
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> June 15th, 2021 -0.00039680612008295636
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On 8 Oct 2020 Thu at 12:21 David Duarte <nh...@gm...>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Are you using c++, python or excel?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Since you already have a yield curve, you can build the
>>>>>>>>>>>>>>>> object by inputting spot rates (ZeroCurve class) or discount factors
>>>>>>>>>>>>>>>> (DiscountCurve).
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Here is an example using python:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>>>>> '10-02-2020', '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>>>>> '09-11-2020', '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>>>>> 1.001941, 1.002146, 1.002355, 1.002534,
>>>>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>>>>> 1.004146, 1.004549, 1.003148, 0.999840]
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> To get the forward rates, you can use the "forwardRate"
>>>>>>>>>>>>>>>> method from the curve:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd,
>>>>>>>>>>>>>>>> dayCounter, ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> or build the floating rate bond object and inspect the rate
>>>>>>>>>>>>>>>> on the cashflows:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>>>>> ql.Date(15,6,2021), ql.Period('6m'))
>>>>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule,
>>>>>>>>>>>>>>>> ql.Euribor6M(yts), ql.Actual360())
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> for cf in map(ql.as_coupon, bond.cashflows()):
>>>>>>>>>>>>>>>> if cf:
>>>>>>>>>>>>>>>> print(cf.accrualStartDate().ISO(),
>>>>>>>>>>>>>>>> cf.accrualStartDate().ISO(), f"{cf.rate():.3%}")
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> or even get the rate from the index for given set of dates:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Thu, 8 Oct 2020 at 06:39, isilay erol <
>>>>>>>>>>>>>>>> ero...@gm...> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Dear Luigi,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I just met with quantlib.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I try to understand from the examples how cash flows of
>>>>>>>>>>>>>>>>> floating rate bonds are created.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> But in the examples, I always see that yield curves are
>>>>>>>>>>>>>>>>> established from scratch.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> I want to calculate forward rates and forward rate coupons
>>>>>>>>>>>>>>>>> with the yield curve which I already have.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> (I don't want to construct a yield curve from scratch
>>>>>>>>>>>>>>>>> again - I have a zero coupon yield curve)
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> And this way I want to create the cash flows of the
>>>>>>>>>>>>>>>>> floating bond. But I could not understand how I could do this.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Can you help me on this issue?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> 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
>>>>>>>>
>>>>>>>
|
|
From: David D. <nh...@gm...> - 2020-10-16 08:24:51
|
Hi Luigi,
All the Python SWIG tests ran successfully.
Ran 112 tests in 18.602s
OK
And the issue that was reported on the cloning of OvernightIndexes is
solved.
The following code now works in 1.20rc, but would through and error in
version 1.19 because the cloned overnightindex would not be accepted in
the OvernightIndexedSwap constructor
crv = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
yts = ql.YieldTermStructureHandle(crv)
index = ql.Eonia()
overnightIndex = index.clone(yts)
ois_swap = ql.MakeOIS(ql.Period('1Y'), overnightIndex, 0.01)
On Thu, 15 Oct 2020 at 17:45, David Duarte <nh...@gm...> wrote:
> Also, all good on Ubuntu Focal 64
>
> Running 838 test cases...
>
> Tests completed in 8 m 31 s
> *** No errors detected
>
> On Thu, 15 Oct 2020 at 14:26, Francois Botha <ig...@gm...> wrote:
>
>> All good on Windows 10 64b and Ubuntu Focal 64b.
>>
>> Tests completed in 10 m 31 s
>>
>>
>> Test module "Master Test Suite" has passed with:
>> 838 test cases out of 838 passed
>> 1002700 assertions out of 1002700 passed
>>
>> real 10m31.130s
>> user 0m0.000s
>> sys 0m0.062s
>>
>>
>> Francois Botha
>>
>>
>> On Wed, 14 Oct 2020 at 18:08, Luigi Ballabio <lui...@gm...>
>> wrote:
>>
>>> Hello everybody,
>>> release candidates for QuantLib 1.20 are available at <
>>> https://bintray.com/beta/#/quantlib/prerelease/QuantLib/1.20-RC?tab=files>.
>>> If you have some spare cycles, please kick their tires and let me know if
>>> there are any problems.
>>>
>>> Thanks,
>>> Luigi
>>>
>>>
>>> _______________________________________________
>>> 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: David D. <nh...@gm...> - 2020-10-15 16:46:06
|
Also, all good on Ubuntu Focal 64 Running 838 test cases... Tests completed in 8 m 31 s *** No errors detected On Thu, 15 Oct 2020 at 14:26, Francois Botha <ig...@gm...> wrote: > All good on Windows 10 64b and Ubuntu Focal 64b. > > Tests completed in 10 m 31 s > > > Test module "Master Test Suite" has passed with: > 838 test cases out of 838 passed > 1002700 assertions out of 1002700 passed > > real 10m31.130s > user 0m0.000s > sys 0m0.062s > > > Francois Botha > > > On Wed, 14 Oct 2020 at 18:08, Luigi Ballabio <lui...@gm...> > wrote: > >> Hello everybody, >> release candidates for QuantLib 1.20 are available at < >> https://bintray.com/beta/#/quantlib/prerelease/QuantLib/1.20-RC?tab=files>. >> If you have some spare cycles, please kick their tires and let me know if >> there are any problems. >> >> Thanks, >> Luigi >> >> >> _______________________________________________ >> 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: Francois B. <ig...@gm...> - 2020-10-15 13:24:30
|
All good on Windows 10 64b and Ubuntu Focal 64b. Tests completed in 10 m 31 s Test module "Master Test Suite" has passed with: 838 test cases out of 838 passed 1002700 assertions out of 1002700 passed real 10m31.130s user 0m0.000s sys 0m0.062s Francois Botha On Wed, 14 Oct 2020 at 18:08, Luigi Ballabio <lui...@gm...> wrote: > Hello everybody, > release candidates for QuantLib 1.20 are available at < > https://bintray.com/beta/#/quantlib/prerelease/QuantLib/1.20-RC?tab=files>. > If you have some spare cycles, please kick their tires and let me know if > there are any problems. > > Thanks, > Luigi > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |
|
From: isilay e. <ero...@gm...> - 2020-10-15 13:06:38
|
I have one more question
After connecting the index to the zero curve, when calculating the fwd
curve, I see that query divides the fwd curve by “2”.
While calculating the fwd rate, the difference between two consecutive
dates in the bond's forward cash flows is taken into account.
Dividing the calculated fwd ratio by two again will cause decrease the
ratio again.
( I guess It should not divide it again), what am I missing?
On 15 Oct 2020 Thu at 11:33 isilay erol <ero...@gm...> wrote:
>
> Thanks for your warning David, after that
> I will post my questions in a relevant email,
> And thanks for your help
>
> Regards
>
> On 12 Oct 2020 Mon at 17:20 isilay erol <ero...@gm...> wrote:
>
>> Dear David I get it now, thank you
>>
>> Well then, if I revise my question as follows;
>>
>> Without linking to Euribor or libor index, if I load the zero yield
>> curves of these indexes into python with their tenors
>>
>> What if I create forward cash flows by obtaining forward rates for
>> floatİng products from these zero coupon curves?
>>
>> David, you had a suggestion for me, but I didn't quite understand this
>> solution.
>>
>> Thanks for your help and answers,
>>
>>
>> On 12 Oct 2020 Mon at 16:24 David Duarte <nh...@gm...> wrote:
>>
>>> Hi,
>>>
>>> You seem to be misinterpreting what this line does:
>>>
>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>
>>> It does create that named index and you check that like this for
>>> example: ql.IndexManager.instance().histories()
>>>
>>> But it is not a method/attribute/class of QuantLib so you should use it
>>> as:
>>>
>>> index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
>>>
>>>
>>>
>>>
>>>
>>> On Mon, 12 Oct 2020 at 14:15, isilay erol <ero...@gm...> wrote:
>>>
>>>> hello, if I wanted to create an index from my own zero curve for TL and
>>>> I wanted to link it in floating bon, I got an error like this.
>>>>
>>>>
>>>>
>>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>>
>>>>
>>>>
>>>> Error message:
>>>>
>>>> “AttributeError: module 'QuantLib' has no attribute 'MyIndex6M'
>>>>
>>>>
>>>>
>>>> import QuantLib as ql
>>>>
>>>> from pandas import DataFrame
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> dates = [
>>>>
>>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017',
>>>> '29.09.2017', '30.12.2017',
>>>>
>>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>>
>>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025',
>>>> '30.12.2026']
>>>>
>>>>
>>>>
>>>> zeros = [
>>>>
>>>> 0.000000,0.0693795966991162,
>>>> 0.0759095626003495,0.0841499536866119, 0.0904620831158592,
>>>> 0.0951565316374134, 0.103938304795234,
>>>>
>>>> 0.106710404148259, 0.107861984374564,
>>>>
>>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>>
>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>
>>>> dayCounter = ql.Actual360()
>>>>
>>>>
>>>>
>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>
>>>>
>>>>
>>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>>
>>>>
>>>>
>>>> print(ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360()))
>>>>
>>>>
>>>>
>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>
>>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>>
>>>> ql.Period('6m'))
>>>>
>>>> index=ql.MyIndex6M(yts)
>>>>
>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>>
>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.MyIndex(yts),
>>>>
>>>> ql.Actual360())
>>>>
>>>> On 9 Oct 2020 Fri at 15:28 isilay erol <ero...@gm...> wrote:
>>>>
>>>>> Dear David,
>>>>>
>>>>>
>>>>>
>>>>> First of all, thank you for your detailed answer.
>>>>>
>>>>>
>>>>>
>>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True) query worked
>>>>>
>>>>> But I couldn’t solve my other problem.
>>>>>
>>>>> I may not be able to express myself or understand your example.
>>>>>
>>>>> I will explain below what I did step by step;
>>>>>
>>>>> · firstly, I put dates and rates on Anaconda python (this
>>>>> zero yield curve)
>>>>>
>>>>> · Secondly, I determined evaluation date, I changed the date
>>>>> format.
>>>>>
>>>>> · Then it was created as a zero coupon curve "zCurve".
>>>>>
>>>>> · After this stage, building the floating rate bond object
>>>>> and inspect the rate on the cashflows;
>>>>>
>>>>> · There is no problem with the following two lines;
>>>>>
>>>>> § yts = ql.YieldTermStructureHandle (zCurve)
>>>>>
>>>>> § schedule = ql.MakeSchedule (ql.Date (15,6,2020), ql.Date
>>>>> (15,6,2021), ql.Period ('6m'))
>>>>>
>>>>>
>>>>>
>>>>> but when I delete “ql.Euribor6M (yts)“in the index section and replace
>>>>> it with yts.linkTo (zCurve), the error message is occured
>>>>>
>>>>> Briefly, I want to make the index statement independent from Euribor
>>>>> or Libor and tie it to my zero coupon yield curve.
>>>>>
>>>>>
>>>>>
>>>>> Also in the next step, my goal is to remove the following
>>>>> "ql.Euribor6M (yts)" statement and not to use it in the same way in the
>>>>> query (I think this will be fixed automatically if I can fulfill my request
>>>>> above.)
>>>>>
>>>>> bond = ql.FloatingRateBond (2,100, program, ql.Euribor6M (yts),
>>>>>
>>>>> ql.Actual360 ())
>>>>>
>>>>>
>>>>>
>>>>> As a result, what should I substitute for ql.Euribor6M (yts) in the
>>>>> query below?
>>>>>
>>>>>
>>>>>
>>>>> Thank you very much,
>>>>>
>>>>>
>>>>>
>>>>> import QuantLib as ql
>>>>>
>>>>> from pandas import DataFrame
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> dates = [
>>>>>
>>>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017',
>>>>> '29.09.2017', '30.12.2017',
>>>>>
>>>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>>>
>>>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025',
>>>>> '30.12.2026']
>>>>>
>>>>>
>>>>>
>>>>> zeros = [
>>>>>
>>>>> 0.000000,0.0693795966991162,
>>>>> 0.0759095626003495,0.0841499536866119, 0.0904620831158592,
>>>>> 0.0951565316374134, 0.103938304795234,
>>>>>
>>>>> 0.106710404148259, 0.107861984374564,
>>>>>
>>>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>>>
>>>>>
>>>>>
>>>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>>>
>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>
>>>>> dayCounter = ql.Actual360()
>>>>>
>>>>>
>>>>>
>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>
>>>>>
>>>>>
>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>
>>>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>>>
>>>>> ql.Period('6m'))
>>>>>
>>>>> index = ql.Euribor6M(yts)
>>>>>
>>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>>>
>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>
>>>>> ql.Actual360())
>>>>>
>>>>>
>>>>>
>>>>> dates = [ c.date() for c in bond.cashflows() ]
>>>>>
>>>>> cfs = [ c.amount() for c in bond.cashflows() ]
>>>>>
>>>>> DataFrame(list(zip(dates, cfs)),
>>>>>
>>>>> columns = ('date','amount'),
>>>>>
>>>>> index = range(1,len(dates)+1))
>>>>>
>>>>> On 9 Oct 2020 Fri at 11:19 David Duarte <nh...@gm...> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> You can either clear the fixings or use the optional boolean third
>>>>>> parameter on the addFixing method to explicitly overwrite the existing
>>>>>> value:
>>>>>>
>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003, True)
>>>>>>
>>>>>>
>>>>>> On the other question, the parameter for the index is a
>>>>>> YieldTermStructureHandle and you can create one and then link to whichever
>>>>>> curve you wish to use.
>>>>>> Maybe this simple example will help you understand:
>>>>>>
>>>>>> yts = ql.RelinkableYieldTermStructureHandle()
>>>>>> index = ql.Euribor6M(yts)
>>>>>>
>>>>>> crv1 = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
>>>>>> yts.linkTo(crv1)
>>>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>>>
>>>>>> crv2 = ql.FlatForward(2, ql.TARGET(), 0.02, ql.Actual360())
>>>>>> yts.linkTo(crv2)
>>>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, 9 Oct 2020 at 08:38, isilay erol <ero...@gm...>
>>>>>> wrote:
>>>>>>
>>>>>>> As you said "index.clearFixings ()" command worked. Thank you very
>>>>>>> much.
>>>>>>>
>>>>>>> Well, there is one more basic point that I cannot understand. How
>>>>>>> can I link the index directly to my index curve?
>>>>>>>
>>>>>>> In all the examples I saw on the internet like in the following ones,
>>>>>>>
>>>>>>> "index = ql.Euribor6M ()"
>>>>>>>
>>>>>>> "index = ql.Euribor3M ()"
>>>>>>>
>>>>>>> or I saw the Libor version of this.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Actually, my zero coupon should be an index curve, right?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> In my query how can I create the bridge between my index and index
>>>>>>> curve zCurve?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> (the part I would like to change: index = ql.Euribor6M(yts))
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thank you very much for your help,
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> import QuantLib as ql
>>>>>>>
>>>>>>> from pandas import DataFrame
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> dates = [
>>>>>>>
>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>> '10-02-2020',
>>>>>>>
>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>
>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>> '09-11-2020',
>>>>>>>
>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> zeros = [
>>>>>>>
>>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>>> 0.002146,
>>>>>>>
>>>>>>> 0.002355, 0.002534,
>>>>>>>
>>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>>> 0.004549,
>>>>>>>
>>>>>>> 0.003148, 0.004040]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>
>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>
>>>>>>> dayCounter = ql.Actual360()
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> #To get the forward rates, you can use the "forwardRate" method from
>>>>>>> the curve:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>
>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>
>>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>
>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>
>>>>>>> print(fwd)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> #or build the floating rate bond object and inspect the rate on the
>>>>>>> cashflows:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>>
>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>
>>>>>>> ql.Period('6m'))
>>>>>>>
>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>
>>>>>>> index.clearFixings()
>>>>>>>
>>>>>>> index.addFixing(ql.Date(6,ql.August,2014), 0.05)
>>>>>>>
>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>
>>>>>>> ql.Actual360())
>>>>>>>
>>>>>>>
>>>>>>> On 9 Oct 2020 Fri at 10:11 Francois Botha <ig...@gm...> wrote:
>>>>>>>
>>>>>>>> So the error message states that you have already added the fixing.
>>>>>>>>
>>>>>>>> I'm unsure whether the Python interface for index.addFixing
>>>>>>>> provides a parameter to optionally overwrite any existing indices. If so,
>>>>>>>> try that. Alternatively, there should be something like
>>>>>>>> index.clearFixings() which you can call first before adding new fixings.
>>>>>>>>
>>>>>>>> regards
>>>>>>>>
>>>>>>>> Francois Botha
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, 9 Oct 2020 at 08:58, isilay erol <ero...@gm...>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hello again,
>>>>>>>>>
>>>>>>>>> I want to ask one more question;
>>>>>>>>>
>>>>>>>>> I want set a past fixing for the current latest coupon (which,
>>>>>>>>> having fixed in the past, can’t be forecast).
>>>>>>>>>
>>>>>>>>> The forecasting of floating bond cashflow should be start generate
>>>>>>>>> from this latest repring coupon rate.
>>>>>>>>>
>>>>>>>>> That’s why I heve added the following querry only to see what will
>>>>>>>>> happen;
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> “index.addFixing(ql.Date(6,ql.March,2019), 0.003)”
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Bu I have the folowing error message;
>>>>>>>>>
>>>>>>>>> Am I thinking wrongly?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> import QuantLib as ql
>>>>>>>>>
>>>>>>>>> from pandas import DataFrame
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> dates = [
>>>>>>>>>
>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>> '10-02-2020',
>>>>>>>>>
>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>
>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>> '09-11-2020',
>>>>>>>>>
>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> zeros = [
>>>>>>>>>
>>>>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>>>>> 0.002146,
>>>>>>>>>
>>>>>>>>> 0.002355, 0.002534,
>>>>>>>>>
>>>>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>>>>> 0.004549,
>>>>>>>>>
>>>>>>>>> 0.003148, 0.004040]
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>
>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>
>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(),
>>>>>>>>> ql.TARGET())
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>
>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>
>>>>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>
>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>
>>>>>>>>> print(fwd)
>>>>>>>>>
>>>>>>>>> 0.005623856615195155
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>>>>
>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>>>
>>>>>>>>> ql.Period('6m'))
>>>>>>>>>
>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>
>>>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>>>
>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>
>>>>>>>>> ql.Actual360())
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "<ipython-input-61-ec28b13dc284>", line 5, in <module>
>>>>>>>>>
>>>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line
>>>>>>>>> 5475, in addFixing
>>>>>>>>>
>>>>>>>>> return _QuantLib.Index_addFixing(self, fixingDate, fixing,
>>>>>>>>> forceOverwrite)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> RuntimeError: At least one duplicated fixing provided: March 6th,
>>>>>>>>> 2019, 0.003 while 0.002 value is already present
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Best regards,
>>>>>>>>>
>>>>>>>>> On 8 Oct 2020 Thu at 17:20 isilay erol <ero...@gm...>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Thank you very much Luigi an David.
>>>>>>>>>>
>>>>>>>>>> On 8 Oct 2020 Thu at 16:32 Luigi Ballabio <
>>>>>>>>>> lui...@gm...> wrote:
>>>>>>>>>>
>>>>>>>>>>> If you use ql.ZeroCurve instead of ql.DiscountCurve you can
>>>>>>>>>>> input zero rates directly and get a curve that you can use in the exact
>>>>>>>>>>> same way.
>>>>>>>>>>>
>>>>>>>>>>> Luigi
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Oct 8, 2020 at 3:13 PM isilay erol <
>>>>>>>>>>> ero...@gm...> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Dear David,
>>>>>>>>>>>>
>>>>>>>>>>>> You are right, the discount factors are increasing,
>>>>>>>>>>>>
>>>>>>>>>>>> this indicates that the curve is negative.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Your sample helped me a lot, thank you very much.
>>>>>>>>>>>>
>>>>>>>>>>>> I need to make my calculation from the zero coupon yield curve
>>>>>>>>>>>> itself,
>>>>>>>>>>>>
>>>>>>>>>>>> not the discount factor. At this point,
>>>>>>>>>>>>
>>>>>>>>>>>> I will try to move forward using the formula of the discount
>>>>>>>>>>>> factor calculation from zero coupon.
>>>>>>>>>>>>
>>>>>>>>>>>> If you already have a Python example of this conversion, I
>>>>>>>>>>>> would be very happy if you could share it with me.
>>>>>>>>>>>>
>>>>>>>>>>>> If not, I will try to derive it.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks again
>>>>>>>>>>>>
>>>>>>>>>>>> Best regards,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On 8 Oct 2020 Thu at 15:39 David Duarte <nh...@gm...>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> That is correct. The rates in EUR are negative.
>>>>>>>>>>>>> Notice the discount factors are above 1
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, 8 Oct 2020, 13:10 isilay erol, <ero...@gm...>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Dear David,
>>>>>>>>>>>>>> I'm working on Anaconda Python,
>>>>>>>>>>>>>> Thank you for your help,
>>>>>>>>>>>>>> When I ran your query,
>>>>>>>>>>>>>> I got negative fwd rates and negative fwd cash flows, am I
>>>>>>>>>>>>>> missing something?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You can see my results in the following:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>>> '10-02-2020',
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>>> '09-11-2020',
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>>> 1.001941, 1.002146,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1.002355, 1.002534,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>>> 1.004146, 1.004549,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1.003148, 0.999840]
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> -0.0019082224391586688
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>>> ql.Date(15,6,2021),
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> June 15th, 2020 -0.00190201607110241
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> December 15th, 2020 -0.001253382120767248
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> June 15th, 2021 -0.00039680612008295636
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On 8 Oct 2020 Thu at 12:21 David Duarte <nh...@gm...>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Are you using c++, python or excel?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Since you already have a yield curve, you can build the
>>>>>>>>>>>>>>> object by inputting spot rates (ZeroCurve class) or discount factors
>>>>>>>>>>>>>>> (DiscountCurve).
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Here is an example using python:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>>>> '10-02-2020', '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>>>> '09-11-2020', '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>>>> 1.001941, 1.002146, 1.002355, 1.002534,
>>>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>>>> 1.004146, 1.004549, 1.003148, 0.999840]
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> To get the forward rates, you can use the "forwardRate"
>>>>>>>>>>>>>>> method from the curve:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd,
>>>>>>>>>>>>>>> dayCounter, ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> or build the floating rate bond object and inspect the rate
>>>>>>>>>>>>>>> on the cashflows:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>>>> ql.Date(15,6,2021), ql.Period('6m'))
>>>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule,
>>>>>>>>>>>>>>> ql.Euribor6M(yts), ql.Actual360())
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> for cf in map(ql.as_coupon, bond.cashflows()):
>>>>>>>>>>>>>>> if cf:
>>>>>>>>>>>>>>> print(cf.accrualStartDate().ISO(),
>>>>>>>>>>>>>>> cf.accrualStartDate().ISO(), f"{cf.rate():.3%}")
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> or even get the rate from the index for given set of dates:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Thu, 8 Oct 2020 at 06:39, isilay erol <
>>>>>>>>>>>>>>> ero...@gm...> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Dear Luigi,
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I just met with quantlib.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I try to understand from the examples how cash flows of
>>>>>>>>>>>>>>>> floating rate bonds are created.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> But in the examples, I always see that yield curves are
>>>>>>>>>>>>>>>> established from scratch.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I want to calculate forward rates and forward rate coupons
>>>>>>>>>>>>>>>> with the yield curve which I already have.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> (I don't want to construct a yield curve from scratch again
>>>>>>>>>>>>>>>> - I have a zero coupon yield curve)
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> And this way I want to create the cash flows of the
>>>>>>>>>>>>>>>> floating bond. But I could not understand how I could do this.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Can you help me on this issue?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> 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
>>>>>>>
>>>>>>
|
|
From: isilay e. <ero...@gm...> - 2020-10-15 08:33:43
|
Thanks for your warning David, after that
I will post my questions in a relevant email,
And thanks for your help
Regards
On 12 Oct 2020 Mon at 17:20 isilay erol <ero...@gm...> wrote:
> Dear David I get it now, thank you
>
> Well then, if I revise my question as follows;
>
> Without linking to Euribor or libor index, if I load the zero yield curves
> of these indexes into python with their tenors
>
> What if I create forward cash flows by obtaining forward rates for
> floatİng products from these zero coupon curves?
>
> David, you had a suggestion for me, but I didn't quite understand this
> solution.
>
> Thanks for your help and answers,
>
>
> On 12 Oct 2020 Mon at 16:24 David Duarte <nh...@gm...> wrote:
>
>> Hi,
>>
>> You seem to be misinterpreting what this line does:
>>
>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>
>> It does create that named index and you check that like this for
>> example: ql.IndexManager.instance().histories()
>>
>> But it is not a method/attribute/class of QuantLib so you should use it
>> as:
>>
>> index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
>>
>>
>>
>>
>>
>> On Mon, 12 Oct 2020 at 14:15, isilay erol <ero...@gm...> wrote:
>>
>>> hello, if I wanted to create an index from my own zero curve for TL and
>>> I wanted to link it in floating bon, I got an error like this.
>>>
>>>
>>>
>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>
>>>
>>>
>>> Error message:
>>>
>>> “AttributeError: module 'QuantLib' has no attribute 'MyIndex6M'
>>>
>>>
>>>
>>> import QuantLib as ql
>>>
>>> from pandas import DataFrame
>>>
>>>
>>>
>>>
>>>
>>> dates = [
>>>
>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
>>> '30.12.2017',
>>>
>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>
>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
>>>
>>>
>>>
>>> zeros = [
>>>
>>> 0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
>>> 0.0904620831158592, 0.0951565316374134, 0.103938304795234,
>>>
>>> 0.106710404148259, 0.107861984374564,
>>>
>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>
>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>
>>> dayCounter = ql.Actual360()
>>>
>>>
>>>
>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>
>>>
>>>
>>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>>
>>>
>>>
>>> print(ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360()))
>>>
>>>
>>>
>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>
>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>
>>> ql.Period('6m'))
>>>
>>> index=ql.MyIndex6M(yts)
>>>
>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>
>>> bond = ql.FloatingRateBond(2,100, schedule, ql.MyIndex(yts),
>>>
>>> ql.Actual360())
>>>
>>> On 9 Oct 2020 Fri at 15:28 isilay erol <ero...@gm...> wrote:
>>>
>>>> Dear David,
>>>>
>>>>
>>>>
>>>> First of all, thank you for your detailed answer.
>>>>
>>>>
>>>>
>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True) query worked
>>>>
>>>> But I couldn’t solve my other problem.
>>>>
>>>> I may not be able to express myself or understand your example.
>>>>
>>>> I will explain below what I did step by step;
>>>>
>>>> · firstly, I put dates and rates on Anaconda python (this zero
>>>> yield curve)
>>>>
>>>> · Secondly, I determined evaluation date, I changed the date
>>>> format.
>>>>
>>>> · Then it was created as a zero coupon curve "zCurve".
>>>>
>>>> · After this stage, building the floating rate bond object and
>>>> inspect the rate on the cashflows;
>>>>
>>>> · There is no problem with the following two lines;
>>>>
>>>> § yts = ql.YieldTermStructureHandle (zCurve)
>>>>
>>>> § schedule = ql.MakeSchedule (ql.Date (15,6,2020), ql.Date
>>>> (15,6,2021), ql.Period ('6m'))
>>>>
>>>>
>>>>
>>>> but when I delete “ql.Euribor6M (yts)“in the index section and replace
>>>> it with yts.linkTo (zCurve), the error message is occured
>>>>
>>>> Briefly, I want to make the index statement independent from Euribor
>>>> or Libor and tie it to my zero coupon yield curve.
>>>>
>>>>
>>>>
>>>> Also in the next step, my goal is to remove the following "ql.Euribor6M
>>>> (yts)" statement and not to use it in the same way in the query (I think
>>>> this will be fixed automatically if I can fulfill my request above.)
>>>>
>>>> bond = ql.FloatingRateBond (2,100, program, ql.Euribor6M (yts),
>>>>
>>>> ql.Actual360 ())
>>>>
>>>>
>>>>
>>>> As a result, what should I substitute for ql.Euribor6M (yts) in the
>>>> query below?
>>>>
>>>>
>>>>
>>>> Thank you very much,
>>>>
>>>>
>>>>
>>>> import QuantLib as ql
>>>>
>>>> from pandas import DataFrame
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> dates = [
>>>>
>>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017',
>>>> '29.09.2017', '30.12.2017',
>>>>
>>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>>
>>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025',
>>>> '30.12.2026']
>>>>
>>>>
>>>>
>>>> zeros = [
>>>>
>>>> 0.000000,0.0693795966991162,
>>>> 0.0759095626003495,0.0841499536866119, 0.0904620831158592,
>>>> 0.0951565316374134, 0.103938304795234,
>>>>
>>>> 0.106710404148259, 0.107861984374564,
>>>>
>>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>>
>>>>
>>>>
>>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>>
>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>
>>>> dayCounter = ql.Actual360()
>>>>
>>>>
>>>>
>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>
>>>>
>>>>
>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>
>>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>>
>>>> ql.Period('6m'))
>>>>
>>>> index = ql.Euribor6M(yts)
>>>>
>>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>>
>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>
>>>> ql.Actual360())
>>>>
>>>>
>>>>
>>>> dates = [ c.date() for c in bond.cashflows() ]
>>>>
>>>> cfs = [ c.amount() for c in bond.cashflows() ]
>>>>
>>>> DataFrame(list(zip(dates, cfs)),
>>>>
>>>> columns = ('date','amount'),
>>>>
>>>> index = range(1,len(dates)+1))
>>>>
>>>> On 9 Oct 2020 Fri at 11:19 David Duarte <nh...@gm...> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> You can either clear the fixings or use the optional boolean third
>>>>> parameter on the addFixing method to explicitly overwrite the existing
>>>>> value:
>>>>>
>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003, True)
>>>>>
>>>>>
>>>>> On the other question, the parameter for the index is a
>>>>> YieldTermStructureHandle and you can create one and then link to whichever
>>>>> curve you wish to use.
>>>>> Maybe this simple example will help you understand:
>>>>>
>>>>> yts = ql.RelinkableYieldTermStructureHandle()
>>>>> index = ql.Euribor6M(yts)
>>>>>
>>>>> crv1 = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
>>>>> yts.linkTo(crv1)
>>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>>
>>>>> crv2 = ql.FlatForward(2, ql.TARGET(), 0.02, ql.Actual360())
>>>>> yts.linkTo(crv2)
>>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Fri, 9 Oct 2020 at 08:38, isilay erol <ero...@gm...>
>>>>> wrote:
>>>>>
>>>>>> As you said "index.clearFixings ()" command worked. Thank you very
>>>>>> much.
>>>>>>
>>>>>> Well, there is one more basic point that I cannot understand. How can
>>>>>> I link the index directly to my index curve?
>>>>>>
>>>>>> In all the examples I saw on the internet like in the following ones,
>>>>>>
>>>>>> "index = ql.Euribor6M ()"
>>>>>>
>>>>>> "index = ql.Euribor3M ()"
>>>>>>
>>>>>> or I saw the Libor version of this.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Actually, my zero coupon should be an index curve, right?
>>>>>>
>>>>>>
>>>>>>
>>>>>> In my query how can I create the bridge between my index and index
>>>>>> curve zCurve?
>>>>>>
>>>>>>
>>>>>>
>>>>>> (the part I would like to change: index = ql.Euribor6M(yts))
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank you very much for your help,
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> import QuantLib as ql
>>>>>>
>>>>>> from pandas import DataFrame
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> dates = [
>>>>>>
>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>> '10-02-2020',
>>>>>>
>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>
>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>> '09-11-2020',
>>>>>>
>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>
>>>>>>
>>>>>>
>>>>>> zeros = [
>>>>>>
>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>> 0.002146,
>>>>>>
>>>>>> 0.002355, 0.002534,
>>>>>>
>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>> 0.004549,
>>>>>>
>>>>>> 0.003148, 0.004040]
>>>>>>
>>>>>>
>>>>>>
>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>
>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>
>>>>>> dayCounter = ql.Actual360()
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> #To get the forward rates, you can use the "forwardRate" method from
>>>>>> the curve:
>>>>>>
>>>>>>
>>>>>>
>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>
>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>
>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>
>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>
>>>>>> print(fwd)
>>>>>>
>>>>>>
>>>>>>
>>>>>> #or build the floating rate bond object and inspect the rate on the
>>>>>> cashflows:
>>>>>>
>>>>>>
>>>>>>
>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>
>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>
>>>>>> ql.Period('6m'))
>>>>>>
>>>>>> index = ql.Euribor6M(yts)
>>>>>>
>>>>>> index.clearFixings()
>>>>>>
>>>>>> index.addFixing(ql.Date(6,ql.August,2014), 0.05)
>>>>>>
>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>
>>>>>> ql.Actual360())
>>>>>>
>>>>>>
>>>>>> On 9 Oct 2020 Fri at 10:11 Francois Botha <ig...@gm...> wrote:
>>>>>>
>>>>>>> So the error message states that you have already added the fixing.
>>>>>>>
>>>>>>> I'm unsure whether the Python interface for index.addFixing provides
>>>>>>> a parameter to optionally overwrite any existing indices. If so, try that.
>>>>>>> Alternatively, there should be something like index.clearFixings() which
>>>>>>> you can call first before adding new fixings.
>>>>>>>
>>>>>>> regards
>>>>>>>
>>>>>>> Francois Botha
>>>>>>>
>>>>>>>
>>>>>>> On Fri, 9 Oct 2020 at 08:58, isilay erol <ero...@gm...>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hello again,
>>>>>>>>
>>>>>>>> I want to ask one more question;
>>>>>>>>
>>>>>>>> I want set a past fixing for the current latest coupon (which,
>>>>>>>> having fixed in the past, can’t be forecast).
>>>>>>>>
>>>>>>>> The forecasting of floating bond cashflow should be start generate
>>>>>>>> from this latest repring coupon rate.
>>>>>>>>
>>>>>>>> That’s why I heve added the following querry only to see what will
>>>>>>>> happen;
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> “index.addFixing(ql.Date(6,ql.March,2019), 0.003)”
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Bu I have the folowing error message;
>>>>>>>>
>>>>>>>> Am I thinking wrongly?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> import QuantLib as ql
>>>>>>>>
>>>>>>>> from pandas import DataFrame
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> dates = [
>>>>>>>>
>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>> '10-02-2020',
>>>>>>>>
>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>
>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>> '09-11-2020',
>>>>>>>>
>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> zeros = [
>>>>>>>>
>>>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>>>> 0.002146,
>>>>>>>>
>>>>>>>> 0.002355, 0.002534,
>>>>>>>>
>>>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>>>> 0.004549,
>>>>>>>>
>>>>>>>> 0.003148, 0.004040]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>
>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>
>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(),
>>>>>>>> ql.TARGET())
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>
>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>
>>>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>
>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>
>>>>>>>> print(fwd)
>>>>>>>>
>>>>>>>> 0.005623856615195155
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>>>
>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>>
>>>>>>>> ql.Period('6m'))
>>>>>>>>
>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>
>>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>>
>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>
>>>>>>>> ql.Actual360())
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Traceback (most recent call last):
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> File "<ipython-input-61-ec28b13dc284>", line 5, in <module>
>>>>>>>>
>>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> File "C:\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line
>>>>>>>> 5475, in addFixing
>>>>>>>>
>>>>>>>> return _QuantLib.Index_addFixing(self, fixingDate, fixing,
>>>>>>>> forceOverwrite)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> RuntimeError: At least one duplicated fixing provided: March 6th,
>>>>>>>> 2019, 0.003 while 0.002 value is already present
>>>>>>>>
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>>
>>>>>>>> On 8 Oct 2020 Thu at 17:20 isilay erol <ero...@gm...>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Thank you very much Luigi an David.
>>>>>>>>>
>>>>>>>>> On 8 Oct 2020 Thu at 16:32 Luigi Ballabio <
>>>>>>>>> lui...@gm...> wrote:
>>>>>>>>>
>>>>>>>>>> If you use ql.ZeroCurve instead of ql.DiscountCurve you can input
>>>>>>>>>> zero rates directly and get a curve that you can use in the exact same way.
>>>>>>>>>>
>>>>>>>>>> Luigi
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, Oct 8, 2020 at 3:13 PM isilay erol <ero...@gm...>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> Dear David,
>>>>>>>>>>>
>>>>>>>>>>> You are right, the discount factors are increasing,
>>>>>>>>>>>
>>>>>>>>>>> this indicates that the curve is negative.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Your sample helped me a lot, thank you very much.
>>>>>>>>>>>
>>>>>>>>>>> I need to make my calculation from the zero coupon yield curve
>>>>>>>>>>> itself,
>>>>>>>>>>>
>>>>>>>>>>> not the discount factor. At this point,
>>>>>>>>>>>
>>>>>>>>>>> I will try to move forward using the formula of the discount
>>>>>>>>>>> factor calculation from zero coupon.
>>>>>>>>>>>
>>>>>>>>>>> If you already have a Python example of this conversion, I would
>>>>>>>>>>> be very happy if you could share it with me.
>>>>>>>>>>>
>>>>>>>>>>> If not, I will try to derive it.
>>>>>>>>>>>
>>>>>>>>>>> Thanks again
>>>>>>>>>>>
>>>>>>>>>>> Best regards,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On 8 Oct 2020 Thu at 15:39 David Duarte <nh...@gm...>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> That is correct. The rates in EUR are negative.
>>>>>>>>>>>> Notice the discount factors are above 1
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, 8 Oct 2020, 13:10 isilay erol, <ero...@gm...>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Dear David,
>>>>>>>>>>>>> I'm working on Anaconda Python,
>>>>>>>>>>>>> Thank you for your help,
>>>>>>>>>>>>> When I ran your query,
>>>>>>>>>>>>> I got negative fwd rates and negative fwd cash flows, am I
>>>>>>>>>>>>> missing something?
>>>>>>>>>>>>>
>>>>>>>>>>>>> You can see my results in the following:
>>>>>>>>>>>>>
>>>>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>>>>
>>>>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>>
>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>> '10-02-2020',
>>>>>>>>>>>>>
>>>>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>>
>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>> '09-11-2020',
>>>>>>>>>>>>>
>>>>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>> 1.001941, 1.002146,
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1.002355, 1.002534,
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>> 1.004146, 1.004549,
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1.003148, 0.999840]
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>>
>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>>
>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>>
>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>>
>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>>>
>>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>>
>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>
>>>>>>>>>>>>> -0.0019082224391586688
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>>
>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>> ql.Date(15,6,2021),
>>>>>>>>>>>>>
>>>>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>>>>
>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>>
>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>>>>
>>>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>>
>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> June 15th, 2020 -0.00190201607110241
>>>>>>>>>>>>>
>>>>>>>>>>>>> December 15th, 2020 -0.001253382120767248
>>>>>>>>>>>>>
>>>>>>>>>>>>> June 15th, 2021 -0.00039680612008295636
>>>>>>>>>>>>>
>>>>>>>>>>>>> On 8 Oct 2020 Thu at 12:21 David Duarte <nh...@gm...>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Are you using c++, python or excel?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Since you already have a yield curve, you can build the
>>>>>>>>>>>>>> object by inputting spot rates (ZeroCurve class) or discount factors
>>>>>>>>>>>>>> (DiscountCurve).
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Here is an example using python:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>>> '10-02-2020', '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>>> '09-11-2020', '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>>> 1.001941, 1.002146, 1.002355, 1.002534,
>>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>>> 1.004146, 1.004549, 1.003148, 0.999840]
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> To get the forward rates, you can use the "forwardRate"
>>>>>>>>>>>>>> method from the curve:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> or build the floating rate bond object and inspect the rate
>>>>>>>>>>>>>> on the cashflows:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>>> ql.Date(15,6,2021), ql.Period('6m'))
>>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule,
>>>>>>>>>>>>>> ql.Euribor6M(yts), ql.Actual360())
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> for cf in map(ql.as_coupon, bond.cashflows()):
>>>>>>>>>>>>>> if cf:
>>>>>>>>>>>>>> print(cf.accrualStartDate().ISO(),
>>>>>>>>>>>>>> cf.accrualStartDate().ISO(), f"{cf.rate():.3%}")
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> or even get the rate from the index for given set of dates:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, 8 Oct 2020 at 06:39, isilay erol <
>>>>>>>>>>>>>> ero...@gm...> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Dear Luigi,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I just met with quantlib.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I try to understand from the examples how cash flows of
>>>>>>>>>>>>>>> floating rate bonds are created.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> But in the examples, I always see that yield curves are
>>>>>>>>>>>>>>> established from scratch.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I want to calculate forward rates and forward rate coupons
>>>>>>>>>>>>>>> with the yield curve which I already have.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> (I don't want to construct a yield curve from scratch again
>>>>>>>>>>>>>>> - I have a zero coupon yield curve)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> And this way I want to create the cash flows of the floating
>>>>>>>>>>>>>>> bond. But I could not understand how I could do this.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Can you help me on this issue?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 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
>>>>>>
>>>>>
|
|
From: David D. <nh...@gm...> - 2020-10-15 08:27:47
|
Hi Isilay,
You should keep your questions in this mailing list on the relevant subject
and shouldn't be asking this question under the subject "Release candidates
for QuantLib 1.20".
In any case, the problem is that you are asking for the bond cashflows on
past dates where you haven't provided an index fixing. The error message
actually identifies the problem.
You can either provide all the fixings and then you can query any cash
flows or query only the cashflows for future dates (you will have to
provide at least the fixing for the current period).
Example:
index.addFixing(ql.Date(26,6,2020), 0.05, True)
pd.DataFrame({
"date": [ c.date() for c in bond.cashflows() if c.date() > today],
"amount": [ c.amount() for c in bond.cashflows() if c.date() > today ]
})
On Thu, 15 Oct 2020 at 08:47, isilay erol <ero...@gm...> wrote:
> Dear all,
>
> I have a question about the last announced coupon rate for floating bond.
>
> When I run the following query, an error occurs like in the following.
>
> This error seems strange to me, because the requested date is too old.
>
> We expect that this bond should be repriced in June 2020, based on
> repricing every 6 months(semiannual).
>
> But the error is asking us for a date before the bond is issued. Can you
> help me?
>
> Thank you,
>
>
>
>
>
> RuntimeError: Missing MyIndex6M Actual/360 fixing for December 27th, 2018
>
>
>
> Query;
>
>
>
> import QuantLib as ql
>
>
>
>
>
> dates = [
>
> '30.12.2019', '30.12.2020',
>
> '30.12.2021', '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025']
>
> zeros = [
>
> 0.000000,
>
> 0.108326014217227, 0.10842920241869, 0.108326911551829,
> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>
>
>
> today = ql.Date(30,ql.September,2020)
>
> ql.Settings.instance().evaluationDate = today
>
> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>
> dayCounter = ql.Actual360()
>
> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>
> yts = ql.RelinkableYieldTermStructureHandle()
>
> yts.linkTo(zCurve)
>
>
>
> ##Then, I instantiate the index to be used. The bond has semiannual
> coupons, Also, I set a past fixing for the current
>
> ##coupon (which, having fixed in the past, can’t be forecast).
>
>
>
> index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
>
> index.addFixing(ql.Date(30,6,2020), 0.05, True)
>
>
>
> ##The bond was issued before the evaluation date and will run for 5 years
> with
>
> ##semiannual coupons.
>
>
>
> issueDate = ql.Date(30,ql.December,2018)
>
> maturityDate = ql.Date(30,ql.June,2023)
>
> schedule = ql.Schedule(issueDate, maturityDate,
>
> ql.Period(ql.Semiannual), ql.TARGET(),
>
> ql.Following, ql.Following,
>
> ql.DateGeneration.Backward, False)
>
> bond = ql.FloatingRateBond(settlementDays = 2,
>
> faceAmount = 100,
>
> schedule = schedule,
>
> index = index,
>
> paymentDayCounter = ql.Actual360())
>
>
>
> dates = [ c.date() for c in bond.cashflows() ]
>
> cfs = [ c.amount() for c in bond.cashflows() ]
>
> DataFrame(list(zip(dates, cfs)),
>
> columns = ('date','amount'),
>
> index = range(1,len(dates)+1))
>
>
> On 14 Oct 2020 Wed at 19:08 Luigi Ballabio <lui...@gm...>
> wrote:
>
>> Hello everybody,
>> release candidates for QuantLib 1.20 are available at <
>> https://bintray.com/beta/#/quantlib/prerelease/QuantLib/1.20-RC?tab=files>.
>> If you have some spare cycles, please kick their tires and let me know if
>> there are any problems.
>>
>> Thanks,
>> Luigi
>>
>>
>> _______________________________________________
>> 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: isilay e. <ero...@gm...> - 2020-10-15 07:45:26
|
Dear all,
I have a question about the last announced coupon rate for floating bond.
When I run the following query, an error occurs like in the following.
This error seems strange to me, because the requested date is too old.
We expect that this bond should be repriced in June 2020, based on
repricing every 6 months(semiannual).
But the error is asking us for a date before the bond is issued. Can you
help me?
Thank you,
RuntimeError: Missing MyIndex6M Actual/360 fixing for December 27th, 2018
Query;
import QuantLib as ql
dates = [
'30.12.2019', '30.12.2020',
'30.12.2021', '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025']
zeros = [
0.000000,
0.108326014217227, 0.10842920241869, 0.108326911551829,
0.108103450370549, 0.107821584741388, 0.107525270883584]
today = ql.Date(30,ql.September,2020)
ql.Settings.instance().evaluationDate = today
qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
dayCounter = ql.Actual360()
zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
yts = ql.RelinkableYieldTermStructureHandle()
yts.linkTo(zCurve)
##Then, I instantiate the index to be used. The bond has semiannual
coupons, Also, I set a past fixing for the current
##coupon (which, having fixed in the past, can’t be forecast).
index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
index.addFixing(ql.Date(30,6,2020), 0.05, True)
##The bond was issued before the evaluation date and will run for 5 years
with
##semiannual coupons.
issueDate = ql.Date(30,ql.December,2018)
maturityDate = ql.Date(30,ql.June,2023)
schedule = ql.Schedule(issueDate, maturityDate,
ql.Period(ql.Semiannual), ql.TARGET(),
ql.Following, ql.Following,
ql.DateGeneration.Backward, False)
bond = ql.FloatingRateBond(settlementDays = 2,
faceAmount = 100,
schedule = schedule,
index = index,
paymentDayCounter = ql.Actual360())
dates = [ c.date() for c in bond.cashflows() ]
cfs = [ c.amount() for c in bond.cashflows() ]
DataFrame(list(zip(dates, cfs)),
columns = ('date','amount'),
index = range(1,len(dates)+1))
On 14 Oct 2020 Wed at 19:08 Luigi Ballabio <lui...@gm...> wrote:
> Hello everybody,
> release candidates for QuantLib 1.20 are available at <
> https://bintray.com/beta/#/quantlib/prerelease/QuantLib/1.20-RC?tab=files>.
> If you have some spare cycles, please kick their tires and let me know if
> there are any problems.
>
> Thanks,
> Luigi
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|
|
From: Luigi B. <lui...@gm...> - 2020-10-14 16:05:12
|
Hello everybody,
release candidates for QuantLib 1.20 are available at <
https://bintray.com/beta/#/quantlib/prerelease/QuantLib/1.20-RC?tab=files>.
If you have some spare cycles, please kick their tires and let me know if
there are any problems.
Thanks,
Luigi
|
|
From: Amine I. <ami...@gm...> - 2020-10-12 14:25:03
|
Hi all, I am thinking of using the C++ library with OpenCL ( GPU hardware acceleration bindings) as I have some computation bottlenecks I would like to optimise. Wondering if anyone has successfully streamlined the CPP code using OpenCL? Thanks, Amine |
|
From: isilay e. <ero...@gm...> - 2020-10-12 14:20:34
|
Dear David I get it now, thank you
Well then, if I revise my question as follows;
Without linking to Euribor or libor index, if I load the zero yield curves
of these indexes into python with their tenors
What if I create forward cash flows by obtaining forward rates for floatİng
products from these zero coupon curves?
David, you had a suggestion for me, but I didn't quite understand this
solution.
Thanks for your help and answers,
On 12 Oct 2020 Mon at 16:24 David Duarte <nh...@gm...> wrote:
> Hi,
>
> You seem to be misinterpreting what this line does:
>
> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(), ql.TARGET(),
> ql.ModifiedFollowing, True, ql.Actual360())
>
> It does create that named index and you check that like this for example:
> ql.IndexManager.instance().histories()
>
> But it is not a method/attribute/class of QuantLib so you should use it as:
>
> index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
>
>
>
>
>
> On Mon, 12 Oct 2020 at 14:15, isilay erol <ero...@gm...> wrote:
>
>> hello, if I wanted to create an index from my own zero curve for TL and I
>> wanted to link it in floating bon, I got an error like this.
>>
>>
>>
>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>
>>
>>
>> Error message:
>>
>> “AttributeError: module 'QuantLib' has no attribute 'MyIndex6M'
>>
>>
>>
>> import QuantLib as ql
>>
>> from pandas import DataFrame
>>
>>
>>
>>
>>
>> dates = [
>>
>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
>> '30.12.2017',
>>
>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>
>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
>>
>>
>>
>> zeros = [
>>
>> 0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
>> 0.0904620831158592, 0.0951565316374134, 0.103938304795234,
>>
>> 0.106710404148259, 0.107861984374564,
>>
>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>
>>
>>
>>
>>
>>
>>
>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>
>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>
>> dayCounter = ql.Actual360()
>>
>>
>>
>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>
>>
>>
>> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360())
>>
>>
>>
>> print(ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
>> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360()))
>>
>>
>>
>> yts = ql.YieldTermStructureHandle(zCurve)
>>
>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>
>> ql.Period('6m'))
>>
>> index=ql.MyIndex6M(yts)
>>
>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>
>> bond = ql.FloatingRateBond(2,100, schedule, ql.MyIndex(yts),
>>
>> ql.Actual360())
>>
>> On 9 Oct 2020 Fri at 15:28 isilay erol <ero...@gm...> wrote:
>>
>>> Dear David,
>>>
>>>
>>>
>>> First of all, thank you for your detailed answer.
>>>
>>>
>>>
>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True) query worked
>>>
>>> But I couldn’t solve my other problem.
>>>
>>> I may not be able to express myself or understand your example.
>>>
>>> I will explain below what I did step by step;
>>>
>>> · firstly, I put dates and rates on Anaconda python (this zero
>>> yield curve)
>>>
>>> · Secondly, I determined evaluation date, I changed the date
>>> format.
>>>
>>> · Then it was created as a zero coupon curve "zCurve".
>>>
>>> · After this stage, building the floating rate bond object and
>>> inspect the rate on the cashflows;
>>>
>>> · There is no problem with the following two lines;
>>>
>>> § yts = ql.YieldTermStructureHandle (zCurve)
>>>
>>> § schedule = ql.MakeSchedule (ql.Date (15,6,2020), ql.Date
>>> (15,6,2021), ql.Period ('6m'))
>>>
>>>
>>>
>>> but when I delete “ql.Euribor6M (yts)“in the index section and replace
>>> it with yts.linkTo (zCurve), the error message is occured
>>>
>>> Briefly, I want to make the index statement independent from Euribor or
>>> Libor and tie it to my zero coupon yield curve.
>>>
>>>
>>>
>>> Also in the next step, my goal is to remove the following "ql.Euribor6M
>>> (yts)" statement and not to use it in the same way in the query (I think
>>> this will be fixed automatically if I can fulfill my request above.)
>>>
>>> bond = ql.FloatingRateBond (2,100, program, ql.Euribor6M (yts),
>>>
>>> ql.Actual360 ())
>>>
>>>
>>>
>>> As a result, what should I substitute for ql.Euribor6M (yts) in the
>>> query below?
>>>
>>>
>>>
>>> Thank you very much,
>>>
>>>
>>>
>>> import QuantLib as ql
>>>
>>> from pandas import DataFrame
>>>
>>>
>>>
>>>
>>>
>>> dates = [
>>>
>>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
>>> '30.12.2017',
>>>
>>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>>
>>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
>>>
>>>
>>>
>>> zeros = [
>>>
>>> 0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
>>> 0.0904620831158592, 0.0951565316374134, 0.103938304795234,
>>>
>>> 0.106710404148259, 0.107861984374564,
>>>
>>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>>
>>>
>>>
>>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>>
>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>
>>> dayCounter = ql.Actual360()
>>>
>>>
>>>
>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>
>>>
>>>
>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>
>>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>>
>>> ql.Period('6m'))
>>>
>>> index = ql.Euribor6M(yts)
>>>
>>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>>
>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>
>>> ql.Actual360())
>>>
>>>
>>>
>>> dates = [ c.date() for c in bond.cashflows() ]
>>>
>>> cfs = [ c.amount() for c in bond.cashflows() ]
>>>
>>> DataFrame(list(zip(dates, cfs)),
>>>
>>> columns = ('date','amount'),
>>>
>>> index = range(1,len(dates)+1))
>>>
>>> On 9 Oct 2020 Fri at 11:19 David Duarte <nh...@gm...> wrote:
>>>
>>>> Hi,
>>>>
>>>> You can either clear the fixings or use the optional boolean third
>>>> parameter on the addFixing method to explicitly overwrite the existing
>>>> value:
>>>>
>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003, True)
>>>>
>>>>
>>>> On the other question, the parameter for the index is a
>>>> YieldTermStructureHandle and you can create one and then link to whichever
>>>> curve you wish to use.
>>>> Maybe this simple example will help you understand:
>>>>
>>>> yts = ql.RelinkableYieldTermStructureHandle()
>>>> index = ql.Euribor6M(yts)
>>>>
>>>> crv1 = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
>>>> yts.linkTo(crv1)
>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>
>>>> crv2 = ql.FlatForward(2, ql.TARGET(), 0.02, ql.Actual360())
>>>> yts.linkTo(crv2)
>>>> print(index.fixing(ql.Date(15,12,2020)))
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, 9 Oct 2020 at 08:38, isilay erol <ero...@gm...> wrote:
>>>>
>>>>> As you said "index.clearFixings ()" command worked. Thank you very
>>>>> much.
>>>>>
>>>>> Well, there is one more basic point that I cannot understand. How can
>>>>> I link the index directly to my index curve?
>>>>>
>>>>> In all the examples I saw on the internet like in the following ones,
>>>>>
>>>>> "index = ql.Euribor6M ()"
>>>>>
>>>>> "index = ql.Euribor3M ()"
>>>>>
>>>>> or I saw the Libor version of this.
>>>>>
>>>>>
>>>>>
>>>>> Actually, my zero coupon should be an index curve, right?
>>>>>
>>>>>
>>>>>
>>>>> In my query how can I create the bridge between my index and index
>>>>> curve zCurve?
>>>>>
>>>>>
>>>>>
>>>>> (the part I would like to change: index = ql.Euribor6M(yts))
>>>>>
>>>>>
>>>>>
>>>>> Thank you very much for your help,
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> import QuantLib as ql
>>>>>
>>>>> from pandas import DataFrame
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> dates = [
>>>>>
>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>> '10-02-2020',
>>>>>
>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>
>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>> '09-11-2020',
>>>>>
>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>
>>>>>
>>>>>
>>>>> zeros = [
>>>>>
>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>> 0.002146,
>>>>>
>>>>> 0.002355, 0.002534,
>>>>>
>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>> 0.004549,
>>>>>
>>>>> 0.003148, 0.004040]
>>>>>
>>>>>
>>>>>
>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>
>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>
>>>>> dayCounter = ql.Actual360()
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> #To get the forward rates, you can use the "forwardRate" method from
>>>>> the curve:
>>>>>
>>>>>
>>>>>
>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>
>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>
>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>
>>>>> ql.Compounded, ql.Annual).rate()
>>>>>
>>>>> print(fwd)
>>>>>
>>>>>
>>>>>
>>>>> #or build the floating rate bond object and inspect the rate on the
>>>>> cashflows:
>>>>>
>>>>>
>>>>>
>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>
>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>
>>>>> ql.Period('6m'))
>>>>>
>>>>> index = ql.Euribor6M(yts)
>>>>>
>>>>> index.clearFixings()
>>>>>
>>>>> index.addFixing(ql.Date(6,ql.August,2014), 0.05)
>>>>>
>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>
>>>>> ql.Actual360())
>>>>>
>>>>>
>>>>> On 9 Oct 2020 Fri at 10:11 Francois Botha <ig...@gm...> wrote:
>>>>>
>>>>>> So the error message states that you have already added the fixing.
>>>>>>
>>>>>> I'm unsure whether the Python interface for index.addFixing provides
>>>>>> a parameter to optionally overwrite any existing indices. If so, try that.
>>>>>> Alternatively, there should be something like index.clearFixings() which
>>>>>> you can call first before adding new fixings.
>>>>>>
>>>>>> regards
>>>>>>
>>>>>> Francois Botha
>>>>>>
>>>>>>
>>>>>> On Fri, 9 Oct 2020 at 08:58, isilay erol <ero...@gm...>
>>>>>> wrote:
>>>>>>
>>>>>>> Hello again,
>>>>>>>
>>>>>>> I want to ask one more question;
>>>>>>>
>>>>>>> I want set a past fixing for the current latest coupon (which,
>>>>>>> having fixed in the past, can’t be forecast).
>>>>>>>
>>>>>>> The forecasting of floating bond cashflow should be start generate
>>>>>>> from this latest repring coupon rate.
>>>>>>>
>>>>>>> That’s why I heve added the following querry only to see what will
>>>>>>> happen;
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> “index.addFixing(ql.Date(6,ql.March,2019), 0.003)”
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Bu I have the folowing error message;
>>>>>>>
>>>>>>> Am I thinking wrongly?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> import QuantLib as ql
>>>>>>>
>>>>>>> from pandas import DataFrame
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> dates = [
>>>>>>>
>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>> '10-02-2020',
>>>>>>>
>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>
>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>> '09-11-2020',
>>>>>>>
>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> zeros = [
>>>>>>>
>>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>>> 0.002146,
>>>>>>>
>>>>>>> 0.002355, 0.002534,
>>>>>>>
>>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>>> 0.004549,
>>>>>>>
>>>>>>> 0.003148, 0.004040]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>
>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>
>>>>>>> dayCounter = ql.Actual360()
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>
>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>
>>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>
>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>
>>>>>>> print(fwd)
>>>>>>>
>>>>>>> 0.005623856615195155
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>>
>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>
>>>>>>> ql.Period('6m'))
>>>>>>>
>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>
>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>
>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>
>>>>>>> ql.Actual360())
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> File "<ipython-input-61-ec28b13dc284>", line 5, in <module>
>>>>>>>
>>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> File "C:\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line
>>>>>>> 5475, in addFixing
>>>>>>>
>>>>>>> return _QuantLib.Index_addFixing(self, fixingDate, fixing,
>>>>>>> forceOverwrite)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> RuntimeError: At least one duplicated fixing provided: March 6th,
>>>>>>> 2019, 0.003 while 0.002 value is already present
>>>>>>>
>>>>>>>
>>>>>>> Best regards,
>>>>>>>
>>>>>>> On 8 Oct 2020 Thu at 17:20 isilay erol <ero...@gm...>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Thank you very much Luigi an David.
>>>>>>>>
>>>>>>>> On 8 Oct 2020 Thu at 16:32 Luigi Ballabio <lui...@gm...>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> If you use ql.ZeroCurve instead of ql.DiscountCurve you can input
>>>>>>>>> zero rates directly and get a curve that you can use in the exact same way.
>>>>>>>>>
>>>>>>>>> Luigi
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Oct 8, 2020 at 3:13 PM isilay erol <ero...@gm...>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Dear David,
>>>>>>>>>>
>>>>>>>>>> You are right, the discount factors are increasing,
>>>>>>>>>>
>>>>>>>>>> this indicates that the curve is negative.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Your sample helped me a lot, thank you very much.
>>>>>>>>>>
>>>>>>>>>> I need to make my calculation from the zero coupon yield curve
>>>>>>>>>> itself,
>>>>>>>>>>
>>>>>>>>>> not the discount factor. At this point,
>>>>>>>>>>
>>>>>>>>>> I will try to move forward using the formula of the discount
>>>>>>>>>> factor calculation from zero coupon.
>>>>>>>>>>
>>>>>>>>>> If you already have a Python example of this conversion, I would
>>>>>>>>>> be very happy if you could share it with me.
>>>>>>>>>>
>>>>>>>>>> If not, I will try to derive it.
>>>>>>>>>>
>>>>>>>>>> Thanks again
>>>>>>>>>>
>>>>>>>>>> Best regards,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 8 Oct 2020 Thu at 15:39 David Duarte <nh...@gm...> wrote:
>>>>>>>>>>
>>>>>>>>>>> That is correct. The rates in EUR are negative.
>>>>>>>>>>> Notice the discount factors are above 1
>>>>>>>>>>>
>>>>>>>>>>> On Thu, 8 Oct 2020, 13:10 isilay erol, <ero...@gm...>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Dear David,
>>>>>>>>>>>> I'm working on Anaconda Python,
>>>>>>>>>>>> Thank you for your help,
>>>>>>>>>>>> When I ran your query,
>>>>>>>>>>>> I got negative fwd rates and negative fwd cash flows, am I
>>>>>>>>>>>> missing something?
>>>>>>>>>>>>
>>>>>>>>>>>> You can see my results in the following:
>>>>>>>>>>>>
>>>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>>>
>>>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> dates = [
>>>>>>>>>>>>
>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>> '10-02-2020',
>>>>>>>>>>>>
>>>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>
>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>> '09-11-2020',
>>>>>>>>>>>>
>>>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>
>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766, 1.001941,
>>>>>>>>>>>> 1.002146,
>>>>>>>>>>>>
>>>>>>>>>>>> 1.002355, 1.002534,
>>>>>>>>>>>>
>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395, 1.004146,
>>>>>>>>>>>> 1.004549,
>>>>>>>>>>>>
>>>>>>>>>>>> 1.003148, 0.999840]
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>
>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>
>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>
>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>
>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>>
>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>
>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>
>>>>>>>>>>>> -0.0019082224391586688
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>
>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>> ql.Date(15,6,2021),
>>>>>>>>>>>>
>>>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>>>
>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>
>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>>>
>>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>
>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> June 15th, 2020 -0.00190201607110241
>>>>>>>>>>>>
>>>>>>>>>>>> December 15th, 2020 -0.001253382120767248
>>>>>>>>>>>>
>>>>>>>>>>>> June 15th, 2021 -0.00039680612008295636
>>>>>>>>>>>>
>>>>>>>>>>>> On 8 Oct 2020 Thu at 12:21 David Duarte <nh...@gm...>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Are you using c++, python or excel?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Since you already have a yield curve, you can build the object
>>>>>>>>>>>>> by inputting spot rates (ZeroCurve class) or discount factors
>>>>>>>>>>>>> (DiscountCurve).
>>>>>>>>>>>>>
>>>>>>>>>>>>> Here is an example using python:
>>>>>>>>>>>>>
>>>>>>>>>>>>> dates = [
>>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>>> '10-02-2020', '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>>> '09-11-2020', '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>>
>>>>>>>>>>>>> dfs = [
>>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766,
>>>>>>>>>>>>> 1.001941, 1.002146, 1.002355, 1.002534,
>>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395,
>>>>>>>>>>>>> 1.004146, 1.004549, 1.003148, 0.999840]
>>>>>>>>>>>>>
>>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> To get the forward rates, you can use the "forwardRate" method
>>>>>>>>>>>>> from the curve:
>>>>>>>>>>>>>
>>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>>
>>>>>>>>>>>>> or build the floating rate bond object and inspect the rate on
>>>>>>>>>>>>> the cashflows:
>>>>>>>>>>>>>
>>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>>> ql.Date(15,6,2021), ql.Period('6m'))
>>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>>>
>>>>>>>>>>>>> for cf in map(ql.as_coupon, bond.cashflows()):
>>>>>>>>>>>>> if cf:
>>>>>>>>>>>>> print(cf.accrualStartDate().ISO(),
>>>>>>>>>>>>> cf.accrualStartDate().ISO(), f"{cf.rate():.3%}")
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> or even get the rate from the index for given set of dates:
>>>>>>>>>>>>>
>>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, 8 Oct 2020 at 06:39, isilay erol <
>>>>>>>>>>>>> ero...@gm...> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Dear Luigi,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I just met with quantlib.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I try to understand from the examples how cash flows of
>>>>>>>>>>>>>> floating rate bonds are created.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> But in the examples, I always see that yield curves are
>>>>>>>>>>>>>> established from scratch.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I want to calculate forward rates and forward rate coupons
>>>>>>>>>>>>>> with the yield curve which I already have.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> (I don't want to construct a yield curve from scratch again -
>>>>>>>>>>>>>> I have a zero coupon yield curve)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> And this way I want to create the cash flows of the floating
>>>>>>>>>>>>>> bond. But I could not understand how I could do this.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Can you help me on this issue?
>>>>>>>>>>>>>>
>>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> 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
>>>>>
>>>>
|
|
From: David D. <nh...@gm...> - 2020-10-12 13:24:24
|
Hi,
You seem to be misinterpreting what this line does:
ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(), ql.TARGET(),
ql.ModifiedFollowing, True, ql.Actual360())
It does create that named index and you check that like this for example:
ql.IndexManager.instance().histories()
But it is not a method/attribute/class of QuantLib so you should use it as:
index = ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360(), yts)
On Mon, 12 Oct 2020 at 14:15, isilay erol <ero...@gm...> wrote:
> hello, if I wanted to create an index from my own zero curve for TL and I
> wanted to link it in floating bon, I got an error like this.
>
>
>
> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(), ql.TARGET(),
> ql.ModifiedFollowing, True, ql.Actual360())
>
>
>
> Error message:
>
> “AttributeError: module 'QuantLib' has no attribute 'MyIndex6M'
>
>
>
> import QuantLib as ql
>
> from pandas import DataFrame
>
>
>
>
>
> dates = [
>
> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
> '30.12.2017',
>
> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>
> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
>
>
>
> zeros = [
>
> 0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
> 0.0904620831158592, 0.0951565316374134, 0.103938304795234,
>
> 0.106710404148259, 0.107861984374564,
>
> 0.108326014217227, 0.10842920241869, 0.108326911551829,
> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>
>
>
>
>
>
>
> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>
> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>
> dayCounter = ql.Actual360()
>
>
>
> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>
>
>
> ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(), ql.TARGET(),
> ql.ModifiedFollowing, True, ql.Actual360())
>
>
>
> print(ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
> ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360()))
>
>
>
> yts = ql.YieldTermStructureHandle(zCurve)
>
> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>
> ql.Period('6m'))
>
> index=ql.MyIndex6M(yts)
>
> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>
> bond = ql.FloatingRateBond(2,100, schedule, ql.MyIndex(yts),
>
> ql.Actual360())
>
> On 9 Oct 2020 Fri at 15:28 isilay erol <ero...@gm...> wrote:
>
>> Dear David,
>>
>>
>>
>> First of all, thank you for your detailed answer.
>>
>>
>>
>> index.addFixing(ql.Date(29,7,2016), 0.0487, True) query worked
>>
>> But I couldn’t solve my other problem.
>>
>> I may not be able to express myself or understand your example.
>>
>> I will explain below what I did step by step;
>>
>> · firstly, I put dates and rates on Anaconda python (this zero
>> yield curve)
>>
>> · Secondly, I determined evaluation date, I changed the date
>> format.
>>
>> · Then it was created as a zero coupon curve "zCurve".
>>
>> · After this stage, building the floating rate bond object and
>> inspect the rate on the cashflows;
>>
>> · There is no problem with the following two lines;
>>
>> § yts = ql.YieldTermStructureHandle (zCurve)
>>
>> § schedule = ql.MakeSchedule (ql.Date (15,6,2020), ql.Date (15,6,2021),
>> ql.Period ('6m'))
>>
>>
>>
>> but when I delete “ql.Euribor6M (yts)“in the index section and replace it
>> with yts.linkTo (zCurve), the error message is occured
>>
>> Briefly, I want to make the index statement independent from Euribor or
>> Libor and tie it to my zero coupon yield curve.
>>
>>
>>
>> Also in the next step, my goal is to remove the following "ql.Euribor6M
>> (yts)" statement and not to use it in the same way in the query (I think
>> this will be fixed automatically if I can fulfill my request above.)
>>
>> bond = ql.FloatingRateBond (2,100, program, ql.Euribor6M (yts),
>>
>> ql.Actual360 ())
>>
>>
>>
>> As a result, what should I substitute for ql.Euribor6M (yts) in the query
>> below?
>>
>>
>>
>> Thank you very much,
>>
>>
>>
>> import QuantLib as ql
>>
>> from pandas import DataFrame
>>
>>
>>
>>
>>
>> dates = [
>>
>> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
>> '30.12.2017',
>>
>> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>>
>> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
>>
>>
>>
>> zeros = [
>>
>> 0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
>> 0.0904620831158592, 0.0951565316374134, 0.103938304795234,
>>
>> 0.106710404148259, 0.107861984374564,
>>
>> 0.108326014217227, 0.10842920241869, 0.108326911551829,
>> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>>
>>
>>
>> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>>
>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>
>> dayCounter = ql.Actual360()
>>
>>
>>
>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>
>>
>>
>> yts = ql.YieldTermStructureHandle(zCurve)
>>
>> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>>
>> ql.Period('6m'))
>>
>> index = ql.Euribor6M(yts)
>>
>> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>>
>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>
>> ql.Actual360())
>>
>>
>>
>> dates = [ c.date() for c in bond.cashflows() ]
>>
>> cfs = [ c.amount() for c in bond.cashflows() ]
>>
>> DataFrame(list(zip(dates, cfs)),
>>
>> columns = ('date','amount'),
>>
>> index = range(1,len(dates)+1))
>>
>> On 9 Oct 2020 Fri at 11:19 David Duarte <nh...@gm...> wrote:
>>
>>> Hi,
>>>
>>> You can either clear the fixings or use the optional boolean third
>>> parameter on the addFixing method to explicitly overwrite the existing
>>> value:
>>>
>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003, True)
>>>
>>>
>>> On the other question, the parameter for the index is a
>>> YieldTermStructureHandle and you can create one and then link to whichever
>>> curve you wish to use.
>>> Maybe this simple example will help you understand:
>>>
>>> yts = ql.RelinkableYieldTermStructureHandle()
>>> index = ql.Euribor6M(yts)
>>>
>>> crv1 = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
>>> yts.linkTo(crv1)
>>> print(index.fixing(ql.Date(15,12,2020)))
>>>
>>> crv2 = ql.FlatForward(2, ql.TARGET(), 0.02, ql.Actual360())
>>> yts.linkTo(crv2)
>>> print(index.fixing(ql.Date(15,12,2020)))
>>>
>>>
>>>
>>>
>>> On Fri, 9 Oct 2020 at 08:38, isilay erol <ero...@gm...> wrote:
>>>
>>>> As you said "index.clearFixings ()" command worked. Thank you very much.
>>>>
>>>> Well, there is one more basic point that I cannot understand. How can I
>>>> link the index directly to my index curve?
>>>>
>>>> In all the examples I saw on the internet like in the following ones,
>>>>
>>>> "index = ql.Euribor6M ()"
>>>>
>>>> "index = ql.Euribor3M ()"
>>>>
>>>> or I saw the Libor version of this.
>>>>
>>>>
>>>>
>>>> Actually, my zero coupon should be an index curve, right?
>>>>
>>>>
>>>>
>>>> In my query how can I create the bridge between my index and index
>>>> curve zCurve?
>>>>
>>>>
>>>>
>>>> (the part I would like to change: index = ql.Euribor6M(yts))
>>>>
>>>>
>>>>
>>>> Thank you very much for your help,
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> import QuantLib as ql
>>>>
>>>> from pandas import DataFrame
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> dates = [
>>>>
>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>> '10-02-2020',
>>>>
>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>
>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>> '09-11-2020',
>>>>
>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>
>>>>
>>>>
>>>> zeros = [
>>>>
>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>> 0.002146,
>>>>
>>>> 0.002355, 0.002534,
>>>>
>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>> 0.004549,
>>>>
>>>> 0.003148, 0.004040]
>>>>
>>>>
>>>>
>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>
>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>
>>>> dayCounter = ql.Actual360()
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> #To get the forward rates, you can use the "forwardRate" method from
>>>> the curve:
>>>>
>>>>
>>>>
>>>> forwardStart = ql.Date(15,6,2020)
>>>>
>>>> forwardEnd = ql.Date(15,12,2020)
>>>>
>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>
>>>> ql.Compounded, ql.Annual).rate()
>>>>
>>>> print(fwd)
>>>>
>>>>
>>>>
>>>> #or build the floating rate bond object and inspect the rate on the
>>>> cashflows:
>>>>
>>>>
>>>>
>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>
>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>
>>>> ql.Period('6m'))
>>>>
>>>> index = ql.Euribor6M(yts)
>>>>
>>>> index.clearFixings()
>>>>
>>>> index.addFixing(ql.Date(6,ql.August,2014), 0.05)
>>>>
>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>
>>>> ql.Actual360())
>>>>
>>>>
>>>> On 9 Oct 2020 Fri at 10:11 Francois Botha <ig...@gm...> wrote:
>>>>
>>>>> So the error message states that you have already added the fixing.
>>>>>
>>>>> I'm unsure whether the Python interface for index.addFixing provides a
>>>>> parameter to optionally overwrite any existing indices. If so, try that.
>>>>> Alternatively, there should be something like index.clearFixings() which
>>>>> you can call first before adding new fixings.
>>>>>
>>>>> regards
>>>>>
>>>>> Francois Botha
>>>>>
>>>>>
>>>>> On Fri, 9 Oct 2020 at 08:58, isilay erol <ero...@gm...>
>>>>> wrote:
>>>>>
>>>>>> Hello again,
>>>>>>
>>>>>> I want to ask one more question;
>>>>>>
>>>>>> I want set a past fixing for the current latest coupon (which, having
>>>>>> fixed in the past, can’t be forecast).
>>>>>>
>>>>>> The forecasting of floating bond cashflow should be start generate
>>>>>> from this latest repring coupon rate.
>>>>>>
>>>>>> That’s why I heve added the following querry only to see what will
>>>>>> happen;
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> “index.addFixing(ql.Date(6,ql.March,2019), 0.003)”
>>>>>>
>>>>>>
>>>>>>
>>>>>> Bu I have the folowing error message;
>>>>>>
>>>>>> Am I thinking wrongly?
>>>>>>
>>>>>>
>>>>>>
>>>>>> import QuantLib as ql
>>>>>>
>>>>>> from pandas import DataFrame
>>>>>>
>>>>>>
>>>>>>
>>>>>> dates = [
>>>>>>
>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>> '10-02-2020',
>>>>>>
>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>
>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>> '09-11-2020',
>>>>>>
>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>
>>>>>>
>>>>>>
>>>>>> zeros = [
>>>>>>
>>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>>> 0.002146,
>>>>>>
>>>>>> 0.002355, 0.002534,
>>>>>>
>>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>>> 0.004549,
>>>>>>
>>>>>> 0.003148, 0.004040]
>>>>>>
>>>>>>
>>>>>>
>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>
>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>
>>>>>> dayCounter = ql.Actual360()
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>>
>>>>>>
>>>>>>
>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>
>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>
>>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>
>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>
>>>>>> print(fwd)
>>>>>>
>>>>>> 0.005623856615195155
>>>>>>
>>>>>>
>>>>>>
>>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>>
>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>
>>>>>> ql.Period('6m'))
>>>>>>
>>>>>> index = ql.Euribor6M(yts)
>>>>>>
>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>
>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>
>>>>>> ql.Actual360())
>>>>>>
>>>>>>
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>>
>>>>>>
>>>>>>
>>>>>> File "<ipython-input-61-ec28b13dc284>", line 5, in <module>
>>>>>>
>>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>>
>>>>>>
>>>>>>
>>>>>> File "C:\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line
>>>>>> 5475, in addFixing
>>>>>>
>>>>>> return _QuantLib.Index_addFixing(self, fixingDate, fixing,
>>>>>> forceOverwrite)
>>>>>>
>>>>>>
>>>>>>
>>>>>> RuntimeError: At least one duplicated fixing provided: March 6th,
>>>>>> 2019, 0.003 while 0.002 value is already present
>>>>>>
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> On 8 Oct 2020 Thu at 17:20 isilay erol <ero...@gm...> wrote:
>>>>>>
>>>>>>> Thank you very much Luigi an David.
>>>>>>>
>>>>>>> On 8 Oct 2020 Thu at 16:32 Luigi Ballabio <lui...@gm...>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> If you use ql.ZeroCurve instead of ql.DiscountCurve you can input
>>>>>>>> zero rates directly and get a curve that you can use in the exact same way.
>>>>>>>>
>>>>>>>> Luigi
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Oct 8, 2020 at 3:13 PM isilay erol <ero...@gm...>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Dear David,
>>>>>>>>>
>>>>>>>>> You are right, the discount factors are increasing,
>>>>>>>>>
>>>>>>>>> this indicates that the curve is negative.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Your sample helped me a lot, thank you very much.
>>>>>>>>>
>>>>>>>>> I need to make my calculation from the zero coupon yield curve
>>>>>>>>> itself,
>>>>>>>>>
>>>>>>>>> not the discount factor. At this point,
>>>>>>>>>
>>>>>>>>> I will try to move forward using the formula of the discount
>>>>>>>>> factor calculation from zero coupon.
>>>>>>>>>
>>>>>>>>> If you already have a Python example of this conversion, I would
>>>>>>>>> be very happy if you could share it with me.
>>>>>>>>>
>>>>>>>>> If not, I will try to derive it.
>>>>>>>>>
>>>>>>>>> Thanks again
>>>>>>>>>
>>>>>>>>> Best regards,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On 8 Oct 2020 Thu at 15:39 David Duarte <nh...@gm...> wrote:
>>>>>>>>>
>>>>>>>>>> That is correct. The rates in EUR are negative.
>>>>>>>>>> Notice the discount factors are above 1
>>>>>>>>>>
>>>>>>>>>> On Thu, 8 Oct 2020, 13:10 isilay erol, <ero...@gm...>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> Dear David,
>>>>>>>>>>> I'm working on Anaconda Python,
>>>>>>>>>>> Thank you for your help,
>>>>>>>>>>> When I ran your query,
>>>>>>>>>>> I got negative fwd rates and negative fwd cash flows, am I
>>>>>>>>>>> missing something?
>>>>>>>>>>>
>>>>>>>>>>> You can see my results in the following:
>>>>>>>>>>>
>>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>>
>>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> dates = [
>>>>>>>>>>>
>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>> '10-02-2020',
>>>>>>>>>>>
>>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>
>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>> '09-11-2020',
>>>>>>>>>>>
>>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> dfs = [
>>>>>>>>>>>
>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766, 1.001941,
>>>>>>>>>>> 1.002146,
>>>>>>>>>>>
>>>>>>>>>>> 1.002355, 1.002534,
>>>>>>>>>>>
>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395, 1.004146,
>>>>>>>>>>> 1.004549,
>>>>>>>>>>>
>>>>>>>>>>> 1.003148, 0.999840]
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>
>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>
>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>
>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>
>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>
>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>
>>>>>>>>>>> print(fwd)
>>>>>>>>>>>
>>>>>>>>>>> -0.0019082224391586688
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>
>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>> ql.Date(15,6,2021),
>>>>>>>>>>>
>>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>>
>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>
>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>>
>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>
>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> June 15th, 2020 -0.00190201607110241
>>>>>>>>>>>
>>>>>>>>>>> December 15th, 2020 -0.001253382120767248
>>>>>>>>>>>
>>>>>>>>>>> June 15th, 2021 -0.00039680612008295636
>>>>>>>>>>>
>>>>>>>>>>> On 8 Oct 2020 Thu at 12:21 David Duarte <nh...@gm...>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Are you using c++, python or excel?
>>>>>>>>>>>>
>>>>>>>>>>>> Since you already have a yield curve, you can build the object
>>>>>>>>>>>> by inputting spot rates (ZeroCurve class) or discount factors
>>>>>>>>>>>> (DiscountCurve).
>>>>>>>>>>>>
>>>>>>>>>>>> Here is an example using python:
>>>>>>>>>>>>
>>>>>>>>>>>> dates = [
>>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>>> '10-02-2020', '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>>> '09-11-2020', '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>>
>>>>>>>>>>>> dfs = [
>>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766, 1.001941,
>>>>>>>>>>>> 1.002146, 1.002355, 1.002534,
>>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395, 1.004146,
>>>>>>>>>>>> 1.004549, 1.003148, 0.999840]
>>>>>>>>>>>>
>>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> To get the forward rates, you can use the "forwardRate" method
>>>>>>>>>>>> from the curve:
>>>>>>>>>>>>
>>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>>> print(fwd)
>>>>>>>>>>>>
>>>>>>>>>>>> or build the floating rate bond object and inspect the rate on
>>>>>>>>>>>> the cashflows:
>>>>>>>>>>>>
>>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>>> ql.Date(15,6,2021), ql.Period('6m'))
>>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>>
>>>>>>>>>>>> for cf in map(ql.as_coupon, bond.cashflows()):
>>>>>>>>>>>> if cf:
>>>>>>>>>>>> print(cf.accrualStartDate().ISO(),
>>>>>>>>>>>> cf.accrualStartDate().ISO(), f"{cf.rate():.3%}")
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> or even get the rate from the index for given set of dates:
>>>>>>>>>>>>
>>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, 8 Oct 2020 at 06:39, isilay erol <ero...@gm...>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Dear Luigi,
>>>>>>>>>>>>>
>>>>>>>>>>>>> I just met with quantlib.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I try to understand from the examples how cash flows of
>>>>>>>>>>>>> floating rate bonds are created.
>>>>>>>>>>>>>
>>>>>>>>>>>>> But in the examples, I always see that yield curves are
>>>>>>>>>>>>> established from scratch.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I want to calculate forward rates and forward rate coupons
>>>>>>>>>>>>> with the yield curve which I already have.
>>>>>>>>>>>>>
>>>>>>>>>>>>> (I don't want to construct a yield curve from scratch again -
>>>>>>>>>>>>> I have a zero coupon yield curve)
>>>>>>>>>>>>>
>>>>>>>>>>>>> And this way I want to create the cash flows of the floating
>>>>>>>>>>>>> bond. But I could not understand how I could do this.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Can you help me on this issue?
>>>>>>>>>>>>>
>>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> 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
>>>>
>>>
|
|
From: isilay e. <ero...@gm...> - 2020-10-12 13:15:57
|
hello, if I wanted to create an index from my own zero curve for TL and I
wanted to link it in floating bon, I got an error like this.
ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(), ql.TARGET(),
ql.ModifiedFollowing, True, ql.Actual360())
Error message:
“AttributeError: module 'QuantLib' has no attribute 'MyIndex6M'
import QuantLib as ql
from pandas import DataFrame
dates = [
'30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
'30.12.2017',
'30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
'30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
zeros = [
0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
0.0904620831158592, 0.0951565316374134, 0.103938304795234,
0.106710404148259, 0.107861984374564,
0.108326014217227, 0.10842920241869, 0.108326911551829,
0.108103450370549, 0.107821584741388, 0.107525270883584]
ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
dayCounter = ql.Actual360()
zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(), ql.TARGET(),
ql.ModifiedFollowing, True, ql.Actual360())
print(ql.IborIndex('MyIndex', ql.Period('6m'), 2, ql.TRYCurrency(),
ql.TARGET(), ql.ModifiedFollowing, True, ql.Actual360()))
yts = ql.YieldTermStructureHandle(zCurve)
schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
ql.Period('6m'))
index=ql.MyIndex6M(yts)
index.addFixing(ql.Date(29,7,2016), 0.0487, True)
bond = ql.FloatingRateBond(2,100, schedule, ql.MyIndex(yts),
ql.Actual360())
On 9 Oct 2020 Fri at 15:28 isilay erol <ero...@gm...> wrote:
> Dear David,
>
>
>
> First of all, thank you for your detailed answer.
>
>
>
> index.addFixing(ql.Date(29,7,2016), 0.0487, True) query worked
>
> But I couldn’t solve my other problem.
>
> I may not be able to express myself or understand your example.
>
> I will explain below what I did step by step;
>
> · firstly, I put dates and rates on Anaconda python (this zero
> yield curve)
>
> · Secondly, I determined evaluation date, I changed the date
> format.
>
> · Then it was created as a zero coupon curve "zCurve".
>
> · After this stage, building the floating rate bond object and
> inspect the rate on the cashflows;
>
> · There is no problem with the following two lines;
>
> § yts = ql.YieldTermStructureHandle (zCurve)
>
> § schedule = ql.MakeSchedule (ql.Date (15,6,2020), ql.Date (15,6,2021),
> ql.Period ('6m'))
>
>
>
> but when I delete “ql.Euribor6M (yts)“in the index section and replace it
> with yts.linkTo (zCurve), the error message is occured
>
> Briefly, I want to make the index statement independent from Euribor or
> Libor and tie it to my zero coupon yield curve.
>
>
>
> Also in the next step, my goal is to remove the following "ql.Euribor6M
> (yts)" statement and not to use it in the same way in the query (I think
> this will be fixed automatically if I can fulfill my request above.)
>
> bond = ql.FloatingRateBond (2,100, program, ql.Euribor6M (yts),
>
> ql.Actual360 ())
>
>
>
> As a result, what should I substitute for ql.Euribor6M (yts) in the query
> below?
>
>
>
> Thank you very much,
>
>
>
> import QuantLib as ql
>
> from pandas import DataFrame
>
>
>
>
>
> dates = [
>
> '30.12.2016','29.01.2017', '31.03.2017', '30.06.2017', '29.09.2017',
> '30.12.2017',
>
> '30.12.2018', '30.12.2019', '30.12.2020', '30.12.2021',
>
> '30.12.2022', '30.12.2023', '30.12.2024', '30.12.2025', '30.12.2026']
>
>
>
> zeros = [
>
> 0.000000,0.0693795966991162, 0.0759095626003495,0.0841499536866119,
> 0.0904620831158592, 0.0951565316374134, 0.103938304795234,
>
> 0.106710404148259, 0.107861984374564,
>
> 0.108326014217227, 0.10842920241869, 0.108326911551829,
> 0.108103450370549, 0.107821584741388, 0.107525270883584]
>
>
>
> ql.Settings.instance().evaluationDate = ql.Date(30,12,2016)
>
> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>
> dayCounter = ql.Actual360()
>
>
>
> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>
>
>
> yts = ql.YieldTermStructureHandle(zCurve)
>
> schedule = ql.MakeSchedule(ql.Date(2,2,2011), ql.Date(24,1,2018),
>
> ql.Period('6m'))
>
> index = ql.Euribor6M(yts)
>
> index.addFixing(ql.Date(29,7,2016), 0.0487, True)
>
> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>
> ql.Actual360())
>
>
>
> dates = [ c.date() for c in bond.cashflows() ]
>
> cfs = [ c.amount() for c in bond.cashflows() ]
>
> DataFrame(list(zip(dates, cfs)),
>
> columns = ('date','amount'),
>
> index = range(1,len(dates)+1))
>
> On 9 Oct 2020 Fri at 11:19 David Duarte <nh...@gm...> wrote:
>
>> Hi,
>>
>> You can either clear the fixings or use the optional boolean third
>> parameter on the addFixing method to explicitly overwrite the existing
>> value:
>>
>> index.addFixing(ql.Date(6,ql.March,2019), 0.003, True)
>>
>>
>> On the other question, the parameter for the index is a
>> YieldTermStructureHandle and you can create one and then link to whichever
>> curve you wish to use.
>> Maybe this simple example will help you understand:
>>
>> yts = ql.RelinkableYieldTermStructureHandle()
>> index = ql.Euribor6M(yts)
>>
>> crv1 = ql.FlatForward(2, ql.TARGET(), 0.05, ql.Actual360())
>> yts.linkTo(crv1)
>> print(index.fixing(ql.Date(15,12,2020)))
>>
>> crv2 = ql.FlatForward(2, ql.TARGET(), 0.02, ql.Actual360())
>> yts.linkTo(crv2)
>> print(index.fixing(ql.Date(15,12,2020)))
>>
>>
>>
>>
>> On Fri, 9 Oct 2020 at 08:38, isilay erol <ero...@gm...> wrote:
>>
>>> As you said "index.clearFixings ()" command worked. Thank you very much.
>>>
>>> Well, there is one more basic point that I cannot understand. How can I
>>> link the index directly to my index curve?
>>>
>>> In all the examples I saw on the internet like in the following ones,
>>>
>>> "index = ql.Euribor6M ()"
>>>
>>> "index = ql.Euribor3M ()"
>>>
>>> or I saw the Libor version of this.
>>>
>>>
>>>
>>> Actually, my zero coupon should be an index curve, right?
>>>
>>>
>>>
>>> In my query how can I create the bridge between my index and index curve
>>> zCurve?
>>>
>>>
>>>
>>> (the part I would like to change: index = ql.Euribor6M(yts))
>>>
>>>
>>>
>>> Thank you very much for your help,
>>>
>>>
>>>
>>>
>>>
>>> import QuantLib as ql
>>>
>>> from pandas import DataFrame
>>>
>>>
>>>
>>>
>>>
>>> dates = [
>>>
>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020', '10-02-2020',
>>>
>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>
>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020', '09-11-2020',
>>>
>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>
>>>
>>>
>>> zeros = [
>>>
>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941, 0.002146,
>>>
>>> 0.002355, 0.002534,
>>>
>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146, 0.004549,
>>>
>>> 0.003148, 0.004040]
>>>
>>>
>>>
>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>
>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>
>>> dayCounter = ql.Actual360()
>>>
>>>
>>>
>>>
>>>
>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> #To get the forward rates, you can use the "forwardRate" method from the
>>> curve:
>>>
>>>
>>>
>>> forwardStart = ql.Date(15,6,2020)
>>>
>>> forwardEnd = ql.Date(15,12,2020)
>>>
>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>
>>> ql.Compounded, ql.Annual).rate()
>>>
>>> print(fwd)
>>>
>>>
>>>
>>> #or build the floating rate bond object and inspect the rate on the
>>> cashflows:
>>>
>>>
>>>
>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>
>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>
>>> ql.Period('6m'))
>>>
>>> index = ql.Euribor6M(yts)
>>>
>>> index.clearFixings()
>>>
>>> index.addFixing(ql.Date(6,ql.August,2014), 0.05)
>>>
>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>
>>> ql.Actual360())
>>>
>>>
>>> On 9 Oct 2020 Fri at 10:11 Francois Botha <ig...@gm...> wrote:
>>>
>>>> So the error message states that you have already added the fixing.
>>>>
>>>> I'm unsure whether the Python interface for index.addFixing provides a
>>>> parameter to optionally overwrite any existing indices. If so, try that.
>>>> Alternatively, there should be something like index.clearFixings() which
>>>> you can call first before adding new fixings.
>>>>
>>>> regards
>>>>
>>>> Francois Botha
>>>>
>>>>
>>>> On Fri, 9 Oct 2020 at 08:58, isilay erol <ero...@gm...> wrote:
>>>>
>>>>> Hello again,
>>>>>
>>>>> I want to ask one more question;
>>>>>
>>>>> I want set a past fixing for the current latest coupon (which, having
>>>>> fixed in the past, can’t be forecast).
>>>>>
>>>>> The forecasting of floating bond cashflow should be start generate
>>>>> from this latest repring coupon rate.
>>>>>
>>>>> That’s why I heve added the following querry only to see what will
>>>>> happen;
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> “index.addFixing(ql.Date(6,ql.March,2019), 0.003)”
>>>>>
>>>>>
>>>>>
>>>>> Bu I have the folowing error message;
>>>>>
>>>>> Am I thinking wrongly?
>>>>>
>>>>>
>>>>>
>>>>> import QuantLib as ql
>>>>>
>>>>> from pandas import DataFrame
>>>>>
>>>>>
>>>>>
>>>>> dates = [
>>>>>
>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>> '10-02-2020',
>>>>>
>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>
>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>> '09-11-2020',
>>>>>
>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>
>>>>>
>>>>>
>>>>> zeros = [
>>>>>
>>>>> 0.000000, 0.001185, 0.001352, 0.001561, 0.001766, 0.001941,
>>>>> 0.002146,
>>>>>
>>>>> 0.002355, 0.002534,
>>>>>
>>>>> 0.002712, 0.002897, 0.003069, 0.003232, 0.003395, 0.004146,
>>>>> 0.004549,
>>>>>
>>>>> 0.003148, 0.004040]
>>>>>
>>>>>
>>>>>
>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>
>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>
>>>>> dayCounter = ql.Actual360()
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> zCurve = ql.ZeroCurve(qlDates, zeros, ql.ActualActual(), ql.TARGET())
>>>>>
>>>>>
>>>>>
>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>
>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>
>>>>> fwd = zCurve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>
>>>>> ql.Compounded, ql.Annual).rate()
>>>>>
>>>>> print(fwd)
>>>>>
>>>>> 0.005623856615195155
>>>>>
>>>>>
>>>>>
>>>>> yts = ql.YieldTermStructureHandle(zCurve)
>>>>>
>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>
>>>>> ql.Period('6m'))
>>>>>
>>>>> index = ql.Euribor6M(yts)
>>>>>
>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>
>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>
>>>>> ql.Actual360())
>>>>>
>>>>>
>>>>>
>>>>> Traceback (most recent call last):
>>>>>
>>>>>
>>>>>
>>>>> File "<ipython-input-61-ec28b13dc284>", line 5, in <module>
>>>>>
>>>>> index.addFixing(ql.Date(6,ql.March,2019), 0.003)
>>>>>
>>>>>
>>>>>
>>>>> File "C:\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line
>>>>> 5475, in addFixing
>>>>>
>>>>> return _QuantLib.Index_addFixing(self, fixingDate, fixing,
>>>>> forceOverwrite)
>>>>>
>>>>>
>>>>>
>>>>> RuntimeError: At least one duplicated fixing provided: March 6th,
>>>>> 2019, 0.003 while 0.002 value is already present
>>>>>
>>>>>
>>>>> Best regards,
>>>>>
>>>>> On 8 Oct 2020 Thu at 17:20 isilay erol <ero...@gm...> wrote:
>>>>>
>>>>>> Thank you very much Luigi an David.
>>>>>>
>>>>>> On 8 Oct 2020 Thu at 16:32 Luigi Ballabio <lui...@gm...>
>>>>>> wrote:
>>>>>>
>>>>>>> If you use ql.ZeroCurve instead of ql.DiscountCurve you can input
>>>>>>> zero rates directly and get a curve that you can use in the exact same way.
>>>>>>>
>>>>>>> Luigi
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Oct 8, 2020 at 3:13 PM isilay erol <ero...@gm...>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Dear David,
>>>>>>>>
>>>>>>>> You are right, the discount factors are increasing,
>>>>>>>>
>>>>>>>> this indicates that the curve is negative.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Your sample helped me a lot, thank you very much.
>>>>>>>>
>>>>>>>> I need to make my calculation from the zero coupon yield curve
>>>>>>>> itself,
>>>>>>>>
>>>>>>>> not the discount factor. At this point,
>>>>>>>>
>>>>>>>> I will try to move forward using the formula of the discount factor
>>>>>>>> calculation from zero coupon.
>>>>>>>>
>>>>>>>> If you already have a Python example of this conversion, I would be
>>>>>>>> very happy if you could share it with me.
>>>>>>>>
>>>>>>>> If not, I will try to derive it.
>>>>>>>>
>>>>>>>> Thanks again
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>>
>>>>>>>>
>>>>>>>> On 8 Oct 2020 Thu at 15:39 David Duarte <nh...@gm...> wrote:
>>>>>>>>
>>>>>>>>> That is correct. The rates in EUR are negative.
>>>>>>>>> Notice the discount factors are above 1
>>>>>>>>>
>>>>>>>>> On Thu, 8 Oct 2020, 13:10 isilay erol, <ero...@gm...>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Dear David,
>>>>>>>>>> I'm working on Anaconda Python,
>>>>>>>>>> Thank you for your help,
>>>>>>>>>> When I ran your query,
>>>>>>>>>> I got negative fwd rates and negative fwd cash flows, am I
>>>>>>>>>> missing something?
>>>>>>>>>>
>>>>>>>>>> You can see my results in the following:
>>>>>>>>>>
>>>>>>>>>> import QuantLib as ql
>>>>>>>>>>
>>>>>>>>>> from pandas import DataFrame
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> dates = [
>>>>>>>>>>
>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>> '10-02-2020',
>>>>>>>>>>
>>>>>>>>>> '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>
>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>> '09-11-2020',
>>>>>>>>>>
>>>>>>>>>> '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> dfs = [
>>>>>>>>>>
>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766, 1.001941,
>>>>>>>>>> 1.002146,
>>>>>>>>>>
>>>>>>>>>> 1.002355, 1.002534,
>>>>>>>>>>
>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395, 1.004146,
>>>>>>>>>> 1.004549,
>>>>>>>>>>
>>>>>>>>>> 1.003148, 0.999840]
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>
>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>
>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>
>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>
>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>
>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>
>>>>>>>>>> print(fwd)
>>>>>>>>>>
>>>>>>>>>> -0.0019082224391586688
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>
>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020), ql.Date(15,6,2021),
>>>>>>>>>>
>>>>>>>>>> ql.Period('6m'))
>>>>>>>>>>
>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>
>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>
>>>>>>>>>> ql.Actual360())
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> for dt in schedule:
>>>>>>>>>>
>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> June 15th, 2020 -0.00190201607110241
>>>>>>>>>>
>>>>>>>>>> December 15th, 2020 -0.001253382120767248
>>>>>>>>>>
>>>>>>>>>> June 15th, 2021 -0.00039680612008295636
>>>>>>>>>>
>>>>>>>>>> On 8 Oct 2020 Thu at 12:21 David Duarte <nh...@gm...> wrote:
>>>>>>>>>>
>>>>>>>>>>> Are you using c++, python or excel?
>>>>>>>>>>>
>>>>>>>>>>> Since you already have a yield curve, you can build the object
>>>>>>>>>>> by inputting spot rates (ZeroCurve class) or discount factors
>>>>>>>>>>> (DiscountCurve).
>>>>>>>>>>>
>>>>>>>>>>> Here is an example using python:
>>>>>>>>>>>
>>>>>>>>>>> dates = [
>>>>>>>>>>> '07-05-2019', '11-11-2019', '09-12-2019', '09-01-2020',
>>>>>>>>>>> '10-02-2020', '09-03-2020', '09-04-2020', '11-05-2020', '09-06-2020',
>>>>>>>>>>> '09-07-2020', '10-08-2020', '09-09-2020', '09-10-2020',
>>>>>>>>>>> '09-11-2020', '10-05-2021', '09-05-2022', '09-05-2023', '09-05-2024']
>>>>>>>>>>>
>>>>>>>>>>> dfs = [
>>>>>>>>>>> 1.000000, 1.001185, 1.001352, 1.001561, 1.001766, 1.001941,
>>>>>>>>>>> 1.002146, 1.002355, 1.002534,
>>>>>>>>>>> 1.002712, 1.002897, 1.003069, 1.003232, 1.003395, 1.004146,
>>>>>>>>>>> 1.004549, 1.003148, 0.999840]
>>>>>>>>>>>
>>>>>>>>>>> ql.Settings.instance().evaluationDate = ql.Date(7,5,2019)
>>>>>>>>>>> qlDates = [ql.Date(dt, '%d-%m-%Y') for dt in dates]
>>>>>>>>>>> dayCounter = ql.Actual360()
>>>>>>>>>>> curve = ql.DiscountCurve(qlDates, dfs, dayCounter,
>>>>>>>>>>> ql.NullCalendar())
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> To get the forward rates, you can use the "forwardRate" method
>>>>>>>>>>> from the curve:
>>>>>>>>>>>
>>>>>>>>>>> forwardStart = ql.Date(15,6,2020)
>>>>>>>>>>> forwardEnd = ql.Date(15,12,2020)
>>>>>>>>>>> fwd = curve.forwardRate(forwardStart, forwardEnd, dayCounter,
>>>>>>>>>>> ql.Compounded, ql.Annual).rate()
>>>>>>>>>>> print(fwd)
>>>>>>>>>>>
>>>>>>>>>>> or build the floating rate bond object and inspect the rate on
>>>>>>>>>>> the cashflows:
>>>>>>>>>>>
>>>>>>>>>>> yts = ql.YieldTermStructureHandle(curve)
>>>>>>>>>>> schedule = ql.MakeSchedule(ql.Date(15,6,2020),
>>>>>>>>>>> ql.Date(15,6,2021), ql.Period('6m'))
>>>>>>>>>>> index = ql.Euribor6M(yts)
>>>>>>>>>>> bond = ql.FloatingRateBond(2,100, schedule, ql.Euribor6M(yts),
>>>>>>>>>>> ql.Actual360())
>>>>>>>>>>>
>>>>>>>>>>> for cf in map(ql.as_coupon, bond.cashflows()):
>>>>>>>>>>> if cf:
>>>>>>>>>>> print(cf.accrualStartDate().ISO(),
>>>>>>>>>>> cf.accrualStartDate().ISO(), f"{cf.rate():.3%}")
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> or even get the rate from the index for given set of dates:
>>>>>>>>>>>
>>>>>>>>>>> for dt in schedule:
>>>>>>>>>>> print(dt, index.fixing(dt))
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, 8 Oct 2020 at 06:39, isilay erol <ero...@gm...>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Dear Luigi,
>>>>>>>>>>>>
>>>>>>>>>>>> I just met with quantlib.
>>>>>>>>>>>>
>>>>>>>>>>>> I try to understand from the examples how cash flows of
>>>>>>>>>>>> floating rate bonds are created.
>>>>>>>>>>>>
>>>>>>>>>>>> But in the examples, I always see that yield curves are
>>>>>>>>>>>> established from scratch.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> I want to calculate forward rates and forward rate coupons with
>>>>>>>>>>>> the yield curve which I already have.
>>>>>>>>>>>>
>>>>>>>>>>>> (I don't want to construct a yield curve from scratch again - I
>>>>>>>>>>>> have a zero coupon yield curve)
>>>>>>>>>>>>
>>>>>>>>>>>> And this way I want to create the cash flows of the floating
>>>>>>>>>>>> bond. But I could not understand how I could do this.
>>>>>>>>>>>>
>>>>>>>>>>>> Can you help me on this issue?
>>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> 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
>>>
>>
|
|
From: Peter C. <pca...@gm...> - 2020-10-11 17:38:37
|
Hi Daniel, I guess it's this one https://github.com/pcaspers/QuantLib/blob/master/ql/experimental/models/mcgaussian1dnonstandardswaptionengine.hpp And yes, I created it for my own use only and I honestly don't remember in which shape this is, probably pretty premature I'd think. It looks there is a dependency to https://github.com/pcaspers/QuantLib/blob/master/ql/experimental/models/longstaffschwartzproxypathpricer.hpp Feel free to grab the stuff from the repo and play around with it though. Thanks Peter On Thu, 8 Oct 2020 at 11:36, Daniel Lobo <dan...@gm...> wrote: > > Hi, > > I posted a similar question elsewhere, however failed to generate > enough response. > > I was looking at an article here - > https://quantlib.wordpress.com/2015/06/27/xva-for-bermudan-swaptions/#respond > > There they mentioned a specific MC engine called > MakeMcGaussian1dNonstandardSwaptionEngine. > > The use of this engine as it appears there - > > boost::shared_ptr<PricingEngine> mcEngine = > MakeMcGaussian1dNonstandardSwaptionEngine<>(gsrFixed) > .withSteps(1) // the gsr model allows for large steps > .withSamples(10000) > .withSeed(42) > .withCalibrationSamples(10000) > .withProxy(true); > > However I failed to find any such engine in the Quantlib repository. > > Could you please help me to identify this engine? > > Is it user created? In that case, how exactly should I create this > engine to price a typical swaption? > > I really appreciate your help. > > Many thanks for your time. > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |