Black 期货期权定价
欧式看涨/看跌期货期权的理论价格
根据期货价格、行权价、无风险利率、到期时间与波动率,使用布莱克模型计算欧式看涨与看跌期货期权的理论价格。Black 模型直接以期货价格为标的,无需额外输入标的收益率。
计算结果
点击「计算」查看输出
code
计算逻辑代码
以下为「ISDA国际通用」Black 期货期权定价的 Python 代码示例(基于 QuantLib)。
# 依赖版本:
# python==3.9
# QuantLib==1.43
import math
import traceback
import QuantLib as ql
def qjquant_calu_blkprice(
price: float,
strike: float,
rate: float,
time: float,
volatility: float,
):
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 所需标量 ----------
# Black 模型中,forward 就是期货价格本身
forward = price
# 标准差 = σ * sqrt(T)
std_dev = volatility * math.sqrt(time)
# 折现因子 = exp(-r * T)
discount = math.exp(-rate * time)
# ---------- 计算看涨期货期权价格 ----------
call_payoff = ql.PlainVanillaPayoff(ql.Option.Call, strike)
call_calc = ql.BlackCalculator(call_payoff, forward, std_dev, discount)
call_price = call_calc.value()
# ---------- 计算看跌期货期权价格 ----------
put_payoff = ql.PlainVanillaPayoff(ql.Option.Put, strike)
put_calc = ql.BlackCalculator(put_payoff, forward, std_dev, discount)
put_price = put_calc.value()
return {
"ok": True,
"call_price": round(call_price, 4),
"put_price": round(put_price, 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_blkprice(
price=100.0,
strike=100.0,
rate=0.05,
time=1.0,
volatility=0.2,
)
print(r1)
print()
print("=" * 60)
print("示例 2:期货价格高于行权价(看涨实值)")
print("=" * 60)
r2 = qjquant_calu_blkprice(
price=105.0,
strike=95.0,
rate=0.03,
time=0.5,
volatility=0.25,
)
print(r2)
print()
print("=" * 60)
print("示例 3:期货价格低于行权价(看跌实值)")
print("=" * 60)
r3 = qjquant_calu_blkprice(
price=90.0,
strike=110.0,
rate=0.04,
time=2.0,
volatility=0.3,
)
print(r3)
print()
print("=" * 60)
print("示例 4:短到期、低波动")
print("=" * 60)
r4 = qjquant_calu_blkprice(
price=100.0,
strike=100.0,
rate=0.02,
time=0.25,
volatility=0.15,
)
print(r4)