Skip to content

lawjar/ParaLand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ParaLand 🏔️

Robust Parameter Landscape Analysis for MT4 Strategy Optimization

ParaLand 是一個專為算法交易者設計的 Python 工具,旨在解決 MetaTrader 4 (MT4) 回測中常見的「過度擬合 (Overfitting)」問題。它透過視覺化熱力圖與穩健性算法,幫助開發者尋找參數的「高原 (Plateaus)」,而非孤立的「尖峰 (Peaks)」。


🚀 核心功能 (Features)

  • 穩健性視覺化 (Robustness Visualization):
    • 利用高斯模糊 (Gaussian Filter) 平滑回測數據,消除隨機噪點。
    • 直觀識別參數的「高原區域」,確保策略在參數微小變動下仍能保持獲利。
  • 參數熱力圖 (Parameter Heatmap):
    • 支援任意兩個參數 (X, Y) 對應目標 (Z, 如 Profit) 的 2D 分析。
    • 使用紅綠色階 (RdYlGn) 直觀顯示虧損與盈利區域。
  • 靈活數據支持:
    • 直接讀取 MT4 導出的 CSV 優化報告。

🛠️ 安裝與依賴 (Installation)

前置需求

  • Python 3.8+

安裝依賴庫

pip install pandas matplotlib seaborn scipy numpy

📖 使用指南 (Usage)

  1. 準備數據:

    • 在 MT4 Strategy Tester 完成優化 (Optimization)。
    • 在 "Optimization Results" 分頁右鍵 -> "Save to Report",或複製到 Excel 並另存為 optimization_results.csv
    • 確保 CSV 包含表頭 (Header),例如 MA_Period, StopLoss, Profit
  2. 運行 ParaLand:

    • optimization_results.csv 放入與 paraland.py 相同的目錄。
    • 執行腳本:
    python paraland.py
  3. 自定義分析:

    • 打開 paraland.py,修改底部執行區塊以指定你要分析的參數:
    app = ParaLand('optimization_results.csv')
    # 分析 MA_Period 和 StopLoss 對 Profit 的影響
    app.plot_heatmap('MA_Period', 'StopLoss', target='Profit', robust_check=True)

🏗️ 項目架構 (Architecture)

class ParaLand

  • __init__(filepath): 負責數據載入與基本的錯誤檢查。
  • plot_heatmap(...): 核心視覺化引擎。包含 robust_check 邏輯,利用 scipy.ndimage.gaussian_filter 進行數據平滑。
  • find_best_cluster(...): (Beta) 簡單的篩選邏輯,用於找出數值表現最好的參數組合。

🗺️ 開發路線圖 (Roadmap)

  • V1.0: 基礎熱力圖與高斯平滑 (已完成)
  • V1.1: 加入綜合評分指標 (Score = Profit / Drawdown)
  • V1.2: 支援 Plotly 互動式圖表 (滑鼠懸停查看數值)
  • V2.0: 自動化參數推薦算法 (Auto-Clustering)

🤝 貢獻 (Contributing)

歡迎提交 Pull Requests 或 Issues 來改進 ParaLand!

📄 License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages