Pythonquantlib
設置 OvernightIndex Quantlib
不知何故,我在關於在 QuantLib 中設置隔夜指數的舊問題上苦苦掙扎(請參閱問題:舊問題)。我不明白的是如何設置
curve_handle
:index = OvernightIndex("EONIA", 0, EURCurrency(), TARGET(), Actual360(), curve_handle)
我有一組新加坡隔夜指數聲納的數據。我現在不知道如何設置,
curve_handle
在下面的範例中標記為xxxxx。我想我可以把它排除在外,如下所示。程式碼如下所示:import QuantLib as ql todaysDate = ql.Date(10, ql.December, 2017) ql.Settings.instance().evaluationDate = todaysDate calendar = ql.Singapore() dayCounter_Act365 = ql.Actual365() settlement_days_sonar = 2 SGD_SONAT_OIS = ql.OvernightIndex("SONAR", settlement_days_sonar, ql.SGDCurrency(), calendar, dayCounter_Act365) #-------------------------------------------------------------------- # Discounting curve #-------------------------------------------------------------------- # setup DepositRateHelper for 0-1 days helpers_disc = [ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate/100)), ql.Period(1,ql.Days), fixingDays, calendar, ql.ModifiedFollowing, False, ql.Actual365()) for rate, fixingDays in [(0.081, 0)]] # Overnight Index Swap rate # setup OISRateHelper for 1,2,3 weeks and 1 month helpers_disc += [ql.OISRateHelper(settlement_days_sonar, ql.Period(*tenor), ql.QuoteHandle(ql.SimpleQuote(rate/100)), SGD_SONAT_OIS) for rate, tenor in [(0.0713, (1,ql.Weeks)), (0.0688, (2,ql.Weeks)), (0.0663, (3,ql.Weeks))]] # OIS quotes up to 30 years # setup OISRateHelper from 1 months to 30 years helpers_disc += [ql.OISRateHelper(settlement_days_sonar, ql.Period(*tenor), ql.QuoteHandle(ql.SimpleQuote(rate/100)), SGD_SONAT_OIS) for rate, tenor in [(0.0656, (1,ql.Months)), (0.0613 , (2,ql.Months)), (0.06 , (3,ql.Months)), (0.0563 , (4,ql.Months)), (0.055 , (5,ql.Months)), (0.0538 , (6,ql.Months)), (0.3356 , (9,ql.Years)), (0.3806 , (10,ql.Years)), (0.4938 , (12,ql.Years)), (0.6888 , (15,ql.Years)), (0.965 , (20,ql.Years)), (1.1081 , (25,ql.Years)), (1.1831, (30,ql.Years))]] sonar_curve = ql.PiecewiseLogCubicDiscount(date, helpers_disc, ql.Actual365()) sonar_curve.enableExtrapolation()
您可以在曲線的引導過程中將其排除在外。在這種情況下,索引僅用於詢問其約定。
稍後,如果您想預測指數固定,您可以使用您引導的曲線初始化句柄並將其傳遞給指數。