Algorithmic Trading

🇹🇭 ภาษาไทย

การซื้อขาย securities โดยใช้ systematic, rule-based strategies ที่ขับเคลื่อนด้วยข้อมูลและ algorithms แทนการตัดสินใจของมนุษย์ — ครอบคลุมตั้งแต่ simple momentum rules ไปจนถึง ML models ที่ซับซ้อน

ML4T Workflow — วงจรกลาง

Idea → Data → Features → Model → Signal → Backtest → Portfolio → Live
         ↑                                    ↓
         └────────── learn from results ───────┘

Alpha Factors

Alpha factor = signal ที่คาดว่าจะ predict returns ก่อน arbitrage

Categoryตัวอย่าง
Momentum12-month return, RSI, MACD
ValueP/E, P/B, earnings yield
Volatility/SizeBeta, market cap, ATR
QualityROE, gross margin, debt/equity
AlternativeSentiment (NLP), satellite data, web traffic

วัดคุณภาพด้วย IC (Information Coefficient) = Spearman rank correlation ระหว่าง predicted vs. actual returns

Key Pitfalls

Pitfallคำอธิบายวิธีแก้
Lookahead Biasใช้ข้อมูลอนาคตใน backtestPoint-in-time data, purging/embargoing
Survivorship Biasใช้เฉพาะหุ้นที่รอด ไม่รวม delistedTrack historical universe
OverfittingModel fit กับ noise ใน trainingCross-validation, Deflated Sharpe Ratio
Multiple Testingทดสอบ many strategies → บางอันดีโดยบังเอิญDSR, Bonferroni correction
Transaction CostsIgnore slippage, commissionsRealistic execution model

Tools Ecosystem ใน Wiki นี้

ToolRole
ML4T PlatformLearning system + Python libraries + agent skills
ML4T Book 2nd EditionComprehensive textbook (858 หน้า, 23 chapters)
TradingView MCPAI-assisted chart analysis + Pine Script dev
MiroFishSwarm intelligence prediction (cross-domain)

🇬🇧 English

The practice of buying and selling securities using systematic, rule-based strategies driven by data and algorithms rather than human discretion — ranging from simple momentum rules to complex ML models.

The ML4T Workflow (Central Framework)

Idea → Data → Features → Model → Signal → Backtest → Portfolio → Live
         ↑                                    ↓
         └────────── learn from results ───────┘

ML4T Book 2nd Edition uses this workflow as its central framework throughout all 23 chapters.

Alpha Factors

An alpha factor is a signal expected to predict returns before being arbitraged away.

CategoryExamples
Momentum12-month return, RSI, MACD
ValueP/E, P/B, earnings yield
Volatility/SizeBeta, market cap, ATR
QualityROE, gross margin, debt/equity
AlternativeSentiment (NLP), satellite data, web traffic

Primary quality metric: IC (Information Coefficient) = Spearman rank correlation between predicted and actual returns.

Key Pitfalls

PitfallDescriptionFix
Lookahead BiasAccidentally using future data in featuresPoint-in-time data; purging/embargoing in CV
Survivorship BiasUsing only stocks that survived (excludes delisted)Track the full historical universe
OverfittingModel fits noise in training dataCross-validation; Deflated Sharpe Ratio
Multiple TestingTesting many strategies until one looks good by chanceDeflated Sharpe Ratio (DSR); Bonferroni
Transaction CostsIgnoring slippage and commissionsRealistic execution model in backtest

Backtesting

Simulating a strategy on historical data to evaluate performance before deploying with real capital.

Key tools in this wiki:

  • backtrader — flexible local event-driven backtesting
  • Zipline (Quantopian) — Pipeline API, point-in-time data bundles
  • ML4T Platform ML4T Backtest — production event-driven backtesting (3rd edition)
  • TradingView MCP replay mode — manual bar-by-bar replay in TradingView Desktop

Strategy Types Using ML

StrategyML ApproachExample
Long-short equityRandom Forest, GBM, DLPredict 1-month returns, long top quintile
Statistical arbitrageCointegration, pairs tradingVAR model, VECM
Volatility forecastingGARCH, LSTMVIX prediction, options pricing
Sentiment tradingNLP, BERTEarnings calls, SEC filings
Portfolio optimizationClustering, autoencodersHRP, conditional risk factors
Intraday/HFTBoosting, microstructureMinute-frequency signals

Tools Ecosystem in This Wiki

ToolRole
ML4T PlatformLearning system with Python libraries, case studies, agent skills
ML4T Book 2nd EditionComprehensive textbook (858 pages, 23 chapters, 400+ notebooks)
TradingView MCPAI-assisted chart analysis and Pine Script development via Claude Code
MiroFishSwarm intelligence prediction engine (cross-domain, applicable to financial markets)