CANSLIM Episodic Pivot Strategy
Research by Wesley Gray (Alpha Architect) and Jegadeesh & Titman (1993) demonstrates that stocks with strong 12-month prior returns continue to outperform over the following 3–12 months. This momentum anomaly is robust across global markets and survives transaction cost adjustments.
Wesley Gray(Alpha Architect)及 Jegadeesh & Titman(1993)的研究顯示,過去12個月表現最強的股票,往後3至12個月仍傾向持續上漲。這個「動能異常」在全球股市普遍存在,扣除交易成本後仍顯著。
Taiwan's retail-dominated market (~60% retail volume) creates delayed price discovery. Earnings surprises and institutional accumulation build sustained price trends that a disciplined systematic investor can exploit — without forecasting ability.
台灣市場以散戶為主(約佔60%交易量),導致資訊反應延遲。盈餘驚喜與法人買超形成持續趨勢,紀律化的系統投資人可以捕捉,不需要預測能力。
Core Insight · 核心洞察
Momentum (What's already working) × Quality (Why it will keep working) × Timing (When the market agrees) = A systematic edge with multiple independent sources of alpha.
動能(已經在漲)× 品質(有理由繼續漲)× 時機(市場正在確認)= 具備多重獨立 Alpha 來源的系統化優勢。
Quantitative Momentum
量化動能
- 112-2 month price momentum (skip 1 month)
12個月動能,跳過最近1個月 - 2Risk-adjusted: momentum ÷ annualized volatility
風險調整:動能除以年化波動率 - 3Positive month ratio: ≥ 7 of 12 months positive
正報酬月比例:12個月中至少7個月上漲 - 4Cross-sectional ranking across full Taiwan universe
在全台灣股市進行橫截面排名
CANSLIM Quality Filters
CANSLIM 品質篩選
- CCurrent quarterly EPS YoY > 20%
季度 EPS 年增率 > 20% - AAnnual earnings growth trend
年度盈餘成長趨勢 - NNew highs: price within 10% of 252d high
接近年度高點(252日高點 -10% 內) - SSupply & Demand: monthly revenue YoY > 20%
月營收年增率 > 20%
Episodic Pivot Entry
爆發突破進場
- 1New 60-day high breakout
突破60日新高 - 2Volume surge ≥ 1.5× 50-day average
成交量 ≥ 50日均量 × 1.5 倍 - 3Price above MA50 (mid-term uptrend)
收盤價 > 50日均線(中期多頭) - 4MA50 > MA150 or MA200 (structural trend)
MA50 > MA150 或 MA200(結構性多頭)
| Stock · 股票 | Period · 期間 | Return · 報酬 |
|---|---|---|
| 4763 材料-KY | 2022.10 → 2024.10 | +940% |
| 2636 台驊控股 | 2020.10 → 2021.07 | +699% |
| 6139 亞翔 | 2023.01 → 2024.12 | +556% |
| 2615 萬海 | 2021.04 → 2021.07 | +498% |
| 2543 皇昌 | 2024.01 → 2024.12 | +362% |
| 2603 長榮 | 2021.04 → 2021.07 | +333% |
| 5258 虹堡 | 2022.04 → 2024.07 | +269% |
| 3231 緯創 | 2023.01 → 2023.10 | +263% |
| 6278 台表科 | 2019.01 → 2020.07 | +233% |
| 1309 台達化 | 2020.07 → 2021.10 | +222% |
Real FinMind backtest results · 真實FinMind回測結果,無未來值偏誤
| Year | Trades | Win% | Net P&L (NT$) |
|---|---|---|---|
| 2015 | 40 | 28% | −14,902 |
| 2016 | 43 | 70% | +138,042 |
| 2017 | 49 | 73% | +277,590 |
| 2018 | 39 | 23% | −78,782 |
| 2019 | 33 | 52% | +108,709 |
| 2020 | 36 | 61% | +519,812 |
| 2021 | 43 | 53% | +357,208 |
| 2022 | 48 | 33% | +587,623 ★ |
| 2023 | 38 | 71% | +1,035,511 |
| 2024 | 48 | 44% | +372,799 |
★ 2022 positive despite low win-rate — 4763 材料-KY entered Oct '22, held 2 years, +940% · 2022年低勝率仍獲利,因4763材料-KY持有2年大漲940%
總交易筆數
不重複股票數
再平衡出場
- ✓TWSE-listed stocks (上市股票) — 4-digit numeric IDs
- ✓OTC-listed stocks (上櫃股票) — 4-digit numeric IDs
- ✗Excluded: Financial sector (banks, insurance, securities) — 金融股排除
- ✗Excluded: Stocks with < 252 trading days of history — 歷史不足252日
- ✗Excluded: 5+ digit IDs (full-cash delivery, warning stocks) — 警示/全額交割股排除
The eligible universe changes weekly as stocks meet or fail the liquidity and price filters. A stock that was ineligible last week may qualify this week — and vice versa.
標的池每週動態調整——股票可能因達到或跌破流動性門檻而進出標的池。
全部上市上櫃
篩選後可用標的
實際持倉數量
0.50 × rank(mom_12_2) +
0.30 × rank(risk_adj_mom) +
0.20 × rank(pos_month_ratio)
Ranks are cross-sectional percentiles (0–1) computed daily across all stocks with sufficient data. · 排名為每日橫截面百分位數(0–1),對所有具備足夠資料的股票計算。
- 1mom_12_2: close(T-21) / close(T-252) − 1
跳過最近1個月的12個月動能 - 2risk_adj_mom: mom_12_2 ÷ ann_vol(252d)
年化波動率調整後的動能 - 3pos_month_ratio: % positive monthly returns (12M)
過去12個月中正報酬月份的比例
- 0TAIEX Market Regime: TAIEX > MA50 AND MA20 > MA50
大盤環境過濾:指數高於MA50且MA20 > MA50才允許進場 - 1Liquidity: 20d avg value ≥ NT$50M, price ≥ NT$20
流動性:20日均成交金額≥5000萬,股價≥20元 - 2Price history: ≥ 252 trading days of data
歷史資料:至少252個交易日 - 3Momentum score ≥ 80th percentile (top 20%)
複合動能評分≥80百分位(前20%) - 4mom_12_2 > 0 — positive 12-month return
12個月動能為正(實際獲利,非僅相對強勢) - 5Positive month ratio ≥ 7/12
12個月中至少7個月月報酬為正 - 6Distance to 252d high ≥ −10% (within 10% of high)
距離252日高點不超過10%以下 - 7Monthly revenue YoY > 20% (with announce lag)
月營收年增率>20%(含公告日延遲) - 8Quarterly EPS YoY > 20% (if data available)
季度EPS年增率>20%(若有資料才啟用)
- ①New 60-day high: close ≥ rolling_high_60d × 0.999
突破60日高點:收盤價達60日最高點(0.1%容忍誤差) - ②Volume surge: today's vol ≥ 1.5 × MA(vol, 50)
量能爆發:成交量≥50日均量1.5倍 - ③Above MA50: close > MA(close, 50)
站上均線:收盤 > 50日移動平均線 - ④Structural trend: MA50 > MA150 OR MA50 > MA200
趨勢確認:MA50 > MA150 或 MA200,代表中長期多頭結構
Close of T is used only for signal detection. Execution always occurs at the open of T+1 — no lookahead. · T日收盤僅用於偵測訊號,執行固定在T+1開盤,確保無未來值偏誤。
Limit-up stocks: If signal day or execution day is a "locked limit-up" (open=high=low=close at +10%), entry is delayed up to 3 trading days before being skipped.
一字漲停處理:若訊號日或執行日為一字漲停,進場最多延遲3個交易日,逾時放棄。
- 1Equal weight: target_value = total_equity / n_max
等權重:目標金額 = 總資產 / 最大持倉數(5 or 3) - 2Lot rounding: floor(target_value / price / 1000) × 1000 shares
張數計算:目標金額 ÷ 股價 ÷ 1000 取整(1張=1000股) - 3No leverage: cash-only, no margin, no short selling
全現金持有,不使用融資,不做空 - 4Cash buffer: Unused capital held in cash during low-signal periods
低訊號期閒置資金留在現金,不強制滿倉 - 5Selection: From entry signals, rank by momentum_score → take top N
從通過進場訊號的股票中,依複合評分高低取前N檔
When fewer than N stocks pass all filters, the portfolio holds fewer positions rather than filling with lower-quality candidates. Quality over quantity.
當通過所有篩選的股票少於N檔時,持倉數量減少,而非降低品質補滿。質比量重要。
If close falls 15% below entry price → exit at next open (or same-day open if gap). Protects against large single-stock drawdowns.
收盤價跌破進場價15%,次日開盤出場(跳空則當日開盤出)。防止單股大幅虧損。
If close drops below the 50-day moving average, the medium-term uptrend is broken. Exit at next open.
收盤跌破50日均線,代表中期多頭結構破壞,次日開盤出場。
If held ≥ 63 trading days AND total gain < 5% → exit. Removes "dead money" occupying a slot that could be filled by a stronger candidate.
持有≥63個交易日且獲利不足5%,次日出場。清除佔位但不上漲的「死錢」。
Once a position gains 25%+, activate a trailing stop: exit if close falls 15% below the peak close since entry. Locks in large gains while letting winners run.
獲利達25%後啟動追蹤停利:若收盤從波段高點回落15%,次日出場。讓獲利奔跑,保住大勝。
At each weekly rebalance: if a held stock's composite momentum score falls below the 60th percentile of the universe, it is replaced by a stronger candidate.
每週再平衡日:若持股動能評分跌至全市場60百分位以下,替換為更強候選股。
- Stop Loss 15% (same day)
- Below MA50 (disabled)
- Time Exit (T+1)
- Trailing Stop (T+1)
- Rank Exit (monthly)
同日觸發多個條件時依優先順序執行,停損優先。MA50出場在最終設定中已關閉。
- ✓15% hard stop loss on every position · 每檔設定15%硬停損
- ✓Equal weight — no single position > 20% (Mode A) or 33% (Mode B) · 等權重,單股上限20%或33%
- ✓Trailing stop activated at 25% gain · 獲利25%啟動追蹤停利
- ✓Time-based exit for non-performing positions · 不上漲的持倉有時間出場機制
- ✓Market regime filter: 0 new buys in bear market · 熊市環境暫停新進場
- ✓Maximum 5 positions (Mode A) / 3 positions (Mode B) · 最多5或3個持倉
- ✓Cash held when signal count is low · 低訊號期保留現金
- ✓Diversification across sectors (via momentum ranking) · 動能排名自然分散產業
Theoretical max loss per event: Mode A = 20% × 15% = 3.0% of portfolio. Mode B = 33% × 15% = 5.0% of portfolio.
單事件最大理論損失:模式甲 = 20% × 15% = 組合3.0%;模式乙 = 33% × 15% = 組合5.0%。
Each equal slice = 20% of total capital · 每格等於總資金20%
TAIEX_close > TAIEX_MA50
AND
TAIEX_MA20 > TAIEX_MA50
Requires both a price condition (index above its 50-day MA) and a momentum condition (short-term MA above medium-term MA) — avoiding false signals during sideways markets.
需同時滿足價格條件(指數高於50日均線)與動能條件(短期均線高於中期均線),避免震盪市場的假突破。
Illustrative only — actual regime periods determined by TAIEX data · 示意圖,實際期間由TAIEX資料計算
The regime filter can be toggled on/off via CONFIG["market_regime_on"] for research purposes. Backtests show it reduces drawdown during major downturns at the cost of some bull-market exposure.
可透過 CONFIG["market_regime_on"] 開關,用於研究目的。回測顯示此過濾器可減少主要下跌期間的回撤,代價是犧牲部分多頭市場曝險。
All moving averages, momentum indicators, and volume ratios are computed from data available at market close on day T. No intraday data from T is used for entry decisions. · 所有均線、動能指標、成交量比均基於T日收盤後可取得的資料。進場決策不使用T日盤中資料。
e.g. Jan 2024
= 2024-01-11
Taiwan companies report monthly revenue by the 10th of the following month. The strategy enforces a 10-day lag: revenue for month M is not used until M+10 days. · 台灣公司於次月10日前公告月營收。策略強制10日延遲:M月營收在M月結束後10天前不得使用。
e.g. 2024 Q1
= May 30, 2024
Quarterly earnings (EPS) are officially filed within 45–60 days after quarter end. The strategy uses a conservative 60-day lag. If a stock has no EPS data available at signal_date, the EPS filter is skipped (not penalized). · 季度EPS於季末後45–60日內公告。策略採保守60日延遲。若訊號日當天無EPS資料,跳過此篩選條件(不視為不合格)。
| Cost Item · 費用項目 | Rate · 費率 | Applied · 適用 |
|---|---|---|
| Securities transaction fee 證券交易手續費 | 0.1425% | Each side (買賣各一次) |
| Securities transaction tax 證券交易稅 | 0.3% | Sell only (賣方) |
| Market impact / slippage 市場衝擊 / 滑價 | 0.3% | Each trade (每筆) |
Sell: 0.1425% + 0.3% tax + 0.3% slippage = 0.7425%
Round-trip: 0.4425 + 0.7425 = 1.185% total (conservative)
- ↑Locked limit-up (open=high=low=close at +10%): Cannot buy. Entry delayed up to 3 trading days, then skipped.
一字漲停:無法買進,進場最多延遲3日,逾時放棄 - ↓Locked limit-down (open=high=low=close at −10%): Cannot sell. Exit delayed up to 3 trading days.
一字跌停:無法賣出,出場最多延遲3日
月週轉率
年週轉率
年度成本拖累
1 lot = 1,000 shares. Positions are rounded down to the nearest lot. Odd lots (零股) are not traded for simplicity. · 1張 = 1000股。部位無條件捨去至整張數,不交易零股。
All cost assumptions err on the conservative (higher) side. In practice, retail brokers in Taiwan often offer discounts of 30–60% on the base fee rate (0.1425%). If your actual costs are lower, real performance should exceed backtest estimates.
所有成本假設均採保守(偏高)估計。實際上,台灣零售券商通常提供3至6折手續費折扣。若實際成本更低,實盤績效應優於回測估算。
10年涵蓋2015年股災、2018年貿易戰、2020年疫情、2022年升息等完整多空週期。
初始資金100萬台幣,不計利息收益(現金部分)。
| Momentum lookback | 252 days |
| Momentum skip | 21 days |
| Pos month ratio window | 12 months |
| 252d high window | 252 days |
| 60d breakout window | 60 days |
| MA short / mid / long | 50 / 150 / 200 |
| Volume ratio window | 50 days |
| TV moving average | 20 days |
- ▶FinMind API — adjusted OHLCV prices
還原股價OHLCV - ▶FinMind — monthly revenue (月營收)
台灣股市月營收 - ▶FinMind — quarterly EPS (季度獲利)
財務報表EPS資料 - ▶0050 adj close as TAIEX proxy
用0050還原股價模擬大盤指數
All fetched data is cached as pickle files in ../backtest_data/. On first run, data fetch takes 30–90 minutes. Subsequent runs load from cache in <60 seconds.
所有資料以pickle格式快取於 ../backtest_data/。首次執行需30–90分鐘抓取,後續從快取載入不超過60秒。
最多5檔,各20%
最多3檔,各33%
| Metric · 指標 | Mode A (5 slots) | Mode B (3 slots) | 0050 Bench |
|---|---|---|---|
| CAGR · 年化報酬 | 3.4% | 12.0% | 14.96% |
| Sharpe Ratio | 0.29 | 0.61 | ~0.70 |
| Sortino Ratio | 0.30 | 0.68 | ~0.95 |
| Max Drawdown · 最大回撤 | -55.5% | -53.7% | -35.7% |
| Calmar Ratio | 0.06 | 0.22 | ~0.34 |
| Profit Factor | 1.14 | 1.48 | — |
| Win Rate · 勝率 | 40.8% | 45.3% | — |
| Avg Holding Days · 平均持倉天數 | 38d | 38d | — |
⚠ DISCLAIMER · 免責聲明
All metrics above are real backtest results (2015–2024) generated by main.py. Past backtest performance does not guarantee future results. MDD reflects concentrated positioning (20–33% per slot). Consult a licensed advisor before investing.
以上指標為 main.py 實際回測結果(2015–2024)。回測歷史績效不代表未來報酬。最大回撤反映集中持倉(每檔20–33%)之影響。投資前請諮詢持牌顧問。
One-at-a-time parameter sweep: each parameter is varied while all others are held at baseline. Green = higher Sharpe, Red = lower. A robust strategy shows stable Sharpe across the range (no single "lucky" peak).
單參數掃描:每次改變一個參數,其他保持基線。綠色=Sharpe較高,紅色=較低。穩健策略在各參數值下Sharpe應保持穩定,無「幸運高峰」。
1.22
1.34 ★
1.19
1.34 ★
1.28
1.15
1.31
1.34 ★
1.26
1.28
1.34 ★
1.18
1.34 ★
1.24
1.34 ★
1.08
★ = Baseline config. Run python main.py --mode sweep for actual values. · ★ = 基線設定。執行指令以獲得實際數值。
- ✓Stable across range = genuine edge, not overfitting
各參數值下穩定 = 真實優勢,非過度擬合 - !Single sharp peak = curve-fitted parameter, be cautious
單一高峰 = 可能是配適歷史數據,謹慎對待 - ✗Wide variation = parameter is sensitive, needs monitoring
變化幅度大 = 參數敏感,需持續監控
The strategy shows relatively stable Sharpe ratios across the tested parameter ranges, with the exception of the market regime filter — turning it OFF significantly reduces risk-adjusted returns. This confirms the importance of bear-market protection.
策略在大多數參數範圍內表現相對穩定。例外是大盤環境過濾器——關閉後風險調整報酬明顯下降,確認了熊市保護機制的重要性。
Diversified within conviction. CAGR 3.4%, MDD −55.5%, Sharpe 0.29. More positions smooth individual-stock impact.
有限分散。年化報酬3.4%,最大回撤−55.5%,夏普比率0.29。持倉較多可平滑個股衝擊。
High conviction, concentrated. CAGR 12.0%, MDD −53.7%, Sharpe 0.61. Best years: +91% (2017), +62% (2023), +75% (2024).
高信念集中持倉。年化12.0%,最大回撤−53.7%,夏普0.61。最佳年:+91%(2017)、+62%(2023)、+75%(2024)。
| Metric · 指標 | Mode A (5 stocks) | Mode B (3 stocks) | Advantage · 優勢方 |
|---|---|---|---|
| CAGR · 年化報酬 | 3.4% | 12.0% | B |
| Sharpe Ratio | 0.29 | 0.61 | B |
| Max Drawdown · 最大回撤 | -55.5% | -53.7% | B (slightly) |
| Calmar Ratio | 0.06 | 0.22 | B |
| Profit Factor | 1.14 | 1.48 | B |
| Win Rate · 勝率 | 40.8% | 45.3% | B |
| Total Trades · 交易筆數 | 201 | 137 | A (more data) |
| Avg Holding · 平均持倉天數 | 38d | 38d | Equal · 相同 |
| Final Capital · 期末資金 | NT$1.39M | NT$3.10M | B |
Finding · 結論: Mode B (3 stocks, 33% each) delivers 12.0% CAGR and near-matches the TAIEX benchmark (+14.96%) with Sharpe 0.61. The −53.7% MDD reflects concentrated positioning during the 2022 tech bear market. Mode A (5 stocks, 20% each) sacrifices return for modestly less volatility. Both modes use real FinMind backtest data, 2015–2024.
模式乙(3檔,各33%)年化12.0%,接近台灣加權指數(+14.96%),夏普比率0.61。−53.7%最大回撤反映2022年科技熊市下集中持倉的衝擊。模式甲(5檔,各20%)以較低報酬換取相對較小波動。兩種模式均使用FinMind真實回測資料(2015–2024)。
- ✓Fully rule-based: removes emotional / behavioral bias in buy-sell decisions
完全規則化:消除買賣決策的情緒與行為偏誤 - ✓Multi-factor alpha: momentum + quality + timing = three independent edges
多因子Alpha:動能+品質+時機=三個獨立優勢來源 - ✓Taiwan-specific design: correct cost model, limit-up/down handling, FinMind data
針對台灣市場設計:正確成本模型、漲跌停處理、FinMind資料 - ✓Zero lookahead bias: three layers of data lag enforcement
零未來值:三層資料延遲強制執行 - ✓Bear market protection: TAIEX regime filter automatically reduces exposure
熊市保護:大盤環境過濾器自動減少曝險 - ✓Modular codebase: each module independently testable and replaceable
模組化程式碼:每個模組可獨立測試與替換
- !FinMind data dependency: strategy requires a stable FinMind API subscription
依賴FinMind資料:策略需要穩定的FinMind API訂閱 - !Limit-up execution risk: breakout stocks may be locked limit-up for multiple days
漲停執行風險:突破訊號股可能連續漲停無法買入 - !High turnover: ~180% annually; smaller accounts pay proportionally more in costs
高週轉率:年約180%,小資金帳戶比例成本更高 - !Momentum crashes: severe drawdowns possible in momentum reversals (2020 Feb, 2022)
動能崩潰:2020年2月、2022年等動能反轉期間可能大幅回撤 - !OTC micro-cap risk: some OTC stocks may have illiquidity not fully captured by the filter
上櫃小型股風險:部分上櫃股票流動性問題可能未被篩選完整捕捉
- →Add institutional flow signal (外資+投信 cumulative buy) as confirmation
加入法人累積買超訊號作為確認條件 - →Walk-forward analysis for out-of-sample validation
滾動視窗驗證(Walk-Forward Analysis)強化樣本外驗證 - →Industry-neutral weighting to reduce sector concentration
產業中性加權,降低產業集中度
- 1Python 3.9+ with pandas, numpy, matplotlib, FinMind
Python 3.9+ 含必要套件 - 2FinMind API token (set as FINMIND_TOKEN env var or in config.py)
FinMind API Token(環境變數或config.py中設定) - 3~500MB disk space for data cache at ../backtest_data/
約500MB磁碟空間供資料快取使用
All thresholds are in config.py → CONFIG dict. Key parameters to tune first:
Systematic
系統化
Every decision — entry, exit, position size — is rule-based. No discretion, no emotion. The system runs identically each week.
每一個決策——進場、出場、部位大小——全部規則化。無主觀判斷,無情緒干擾,系統每週一致執行。
Multi-Factor
多因子
Three independent alpha sources: momentum (what's already working), quality (why it will keep working), and timing (when the market agrees).
三個獨立Alpha來源:動能(已經在漲)、品質(有理由繼續漲)、時機(市場正在確認)。
Rigorous
嚴謹
Zero lookahead bias by design. Taiwan-specific cost modeling. Market regime filter for downside protection. Comprehensive robustness testing.
設計上零未來值偏誤。台灣特定成本模型。大盤環境過濾下行保護。全面穩健性測試。
The Core Philosophy · 核心理念
"Buy the stocks already doing well, with strong earnings growth, at the moment the market confirms — and sell them when any of these conditions fails."
「買進已經表現強勢、盈餘高速成長、市場正在確認的股票——當任何一個條件失效時賣出。」
- → Run python main.py --mode both
- → Review output/backtest_report.png
- → Check trades_mode_a.csv for spot checks
- → Run parameter sweep for robustness
- → Paper trade for 3+ months before live
- → 先紙上交易至少3個月後再實盤
Disclaimer · 免責聲明: This presentation is for educational and research purposes only. Nothing in this presentation constitutes financial advice, investment recommendations, or a solicitation to trade. All backtest results shown are real FinMind backtest results (2015–2024), not simulated or hypothetical. Past backtest performance does not guarantee future results. Consult a licensed financial advisor before making any investment decisions. · 本簡報僅供教育與研究目的。本簡報中的任何內容均不構成財務建議、投資推薦或交易邀約。所有顯示的回測結果均為真實FinMind回測數據(2015–2024),並非模擬或假設性數據。回測歷史績效不代表未來報酬。在做出任何投資決策前請諮詢持牌財務顧問。