SiamCafe.net Blog
Technology

Volatility คืออะไร

volatility คอ
Volatility คืออะไร | SiamCafe Blog
2026-03-08· อ. บอม — SiamCafe.net· 9,944 คำ

Volatility ความผันผวน

Volatility ความผันผวน การเปลี่ยนแปลงราคาสินทรัพย์ วัดความเสี่ยง Historical Volatility Implied Volatility VIX Index Options หุ้น Forex Crypto

ประเภทวิธีวัดใช้ทำอะไรตัวอย่าง
Historical VolStandard Deviation ของ Returnsวัดความเสี่ยงในอดีตHV 30 วัน
Implied Volคำนวณจากราคา Optionsคาดการณ์อนาคตIV ของ Options
Realized VolActual Price Movementเปรียบเทียบกับ IVRV vs IV
VIX IndexIV ของ S&P 500 OptionsวัดความกลัวตลาดVIX > 30 = กลัว

คำนวณ Volatility Python

# volatility.py — Volatility Calculator
import math
from dataclasses import dataclass
from typing import List

@dataclass
class PriceData:
 date: str
 close: float

def calc_returns(prices: List[PriceData]) -> List[float]:
 """คำนวณ Daily Log Returns"""
 returns = []
 for i in range(1, len(prices)):
 r = math.log(prices[i].close / prices[i-1].close)
 returns.append(r)
 return returns

def historical_volatility(prices: List[PriceData], window: int = 30) -> float:
 """คำนวณ Historical Volatility (Annualized)"""
 returns = calc_returns(prices)
 if len(returns) < window:
 returns_window = returns
 else:
 returns_window = returns[-window:]

 n = len(returns_window)
 if n < 2:
 return 0

 mean = sum(returns_window) / n
 variance = sum((r - mean) ** 2 for r in returns_window) / (n - 1)
 daily_vol = math.sqrt(variance)
 annual_vol = daily_vol * math.sqrt(252)
 return annual_vol * 100 # เป็น %

def calc_atr(highs: List[float], lows: List[float],
 closes: List[float], period: int = 14) -> float:
 """คำนวณ Average True Range"""
 true_ranges = []
 for i in range(1, len(highs)):
 tr = max(
 highs[i] - lows[i],
 abs(highs[i] - closes[i-1]),
 abs(lows[i] - closes[i-1])
 )
 true_ranges.append(tr)
 if len(true_ranges) < period:
 return sum(true_ranges) / len(true_ranges) if true_ranges else 0
 return sum(true_ranges[-period:]) / period

# ตัวอย่างข้อมูลราคาหุ้น
prices = [
 PriceData("2024-01-01", 100.0),
 PriceData("2024-01-02", 102.5),
 PriceData("2024-01-03", 101.0),
 PriceData("2024-01-04", 104.0),
 PriceData("2024-01-05", 103.5),
 PriceData("2024-01-06", 106.0),
 PriceData("2024-01-07", 105.0),
 PriceData("2024-01-08", 108.0),
 PriceData("2024-01-09", 107.5),
 PriceData("2024-01-10", 110.0),
 PriceData("2024-01-11", 108.0),
 PriceData("2024-01-12", 112.0),
 PriceData("2024-01-13", 111.0),
 PriceData("2024-01-14", 109.0),
 PriceData("2024-01-15", 113.0),
]

hv = historical_volatility(prices)
returns = calc_returns(prices)

print("=== Volatility Analysis ===")
print(f"ราคาเริ่มต้น: {prices[0].close}")
print(f"ราคาล่าสุด: {prices[-1].close}")
print(f"Historical Volatility (Annualized): {hv:.1f}%")
print(f"Daily Returns: {len(returns)} days")
print(f"Max Return: {max(returns)*100:.2f}%")
print(f"Min Return: {min(returns)*100:.2f}%")

# เปรียบเทียบ Volatility สินทรัพย์ต่างๆ
assets = {
 "US Treasury": {"hv": 5, "risk": "ต่ำมาก"},
 "S&P 500": {"hv": 15, "risk": "ปานกลาง"},
 "Gold": {"hv": 18, "risk": "ปานกลาง"},
 "หุ้นไทย SET": {"hv": 20, "risk": "ปานกลาง-สูง"},
 "Tesla": {"hv": 55, "risk": "สูง"},
 "Bitcoin": {"hv": 70, "risk": "สูงมาก"},
 "Altcoins": {"hv": 120, "risk": "สูงสุด"},
}

print(f"\n\nVolatility เปรียบเทียบ:")
for asset, info in assets.items():
 bar = "█" * (info["hv"] // 5)
 print(f" {asset:<15} HV {info['hv']:>3}% | {info['risk']:<12} {bar}")

VIX และ Implied Volatility

# vix.py — VIX and Implied Volatility
from dataclasses import dataclass

@dataclass
class VIXLevel:
 range_low: float
 range_high: float
 sentiment: str
 description: str
 strategy: str

vix_levels = [
 VIXLevel(0, 12, "Complacent", "ตลาดสงบมาก นักลงทุนมั่นใจ", "ซื้อ Put Protection ถูก"),
 VIXLevel(12, 15, "Low Vol", "ตลาดสงบ ความเสี่ยงต่ำ", "Sell Premium (Options)"),
 VIXLevel(15, 20, "Normal", "ตลาดปกติ", "ลงทุนตามปกติ"),
 VIXLevel(20, 25, "Elevated", "ตลาดผันผวนขึ้น ระวัง", "ลดขนาด Position"),
 VIXLevel(25, 35, "High", "ตลาดกลัว ผันผวนสูง", "ลด Risk หรือ Hedge"),
 VIXLevel(35, 50, "Very High", "ตลาดตื่นตระหนัก", "ซื้อสะสม (Contrarian)"),
 VIXLevel(50, 100, "Extreme", "วิกฤต COVID 2020 GFC 2008", "ซื้อหนัก (ถ้ารับ Risk ได้)"),
]

print("=== VIX Levels ===")
for v in vix_levels:
 print(f" VIX {v.range_low:>2}-{v.range_high:>3}: [{v.sentiment}]")
 print(f" {v.description}")
 print(f" Strategy: {v.strategy}\n")

# VIX Historical Events
events = {
 "Black Monday 1987": {"vix": 150, "desc": "ตลาดหุ้นร่วง 22% ในวันเดียว"},
 "LTCM Crisis 1998": {"vix": 45, "desc": "กองทุน Hedge Fund ล้ม"},
 "9/11 Attack 2001": {"vix": 43, "desc": "ตลาดปิด 4 วัน"},
 "GFC 2008": {"vix": 80, "desc": "Lehman Brothers ล้มละลาย"},
 "COVID 2020": {"vix": 82, "desc": "Pandemic Lockdown ทั่วโลก"},
 "Normal 2024": {"vix": 14, "desc": "ตลาดสงบ AI Rally"},
}

print("VIX Historical Events:")
for event, info in events.items():
 print(f" {event}: VIX {info['vix']} — {info['desc']}")

# Implied Volatility
print(f"\n\nImplied Volatility Tips:")
tips = [
 "IV สูง = Options แพง = ขาย Options (Premium Selling)",
 "IV ต่ำ = Options ถูก = ซื้อ Options (Long Straddle)",
 "IV Crush = IV ลดลงหลัง Earnings = Options ราคาลด",
 "IV Rank = เปรียบเทียบ IV ปัจจุบัน กับ IV ย้อนหลัง 52 สัปดาห์",
 "IV Percentile = % ของวันที่ IV ต่ำกว่าปัจจุบัน",
]
for tip in tips:
 print(f" - {tip}")

Bollinger Bands

# bollinger.py — Bollinger Bands (Volatility Indicator)
from typing import List

def simple_moving_average(data: List[float], period: int) -> List[float]:
 sma = []
 for i in range(len(data)):
 if i < period - 1:
 sma.append(None)
 else:
 avg = sum(data[i-period+1:i+1]) / period
 sma.append(avg)
 return sma

def bollinger_bands(prices: List[float], period: int = 20,
 std_dev: float = 2.0):
 sma = simple_moving_average(prices, period)
 upper = []
 lower = []
 bandwidth = []

 for i in range(len(prices)):
 if sma[i] is None:
 upper.append(None)
 lower.append(None)
 bandwidth.append(None)
 else:
 window = prices[i-period+1:i+1]
 mean = sum(window) / len(window)
 var = sum((x - mean) ** 2 for x in window) / len(window)
 sd = math.sqrt(var)
 u = sma[i] + std_dev * sd
 l = sma[i] - std_dev * sd
 bw = ((u - l) / sma[i]) * 100
 upper.append(u)
 lower.append(l)
 bandwidth.append(bw)

 return sma, upper, lower, bandwidth

closes = [p.close for p in prices]
sma, upper, lower, bw = bollinger_bands(closes, period=10)

print("=== Bollinger Bands ===")
for i in range(len(prices)):
 if sma[i] is not None:
 print(f" {prices[i].date} | Close: {closes[i]:>6.1f} | "
 f"SMA: {sma[i]:>6.1f} | Upper: {upper[i]:>6.1f} | "
 f"Lower: {lower[i]:>6.1f} | BW: {bw[i]:>5.1f}%")

# Volatility Trading Rules
rules = {
 "Bollinger Squeeze": "Bandwidth แคบ = Volatility ต่ำ = รอ Breakout",
 "Bollinger Expansion": "Bandwidth กว้าง = Volatility สูง = Trend กำลังแรง",
 "Touch Upper Band": "ราคาแตะ Upper = อาจ Overbought",
 "Touch Lower Band": "ราคาแตะ Lower = อาจ Oversold",
 "Mean Reversion": "ราคามักกลับมาที่ SMA (Mean)",
}

print(f"\n\nBollinger Band Trading Rules:")
for rule, desc in rules.items():
 print(f" [{rule}]: {desc}")

เคล็ดลับ

การนำความรู้ไปประยุกต์ใช้งานจริง

แหล่งเรียนรู้ที่แนะนำ ได้แก่ Official Documentation ที่อัพเดทล่าสุดเสมอ Online Course จาก Coursera Udemy edX ช่อง YouTube คุณภาพทั้งไทยและอังกฤษ และ Community อย่าง Discord Reddit Stack Overflow ที่ช่วยแลกเปลี่ยนประสบการณ์กับนักพัฒนาทั่วโลก

เปรียบเทียบข้อดีและข้อเสีย

ข้อดีข้อเสีย
ประสิทธิภาพสูง ทำงานได้เร็วและแม่นยำ ลดเวลาทำงานซ้ำซ้อนต้องใช้เวลาเรียนรู้เบื้องต้นพอสมควร มี Learning Curve สูง
มี Community ขนาดใหญ่ มีคนช่วยเหลือและแหล่งเรียนรู้มากมายบางฟีเจอร์อาจยังไม่เสถียร หรือมีการเปลี่ยนแปลงบ่อยในเวอร์ชันใหม่
รองรับ Integration กับเครื่องมือและบริการอื่นได้หลากหลายต้นทุนอาจสูงสำหรับ Enterprise License หรือ Cloud Service
เป็น Open Source หรือมีเวอร์ชันฟรีให้เริ่มต้นใช้งานต้องการ Hardware หรือ Infrastructure ที่เพียงพอ

จากตารางเปรียบเทียบจะเห็นว่าข้อดีมีมากกว่าข้อเสียอย่างชัดเจน โดยเฉพาะในแง่ของประสิทธิภาพและความสามารถในการ Scale สำหรับข้อเสียส่วนใหญ่สามารถแก้ไขได้ด้วยการเรียนรู้อย่างเป็นระบบและวางแผนทรัพยากรให้เหมาะสม

Volatility คืออะไร

ความผันผวน การเปลี่ยนแปลงราคาสินทรัพย์ วัดความเสี่ยง Historical Implied VIX สูง=เสี่ยงมาก กำไร/ขาดทุนมาก

Historical Volatility คำนวณอย่างไร

Standard Deviation ของ Daily Log Returns คูณ sqrt(252) Annualized HV 20% ราคาอาจเปลี่ยน 20% ใน 1 ปี

VIX Index คืออะไร

Volatility Index Fear Index S&P 500 Implied Volatility ต่ำกว่า 15 สงบ 25-35 ผันผวน มากกว่า 35 ตื่นตระหนัก

Implied Volatility ใช้ทำอะไร

ตีราคา Options IV สูง Options แพง คาดการณ์ราคาอนาคต IV Crush หลัง Event ซื้อ IV ต่ำ ขาย IV สูง

สรุป

Volatility ความผันผวน Historical Implied VIX Fear Index Standard Deviation Returns Bollinger Bands Options Pricing IV Crush Position Sizing Risk Management Diversification

📖 บทความที่เกี่ยวข้อง

volatility แปลว่าอ่านบทความ → gold price xauusd last 15 minutes volatilityอ่านบทความ → gold price xauusd live chart 15 minute volatilityอ่านบทความ → gold price xauusd volatility last 15 minutesอ่านบทความ →

📚 ดูบทความทั้งหมด →