Interpolate discount factor by swap rates

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Interpolate discount factor by swap rates

emmajyu
Hi All, I am new to QuantLib. How does QuantLib interpolate discount factor from Swap Rates for those rates 1.5 yr, 2.5 yr, 2.75yr etc? I am looking for this: From swap rates of 1 yr, 2 yr which are known from market, fixed leg=floating leg. interpolate discount factor of 1.5yr by log linear Thanks a lot!
Reply | Threaded
Open this post in threaded view
|

R: Interpolate discount factor by swap rates

Ballabio Gerardo-4

You need to build a yield curve. You can find how to do that in the QuantLib documentation, for example here: http://quantlib.org/slides/dima-ql-intro-2.pdf

 

Gerardo

 

 

Da: emmajyu [mailto:[hidden email]]
Inviato: giovedì 9 maggio 2013 17.40
A: [hidden email]
Oggetto: [Quantlib-users] Interpolate discount factor by swap rates

 

Hi All, I am new to QuantLib. How does QuantLib interpolate discount factor from Swap Rates for those rates 1.5 yr, 2.5 yr, 2.75yr etc? I am looking for this: >From swap rates of 1 yr, 2 yr which are known from market, fixed leg=floating leg. interpolate discount factor of 1.5yr by log linear Thanks a lot!


View this message in context: Interpolate discount factor by swap rates
Sent from the quantlib-users mailing list archive at Nabble.com.




Banca Profilo S.p.A. Corso Italia, 49 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057 Capitale Sociale Euro 136.794.106,00 i.v. Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email] Iscritta all’Albo delle Banche e dei Gruppi bancari Aderente al Fondo Interbancario di Tutela dei depositi Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A. DISCLAIMER: The information transmitted may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: R: Interpolate discount factor by swap rates

emmajyu
thanks, Gerardo.
I read the 2-pdf. It seems QuantLib calculates the discount factor by Log Linear or Linear.

But I need more help.
I want to get DF (e.g. 1.5 Yr) from swap rate.
For example, rate of 1 year, 2 year are known, but need to calculate 1.5 yr from the swap rate.
As in swaps,
Fixed Leg = Floating Leg
   ==> Fix leg, DF(0.5) * Delta_t(0.5) + DF(1) * Delta_t(1) + DF(1.5) * Delta_t(1.5) + DF(2) * Delta_t(2)
         Floating leg, = 1 - DF(2)
Here we have 2 unknown var, DF(1.5 Yr) and DF(2 Yr)
To solve this, use Log Linear to interpolate the DF(1.5)
DF(1.5) = DF(2)^((t1.5-t1)/(t2-t1)) * DF(1)^((t2-t1.5)/(t2-t1))


Thanks a lot
Reply | Threaded
Open this post in threaded view
|

Re: R: Interpolate discount factor by swap rates

Peter Caspers-4
you can specify the interpolation and bootstrap policy via template arguments like in

PiecewiseYieldCurve<T,I,B>(...)

T = what to interpolate = Discount, ZeroYield, ForwardRate
I = how to interpolate = Linear, LogLinear, BackwardFlat, Cubic, ... many more ...
B = how to bootstrap = IterativeBootstrap, LocalBootstrap

so basically you might want to put your instruments into the PiecewiseYieldCurve and then
retrieve discount factors (for whatever maturity) using the discount method on your yield curve object.

regards
 Peter

emmajyu <[hidden email]> writes:

> thanks, Gerardo.
> I read the 2-pdf. It seems QuantLib calculates the discount factor by Log
> Linear or Linear.
>
> But I need more help.
> I want to get DF (e.g. 1.5 Yr) from swap rate.
> For example, rate of 1 year, 2 year are known, but need to calculate 1.5 yr
> from the swap rate.
> As in swaps,
> Fixed Leg = Floating Leg
>    ==> Fix leg, DF(0.5) * Delta_t(0.5) + DF(1) * Delta_t(1) + DF(1.5) *
> Delta_t(1.5) + DF(2) * Delta_t(2)
>          Floating leg, = 1 - DF(2)
> Here we have 2 unknown var, DF(1.5 Yr) and DF(2 Yr)
> To solve this, use Log Linear to interpolate the DF(1.5)
> DF(1.5) = DF(2)^((t1.5-t1)/(t2-t1)) * DF(1)^((t2-t1.5)/(t2-t1))
>
>
> Thanks a lot
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Interpolate-discount-factor-by-swap-rates-tp14249p14251.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: R: Interpolate discount factor by swap rates

Luigi Ballabio
Peter is correct. You can look at Examples/Swap/swapvaluation.cpp for
an example. Once you've built the curve based on the given swaps, just
ask it for discounts with

discountingTermStructure->discount(d);

where d is the desired date.

Luigi


On Sun, May 12, 2013 at 8:07 PM, Peter Caspers <[hidden email]> wrote:

> you can specify the interpolation and bootstrap policy via template arguments like in
>
> PiecewiseYieldCurve<T,I,B>(...)
>
> T = what to interpolate = Discount, ZeroYield, ForwardRate
> I = how to interpolate = Linear, LogLinear, BackwardFlat, Cubic, ... many more ...
> B = how to bootstrap = IterativeBootstrap, LocalBootstrap
>
> so basically you might want to put your instruments into the PiecewiseYieldCurve and then
> retrieve discount factors (for whatever maturity) using the discount method on your yield curve object.
>
> regards
>  Peter
>
> emmajyu <[hidden email]> writes:
>
>> thanks, Gerardo.
>> I read the 2-pdf. It seems QuantLib calculates the discount factor by Log
>> Linear or Linear.
>>
>> But I need more help.
>> I want to get DF (e.g. 1.5 Yr) from swap rate.
>> For example, rate of 1 year, 2 year are known, but need to calculate 1.5 yr
>> from the swap rate.
>> As in swaps,
>> Fixed Leg = Floating Leg
>>    ==> Fix leg, DF(0.5) * Delta_t(0.5) + DF(1) * Delta_t(1) + DF(1.5) *
>> Delta_t(1.5) + DF(2) * Delta_t(2)
>>          Floating leg, = 1 - DF(2)
>> Here we have 2 unknown var, DF(1.5 Yr) and DF(2 Yr)
>> To solve this, use Log Linear to interpolate the DF(1.5)
>> DF(1.5) = DF(2)^((t1.5-t1)/(t2-t1)) * DF(1)^((t2-t1.5)/(t2-t1))
>>
>>
>> Thanks a lot
>>
>>
>>
>> --
>> View this message in context: http://quantlib.10058.n7.nabble.com/Interpolate-discount-factor-by-swap-rates-tp14249p14251.html
>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> Learn Graph Databases - Download FREE O'Reilly Book
>> "Graph Databases" is the definitive new guide to graph databases and
>> their applications. This 200-page book is written by three acclaimed
>> leaders in the field. The early access version is available now.
>> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
>> _______________________________________________
>> QuantLib-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users