BLS Theta

BLS Theta 期权价值对到期时间变化的敏感度
根据标的资产价格、行权价、无风险利率、到期时间与波动率,使用布莱克-斯科尔斯模型计算看涨与看跌期权的 Theta(期权价值对时间流逝的敏感度,以年为单位)。
计算结果
点击「计算」查看输出
code 计算逻辑代码
以下为「ISDA国际通用」BLS Theta 的 Python 代码示例(基于 QuantLib)。

# 依赖版本:
# python==3.9
# QuantLib==1.43
import math
import traceback
import QuantLib as ql

def qjquant_calu_blstheta(
    price: float,
    strike: float,
    rate: float,
    time: float,
    volatility: float,
    yield_rate: float = 0.0,
):
    try:
        # ---------- 参数校验 ----------
        if price <= 0 or strike <= 0:
            return {"ok": False, "msg": "标的价格与行权价必须大于 0"}
        if rate < 0:
            return {"ok": False, "msg": "无风险利率不能为负"}
        if time <= 0:
            return {"ok": False, "msg": "到期时间必须大于 0"}
        if volatility <= 0:
            return {"ok": False, "msg": "波动率必须大于 0"}

        # ---------- 构建 BlackCalculator 所需标量 ----------
        forward = price * math.exp((rate - yield_rate) * time)
        std_dev = volatility * math.sqrt(time)
        discount = math.exp(-rate * time)

        # ---------- 计算看涨期权 Theta ----------
        call_payoff = ql.PlainVanillaPayoff(ql.Option.Call, strike)
        call_calc = ql.BlackCalculator(call_payoff, forward, std_dev, discount)
        # QuantLib theta 的符号已与 MATLAB blstheta 一致,直接使用
        call_theta = call_calc.theta(price, time)

        # ---------- 计算看跌期权 Theta ----------
        put_payoff = ql.PlainVanillaPayoff(ql.Option.Put, strike)
        put_calc = ql.BlackCalculator(put_payoff, forward, std_dev, discount)
        put_theta = put_calc.theta(price, time)

        return {
            "ok": True,
            "call_theta": round(call_theta, 4),
            "put_theta": round(put_theta, 4),
        }

    except ValueError as ve:
        traceback.print_exc()
        return {"ok": False, "msg": f"参数错误: {ve}"}
    except Exception as e:
        traceback.print_exc()
        return {"ok": False, "msg": f"未知错误: {e}"}


# ============================================================
# 示例:复制本文件后直接运行
# ============================================================
if __name__ == "__main__":
    print("=" * 60)
    print("示例 1:标准欧式期权(无股息,平值附近)")
    print("=" * 60)
    r1 = qjquant_calu_blstheta(
        price=100.0,
        strike=100.0,
        rate=0.05,
        time=1.0,
        volatility=0.2,
        yield_rate=0.0,
    )
    print(r1)

    print()
    print("=" * 60)
    print("示例 2:含股息率的欧式期权(半年期限)")
    print("=" * 60)
    r2 = qjquant_calu_blstheta(
        price=100.0,
        strike=95.0,
        rate=0.03,
        time=0.5,
        volatility=0.25,
        yield_rate=0.02,
    )
    print(r2)

    print()
    print("=" * 60)
    print("示例 3:深度实值看涨期权(高波动、长到期)")
    print("=" * 60)
    r3 = qjquant_calu_blstheta(
        price=120.0,
        strike=80.0,
        rate=0.04,
        time=2.0,
        volatility=0.3,
        yield_rate=0.01,
    )
    print(r3)

    print()
    print("=" * 60)
    print("示例 4:深度虚值看跌期权(低波动、短到期)")
    print("=" * 60)
    r4 = qjquant_calu_blstheta(
        price=100.0,
        strike=120.0,
        rate=0.02,
        time=0.25,
        volatility=0.15,
        yield_rate=0.0,
    )
    print(r4)