Bond.yield_to_maturity defaults to US_TREASURY while price and risk methods default to UK_DMO
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 66/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- backend, fintech-quant
調査の方向性
financepy/products/bonds/bond.py のデフォルト規約と、影響を受ける債券テスト、特に tests/unit/test_bond_portfolio.py::test_11 を読む。価格評価メソッドとリスクメソッドがどのようにデフォルト値を設定しているかを確認し、クーポン日間の往復を再現する。デフォルト規約に一貫性があり、往復がテストでカバーされ、既存の US_TREASURY に関する期待値を維持する場合は明示されていれば完了。
索引モデルが issue の本文から書いたものです。
説明
Bond.yield_to_maturity uses convention=YTMCalcType.US_TREASURY by default, but clean_price_from_ytm, dirty_price_from_ytm, modified_duration, macaulay_duration, dollar_duration, dv01, convexity_from_ytm and theta all default to YTMCalcType.UK_DMO. With default arguments, a price-to-yield round trip does not return the yield you started from, and a yield from yield_to_maturity is then fed into risk measures that assume a different convention.
The two conventions differ in how the fractional first period is discounted (simple interest for US_TREASURY, compounded for UK_DMO), so the gap shows up whenever settlement is between coupon dates.
from financepy.utils import Date, FrequencyTypes, DayCountTypes
from financepy.products.bonds.bond import Bond
bond = Bond(Date(15, 5, 2020), Date(15, 5, 2030), 0.05,
FrequencyTypes.SEMI_ANNUAL, DayCountTypes.THIRTY_E_360)
settle = Date(15, 8, 2025)
clean = bond.clean_price_from_ytm(settle, 0.06) # default UK_DMO
ytm = bond.yield_to_maturity(settle, clean) # default US_TREASURY
print(f"{ytm:.6f}") # 0.059973, not 0.060000
So the default round trip is off by about 2.7 bp for this bond. On a coupon date, the two agree.
Is the different default intended? If not, the smallest fix is to make yield_to_maturity default to UK_DMO, like the other Bond methods. I tried that locally: 184 of the 185 bond unit tests pass. The one that changes is tests/unit/test_bond_portfolio.py::test_11, which pins the US_TREASURY default (0.7639% becomes 0.7640%). It would need to pass convention=YTMCalcType.US_TREASURY explicitly to keep testing that value.
Since this changes the default output for existing users, I wanted to check before opening a PR. I'm happy to send it, or to go the other way (for example, a note in the docstring) if you prefer.
- 主要言語
- Python
- スター
- 3.2k
- フォーク
- 457
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
domokane/FinancePy のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
domokane/FinancePy の issue をすべて見る
似ている issue
-
Make the "%" unit spacing the same in the web and in A10対応中かも @kragent66-glitch が今日担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
maiychrus25/OpenTea-DX-OS#226 · コメント 1 件 ·
-
ci severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TMHSDigital/Spackle#205 ·
メンテナーはふだん 1 日以内に返信
-
pkg:lgm type:chore upstream-gaussx
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
jejjohnson/pyrox#610 ·
メンテナーはふだん 1 日以内に返信
-
changelog investigate
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ramnes/notion-sdk-py#523 ·
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
open-telemetry/opentelemetry-python#5994 ·
メンテナーはふだん 2 日以内に返信