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 | ตัวอย่าง |
|---|---|
| Momentum | 12-month return, RSI, MACD |
| Value | P/E, P/B, earnings yield |
| Volatility/Size | Beta, market cap, ATR |
| Quality | ROE, gross margin, debt/equity |
| Alternative | Sentiment (NLP), satellite data, web traffic |
วัดคุณภาพด้วย IC (Information Coefficient) = Spearman rank correlation ระหว่าง predicted vs. actual returns
Key Pitfalls
| Pitfall | คำอธิบาย | วิธีแก้ |
|---|---|---|
| Lookahead Bias | ใช้ข้อมูลอนาคตใน backtest | Point-in-time data, purging/embargoing |
| Survivorship Bias | ใช้เฉพาะหุ้นที่รอด ไม่รวม delisted | Track historical universe |
| Overfitting | Model fit กับ noise ใน training | Cross-validation, Deflated Sharpe Ratio |
| Multiple Testing | ทดสอบ many strategies → บางอันดีโดยบังเอิญ | DSR, Bonferroni correction |
| Transaction Costs | Ignore slippage, commissions | Realistic execution model |
Tools Ecosystem ใน Wiki นี้
| Tool | Role |
|---|---|
| ML4T Platform | Learning system + Python libraries + agent skills |
| ML4T Book 2nd Edition | Comprehensive textbook (858 หน้า, 23 chapters) |
| TradingView MCP | AI-assisted chart analysis + Pine Script dev |
| MiroFish | Swarm intelligence prediction (cross-domain) |
Related
- ML4T Platform — platform ecosystem
- ML4T Book 2nd Edition — textbook
- TradingView MCP — chart interaction via Claude Code
🇬🇧 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.
| Category | Examples |
|---|---|
| Momentum | 12-month return, RSI, MACD |
| Value | P/E, P/B, earnings yield |
| Volatility/Size | Beta, market cap, ATR |
| Quality | ROE, gross margin, debt/equity |
| Alternative | Sentiment (NLP), satellite data, web traffic |
Primary quality metric: IC (Information Coefficient) = Spearman rank correlation between predicted and actual returns.
Key Pitfalls
| Pitfall | Description | Fix |
|---|---|---|
| Lookahead Bias | Accidentally using future data in features | Point-in-time data; purging/embargoing in CV |
| Survivorship Bias | Using only stocks that survived (excludes delisted) | Track the full historical universe |
| Overfitting | Model fits noise in training data | Cross-validation; Deflated Sharpe Ratio |
| Multiple Testing | Testing many strategies until one looks good by chance | Deflated Sharpe Ratio (DSR); Bonferroni |
| Transaction Costs | Ignoring slippage and commissions | Realistic 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
| Strategy | ML Approach | Example |
|---|---|---|
| Long-short equity | Random Forest, GBM, DL | Predict 1-month returns, long top quintile |
| Statistical arbitrage | Cointegration, pairs trading | VAR model, VECM |
| Volatility forecasting | GARCH, LSTM | VIX prediction, options pricing |
| Sentiment trading | NLP, BERT | Earnings calls, SEC filings |
| Portfolio optimization | Clustering, autoencoders | HRP, conditional risk factors |
| Intraday/HFT | Boosting, microstructure | Minute-frequency signals |
Tools Ecosystem in This Wiki
| Tool | Role |
|---|---|
| ML4T Platform | Learning system with Python libraries, case studies, agent skills |
| ML4T Book 2nd Edition | Comprehensive textbook (858 pages, 23 chapters, 400+ notebooks) |
| TradingView MCP | AI-assisted chart analysis and Pine Script development via Claude Code |
| MiroFish | Swarm intelligence prediction engine (cross-domain, applicable to financial markets) |