← 返回题库
中级

隐含波动率

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve(____):
    import math
    from math import erf
    N = lambda x: ____ * (____ + erf(x / math.sqrt(____)))
    def bs_price(____):
        d1 = (math.log(____) + (____) * T) / (sigma * math.sqrt(____))
        d2 = d1 - sigma * math.sqrt(____)
        if option_type == "____":
            return S * N(____) - K * math.exp(____) * N(____)
        else:
            return K * math.exp(____) * N(____) - S * N(____)
    sigma_low, sigma_high = ____, ____
    for _ in range(____):
        sigma_mid = (____) / ____
        price = bs_price(____)
        if abs(____) < ____:
            break
        if price > market_price:
            sigma_high = sigma_mid
        else:
            sigma_low = sigma_mid
    return {"____": market_price, "____": round(____)}

示例

输入
solve(100, 100, 0.05, 1, 12, "call")
期望输出
{'市场价': 12, '隐含波动率': 0.2549}
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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