Bond.yield_to_maturity defaults to US_TREASURY while price and risk methods default to UK_DMO
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- backend, fintech-quant
Hướng nghiên cứu
Đọc quy ước mặc định trong financepy/products/bonds/bond.py và các bài kiểm thử trái phiếu bị ảnh hưởng, đặc biệt là tests/unit/test_bond_portfolio.py::test_11. Kiểm tra cách các phương thức định giá và rủi ro đặt giá trị mặc định, rồi tái hiện lượt đi và về giữa các ngày trả coupon. Hoàn tất khi các quy ước mặc định nhất quán, lượt đi và về được kiểm thử và kỳ vọng US_TREASURY hiện có được nêu rõ nếu cần giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 3.2k
- Fork
- 457
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của domokane/FinancePy
-
Build SOFR curve - suggestionsĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
-
Some swap suggestionsĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
-
Add Equity Vol productĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
-
Add Equity Autocallable productĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
-
FinEquityVolSurfacePlusĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Tất cả issue của domokane/FinancePy
Issue tương tự
-
Make the "%" unit spacing the same in the web and in A10Có thể đã có người làm @kragent66-glitch đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 bình luận ·
-
ci severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TMHSDigital/Spackle#205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pkg:lgm type:chore upstream-gaussx
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jejjohnson/pyrox#610 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
changelog investigate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ramnes/notion-sdk-py#523 ·
-
feature-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
open-telemetry/opentelemetry-python#5994 ·
Maintainer thường phản hồi trong vòng 2 ngày