การเทรด Crypto Options ไม่ใช่เรื่องของการทายทิศทางราคาเพียงอย่างเดียว แต่ต้องเข้าใจ Greek Letters ที่เป็นตัวชี้วัดความอ่อนไหวของราคา Option ต่อปัจจัยต่าง ๆ ในตลาด ในบทความนี้ผมจะสอนการพัฒนา Options Greeks Dashboard ที่แสดงผล Delta, Gamma, Theta, Vega และ Rho แบบ real-time โดยใช้ Python ร่วมกับ HolySheep AI เพื่อวิเคราะห์ข้อมูลอย่างมีประสิทธิภาพ
ทำไมต้องสร้าง Options Greeks Dashboard
จากประสบการณ์การเทรด Options บน Binance และ Deribit มากว่า 3 ปี ผมพบว่าการติดตาม Greeks ทั้ง 5 ตัวพร้อมกันบนหน้าจอเดียวช่วยให้:
- เข้าใจความเสี่ยงเชิงลึก - รู้ว่าพอร์ตจะเปลี่ยนแปลงอย่างไรเมื่อราคา BTC ขยับ 1%
- วางแผน Delta Hedging - รู้ว่าต้องซื้อหรือขายเท่าไหร่เพื่อรักษาสมดุล
- คำนวณ Time Decay - เห็นว่า Theta กินกำไรเท่าไหร่ต่อวัน
- ประเมิน Implied Volatility - วิเคราะห์ Vega เพื่อหาจังหวะ Long Volatility หรือ Short Volatility
ราคา AI API ปี 2026 — ค่าใช้จ่ายสำหรับการพัฒนา Dashboard
การสร้าง Dashboard ที่ฉลาดต้องใช้ AI ช่วยวิเคราะห์และสร้างรายงาน ต้นทุนต่อเดือนสำหรับ 10 ล้าน tokens คือ:
| AI Model | ราคา/MTok | 10M Tokens/เดือน | ประหยัด vs OpenAI |
|---|---|---|---|
| DeepSeek V3.2 | $0.42 | $4.20 | 94.75% |
| Gemini 2.5 Flash | $2.50 | $25.00 | 68.75% |
| GPT-4.1 | $8.00 | $80.00 | — |
| Claude Sonnet 4.5 | $15.00 | $150.00 | +87.5% แพงกว่า |
พื้นฐาน Options Greeks ที่ต้องเข้าใจ
Delta (Δ) — ความอ่อนไหวต่อราคา
Delta บอกว่าเมื่อราคา asset เปลี่ยนแปลง $1 ราคา Option จะเปลี่ยนเท่าไหร่ ค่าระหว่าง -1 ถึง 1
- Call Option: Delta 0 ถึง 1
- Put Option: Delta -1 ถึง 0
- ATM Option: Delta ประมาณ 0.5 หรือ -0.5
Gamma (Γ) — อัตราการเปลี่ยนแปลงของ Delta
Gamma บอกว่า Delta จะเปลี่ยนแปลงเท่าไหร่เมื่อราคา asset เปลี่ยน $1 สำคัญมากสำหรับ:
- Gamma Risk ของ Short Option Traders
- การวางแผน Delta Hedging ที่ถี่แค่ไหน
Theta (Θ) — Time Decay
Theta บอกว่าทุกวันที่ผ่านไป Option จะเสียมูลค่าเท่าไหร่ มักเป็นค่าลบสำหรับ Long Position
Vega (ν) — ความอ่อนไหวต่อ Volatility
Vega บอกว่าเมื่อ Implied Volatility (IV) เปลี่ยน 1% ราคา Option จะเปลี่ยนเท่าไหร่ สำคัญสำหรับ:
- Long Straddle/Strangle (Long Vega)
- Short Straddle/Strangle (Short Vega)
Rho (ρ) — ความอ่อนไหวต่ออัตราดอกเบี้ย
Rho ส่วนใหญ่ไม่ค่อยมีผลใน Crypto Options เนื่องจากอัตราดอกเบี้ยคงที่หรือใช้ Funding Rate แทน
การติดตั้ง Development Environment
# สร้าง Virtual Environment
python -m venv crypto_greeks_env
source crypto_greeks_env/bin/activate # Windows: crypto_greeks_env\Scripts\activate
ติดตั้ง Dependencies
pip install requests pandas numpy plotly dash
pip install scipy # สำหรับคำนวณ Black-Scholes
pip install websockets asyncio aiohttp
สำหรับ HolySheep AI Integration
pip install openai # Compatible API Format
ติดตั้ง Flask สำหรับ Dashboard
pip install flask flask-socketio
โครงสร้างโค้ดหลัก — Dashboard Application
# app.py — Main Dashboard Application
import os
from flask import Flask, render_template, jsonify, request
from flask_socketio import SocketIO, emit
import asyncio
import threading
from datetime import datetime
import numpy as np
from scipy.stats import norm
HolySheep AI Configuration
สมัครได้ที่ https://www.holysheep.ai/register
HOLYSHEEP_API_KEY = os.environ.get('YOUR_HOLYSHEEP_API_KEY', 'sk-your-key-here')
HOLYSHEEP_BASE_URL = 'https://api.holysheep.ai/v1'
app = Flask(__name__)
app.config['SECRET_KEY'] = 'crypto-greeks-secret-2026'
socketio = SocketIO(app, cors_allowed_origins="*")
============================================
Black-Scholes Greeks Calculator
============================================
def calculate_greeks(S, K, T, r, sigma, option_type='call'):
"""
S = Spot Price (ราคา Spot ปัจจุบัน)
K = Strike Price (ราคา Strike)
T = Time to Maturity ในปี (เช่น 7 วัน = 7/365)
r = Risk-free Rate (อัตราดอกเบี้ย)
sigma = Implied Volatility
option_type = 'call' หรือ 'put'
คืนค่า Dictionary ของ Greeks ทั้งหมด
"""
d1 = (np.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
d2 = d1 - sigma * np.sqrt(T)
if option_type == 'call':
# Delta
delta = norm.cdf(d1)
# Probability of Exercise
prob_exercise = norm.cdf(d2)
# Theta (ต่อวัน)
theta = (-(S * norm.pdf(d1) * sigma) / (2 * np.sqrt(T))
- r * K * np.exp(-r * T) * norm.cdf(d2)) / 365
# Rho
rho = K * T * np.exp(-r * T) * norm.cdf(d2) / 100
else: # Put Option
delta = norm.cdf(d1) - 1
prob_exercise = norm.cdf(-d2)
theta = (-(S * norm.pdf(d1) * sigma) / (2 * np.sqrt(T))
+ r * K * np.exp(-r * T) * norm.cdf(-d2)) / 365
rho = -K * T * np.exp(-r * T) * norm.cdf(-d2) / 100
# Gamma (เหมือนกันสำหรับ Call และ Put)
gamma = norm.pdf(d1) / (S * sigma * np.sqrt(T))
# Vega (ต่อ 1% IV change)
vega = S * norm.pdf(d1) * np.sqrt(T) / 100
# คำนวณราคา Option
if option_type == 'call':
price = S * norm.cdf(d1) - K * np.exp(-r * T) * norm.cdf(d2)
else:
price = K * np.exp(-r * T) * norm.cdf(-d2) - S * norm.cdf(-d1)
return {
'price': round(price, 4),
'delta': round(delta, 4),
'gamma': round(gamma, 4),
'theta': round(theta, 4),
'vega': round(vega, 4),
'rho': round(rho, 4),
'd1': round(d1, 4),
'd2': round(d2, 4),
'prob_itm': round(prob_exercise * 100, 2) # % ความน่าจะเป็น ITM
}
============================================
Portfolio Greeks Calculator
============================================
class PortfolioGreeks:
def __init__(self):
self.positions = []
def add_position(self, symbol, side, quantity, strike, expiry_days,
option_type, iv, current_price):
"""เพิ่ม Position สำหรับคำนวณ Portfolio Greeks"""
multiplier = 1 if side == 'long' else -1
T = expiry_days / 365
greeks = calculate_greeks(
S=current_price,
K=strike,
T=T,
r=0.0, # Crypto ไม่มี risk-free rate
sigma=iv / 100,
option_type=option_type
)
position = {
'symbol': symbol,
'side': side,
'quantity': quantity * multiplier,
'strike': strike,
'expiry_days': expiry_days,
'type': option_type,
'iv': iv,
'current_price': current_price,
**greeks
}
self.positions.append(position)
return position
def get_portfolio_greeks(self):
"""คำนวณ Greeks รวมของ Portfolio"""
totals = {
'delta': 0,
'gamma': 0,
'theta': 0,
'vega': 0,
'rho': 0,
'total_cost': 0,
'positions_count': len(self.positions)
}
for pos in self.positions:
qty = abs(pos['quantity'])
side_mult = 1 if pos['side'] == 'long' else -1
totals['delta'] += pos['delta'] * qty * side_mult * pos['current_price']
totals['gamma'] += pos['gamma'] * qty * side_mult
totals['theta'] += pos['theta'] * qty * side_mult
totals['vega'] += pos['vega'] * qty * side_mult
totals['rho'] += pos['rho'] * qty * side_mult
totals['total_cost'] += pos['price'] * qty * side_mult * -1
return {k: round(v, 4) for k, v in totals.items()}
def get_position_pnl_scenarios(self, price_change_pct):
"""คำนวณ P&L ในสถานการณ์ต่าง ๆ"""
scenarios = {}
for pos in self.positions:
original_price = pos['current_price']
new_price = original_price * (1 + price_change_pct / 100)
T = pos['expiry_days'] / 365
new_greeks = calculate_greeks(
S=new_price,
K=pos['strike'],
T=T,
r=0.0,
sigma=pos['iv'] / 100,
option_type=pos['type']
)
pnl_per_unit = (new_greeks['price'] - pos['price']) * pos['quantity']
scenarios[pos['symbol']] = {
'new_price': round(new_price, 2),
'new_delta': new_greeks['delta'],
'pnl': round(pnl_per_unit, 2)
}
return scenarios
============================================
Routes
============================================
@app.route('/')
def index():
return render_template('dashboard.html')
@app.route('/api/calculate', methods=['POST'])
def calculate():
data = request.json
result = calculate_greeks(
S=float(data['spot_price']),
K=float(data['strike_price']),
T=float(data['days_to_expiry']) / 365,
r=float(data.get('risk_free_rate', 0)),
sigma=float(data['iv']) / 100,
option_type=data.get('option_type', 'call')
)
return jsonify({
'success': True,
'data': result,
'timestamp': datetime.now().isoformat()
})
@app.route('/api/portfolio/greeks', methods=['POST'])
def portfolio_greeks():
portfolio = PortfolioGreeks()
positions = request.json.get('positions', [])
for pos in positions:
portfolio.add_position(
symbol=pos['symbol'],
side=pos['side'],
quantity=float(pos['quantity']),
strike=float(pos['strike']),
expiry_days=int(pos['expiry_days']),
option_type=pos['option_type'],
iv=float(pos['iv']),
current_price=float(pos['current_price'])
)
return jsonify({
'success': True,
'portfolio_greeks': portfolio.get_portfolio_greeks(),
'positions': portfolio.positions,
'timestamp': datetime.now().isoformat()
})
if __name__ == '__main__':
print(f"🚀 Starting Crypto Greeks Dashboard...")
print(f"📡 API Base: {HOLYSHEEP_BASE_URL}")
socketio.run(app, host='0.0.0.0', port=5000, debug=True)
Frontend Dashboard — HTML/JavaScript
<!-- templates/dashboard.html -->
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crypto Options Greeks Dashboard</title>
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
color: #ffffff;
min-height: 100vh;
}
.header {
background: rgba(0, 0, 0, 0.3);
padding: 20px 40px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.header h1 {
color: #00d4ff;
font-size: 24px;
}
.container {
display: grid;
grid-template-columns: 300px 1fr;
gap: 20px;
padding: 20px;
max-width: 1600px;
margin: 0 auto;
}
.panel {
background: rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 20px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.input-group {
margin-bottom: 15px;
}
.input-group label {
display: block;
margin-bottom: 5px;
color: #aaa;
font-size: 14px;
}
.input-group input, .input-group select {
width: 100%;
padding: 10px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(0, 0, 0, 0.3);
color: #fff;
font-size: 14px;
}
.btn {
width: 100%;
padding: 12px;
border-radius: 8px;
border: none;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background: linear-gradient(135deg, #00d4ff, #0099cc);
color: #000;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}
.greeks-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 15px;
margin-bottom: 20px;
}
.greek-card {
background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 153, 204, 0.1));
border-radius: 10px;
padding: 15px;
text-align: center;
border: 1px solid rgba(0, 212, 255, 0.3);
}
.greek-card.delta { border-color: #00ff00; background: rgba(0, 255, 0, 0.1); }
.greek-card.gamma { border-color: #ff9900; background: rgba(255, 153, 0, 0.1); }
.greek-card.theta { border-color: #ff0066; background: rgba(255, 0, 102, 0.1); }
.greek-card.vega { border-color: #9900ff; background: rgba(153, 0, 255, 0.1); }
.greek-card.rho { border-color: #ffff00; background: rgba(255, 255, 0, 0.1); }
.greek-value {
font-size: 28px;
font-weight: bold;
margin-bottom: 5px;
}
.greek-label {
font-size: 12px;
color: #aaa;
text-transform: uppercase;
}
.chart-container {
height: 400px;
margin-top: 20px;
}
.ai-insights {
margin-top: 20px;
padding: 15px;
background: rgba(0, 255, 136, 0.1);
border-radius: 8px;
border-left: 4px solid #00ff88;
}
.ai-insights h3 {
color: #00ff88;
margin-bottom: 10px;
}
@media (max-width: 1024px) {
.container {
grid-template-columns: 1fr;
}
.greeks-grid {
grid-template-columns: repeat(3, 1fr);
}
}
</style>
</head>
<body>
<div class="header">
<h1>📊 Crypto Options Greeks Dashboard</h1>
<p>Real-time Risk Visualization for BTC & ETH Options</p>
</div>
<div class="container">
<div class="panel">
<h2 style="margin-bottom: 20px; color: #00d4ff;">⚙️ Input Parameters</h2>
<div class="input-group">
<label>Spot Price ($)</label>
<input type="number" id="spotPrice" value="67500" step="100">
</div>
<div class="input-group">
<label>Strike Price ($)</label>
<input type="number" id="strikePrice" value="70000" step="100">
</div>
<div class="input-group">
<label>Days to Expiry</label>
<input type="number" id="daysToExpiry" value="7" min="1">
</div>
<div class="input-group">
<label>Implied Volatility (%)</label>
<input type="number" id="iv" value="65" step="0.5">
</div>
<div class="input-group">
<label>Option Type</label>
<select id="optionType">
<option value="call">Call Option</option>
<option value="put">Put Option</option>
</select>
</div>
<button class="btn btn-primary" onclick="calculateGreeks()">
📊 Calculate Greeks
</button>
<div style="margin-top: 20px; padding: 15px; background: rgba(0,212,255,0.1); border-radius: 8px;">
<h3 style="color: #00d4ff; margin-bottom: 10px;">💡 AI Analysis</h3>
<div id="aiInsights" style="font-size: 14px; line-height: 1.6;">
กดปุ่ม Calculate เพื่อรับการวิเคราะห์จาก AI
</div>
</div>
</div>
<div>
<div class="greeks-grid">
<div class="greek-card delta">
<div class="greek-value" id="deltaValue">0.00</div>
<div class="greek-label">Delta (Δ)</div>
</div>
<div class="greek-card gamma">
<div class="greek-value" id="gammaValue">0.00</div>
<div class="greek-label">Gamma (Γ)</div>
</div>
<div class="greek-card theta">
<div class="greek-value" id="thetaValue">0.00</div>
<div class="greek-label">Theta (Θ)</div>
</div>
<div class="greek-card vega">
<div class="greek-value" id="vegaValue">0.00</div>
<div class="greek-label">Vega (ν)</div>
</div>
<div class="greek-card rho">
<div class="greek-value" id="rhoValue">0.00</div>
<div class="greek-label">Rho (ρ)</div>
</div>
</div>
<div class="panel">
<h2 style="margin-bottom: 15px; color: #00d4ff;">📈 Greeks Sensitivity Analysis</h2>
<div id="sensitivityChart" class="chart-container"></div>
</div>
<div class="panel" style="margin-top: 20px;">
<h2 style="margin-bottom: 15px; color: #00d4ff;">📊 Price & Greeks Over Time to Expiry</h2>
<div id="expiryChart" class="chart-container"></div>
</div>
</div>
</div>
<script>
const HOLYSHEEP_API_KEY = 'YOUR_HOLYSHEEP_API_KEY';
const HOLYSHEEP_BASE_URL = 'https://api.holysheep.ai/v1';
let currentGreeks = null;
async function calculateGreeks() {
const data = {
spot_price: document.getElementById('spotPrice').value,
strike_price: document.getElementById('strikePrice').value,
days_to_expiry: document.getElementById('daysToExpiry').value,
iv: document.getElementById('iv').value,
option_type: document.getElementById('optionType').value,
risk_free_rate: 0
};
try {
const response = await fetch('/api/calculate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
const result = await response.json();
if (result.success) {