0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

QuantLibのダウンキャスト

Posted at

QuantLibでダウンキャストする際の関数一覧。QuantLib 1.30で確認。たぶん完成しないので随時更新。

メソッド一覧

キャッシュフロー

メソッド キャスト先 備考
as_capped_floored_yoy_inflation_coupon
as_coupon Coupon as_redemptionは無い
as_cpi_cashflow
as_cpi_coupon
as_fixed_rate_coupon FixedRateCoupon
as_floating_rate_coupon FloatingRateCoupon
as_indexed_cashflow
as_inflation_coupon
as_overnight_indexed_coupon
as_sub_periods_coupon
as_yoy_inflation_coupon
as_zero_inflation_cash_flow

インデックス

メソッド キャスト先 備考
as_iborindex IborIndex
as_overnight_swap_index
as_swap_index
as_zero_inflation_index

ヘルパー

メソッド キャスト先 備考
as_black_helper
as_constnotionalcrosscurrencybasisswapratehelper
as_depositratehelper
as_fraratehelper
as_mtmcrosscurrencybasisswapratehelper
as_oisratehelper
as_swapratehelper
as_swaption_helper

その他

メソッド キャスト先 備考
as_gsr_process
as_plain_vanilla_payoff

使用例

債券キャッシュフローからクーポンキャッシュフローのみを抽出

input
import QuantLib as ql

bond = ql.FixedRateBond(
    2,                      # settlementDays
    ql.TARGET(),            # calendar
    100.0,                  # faceAmount
    ql.Date(15,12,2020),    # startDate
    ql.Date(15,12,2022),    # maturityDate
    ql.Period(6, ql.Months),# tenor
    [0.05],                 # coupon   
    ql.Actual365Fixed()     # paymentConvention
)

[(cf.date(), cf.amount()) for cf in bond.cashflows() if ql.as_coupon(cf) is not None]
output
[(Date(15,6,2021), 2.4931506849315),
 (Date(15,12,2021), 2.5068493150684823),
 (Date(15,6,2022), 2.4931506849315),
 (Date(15,12,2022), 2.5068493150684823)]

変動利付債から金利指標を取り出す

ql.as_floating_rate_coupon(cashdlow).indexで金利指標を取り出す。さらに、ql.as_iborindex()iborに。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?