SuperAPI AI Directory

strategy-optimization

General & other

View repository

Updated 10-16 01:15

About this skill

Trading Strategy Optimization Strategy Optimization

A systematic strategy optimization process, from diagnosing problems to achieving goals

Applicable Scenarios

  • Win rate too low (< 40%)
  • Returns below target
  • Strategy performs poorly in specific market states
  • Need to achieve a specific return target (e.g., 15%+)

Core Process

┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│                   策略優化迭代循環                              │
│                                                                 │
│  ┌─────────┐   ┌─────────┐   ┌─────────┐   ┌─────────┐         │
│  │ ANALYZE │ → │ DIAGNOSE│ → │ RESEARCH│ → │IMPLEMENT│         │
│  │  分析   │   │  診斷   │   │  研究   │   │  實作   │         │
│  └────┬────┘   └────┬────┘   └────┬────┘   └────┬────┘         │
│       │             │             │             │               │
│       ▼             ▼             ▼             ▼               │
│  收集指標      找根因       搜尋方案      實作變更             │
│                                                                 │
│       ┌─────────────────────────────────────────┐               │
│       │                                         │               │
│       ▼                                         │               │
│  ┌─────────┐   ┌─────────┐                     │               │
│  │VALIDATE │ → │ ITERATE │ ────────────────────┘               │
│  │  驗證   │   │  迭代   │   未達標 → 回到 ANALYZE              │
│  └────┬────┘   └─────────┘                                      │
│       │                                                         │
│       ▼                                                         │
│   達標 → 文檔化部署                                             │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Phase 1: ANALYZE

Collect current performance metrics:

Metric Description Healthy Standard
Win Rate Proportion of profitable trades > 40%
Return Total profit and loss Positive
Drawdown Maximum loss magnitude < 20%
Number of Trades Statistical significance > 100 trades
Expected Value Expected profit per trade Positive

Expected Value Formula

Expectancy = (WinRate × AvgWin) - ((1-WinRate) × AvgLoss)

範例:
勝率: 54.5%, 平均贏: $7.42, 平均輸: $8.26
期望值: (0.545 × 7.42) - (0.455 × 8.26) = +$0.29/筆

正期望值 × 大量交易 = 穩定獲利

Phase 2: DIAGNOSE

Key: find the root cause, not the symptom

Common Root Causes

Symptom Possible Root Cause Diagnostic Method
Low win rate Strategy not suited to market state Check ADX/market regime
Low return Poor SL/TP ratio Analyze profit/loss distribution
Large drawdown Leverage too high Calculate risk exposure
Few trades Conditions too strict Loosen entry conditions

Market State Analysis

┌─────────────────────────────────────────────────────────────────┐
│  市場狀態 vs 策略匹配                                           │
│                                                                 │
│  ADX < 25 (盤整)  → Grid Trading, Mean Reversion               │
│  ADX > 25 (趨勢)  → Trend Following, Momentum                   │
│  高波動            → Scalping, 減少部位                         │
│  低波動            → Grid Trading, Breakout 準備                │
│                                                                 │
│  ⚠️ 90% 時間市場在盤整,趨勢策略會持續虧損!                    │
└─────────────────────────────────────────────────────────────────┘

Diagnosis Example

症狀: 勝率只有 25%
  ↓
分析: 使用 RSI+MACD 趨勢策略
  ↓
檢查: ADX 平均 < 25(90% 時間在盤整)
  ↓
根因: 趨勢策略用在盤整市場
  ↓
方向: 需要盤整市場策略(Grid Trading)

Phase 3: RESEARCH

Strategy-Market State Mapping Table

Market State Recommended Strategy Reason
Consolidation (ADX < 25) Grid Trading Exploit price oscillation
Mean Reversion Mean reversion
Scalping Quick in, quick out
Trend (ADX > 25) Trend Following Follow the trend
Momentum Momentum continuation
Breakout Breakout follow-through
High Volatility Scalping Quick profit taking
Reduce position size Control risk

Sharp Edge: Research Data Validation

┌─────────────────────────────────────────────────────────────────┐
│  ⚠️ SE-1: 研究數據必須實測驗證                                  │
│                                                                 │
│  嚴重度: critical                                               │
│                                                                 │
│  案例:                                                         │
│  - 研究聲稱圖表模式有 80-84% 成功率                             │
│  - 實際回測:讓策略表現更差                                     │
│  - 原因:股市數據不適用於加密貨幣                               │
│                                                                 │
│  教訓:                                                         │
│  ❌ 看到研究數據就實作                                          │
│  ✅ 先用真實數據回測驗證                                        │
└─────────────────────────────────────────────────────────────────┘

Phase 4: IMPLEMENT

Parameter Adjustment Strategy

Parameter Adjustment Direction Impact
SL/TP Ratio Symmetric (1:1) vs asymmetric Win rate vs profit/loss ratio
Leverage 1x → 10x Return vs risk
Entry Threshold Loose vs strict Number of trades vs quality

Key Findings

┌─────────────────────────────────────────────────────────────────┐
│  優化發現                                                       │
│                                                                 │
│  1. 對稱 SL/TP 更好                                             │
│     - 1.8%/1.8% 產生 ~55% 勝率                                  │
│     - 比 1%/3% 的表現更好                                       │
│                                                                 │
│  2. Grid Trading 在盤整市場                                     │
│     - 勝率從 25% 提升到 55%                                     │
│     - 關鍵:ADX < 25 時啟用                                     │
│                                                                 │
│  3. 更多交易 + 正期望值                                         │
│     - 小獲利累積成大報酬                                        │
│     - 191 筆交易 × $0.29/筆 = +$55                              │
└─────────────────────────────────────────────────────────────────┘

Phase 5: VALIDATE

Backtest Requirements

Item Minimum Requirement Recommended
Backtest Period 60 days 180 days
Number of Trades 50 trades 100+ trades
Out-of-sample testing Yes Required
Transaction costs Included Including slippage

Validation Checklist

□ 勝率是否改善?
□ 報酬是否達標?
□ 回撤是否可接受?
□ 期望值是否為正?
□ 樣本外表現如何?

Phase 6: ITERATE

未達標 → 回到 ANALYZE
  │
  ├── 分析新結果
  ├── 調整參數或策略
  ├── 重新驗證
  └── 重複直到達標

Best Practices

  1. Diagnose before acting - Do not blindly tune parameters
  2. Change one variable at a time - Only then can you know what works
  3. Validate research conclusions - Theoretical data is not trustworthy
  4. Sufficient number of trades - Statistical significance
  5. Document successful experience - Write it as an ADR

Common Mistakes

Mistake Consequence Fix
❌ Only tuning parameters without changing the strategy Cannot solve the root problem Diagnose the root cause first
❌ Backtest period too short Overfitting 180+ days
❌ Ignoring market regimes Strategy-market mismatch Use Regime Detection
❌ Pursuing a high win rate Sacrificing the profit-loss ratio Focus on expected value

Success Cases

優化前:
- 報酬: 0.46%
- 勝率: 23.5%
- 策略: RSI+MACD(趨勢策略用在盤整市場)

診斷:
- 90% 時間 ADX < 25(盤整)
- 趨勢策略不適合

優化後:
- 報酬: +19.93%
- 勝率: 54.5%
- 策略: Grid Trading + Regime Detection

關鍵改變:
1. 新增 Grid Trading 策略
2. 使用 Regime Detection 動態切換
3. 對稱 SL/TP (1.8%/1.8%)
4. 10x 槓桿 + 191 筆交易

Risk Warnings

⚠️ 高報酬伴隨高風險

- 上述案例最大回撤 48.84%
- 考慮降低槓桿 (5x) 換取更低風險
- 持續監控市場狀態變化
- 設定停損機制

Reference Configuration

# 經過驗證的配置
config = {
    "leverage": 10.0,          # 或 5.0 降低風險
    "stop_loss_pct": 0.018,    # 1.8%
    "take_profit_pct": 0.018,  # 1.8%
    "top_n_signals": 3,
    "min_confidence": 0.5,
    "use_regime_selector": True,
}

Related Skills

  • finance/quant-trading - Quantitative Trading Fundamentals
  • finance/investment-analysis - Investment Analysis
  • methodology/knowledge-acquisition-4c - Learning New Domains