CPI Time Series Interpolation

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

CPI Time Series Interpolation

Charles Allderman
Hi

I am digging into the pricing of a CPIBond. I have this index CPI index time series:

DATE            
2016-08-31  123.0
2016-09-30  123.2
2016-10-31  123.8
2016-11-30  124.2
2016-12-31  124.7

If I interpolate for 10 February 2017 I get:
(10.0-1)/28.0*(124.2-123.8)+123.8
>123.92857142857143

Deriving the values as calculated by QuantLib using the last cash flow I get:
principal*baseCPI/notional
>123.92000000000002

So it appears to be rounded down.

The inflation index is simply created by passing in a vector of dates(month-end date plus 1 day) and values.
inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)

So is there a way to get the full interpolated value?

Thanks
Charles







Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

Peter Caspers-4
Hi,

it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x (10-1) / 30, i.e. takes November instead of February as the basis for the interpolation. This is due to a bug described here


There is an attempt to solve that, but this is not yet merged


Looking at that I think we also need to fix the interpolation in CPICoupon, the code for this starts here


What do you think, Francois, Luigi?

Kind Regards
Peter


On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]> wrote:

Hi

I am digging into the pricing of a CPIBond. I have this index CPI index time
series:

DATE             
2016-08-31  123.0
2016-09-30  123.2
2016-10-31  123.8
2016-11-30  124.2
2016-12-31  124.7

If I interpolate for 10 February 2017 I get:
(10.0-1)/28.0*(124.2-123.8)+123.8
123.92857142857143

Deriving the values as calculated by QuantLib using the last cash flow I
get:
principal*baseCPI/notional
123.92000000000002

So it appears to be rounded down.

The inflation index is simply created by passing in a vector of
dates(month-end date plus 1 day) and values.
inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)

So is there a way to get the full interpolated value?

Thanks
Charles











--
View this message in context: http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

Charles Allderman
Hi Peter

Thanks for clearing that up. If I created an interpolated daily series and passed that in would this workaround work?

Thanks
Charles

On Thu, Feb 9, 2017 at 1:57 PM, Peter Caspers <[hidden email]> wrote:
Hi,

it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x (10-1) / 30, i.e. takes November instead of February as the basis for the interpolation. This is due to a bug described here


There is an attempt to solve that, but this is not yet merged


Looking at that I think we also need to fix the interpolation in CPICoupon, the code for this starts here


What do you think, Francois, Luigi?

Kind Regards
Peter


On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]> wrote:

Hi

I am digging into the pricing of a CPIBond. I have this index CPI index time
series:

DATE             
2016-08-31  123.0
2016-09-30  123.2
2016-10-31  123.8
2016-11-30  124.2
2016-12-31  124.7

If I interpolate for 10 February 2017 I get:
(10.0-1)/28.0*(124.2-123.8)+123.8
123.92857142857143

Deriving the values as calculated by QuantLib using the last cash flow I
get:
principal*baseCPI/notional
123.92000000000002

So it appears to be rounded down.

The inflation index is simply created by passing in a vector of
dates(month-end date plus 1 day) and values.
inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)

So is there a way to get the full interpolated value?

Thanks
Charles











--
View this message in context: http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

Peter Caspers-4
Hi Charles,

I don’t think so, because InflationIndex::addFixing(d,v) writes v to each day of the applicable inflation period (in your case the whole month) containing d.

Kind Regards
Peter

On 09 Feb 2017, at 13:07, Charles Allderman <[hidden email]> wrote:

Hi Peter

Thanks for clearing that up. If I created an interpolated daily series and passed that in would this workaround work?

Thanks
Charles

On Thu, Feb 9, 2017 at 1:57 PM, Peter Caspers <[hidden email]> wrote:
Hi,

it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x (10-1) / 30, i.e. takes November instead of February as the basis for the interpolation. This is due to a bug described here


There is an attempt to solve that, but this is not yet merged


Looking at that I think we also need to fix the interpolation in CPICoupon, the code for this starts here


What do you think, Francois, Luigi?

Kind Regards
Peter


On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]> wrote:

Hi

I am digging into the pricing of a CPIBond. I have this index CPI index time
series:

DATE             
2016-08-31  123.0
2016-09-30  123.2
2016-10-31  123.8
2016-11-30  124.2
2016-12-31  124.7

If I interpolate for 10 February 2017 I get:
(10.0-1)/28.0*(124.2-123.8)+123.8
123.92857142857143

Deriving the values as calculated by QuantLib using the last cash flow I
get:
principal*baseCPI/notional
123.92000000000002

So it appears to be rounded down.

The inflation index is simply created by passing in a vector of
dates(month-end date plus 1 day) and values.
inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)

So is there a way to get the full interpolated value?

Thanks
Charles











--
View this message in context: http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

igitur
In reply to this post by Peter Caspers-4
Hi,

Charles, you might remember we had a chat about this about a year back. Sadly, this illustrates my laziness and I have to do some more work on that PR before it is ready for merging. 

PR50 is necessary if bonds are valued at the real curve, and the inflation curve in the future is assume to be a flat 0. Past inflation fixings (since issue date) allows for the rolling up until effective date. This is the method that BESA prescribes in the ZA inflation linked bond valuation.

The alternative way is to value the bond at the nominal curve, but then you have to deduce the inflation curve yourself (difference between nominal and real yield curves) and add the fixings as in the first method. 

I still wanted to thoroughly investigate whether the 2nd approach isn't a better approach that wouldn't require PR50 before I cleaned up the PR.

The above doesn't solve your issue, but I just wanted to explain why PR50 is still in limbo.



Francois Botha

On 9 February 2017 at 13:57, Peter Caspers <[hidden email]> wrote:
Hi,

it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x (10-1) / 30, i.e. takes November instead of February as the basis for the interpolation. This is due to a bug described here


There is an attempt to solve that, but this is not yet merged


Looking at that I think we also need to fix the interpolation in CPICoupon, the code for this starts here


What do you think, Francois, Luigi?

Kind Regards
Peter


On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]> wrote:

Hi

I am digging into the pricing of a CPIBond. I have this index CPI index time
series:

DATE             
2016-08-31  123.0
2016-09-30  123.2
2016-10-31  123.8
2016-11-30  124.2
2016-12-31  124.7

If I interpolate for 10 February 2017 I get:
(10.0-1)/28.0*(124.2-123.8)+123.8
123.92857142857143

Deriving the values as calculated by QuantLib using the last cash flow I
get:
principal*baseCPI/notional
123.92000000000002

So it appears to be rounded down.

The inflation index is simply created by passing in a vector of
dates(month-end date plus 1 day) and values.
inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)

So is there a way to get the full interpolated value?

Thanks
Charles











--
View this message in context: http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

Charles Allderman
Hi Francois

I remember the discussion but we did not delve into the interpolation base issue then I think. Is the interpolation issue then the only issue? If I understand you correctly, I think I like the first method as it allows the user the option of passing in an inflation curve and the valuing off nominal should he so wish.

Thanks
Charles

On Thu, Feb 9, 2017 at 2:57 PM, Francois Botha <[hidden email]> wrote:
Hi,

Charles, you might remember we had a chat about this about a year back. Sadly, this illustrates my laziness and I have to do some more work on that PR before it is ready for merging. 

PR50 is necessary if bonds are valued at the real curve, and the inflation curve in the future is assume to be a flat 0. Past inflation fixings (since issue date) allows for the rolling up until effective date. This is the method that BESA prescribes in the ZA inflation linked bond valuation.

The alternative way is to value the bond at the nominal curve, but then you have to deduce the inflation curve yourself (difference between nominal and real yield curves) and add the fixings as in the first method. 

I still wanted to thoroughly investigate whether the 2nd approach isn't a better approach that wouldn't require PR50 before I cleaned up the PR.

The above doesn't solve your issue, but I just wanted to explain why PR50 is still in limbo.



Francois Botha

On 9 February 2017 at 13:57, Peter Caspers <[hidden email]> wrote:
Hi,

it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x (10-1) / 30, i.e. takes November instead of February as the basis for the interpolation. This is due to a bug described here


There is an attempt to solve that, but this is not yet merged


Looking at that I think we also need to fix the interpolation in CPICoupon, the code for this starts here


What do you think, Francois, Luigi?

Kind Regards
Peter


On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]> wrote:

Hi

I am digging into the pricing of a CPIBond. I have this index CPI index time
series:

DATE             
2016-08-31  123.0
2016-09-30  123.2
2016-10-31  123.8
2016-11-30  124.2
2016-12-31  124.7

If I interpolate for 10 February 2017 I get:
(10.0-1)/28.0*(124.2-123.8)+123.8
123.92857142857143

Deriving the values as calculated by QuantLib using the last cash flow I
get:
principal*baseCPI/notional
123.92000000000002

So it appears to be rounded down.

The inflation index is simply created by passing in a vector of
dates(month-end date plus 1 day) and values.
inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)

So is there a way to get the full interpolated value?

Thanks
Charles











--
View this message in context: http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

Peter Caspers-4
Hi Francois,

to be honest I don't understand why this is so complicated to fix?
Isn't it enough to go forward from the original inflation period by
what the observation lag says to get the correct number of days for
the denominator in the interpolation formula? And this needs to be
corrected in any case, independent of the other stuff with the real
curve you are talking about?

Best Regards
Peter


On 9 February 2017 at 14:24, Charles Allderman <[hidden email]> wrote:

> Hi Francois
>
> I remember the discussion but we did not delve into the interpolation base
> issue then I think. Is the interpolation issue then the only issue? If I
> understand you correctly, I think I like the first method as it allows the
> user the option of passing in an inflation curve and the valuing off nominal
> should he so wish.
>
> Thanks
> Charles
>
> On Thu, Feb 9, 2017 at 2:57 PM, Francois Botha <[hidden email]> wrote:
>>
>> Hi,
>>
>> Charles, you might remember we had a chat about this about a year back.
>> Sadly, this illustrates my laziness and I have to do some more work on that
>> PR before it is ready for merging.
>>
>> PR50 is necessary if bonds are valued at the real curve, and the inflation
>> curve in the future is assume to be a flat 0. Past inflation fixings (since
>> issue date) allows for the rolling up until effective date. This is the
>> method that BESA prescribes in the ZA inflation linked bond valuation.
>>
>> The alternative way is to value the bond at the nominal curve, but then
>> you have to deduce the inflation curve yourself (difference between nominal
>> and real yield curves) and add the fixings as in the first method.
>>
>> I still wanted to thoroughly investigate whether the 2nd approach isn't a
>> better approach that wouldn't require PR50 before I cleaned up the PR.
>>
>> The above doesn't solve your issue, but I just wanted to explain why PR50
>> is still in limbo.
>>
>>
>>
>> Francois Botha
>>
>> On 9 February 2017 at 13:57, Peter Caspers <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x
>>> (10-1) / 30, i.e. takes November instead of February as the basis for the
>>> interpolation. This is due to a bug described here
>>>
>>>
>>> http://quantlib.10058.n7.nabble.com/Interpolated-ZeroInflationIndexes-td15507.html
>>>
>>> There is an attempt to solve that, but this is not yet merged
>>>
>>> https://github.com/lballabio/QuantLib/pull/50
>>>
>>> Looking at that I think we also need to fix the interpolation in
>>> CPICoupon, the code for this starts here
>>>
>>>
>>> https://github.com/lballabio/QuantLib/blob/master/ql/cashflows/cpicoupon.cpp#L88
>>>
>>> What do you think, Francois, Luigi?
>>>
>>> Kind Regards
>>> Peter
>>>
>>>
>>> On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]>
>>> wrote:
>>>
>>> Hi
>>>
>>> I am digging into the pricing of a CPIBond. I have this index CPI index
>>> time
>>> series:
>>>
>>> DATE
>>> 2016-08-31  123.0
>>> 2016-09-30  123.2
>>> 2016-10-31  123.8
>>> 2016-11-30  124.2
>>> 2016-12-31  124.7
>>>
>>> If I interpolate for 10 February 2017 I get:
>>> (10.0-1)/28.0*(124.2-123.8)+123.8
>>>
>>> 123.92857142857143
>>>
>>>
>>> Deriving the values as calculated by QuantLib using the last cash flow I
>>> get:
>>> principal*baseCPI/notional
>>>
>>> 123.92000000000002
>>>
>>>
>>> So it appears to be rounded down.
>>>
>>> The inflation index is simply created by passing in a vector of
>>> dates(month-end date plus 1 day) and values.
>>> inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)
>>>
>>> So is there a way to get the full interpolated value?
>>>
>>> Thanks
>>> Charles
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
>>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>>
>>
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: CPI Time Series Interpolation

igitur
Yes, you're right. I'll sort it out by the end of the week. 

On 11 Feb 2017 19:34, "Peter Caspers" <[hidden email]> wrote:
Hi Francois,

to be honest I don't understand why this is so complicated to fix?
Isn't it enough to go forward from the original inflation period by
what the observation lag says to get the correct number of days for
the denominator in the interpolation formula? And this needs to be
corrected in any case, independent of the other stuff with the real
curve you are talking about?

Best Regards
Peter


On 9 February 2017 at 14:24, Charles Allderman <[hidden email]> wrote:
> Hi Francois
>
> I remember the discussion but we did not delve into the interpolation base
> issue then I think. Is the interpolation issue then the only issue? If I
> understand you correctly, I think I like the first method as it allows the
> user the option of passing in an inflation curve and the valuing off nominal
> should he so wish.
>
> Thanks
> Charles
>
> On Thu, Feb 9, 2017 at 2:57 PM, Francois Botha <[hidden email]> wrote:
>>
>> Hi,
>>
>> Charles, you might remember we had a chat about this about a year back.
>> Sadly, this illustrates my laziness and I have to do some more work on that
>> PR before it is ready for merging.
>>
>> PR50 is necessary if bonds are valued at the real curve, and the inflation
>> curve in the future is assume to be a flat 0. Past inflation fixings (since
>> issue date) allows for the rolling up until effective date. This is the
>> method that BESA prescribes in the ZA inflation linked bond valuation.
>>
>> The alternative way is to value the bond at the nominal curve, but then
>> you have to deduce the inflation curve yourself (difference between nominal
>> and real yield curves) and add the fixings as in the first method.
>>
>> I still wanted to thoroughly investigate whether the 2nd approach isn't a
>> better approach that wouldn't require PR50 before I cleaned up the PR.
>>
>> The above doesn't solve your issue, but I just wanted to explain why PR50
>> is still in limbo.
>>
>>
>>
>> Francois Botha
>>
>> On 9 February 2017 at 13:57, Peter Caspers <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> it’s not rounding, QuantLib calculates 123.92 = 123.8 + (124.2-123.8) x
>>> (10-1) / 30, i.e. takes November instead of February as the basis for the
>>> interpolation. This is due to a bug described here
>>>
>>>
>>> http://quantlib.10058.n7.nabble.com/Interpolated-ZeroInflationIndexes-td15507.html
>>>
>>> There is an attempt to solve that, but this is not yet merged
>>>
>>> https://github.com/lballabio/QuantLib/pull/50
>>>
>>> Looking at that I think we also need to fix the interpolation in
>>> CPICoupon, the code for this starts here
>>>
>>>
>>> https://github.com/lballabio/QuantLib/blob/master/ql/cashflows/cpicoupon.cpp#L88
>>>
>>> What do you think, Francois, Luigi?
>>>
>>> Kind Regards
>>> Peter
>>>
>>>
>>> On 08 Feb 2017, at 13:08, Charles Allderman <[hidden email]>
>>> wrote:
>>>
>>> Hi
>>>
>>> I am digging into the pricing of a CPIBond. I have this index CPI index
>>> time
>>> series:
>>>
>>> DATE
>>> 2016-08-31  123.0
>>> 2016-09-30  123.2
>>> 2016-10-31  123.8
>>> 2016-11-30  124.2
>>> 2016-12-31  124.7
>>>
>>> If I interpolate for 10 February 2017 I get:
>>> (10.0-1)/28.0*(124.2-123.8)+123.8
>>>
>>> 123.92857142857143
>>>
>>>
>>> Deriving the values as calculated by QuantLib using the last cash flow I
>>> get:
>>> principal*baseCPI/notional
>>>
>>> 123.92000000000002
>>>
>>>
>>> So it appears to be rounded down.
>>>
>>> The inflation index is simply created by passing in a vector of
>>> dates(month-end date plus 1 day) and values.
>>> inflationIndex.addFixings(dte_fixings[:len(fixData)], fixData)
>>>
>>> So is there a way to get the full interpolated value?
>>>
>>> Thanks
>>> Charles
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://quantlib.10058.n7.nabble.com/CPI-Time-Series-Interpolation-tp18062.html
>>> Sent from the quantlib-users mailing list archive at Nabble.com.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>>>
>>
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users