|
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
>>>>>>>
>>>>>>
|