|
From: Luís M. A. <lui...@gm...> - 2020-06-17 21:26:44
|
Sorry miss pasted a part of the code, here is it fully (missed part is in
bold):
*today = ql.Date(9, 6, 2020)*
*ql.Settings.instance().evaluationDate = todayON = today + ql.Period('1D')*
*A = list(ql.Schedule(ql.Date(1, today.month(), 2020), ql.Date(1, 11,
2021), ql.Period(ql.Monthly), ql.UnitedStates(),
ql.Unadjusted, ql.Unadjusted, ql.DateGeneration.Forward,
False))*
*I have the following instruments:- 1 overnight deposit - From 9/6/2020 to
10/6/2020-17 1month FF futures - First is the June contract 2020 contract,
second is July 2020, .. *
*FF_schedule = [today] + A*
*Start = FF_schedule[:-1]*
*End = [ON] + FF_schedule[2:]*
*Tenor = ['OIS', 'FF1', 'FF2', 'FF3', 'FF4', 'FF5', 'FF6', 'FF7', 'FF8',
'FF9', 'FF10', 'FF11', 'FF12', 'FF13', 'FF14', 'FF15', 'FF16',
'FF17']*
*Mids = [0.070, 99.92375, 99.9225, 99.9275, 99.9325, 99.9425, 99.9475,
99.9475, 99.9525, 99.9625, 99.9650, 99.9625, 99.9725, 99.9775, 99.9975,
99.9825, 99.9800, 99.9750]*
*calendar = ql.NullCalendar()dc = ql.ActualActual()bc =
ql.Followingsettlement_date = todaysettlementDays = 1end_of_month =
Truehelpers = []depo_helper =
[ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(Tenor_Rates['OIS']/100)),
ql.Period(ON - today, ql.Days),
settlementDays, calendar, bc, end_of_month, dc)]helpers += depo_helper*
*#Just organising the dates*
*fed_funds = ql.FedFunds()Start_Futures = [Start[0]] + Start[2:]End_Futures
= End[1:]Futures_Mids = Mids[1:]Futures_Rates = [100-i for i in
Futures_Mids]*
*#Using Sofr_Future_Rate_HelperOvernightIndex = ql.Sofr()Sofr_data = []for
i in range(len(End_Futures)): Sofr_data.append([Futures_Mids[i],
End_Futures[i].month(), End_Futures[i].year()])referenceFreq = ql.Monthly
futures_helper =
[ql.SofrFutureRateHelper(ql.QuoteHandle(ql.SimpleQuote(Futures_Mid)),
reference_month, reference_year,
referenceFreq, OvernightIndex) for Futures_Mid,
reference_month, reference_year in Sofr_data]
helpers_with_SOFR_Future_Rate_Helpers += sofr_future_helper*
*OIS_Curve = ql.PiecewiseLogLinearDiscount(today, futures_helper , dc)*
Kind regards,
Luis
On Wed, Jun 17, 2020 at 10:19 PM Luís Miguel Aguiar <
lui...@gm...> wrote:
> Good evening everyone,
>
> I have been trying to use the SofrFutureRateHelper class but am having
> some trouble with it and was hoping I could post my doubt here.
>
> As it is quite recent (only in Version 1.18), I have trouble finding
> examples online, plus I am doing it in Python and not C++, where examples
> are scarcer.
>
> Could anyone be so kind to point out where I am wrong in the code?
>
> When I see the discount factors of the pillars, I see it is giving me
> quite different results than the following:
>
> Tenor Start End Mid FRA DF (in End
> Date)
> OIS 9/6/20 10/6/20 0.070% 0.070% a
> FF1 1/6/20 1/7/20 99.92375 0.07625% b
> FF2 1/7/20 1/8/20 99.9225 0.0775% c
> FF3 1/8/20 1/9/20 99.9275 0.0725% d
> FF4 1/9/20 1/10/20 99.9325 0.0675% e
> .................
> FF17 1/10/21 1/11/21 99.9750 0.0250%
>
> a = 1/(1+0.070%*(10/6/20 - 9/6/20)/366) = 0.9999980874353520
> b = 1/(1+0.07625%*(1/7/20-9/6/20)/366) = 0.9999541687672650
> c = b/(1+0.0775%*(1/8/20-1/7/20)/366 = 0.9998885340076210
> d = c/(1+0.0725%*(1/9/20-1/8/20)/366 = 0.9998271375187800
> e = d/(1+0.0675%*(1/10/20-1/9/20)/366 = 0.9997718222745150
>
> So for all my pillars (1 ON deposit rate and 17 futures) the correct DFs
> should be
>
> Correct_DFs = [0.9999980874353520, 0.9999541687672650,
> 0.9998885340076210,
> 0.9998271375187800, 0.9997718222745150, 0.9997231335727230,
> 0.9996801145514000, 0.9996356635393120,
> 0.9995953373986460,
> 0.9995665827435260, 0.9995368704831300,
> 0.9995060637893830,
> 0.9994827197066830, 0.9994642364639530, 0.9994451374781070,
> 0.9994302829321210, 0.9994138542112300,
> 0.9993926342306400]
>
> I cannot seem to replicate the correct answers with the following code:
>
>
>
>
> *today = ql.Date(9, 6, 2020)ql.Settings.instance().evaluationDate =
> todayON = today + ql.Period('1D')*
>
>
>
>
> *A = list(ql.Schedule(ql.Date(1, today.month(), 2020), ql.Date(1, 11,
> 2021), ql.Period(ql.Monthly), ql.UnitedStates(),
> ql.Unadjusted, ql.Unadjusted,
> ql.DateGeneration.Forward, False))*
>
>
>
> *I have the following instruments:- 1 overnight deposit - From 9/6/2020 to
> 10/6/2020-17 1month FF futures - First is the June contract 2020 contract,
> second is July 2020, .. *
>
>
> *Tenor = ['OIS', 'FF1', 'FF2', 'FF3', 'FF4', 'FF5', 'FF6', 'FF7', 'FF8',
> 'FF9', 'FF10', 'FF11', 'FF12', 'FF13', 'FF14', 'FF15', 'FF16',
> 'FF17']*
>
>
> *Mids = [0.070, 99.92375, 99.9225, 99.9275, 99.9325, 99.9425, 99.9475,
> 99.9475, 99.9525, 99.9625, 99.9650, 99.9625, 99.9725, 99.9775, 99.9975,
> 99.9825, 99.9800, 99.9750]*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *calendar = ql.NullCalendar()dc = ql.ActualActual()bc =
> ql.Followingsettlement_date = todaysettlementDays = 1end_of_month =
> Truehelpers = []depo_helper =
> [ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(Tenor_Rates['OIS']/100)),
> ql.Period(ON - today, ql.Days),
> settlementDays, calendar, bc, end_of_month, dc)]helpers += depo_helper*
>
> *#Just organising the dates*
>
>
>
>
>
> *fed_funds = ql.FedFunds()Start_Futures = [Start[0]] +
> Start[2:]End_Futures = End[1:]Futures_Mids = Mids[1:]Futures_Rates = [100-i
> for i in Futures_Mids]*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *#Using Sofr_Future_Rate_HelperOvernightIndex = ql.Sofr()Sofr_data = []for
> i in range(len(End_Futures)): Sofr_data.append([Futures_Mids[i],
> End_Futures[i].month(), End_Futures[i].year()])referenceFreq = ql.Monthly
> futures_helper =
> [ql.SofrFutureRateHelper(ql.QuoteHandle(ql.SimpleQuote(Futures_Mid)),
> reference_month, reference_year,
> referenceFreq, OvernightIndex) for Futures_Mid,
> reference_month, reference_year in Sofr_data]
> helpers_with_SOFR_Future_Rate_Helpers += sofr_future_helper*
>
>
> *OIS_Curve = ql.PiecewiseLogLinearDiscount(today, futures_helper , dc)*
>
> Sorry for the lengthy doubt and possibly inefficient code. I have just
> been trying to get it right the past few days and unfortunately made no
> progress.
>
> Kind regards,
> Luis Aguiar
>
|