Black-Scholes 選擇權定價模型

Black-Scholes 模型是選擇權定價的基石。由 Fischer Black 和 Myron Scholes 在 1973 年提出,這項發現後來為他們贏得了諾貝爾經濟學獎。

🔥 Vibe Prompt

「用 Python 實作 Black-Scholes 模型,計算歐式 Call 與 Put 選擇權的理論價格。輸入參數包含股票價格、履約價、到期時間、無風險利率、波動率。並計算選擇權的內含價值與時間價值。」

模型公式

對於歐式選擇權(只能在到期日執行),Black-Scholes 公式為:

Call 選擇權價格

$$C = S_0 N(d_1) - K e^{-rT} N(d_2)$$

Put 選擇權價格

$$P = K e^{-rT} N(-d_2) - S_0 N(-d_1)$$

其中: $$d_1 = \frac{\ln(S_0/K) + (r + \sigma^2/2)T}{\sigma\sqrt{T}}$$ $$d_2 = d_1 - \sigma\sqrt{T}$$

| 變數 | 說明 | |------|------| | $S_0$ | 當前股價 | | $K$ | 履約價 (Strike Price) | | $T$ | 到期時間(年) | | $r$ | 無風險利率 | | $\sigma$ | 波動率 (Volatility) | | $N(\cdot)$ | 標準常態分配的累積分布函數 |

Python 實作

import math
from scipy.stats import norm

def black_scholes(S, K, T, r, sigma, option_type='call'):
    """
    計算歐式選擇權的 Black-Scholes 價格
    
    Parameters:
    S: 當前股價
    K: 履約價
    T: 到期時間(年)
    r: 無風險利率
    sigma: 波動率
    option_type: 'call' 或 'put'
    """
    d1 = (math.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * math.sqrt(T))
    d2 = d1 - sigma * math.sqrt(T)
    
    if option_type == 'call':
        price = S * norm.cdf(d1) - K * math.exp(-r * T) * norm.cdf(d2)
    else:
        price = K * math.exp(-r * T) * norm.cdf(-d2) - S * norm.cdf(-d1)
    
    return price

# 範例
S = 100      # 當前股價 100
K = 105      # 履約價 105
T = 0.5      # 半年到期
r = 0.05     # 5% 無風險利率
sigma = 0.2  # 20% 波動率

call_price = black_scholes(S, K, T, r, sigma, 'call')
put_price = black_scholes(S, K, T, r, sigma, 'put')

print(f"Call 選擇權價格: ${call_price:.2f}")
print(f"Put 選擇權價格: ${put_price:.2f}")
print(f"內含價值 (Call): ${max(S - K, 0):.2f}")
print(f"時間價值 (Call): ${call_price - max(S - K, 0):.2f}")

敏感性分析

import numpy as np
import matplotlib.pyplot as plt

def plot_option_price_by_stock():
    """繪製選擇權價格與股價關係"""
    stock_prices = np.linspace(50, 150, 100)
    K = 100
    
    call_prices = [black_scholes(S, K, 0.5, 0.05, 0.2, 'call') for S in stock_prices]
    put_prices = [black_scholes(S, K, 0.5, 0.05, 0.2, 'put') for S in stock_prices]
    
    print("股價與選擇權價格關係:")
    print(f"{'股價':>8} {'Call':>8} {'Put':>8}")
    print("-" * 28)
    for i in range(0, len(stock_prices), 10):
        print(f"{stock_prices[i]:>8.0f} {call_prices[i]:>8.2f} {put_prices[i]:>8.2f}")

plot_option_price_by_stock()

模型假設與限制

| 假設 | 說明 | 現實情況 | |------|------|---------| | 市場效率 | 無套利機會 | 存在套利(但很短暫) | | 連續交易 | 可隨時買賣 | 有限制(非交易時間) | | 波動率固定 | $\sigma$ 為常數 | 波動率會變化(波動率微笑) | | 無交易成本 | 買賣無手續費 | 有手續費與滑價 | | 無風險利率固定 | $r$ 為常數 | 利率會變化 | | 標的資產不配息 | 無股利 | 多數股票會配息 |

波動率微笑 (Volatility Smile)

實際市場中,不同履約價的選擇權會有不同的隱含波動率,形成「微笑」曲線。這證明了 Black-Scholes 假設波動率固定的缺陷,但也催生了更進階的模型(如局部波動率模型、隨機波動率模型)。

總結

  • Black-Scholes 是選擇權定價的基礎模型
  • Call/Put 公式透過常態分配計算期望價格
  • 五個輸入參數:股價、履約價、到期時間、利率、波動率
  • 模型有限制,但仍是市場的基準定價方式
  • 波動率微笑是模型假設與現實的主要差異

實戰練習

💡 Vibe Coding 練習:請 AI 建立一個「選擇權定價計算器」:

  1. 輸入股價、履約價、到期日、利率、波動率
  2. 計算 Call 與 Put 價格
  3. 分別顯示內含價值與時間價值
  4. 繪製股價 vs 選擇權價格的曲線圖
  5. 支援多組參數比較

會員專屬免費教學

本章節為註冊會員專屬的免費開放內容!請先登入或註冊會員,即可立即解鎖閱讀。

立即登入 / 註冊