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: isilay e. <ero...@gm...> - 2020-10-09 12:28:31
|
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-09 08:19:18
|
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-09 07:37:08
|
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
>>
>
|
|
From: Francois B. <ig...@gm...> - 2020-10-09 07:11:37
|
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
>
|
|
From: isilay e. <ero...@gm...> - 2020-10-09 06:55:38
|
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
>>>
>>
|
|
From: isilay e. <ero...@gm...> - 2020-10-08 14:20:48
|
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
>>
>
|
|
From: David D. <nh...@gm...> - 2020-10-08 13:37:12
|
There is no need to convert. You can build the curve from spot rates
directly.
For example:
dates = [ql.Date(31,12,2019), ql.Date(31,12,2020),
ql.Date(31,12,2021)]zeros = [0.01, 0.02, 0.03]ql.ZeroCurve(dates,
zeros, ql.ActualActual(), ql.TARGET())
On Thu, 8 Oct 2020 at 14:09, 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
>>>>>
>>>>
|
|
From: Luigi B. <lui...@gm...> - 2020-10-08 13:32:49
|
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
>
|
|
From: isilay e. <ero...@gm...> - 2020-10-08 13:10:24
|
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
>>>>
>>>
|
|
From: David D. <nh...@gm...> - 2020-10-08 12:40:15
|
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
>>>
>>
|
|
From: isilay e. <ero...@gm...> - 2020-10-08 12:10:48
|
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
>>
>
|
|
From: Daniel L. <dan...@gm...> - 2020-10-08 09:35:21
|
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. |
|
From: David D. <nh...@gm...> - 2020-10-08 09:22:02
|
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
>
|
|
From: isilay e. <ero...@gm...> - 2020-10-08 08:55:28
|
Dear Ben,
Thank you for your quick answer.
I want to do my calculations on anaconda python.
At this point, what kind of a link should I proceed between the solution
you suggested and quantlibXL and python?
Can you give me a simple example of floating bond cashflow generation so
that I can visualize it better in my mind?
At this point, without the yield curve construction part (with a given Zero
coupon curve) how can I generate cashflow and index in the example below?
I don’t want to use this yield curve contruction part.
##forecast_curve = ql.RelinkableYieldTermStructureHandle()
##forecast_curve.linkTo(ql.FlatForward(today, 0.002, ql.Actual360(),
##ql.Compounded, ql.Semiannual))
##index = ql.Euribor6M(forecast_curve)
##index.addFixing(ql.Date(6,ql.August,2014), 0.002)
import QuantLib as ql
from pandas import DataFrame
today = ql.Date(8,ql.October,2014)
ql.Settings.instance().evaluationDate = today
forecast_curve = ql.RelinkableYieldTermStructureHandle()
forecast_curve.linkTo(ql.FlatForward(today, 0.002, ql.Actual360(),
ql.Compounded, ql.Semiannual))
index = ql.Euribor6M(forecast_curve)
index.addFixing(ql.Date(6,ql.August,2014), 0.002)
issueDate = ql.Date(8,ql.August,2014)
maturityDate = ql.Date(8,ql.August,2019)
schedule = ql.Schedule(issueDate, maturityDate,
ql.Period(ql.Semiannual), ql.TARGET(),
ql.Following, ql.Following,
ql.DateGeneration.Backward, False)
bond = ql.FloatingRateBond(settlementDays = 3,
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))
|
|
From: Francois B. <ig...@gm...> - 2020-10-08 08:44:43
|
Hi Isilay,
To add to Ben's comment, if you're using pure QuantLib (not QuantLibXL),
you can use InterpolatedZeroCurve<> template class. You'll have to choose
your interpolation method, but Linear is the typical choice. Here is a
small code sample..
Snippet
// SET UP YIELD CURVEstd::vector<Date> dates;std::vector<Real> rates;
for (std::map<Date, Real>::iterator iter = i.yieldCurve.begin(); iter
!= i.yieldCurve.end(); ++iter) {
dates.push_back(iter->first);
rates.push_back(iter->second);}
ext::shared_ptr<YieldTermStructure> yieldTermStructure =
ext::shared_ptr<YieldTermStructure>(
new InterpolatedZeroCurve<Linear>(dates, rates, dc));
RelinkableHandle<YieldTermStructure>
yieldHandle;yieldHandle.linkTo(yieldTermStructure);
regards
Francois Botha
On Thu, 8 Oct 2020 at 10:29, <ben...@ma...> wrote:
> QuantlibXL has qlInterpolatedYieldCurve which takes dates and either discount
> factors, Zero rates, or Forward Rates
>
>
>
> That curve is then able to sued for pricing or calculating forwards.
>
>
>
> Regards
>
>
>
> Ben
>
>
>
> *From:* isilay erol <ero...@gm...>
> *Sent:* Thursday, 8 October 2020 4:38 PM
> *To:* qua...@li...
> *Subject:* [Quantlib-users] Calculating forward rates and forward rate
> coupons with the yield curve which I already have
>
>
>
> 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
>
|
|
From: <ben...@ma...> - 2020-10-08 08:26:44
|
QuantlibXL has qlInterpolatedYieldCurve which takes dates and either discount factors, Zero rates, or Forward Rates That curve is then able to sued for pricing or calculating forwards. Regards Ben From: isilay erol <ero...@gm...> Sent: Thursday, 8 October 2020 4:38 PM To: qua...@li... Subject: [Quantlib-users] Calculating forward rates and forward rate coupons with the yield curve which I already have 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? |
|
From: isilay e. <ero...@gm...> - 2020-10-08 05:38:38
|
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? |
|
From: Eric E. <eri...@re...> - 2020-10-07 14:24:00
|
Hi Philip, Many thanks for pointing that out, I will take a look and get back to you. Regards, Eric On 10/7/20 6:43 AM, SX L wrote: > I was trying the Quantlib Addin. The QLADemo exits abnormally in the > debug version with an access violation exception. It turned out to be > the case that ObervableSettings is deleted earlier than some observer > and observables at exit. So in the dtor of the observer, > ObservableSettings is called to check if update is deferred, hence > causing the exception. I feel it's unsafe to use shared pointers > inside a singleton. Any suggestion? Thanks. > > Regards, > > Philip > > > Get Outlook for Android <https://aka.ms/ghei36> > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
From: SX L <han...@ho...> - 2020-10-07 04:43:53
|
I was trying the Quantlib Addin. The QLADemo exits abnormally in the debug version with an access violation exception. It turned out to be the case that ObervableSettings is deleted earlier than some observer and observables at exit. So in the dtor of the observer, ObservableSettings is called to check if update is deferred, hence causing the exception. I feel it's unsafe to use shared pointers inside a singleton. Any suggestion? Thanks. Regards, Philip Get Outlook for Android<https://aka.ms/ghei36> |
|
From: Brian S. <bri...@gm...> - 2020-10-06 15:36:23
|
Hi, I appreciate any idea if the nearly identical values of American
and European options make sense. Thanks for your input.
On Sat, 3 Oct 2020 at 00:18, 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,
|
|
From: berat p. <bpo...@gm...> - 2020-10-04 13:41:37
|
Thanks for your suggestions, As you suggest I will implement a TRCPI class with ZeroInflationIndex. I think I need to define observationLag as 3. Regards. On Fri, Oct 2, 2020 at 12:07 PM Francois Botha <ig...@gm...> wrote: > Hi Berat, > > My suggestion would be to just create your own TRCPI class and follow the > example of the other country inflation classes. However, I believe the 3 > month observation lag doesn't affect your index directly, but rather the > ZeroInflationTermStructure, which is then an input to your index. The index > itself does accept an availability lag, which is typically 1 month. > > I had to do similar work on South African CPI bonds and I just used the > code from inflationcpibond.cpp in the test suite, which uses UKRPI bonds. > You'll notice the observationLag is defined as 2 months, so I'm unsure > whether you should keep it at 2 or change it to 3. > > regards > Francois Botha > > > On Wed, 30 Sep 2020 at 15:03, berat postalcioglu <bpo...@gm...> > wrote: > >> Hi all, >> >> I want to use CPI bond calculation with QuantLib for Turkey. The daily >> reference index calculation in Turkey is as follow: >> >> [image: cpi_turkey.PNG] >> >> Should I use UKRPI class for cpi bond calculation? It seems the UK is >> using 3 month indexation lag. >> >> Thanks in advance. Regards. >> >> -- >> BERAT POSTALCIOĞLU >> _______________________________________________ >> QuantLib-users mailing list >> Qua...@li... >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > -- BERAT POSTALCIOĞLU |
|
From: Daniel L. <dan...@gm...> - 2020-10-04 10:08:04
|
Hi, I refer to the LiborForwardModelProcess class as defined in https://rkapl123.github.io/QLAnnotatedSource/d9/dd3/class_quant_lib_1_1_libor_forward_model_process.html. The constructor is defined as - LiborForwardModelProcess(Size size, const boost::shared_ptr< IborIndex > & index ) I am struggling to understand what the Size here refers to. Can you please help me to understand. Thanks for your time. Regards |
|
From: Jack G <jac...@gm...> - 2020-10-03 13:01:43
|
Dear Luigi, Many thanks for the help! I'm pleased to say I finally got it to work. In case others struggle with this in future, here was what I did (this is running on a reasonably new, mid-range Windows 10 laptop): 1) Built an ubuntu docker image with the QuantLib 1.19 binaries installed, following the instructions here: https://www.quantlib.org/install/linux.shtml - this was a slow step and took many hours to build (I left it running overnight). It also ended up around 17GB, I'm looking to improve on this by using one of Luigi's docker images in future (https://github.com/lballabio/dockerfiles). 2) I build a second image on top of this that git cloned down the 'binder' branch of my fork of the https://github.com/lballabio/QuantLib-SWIG repository (I found binder was important to make sure QuantLib and QuantLib-SWIG both matched version at 1.19). It is also important that this is not cloned down into a shared windows-docker drive, or else the bash scripts won't run correctly (something to do with line endings?), but is cloned directly into a folder inside the ubuntu image. This image also had a jupyter notebook server running in it (which I later use to test the code). 3) Once that was done, I built a container from the second image via docker-compose (I added 'mem_limit: 4096m' to up the memory limits, but I'm not sure if this helped in the end, now it's part of my cargo cult). I bashed into the container, navigated to the repo that I'd cloned down, and made the changes I had in mine to the SWIG .i files (the first time round, I made no changes - and I ran a new container for each set of changes I wanted to test) 4) Then I ran the following in the repo's top directory (nb. I had python3 only, installed in '/usr/bin/python3'): > ./autogen.sh > ./configure PYTHON=/usr/bin/python3 CXXFLAGS='-O0' > make -C Python <-- slow step, took approx 10 mins > sudo make -C Python install 5) After this, I could import QuantLib into my jupyter notebooks, and any changes I'd make to the SWIG interfaces was visible in the code. On one occasion when I omitted a comma in a C++ script, the procedure above broke a few seconds in to the 'make -C Python' step above. Once again, thanks for the support. Best, Jack On Fri, Oct 2, 2020 at 7:11 PM Luigi Ballabio <lui...@gm...> wrote: > It sounds like you're running out of memory. How much did you make > available to Docker? If that's the problem, you can try reducing the > amount of memory used by the compiler by disabling some or all > optimizations, i.e., by passing '-O1' or '-O0'. You can do that by setting > the environment variable CXXFLAGS to the desired flag. > > Luigi > > > On Fri, Oct 2, 2020 at 11:25 AM Jack G <jac...@gm...> wrote: > >> Dear Luigi, >> >> Thanks for coming back. The configure problem turned out to be dos/unix >> related - I was git cloning the files onto windows and sharing the volume >> within my container, which made ubuntu unhappy. When I git clone directly >> into the ubuntu container, all problems with that step are resolved. >> >> However, I'm still having trouble at the build step. I encounter this >> issue at the "make -C Python" command, and also cd'ing into the Python >> folder and following your instructions to build via python (here: >> https://github.com/lballabio/QuantLib-SWIG/blob/master/Python/README.txt) >> when I run this command "python setup.py build". In each case, I see a >> lot of deprecation warnings ending with one for "FDDividendAmericanEngine" >> (I've attached the full output of my most recent attempt >> in swig_stack_output.txt), followed by a very long delay. At this point >> nothing happens for a very long time, in one case it eventually failed due >> to virtual memory running out but on other occasions it stayed at this step >> for many hours: >> [image: image.png] >> >> I've tried my own docker image, and I also tried the same using a >> Dockerfile borrowed from one of your repos (I built this dockerfile >> https://github.com/lballabio/dockerfiles/blob/master/quantlib-swig-devenv/Dockerfile.python3, >> then ran an image, installed git and cloned the QuantLib-SWIG repo's >> 'binder' branch, then followed the instructions). >> >> I feel like I'm missing something but can't see what it might be. >> >> Thanks for the help, >> Jack >> >> On Fri, Oct 2, 2020 at 4:44 PM Luigi Ballabio <lui...@gm...> >> wrote: >> >>> Hello Jack, >>> may you post the full output from running configure? >>> >>> Luigi >>> >>> >>> On Thu, Oct 1, 2020 at 4:03 AM Jack G <jac...@gm...> wrote: >>> >>>> Dear QuantLib Users, >>>> >>>> I'm trying to install QuantLib-SWIG version 1.19 to add some additional >>>> interfaces into the C++ QuantLib functionality for use in Python, using the >>>> instructions here: https://www.quantlib.org/install/linux-python.shtml, >>>> and facing two problems. >>>> >>>> I'm developing inside a ubuntu docker container on a windows machine, >>>> and built QuantLib from source in the Dockerfile (it causes my image to be >>>> 17GB, not sure if this is expected?). I'm quite experienced with Python but >>>> not very experienced building C++. >>>> >>>> First I tried to compile from the git repo, I cloned down a version and >>>> ran ./autogen.sh, followed by ./configure, which gives the following error: >>>> [image: image.png] >>>> >>>> If I instead download the binary here >>>> https://bintray.com/quantlib/releases/download_file?file_path=QuantLib-SWIG-1.19.tar.gz >>>> and unzip, I can successfully run the ./configure step (note that as far as >>>> I can see, these two configure files are identical - compared via git). >>>> However I run into some trouble a little later. When I first run "make -C >>>> Python" or any step featuring "make", it tells me there is nothing to do. >>>> I'm able to fix this with "make clean" and then "make -C Python", then I >>>> have to "make clean" again but I get the following error again when I try >>>> to run "sudo make -C Python install", which (I think) builds/links the C++ >>>> code but is saying it doesn't want to install the python: >>>> [image: image.png] >>>> >>>> Am I doing something obviously wrong? My preference would be to install >>>> from the repo as I plan to test some code changes, but I'm not having much >>>> luck with it. If I instead unpack the binaries (in which I can see the code >>>> as text in .i files in the SWIG directory), modify the code, and then >>>> build, will that see and compile my changes? >>>> >>>> Thanks >>>> Jack >>>> _______________________________________________ >>>> QuantLib-users mailing list >>>> Qua...@li... >>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>>> >>> |
|
From: Brian S. <bri...@gm...> - 2020-10-02 18:49:11
|
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,
|
|
From: Luigi B. <lui...@gm...> - 2020-10-02 13:35:21
|
Ioannis is right, there is a variance swap in C++ but it's not exported to Python. Also, no cap/floor and no swaption. Please open an issue on GitHub if you're interested in any of the above. Luigi On Fri, Sep 25, 2020 at 12:25 PM Ioannis Rigopoulos <qua...@de...> wrote: > There is one in C++. > On 25/09/2020 10:15, Amine Ifri wrote: > > Hi, > > Haven’t seen VarSwap instrument interface so I am not sure they are > currently handled by the library. I use an old version of the lib though... > > Thanks. > > Amine Ifri > > On 25 Sep 2020, at 04:23, Pierre Dugland <mer...@gm...> > <mer...@gm...> wrote: > > > Hello All, > > Re-upping as I didn't get any replies the first time :) > Still looking for a way to price variance swaps using Python Quantlib. Is > it possible and if it is, where could I find an example ? > > Thank you for your help. > > Best, > > Pierre > > > > On Mon, Aug 3, 2020 at 9:32 AM Pierre Dugland <mer...@gm...> > wrote: > >> Hello All, >> >> I could not find an example to price volatility and variance swaps. Is it >> at all possible using the Python bindings ? >> Ideally I am also looking for the capped versions of both those products. >> >> Thank you for your help. >> >> Best, >> >> Pierre >> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > > _______________________________________________ > QuantLib-users mailing lis...@li...://lists.sourceforge.net/lists/listinfo/quantlib-users > > > > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Virus-free. > www.avast.com > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > <#m_9180871932010952869_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |