SiamCafe · Blog
Position Sizing หุ้น — คู่มือบริหารขนาด Position ฉบับสมบูรณ์
บทความ

Position Sizing หุ้น — คู่มือบริหารขนาด Position ฉบับสมบูรณ์

เผยแพร่ 28 พฤษภาคม 2569

Position Sizing หุ้น

Position Sizing หุ้น บริหารขนาด Risk per Trade Fixed Fraction Kelly Criterion Volatility ATR Portfolio Management

วิธีสูตรความยากปลอดภัยเหมาะกับ
Fixed FractionRisk% × Port / (Entry-SL)ง่ายสูงทุกู้คืน แนะนำ
Equal WeightPort / จำนวน Positionง่ายมากกลางเริ่มต้น
Volatility (ATR)Risk / (N × ATR)กลางสูงTrend Following
Kelly Criterion(bp-q)/bสูงกลาง-สูงมี Edge ชัดเจน
Anti-Martingaleเพิ่มเมื่อชนะ ลดเมื่อแพ้กลางกลางTrend Following

Position Calculator

# === Position Size Calculator ===

from dataclasses import dataclass

def calculate_position(portfolio, risk_pct, entry, stop_loss):
 risk_amount = portfolio * (risk_pct / 100)
 risk_per_share = abs(entry - stop_loss)
 if risk_per_share == 0:
 return None
 shares = int(risk_amount / risk_per_share)
 # Round down to lot size (100 shares for Thai stocks)
 shares = (shares // 100) * 100
 position_value = shares * entry
 position_pct = (position_value / portfolio) * 100
 return {
 "portfolio": portfolio,
 "risk_pct": risk_pct,
 "risk_amount": risk_amount,
 "entry": entry,
 "stop_loss": stop_loss,
 "risk_per_share": risk_per_share,
 "shares": shares,
 "position_value": position_value,
 "position_pct": position_pct,
 "max_loss": shares * risk_per_share,
 }

# ตัวอย่างการคำนวณ
examples = [
 {"name": "หุ้น A - SL แคบ", "port": 1000000, "risk": 1, "entry": 50, "sl": 48},
 {"name": "หุ้น B - SL กลาง", "port": 1000000, "risk": 1, "entry": 100, "sl": 92},
 {"name": "หุ้น C - SL กว้าง", "port": 1000000, "risk": 1, "entry": 200, "sl": 170},
 {"name": "หุ้น D - Risk 2%", "port": 1000000, "risk": 2, "entry": 30, "sl": 27},
 {"name": "พอร์ตเล็ก", "port": 100000, "risk": 2, "entry": 10, "sl": 9},
]

print("=== Position Size Calculator ===")
for ex in examples:
 result = calculate_position(ex["port"], ex["risk"], ex["entry"], ex["sl"])
 if result:
 print(f"\n [{ex['name']}]")
 print(f" Portfolio: {result['portfolio']:,.0f} | Risk: {result['risk_pct']}% = {result['risk_amount']:,.0f}")
 print(f" Entry: {result['entry']} | SL: {result['stop_loss']} | Risk/Share: {result['risk_per_share']}")
 print(f" Shares: {result['shares']:,} | Value: {result['position_value']:,.0f} ({result['position_pct']:.1f}%)")
 print(f" Max Loss: {result['max_loss']:,.0f}")

Volatility-based Sizing

# === ATR-based Position Sizing ===

# ATR (Average True Range) วัด Volatility ของหุ้น
# SL = Entry - (N × ATR)
# Position Size = Risk Amount / (N × ATR)

@dataclass
class ATRExample:
 stock: str
 entry: float
 atr: float
 n_multiplier: float
 portfolio: float
 risk_pct: float

def atr_position(ex):
 risk_amount = ex.portfolio * (ex.risk_pct / 100)
 sl_distance = ex.n_multiplier * ex.atr
 stop_loss = ex.entry - sl_distance
 shares = int(risk_amount / sl_distance)
 shares = (shares // 100) * 100
 value = shares * ex.entry
 return {
 "sl_distance": sl_distance,
 "stop_loss": stop_loss,
 "shares": shares,
 "value": value,
 "pct": (value / ex.portfolio) * 100,
 }

atr_examples = [
 ATRExample("หุ้นมั่นคง (ATR ต่ำ)", 100, 2.0, 2.0, 1000000, 1),
 ATRExample("หุ้นผันผวน (ATR สูง)", 100, 8.0, 2.0, 1000000, 1),
 ATRExample("หุ้น Growth (ATR กลาง)", 50, 3.0, 2.5, 1000000, 1),
]

print("=== ATR-based Sizing ===")
for ex in atr_examples:
 r = atr_position(ex)
 print(f"\n [{ex.stock}] Entry: {ex.entry} | ATR: {ex.atr} | N: {ex.n_multiplier}")
 print(f" SL Distance: {r['sl_distance']} | SL: {r['stop_loss']}")
 print(f" Shares: {r['shares']:,} | Value: {r['value']:,.0f} ({r['pct']:.1f}%)")

# ข้อดี ATR-based:
# - หุ้นผันผวนสูง → Position เล็ก (ปลอดภัย)
# - หุ้นผันผวนต่ำ → Position ใหญ่ (ใช้ทุนดี)
# - ปรับ SL ตาม Volatility จริง ไม่ใช่คาดเดา

Portfolio Management

# === Portfolio Risk Management ===

@dataclass
class PortfolioRule:
 rule: str
 limit: str
 reason: str
 example: str

rules = [
 PortfolioRule("Max Risk per Trade",
 "1-2% ของพอร์ต",
 "แพ้ 10 ครั้งติด เสียแค่ 10-20% ยังกลับมาได้",
 "พอร์ต 1M → Risk ไม่เกิน 10K-20K ต่อ Trade"),
 PortfolioRule("Max Position Size",
 "ไม่เกิน 20-25% ของพอร์ตต่อตัว",
 "กระจายความเสี่ยง ไม่พึ่งหุ้นตัวเดียว",
 "พอร์ต 1M → Position ไม่เกิน 200K-250K"),
 PortfolioRule("Max Open Positions",
 "5-10 ตัวพร้อมกัน",
 "ดูแลได้ทั่วถึง ไม่กระจายมากเกิน",
 "5 ตัว × 20% = 100% Fully Invested"),
 PortfolioRule("Max Correlated Risk",
 "ไม่เกิน 3 ตัวในอุตสาหกรรมเดียว",
 "ป้องกัน Sector Risk ถ้า Sector ลง ไม่เสียหนัก",
 "ธนาคาร 2 ตัว + พลังงาน 2 ตัว + Tech 1 ตัว"),
 PortfolioRule("Max Portfolio Heat",
 "Total Open Risk ไม่เกิน 6-10%",
 "ป้องกันกรณีตลาดลงพร้อมกัน ทุกตัว Hit SL",
 "5 ตัว × Risk 1.5% = 7.5% Max Heat"),
 PortfolioRule("Drawdown Limit",
 "หยุดเทรดเมื่อ Drawdown > 15-20%",
 "ป้องกันการเทรดตาม Emotion หลัง Drawdown",
 "พอร์ตลดจาก 1M เหลือ 800K → หยุด Review"),
]

print("=== Portfolio Rules ===")
for r in rules:
 print(f" [{r.rule}] Limit: {r.limit}")
 print(f" Reason: {r.reason}")
 print(f" Example: {r.example}")

เคล็ดลับ

  • 1%: เริ่มจาก Risk 1% ต่อ Trade ปลอดภัยที่สุด
  • SL: กำหนด Stop Loss ก่อนเข้า แล้วค่อยคำนวณ Position Size
  • ATR: ใช้ ATR-based Sizing สำหรับ SL ที่ปรับตาม Volatility
  • Heat: ดู Portfolio Heat รวม ไม่ให้เกิน 6-10%
  • อย่า: อย่า All-in อย่า Average Down อย่าเทรดตามอารมณ์

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

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

Position Sizing คืออะไร

กำหนดขนาด Position จำนวนหุ้น Risk per Trade 1-2% พอร์ต คำนวณจาก Risk/(Entry-SL) ควบคุมความเสี่ยง อยู่รอดระยะยาว

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

จำนวนหุ้น = Risk Amount / (Entry - SL) พอร์ต 1M Risk 1% = 10K Entry 100 SL 95 Risk/หุ้น 5 = 2000 หุ้น SL กว้าง Position เล็ก

วิธีไหนดีที่สุด

Fixed Fraction 1-2% ดีสุดสำหรับทุกู้คืน ATR-based ดีสำหรับ Trend Following Kelly Criterion ทฤษฎีดี ใช้ Half Kelly เริ่ม Fixed 1% แล้วปรับ

ผิดพลาดที่พบบ่อยมีอะไร

All-in ไม่มี SL Risk เกิน 5% เปลี่ยน Size ตามอารมณ์ Average Down Revenge Trading Over-diversification ไม่คำนวณ Position Size

สรุป

Position Sizing หุ้น Risk 1-2% Fixed Fraction ATR Volatility Kelly Criterion Stop Loss Portfolio Heat Drawdown บริหารความเสี่ยง