← 返回题库
中级

债券久期

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve(____):
    coupon = face_value * coupon_rate
    price = sum(coupon / (____ + ytm) ** t for t in range(____, maturity + ____))
    price += face_value / (____ + ytm) ** maturity
    weighted_time = sum(t * coupon / (____ + ytm) ** t for t in range(____, maturity + ____))
    weighted_time += maturity * face_value / (____ + ytm) ** maturity
    duration = weighted_time / price
    return {"____": round(____), "____": round(____), "____": round(duration / (____ + ytm), ____)}

示例

输入
solve(1000, 0.05, 0.06, 5)
期望输出
{'债券价格': 957.88, '麦考利久期': 4.53, '修正久期': 4.27}
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码