コンテンツへスキップ
ライブラリの全資料

補間したイールドカーブから割引係数を取得する

記事 Quant Q&A · 著者: Mike

サマリー

この文書では、QuantLibの割引曲線を構築する際に使った、提示満期の間の日付について割引係数を取得する方法を示します。スワップレートを入力して区分的な対数線形の割引曲線を構築した後、例では将来の日付を並べ、各日付について曲線のdiscountメソッドを呼び出します。得られた値は曲線を等間隔でサンプリングしたもので、日付と並べて表示できます。

質問では半年間隔を求めていますが、例のコードは5年間隔でサンプリングしています。日付の増分を6か月にすれば、同じ方法を使えます。2つ目の回答は、曲線から任意の日付の割引係数を取得できるため、元の曲線ノードに出力を限定する必要はないと説明しています。この例では合成のスウェーデンクローナのスワップデータを使い、最後の入力期間を超えた外挿を有効にしています。そのため、出力が示すのはAPIの使い方であり、市場の実証データではありません。また、外挿値は曲線の前提と設定に左右されます。

主なアイデア

  • 構築した割引曲線から、入力した満期ノードの間の日付についても割引係数を取得できます。
  • 希望する日付間隔を選び、各日付について曲線に問い合わせます。
  • 例は5年刻みでサンプリングしていますが、日付の増分を変えれば半年間隔にできます。
  • 最後の曲線ノードを超える割引係数は外挿設定に依存する場合があるため、その点を踏まえて解釈してください。

タグ

全文
# QuantLib Python - Discount Factor Interpolation within curve nodes


# QuantLib Python - Discount Factor Interpolation within curve nodes












Generated a discount curve, dCurve.PiecewiseLogLinearDiscount() using input par rate for terms (.5Y, 1Y, 2Y, 3Y, 5Y, 7Y, 10Y, 15Y, 20Y, 30Y) and output discount curve matching the input term structure. Any suggestions on how to output the discount factor curve on a .5Y interval term structure up to 30Y?

## Answer by Xiarpedia (score 1)

https://quant.stackexchange.com/a/77563

Based on your question I created the following curve example:

```
import QuantLib as ql
import pandas as pd

# Set the evaluation date
ql.Settings.instance().evaluationDate = ql.Date(30, 12, 2022)
# Declare a store variable for the helpers
helpers = []
# Create the attributes of the swap
calendar = ql.Sweden()
frequency = ql.Annual
convention = ql.ModifiedFollowing
# Synthetic market data
daycount = ql.Thirty360(ql.Thirty360.BondBasis)
index = ql.IborIndex(
    "MyIndex",
    ql.Period("3M"),
    2,
    ql.SEKCurrency(),
    calendar,
    ql.Following,
    False,
    daycount,
)

tenor = ["4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "12Y", "15Y", "20Y", "25Y", "30Y"]
quotes = [
    3.33,
    3.2775,
    3.235,
    3.205,
    3.1775,
    3.1525,
    3.1325,
    3.095,
    3.0275,
    2.92,
    2.815,
    2.6925,
]
for r, m in zip(quotes, tenor):
    rate = ql.QuoteHandle(ql.SimpleQuote(r / 100.0))
    tenor = ql.Period(m)
    helpers.append(
        ql.SwapRateHelper(
            rate, tenor, calendar, frequency, convention, daycount, index
        )
    )
curve = ql.PiecewiseLogLinearDiscount(0, calendar, helpers, ql.Actual365Fixed())
curve.enableExtrapolation()
dates, rates = zip(*curve.nodes())
```

Which leaves me at the stage you are at. We can then interpolate on a 5 year interval as following:

```
# Interpolate on a 5Y interval
nodes = []
start_date = ql.Date(30, 12, 2022)
while True:
    start_date += ql.Period("5Y")
    nodes.append(start_date)
    if start_date > ql.Date(30, 12, 2053):
        break
discount_factors = [curve.discount(d) for d in nodes]
display(pd.DataFrame(dict({"Date": nodes, "Discount Factor": discount_factors})))
```

Which results in:

|  | Date | Discount Factor |
| 0 | December 30th, 2027 | 0.851205 |
| 1 | December 30th, 2032 | 0.735589 |
| 2 | December 30th, 2037 | 0.641855 |
| 3 | December 30th, 2042 | 0.567462 |
| 4 | December 30th, 2047 | 0.508218 |
| 5 | December 30th, 2052 | 0.464726 |
| 6 | December 30th, 2057 | 0.424997 |

## Answer by Luigi Ballabio (score 0)

https://quant.stackexchange.com/a/77564

You can pass any date you like to the `discount` method of the curve you built. It will return the corresponding discount factor.

出典を明記したうえで、ライセンスに従って全文を掲載しています。 ライセンス: CC BY-SA 4.0 (Stack Exchange)

この要約は原文をもとにStratmillのリサーチエージェントが作成したもので、出典の複製ではありません。