matching EUR OIS to bloomberg with python

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

matching EUR OIS to bloomberg with python

vinnieb
Hi,

Apologies if I've made a basic error somewhere, but I've been banging my head against this problem for a while now!

I'd been trying to match curves from a different system with no joy, so instead gone back to Bloomberg, taken market rates for a given day and based on the EONIA bootstrapping example in the ql python cookbook, substituted in values and dates, largely using all the code as is there - just the deposit rate helper has a single 1day value, then the OISRateHelper populated out with 1wk, 2wk, onwards as per the Bloomberg screen.

Discount rates seem to match up to about the 4th or 5th decimal place, but I can't get accurately close to the zero rates. Is something wrong here (this is about the closest I can bring the zero rate to the bbg zero rate)

    for d in curve.dates():
            yrs = ql.Thirty360(ql.Thirty360.European).yearFraction(todaysDate, d)
            compounding = ql.Compounded
            freq = ql.Quarterly
            zero_rate = curve.zeroRate(yrs, compounding, freq)
            print(d, zero_rate.rate()*100, curve.discount(d))

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

Re: matching EUR OIS to bloomberg with python

Luigi Ballabio
Hi,
    can you share the data you're using (and possibly the rate you're trying to reproduce)?

Luigi


On Tue, Aug 2, 2016 at 11:22 AM vinnieb <[hidden email]> wrote:
Hi,

Apologies if I've made a basic error somewhere, but I've been banging my
head against this problem for a while now!

I'd been trying to match curves from a different system with no joy, so
instead gone back to Bloomberg, taken market rates for a given day and based
on the EONIA bootstrapping example in the ql python cookbook, substituted in
values and dates, largely using all the code as is there - just the deposit
rate helper has a single 1day value, then the OISRateHelper populated out
with 1wk, 2wk, onwards as per the Bloomberg screen.

Discount rates seem to match up to about the 4th or 5th decimal place, but I
can't get accurately close to the zero rates. Is something wrong here (this
is about the closest I can bring the zero rate to the bbg zero rate)

    for d in curve.dates():
            yrs =
ql.Thirty360(ql.Thirty360.European).yearFraction(todaysDate, d)
            compounding = ql.Compounded
            freq = ql.Quarterly
            zero_rate = curve.zeroRate(yrs, compounding, freq)
            print(d, zero_rate.rate()*100, curve.discount(d))

Thanks a lot!



--
View this message in context: http://quantlib.10058.n7.nabble.com/matching-EUR-OIS-to-bloomberg-with-python-tp17631.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: matching EUR OIS to bloomberg with python

vinnieb
Hi Luigi,

I've come up with a data set that replicates the shape of the curve I'm interested in without being an actual copy (just playing it safe on data rights). Not sure if there is a format that helps, so I've just pasted as is from the Python code below. When I look at something similar in Bloomberg, I see a pretty tight tracking of zero rate to market rate with perhaps deviation at the 3rd decimal place, but when I calculate from those same market rates I get a big difference at the 2nd decimal between QL zero rates and bloomberg, and the same when I try compared to the other system I'm looking at.  I don't know if there's either a solver accuracy threshold value that I need to set somewhere, or a mistake in code assumptions below maybe? I thought maybe interpolation method but I've tried a few variations on that without any significant improvement.

marketData = [(-0.34, (1,ql.Weeks)), (-0.34, (2,ql.Weeks)),
                  (-0.335, (1,ql.Months)), (-0.34, (2,ql.Months)),
                  (-0.34, (3,ql.Months)), (-0.34, (4,ql.Months)),
                  (-0.35, (5,ql.Months)), (-0.36, (6,ql.Months)),
                  (-0.362, (7,ql.Months)), (-0.366, (8,ql.Months)),
                  (-0.36, (9,ql.Months)), (-0.37, (10,ql.Months)),
                  (-0.375, (11,ql.Months)), (-0.378, (12,ql.Months)),
                  (-0.38, (18,ql.Months)), (-0.39, (2,ql.Years)),
                  (-0.38, (30,ql.Months)),
                  (-0.37, (3,ql.Years)), (-0.31, (4,ql.Years)),
                  (-0.25, (5,ql.Years)), (-0.15, (6,ql.Years)),
                  (-0.05, (7,ql.Years)), (0.05, (8,ql.Years)),
                  (0.15, (9,ql.Years)), (0.25, (10,ql.Years)),
                  (0.35, (11,ql.Years)), (0.45, (12,ql.Years)),
                  (0.60, (15,ql.Years)), (0.75, (20,ql.Years)),
                  (0.8, (25,ql.Years)), (0.84, (30,ql.Years)),
                  (0.85, (35,ql.Years)), (0.84, (40,ql.Years)),
                  (0.75, (50,ql.Years))]

rest of the code:
    todaysDate = ql.Date(6,ql.July,2016)
    ql.Settings.instance().evaluationDate = todaysDate

    OIShelpers = [ ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate/100)),
                                          ql.Period(1,ql.Days), fixingDays,
                                          ql.TARGET(), ql.Following, False, ql.Actual360())
                        for rate, fixingDays in [(-0.33, 0) ] ]
    eonia = ql.Eonia()
    OIShelpers += [ ql.OISRateHelper(2, ql.Period(*tenor),
                                       ql.QuoteHandle(ql.SimpleQuote(rate/100)), eonia)
                         for rate, tenor in marketData ]
    eonia_curve = ql.PiecewiseLogCubicDiscount(0, ql.TARGET(), OIShelpers, ql.Actual365Fixed())    
    eonia_curve.enableExtrapolation()

And then data extracted via the code snippet in the original message.

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

Re: matching EUR OIS to bloomberg with python

Luigi Ballabio
Hi,
    apologies---I lost track of your email during vacations. Did you make any progress, or should I still look into this?

Luigi

On Wed, Aug 3, 2016 at 8:11 PM vinnieb <[hidden email]> wrote:
Hi Luigi,

I've come up with a data set that replicates the shape of the curve I'm
interested in without being an actual copy (just playing it safe on data
rights). Not sure if there is a format that helps, so I've just pasted as is
from the Python code below. When I look at something similar in Bloomberg, I
see a pretty tight tracking of zero rate to market rate with perhaps
deviation at the 3rd decimal place, but when I calculate from those same
market rates I get a big difference at the 2nd decimal between QL zero rates
and bloomberg, and the same when I try compared to the other system I'm
looking at.  I don't know if there's either a solver accuracy threshold
value that I need to set somewhere, or a mistake in code assumptions below
maybe? I thought maybe interpolation method but I've tried a few variations
on that without any significant improvement.

marketData = [(-0.34, (1,ql.Weeks)), (-0.34, (2,ql.Weeks)),
                  (-0.335, (1,ql.Months)), (-0.34, (2,ql.Months)),
                  (-0.34, (3,ql.Months)), (-0.34, (4,ql.Months)),
                  (-0.35, (5,ql.Months)), (-0.36, (6,ql.Months)),
                  (-0.362, (7,ql.Months)), (-0.366, (8,ql.Months)),
                  (-0.36, (9,ql.Months)), (-0.37, (10,ql.Months)),
                  (-0.375, (11,ql.Months)), (-0.378, (12,ql.Months)),
                  (-0.38, (18,ql.Months)), (-0.39, (2,ql.Years)),
                  (-0.38, (30,ql.Months)),
                  (-0.37, (3,ql.Years)), (-0.31, (4,ql.Years)),
                  (-0.25, (5,ql.Years)), (-0.15, (6,ql.Years)),
                  (-0.05, (7,ql.Years)), (0.05, (8,ql.Years)),
                  (0.15, (9,ql.Years)), (0.25, (10,ql.Years)),
                  (0.35, (11,ql.Years)), (0.45, (12,ql.Years)),
                  (0.60, (15,ql.Years)), (0.75, (20,ql.Years)),
                  (0.8, (25,ql.Years)), (0.84, (30,ql.Years)),
                  (0.85, (35,ql.Years)), (0.84, (40,ql.Years)),
                  (0.75, (50,ql.Years))]

rest of the code:
    todaysDate = ql.Date(6,ql.July,2016)
    ql.Settings.instance().evaluationDate = todaysDate

    OIShelpers = [
ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate/100)),
                                          ql.Period(1,ql.Days), fixingDays,
                                          ql.TARGET(), ql.Following, False,
ql.Actual360())
                        for rate, fixingDays in [(-0.33, 0) ] ]
    eonia = ql.Eonia()
    OIShelpers += [ ql.OISRateHelper(2, ql.Period(*tenor),

ql.QuoteHandle(ql.SimpleQuote(rate/100)), eonia)
                         for rate, tenor in marketData ]
    eonia_curve = ql.PiecewiseLogCubicDiscount(0, ql.TARGET(), OIShelpers,
ql.Actual365Fixed())
    eonia_curve.enableExtrapolation()

And then data extracted via the code snippet in the original message.

Thanks a lot!



--
View this message in context: http://quantlib.10058.n7.nabble.com/matching-EUR-OIS-to-bloomberg-with-python-tp17631p17634.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users