|
From: Luigi B. <lui...@gm...> - 2019-08-07 15:30:45
|
You can extract the information with something like this:
for i, x in enumerate(ir_swap.floatingLeg()):
cf = ql.as_floating_rate_coupon(x)
print(f"cf[{i}]")
print(f"payment date: {cf.date()}")
print(f"fixing date: {cf.fixingDate()}")
print(f"start of accrual: {cf.accrualStartDate()}")
print(f"end of accrual: {cf.accrualEndDate()}")
print(f"floating rate: {cf.rate()}")
print(f"index fixing: {libor_3M_index.fixing(cf.fixingDate())}")
print(f"discount factor: {discount_curve.discount(cf.date())}")
Note that, as a default, the floating rate is calculated at par on the life
of the coupon (between start and end of the accrual period) and so it might
differ slightly from the fixing returned by the index. Case in point: due
to adjustments over holidays and weekends, the last coupon accrues from
June 13th to September 12th, while the corresponding LIBOR fixing probably
goes from 13th to 13th.
Luigi
On Wed, Jun 26, 2019 at 9:53 AM R S <raj...@ho...> wrote:
> Apologies as I am sure this has been asked before but I cannot find the
> answers from the archive.
>
>
>
> I attach a jupyter notebook file where I have constructed a simple swap.
>
>
>
> I am using the forward and discount rates to manually calculate the
> cashflows and am always slightly out w.r.t the cashflows from the legs
>
>
>
> (see image - quantlibex.png)
>
>
>
> How can I get hold of the forward and discount rates being used internally
> (I presume these re off the equivalent z-curve, hence the diff?)
>
>
>
> I attach the requirements.txt for my virtual env called quantlibenv (if
> you wish to recreate)
>
>
>
> I add this env to jupyter using the command:
>
>
>
> ipython kernel install --user --name=quantlibenv
>
>
>
> as outlined here
> <https://anbasile.github.io/programming/2017/06/25/jupyter-venv/>
>
>
>
>
> _______________________________________________
> QuantLib-dev mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>
|