Skip to content

hi66724389/cl-option-zone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛢️ CL Option Zone Analyzer

WTI 原油期貨成交量分布與量化策略分析工具 / Automated Volume Profile & Quantitative Strategy Engine for WTI Crude Oil Futures (CL)

一個專為 WTI 原油期貨 (CL) 設計的量化分析工具,透過 成交量分布 (Volume Profile) 指標自動計算關鍵支撐/阻力位,並根據市場統計環境建議合適的選擇權策略。

License Python


📋 目錄 / Table of Contents


🎯 功能特色 / Features

1. 成交量分布分析 / Volume Profile Analysis

指標 / Metric 說明 / Description
POC (Point of Control) 最高成交量價格 / The price level with the highest traded volume
VAH (Value Area High) 價值區高點 - 70% 成交量區間的上緣 / Upper boundary of 70% volume range
VAL (Value Area Low) 價值區低點 - 70% 成交量區間的下緣 / Lower boundary of 70% volume range
HVN (High Volume Nodes) 高成交量節點 - 強支撐/阻力區 / Strong support/resistance zones
LVN (Low Volume Nodes) 低成交量節點 - 快速移動的「真空」區 / Fast-move "vacuum" zones

2. 支撐強度分析 / Support Strength Analysis

  • 多維度計算: 成交量權重 + 歷史反彈次數 + 距離衰減
  • 標準化排名: Z-Score + Min-Max 標準化 (0-100分)
  • 視覺化呈現: 條形圖顯示強度分數
  • Top 15 強支撐位: 自動標註 POC/VAH/VAL

3. 市場環境偵測 / Market Context Detection

環境 / Context 說明 / Description 建議策略 / Recommended Strategy
Inside Value (區間內) 價格在 VAH 和 VAL 之間 / Price between VAH and VAL 鐵鷹策略 (Iron Condor) / 信用價差 (Credit Spread)
Above Value (區間上) 價格高於 VAH / Price above VAH 多方向價差 / Directional Bull Spreads
Below Value (區間下) 價格低於 VAL / Price below VAL 空方向價差 / Directional Bear Spreads

4. 雙語言支援 / Bilingual Support

  • 繁體中文 (zh-TW)
  • English (en)

5. 互動式輸入 / Interactive Input Mode

  • 支援互動式參數詢問
  • 支援命令行參數
  • 支援多種標的物: CL=F, GC=F, ES=F, NQ=F, YM=F, SI=F, NG=F

🚀 安裝指南 / Installation

1. 複製專案 / Clone Repository

git clone https://github.com/hi66724389/cl-option-zone.git
cd cl-option-zone

2. 安裝依賴套件 / Install Dependencies

pip install -r requirements.txt

⚠️ Windows Users / Python 3.13+ Note: 如果遇到 pandas-tascipy 安裝錯誤,嘗試使用預發布版本:

pip install -r requirements.txt --pre

或直接從源碼安裝 pandas-ta:

pip install git+https://github.com/twopirllc/pandas-ta.git@development

📖 使用方式 / Usage

模式一: 命令行模式 / Command Line Mode

# 預設設定 (5天回看, 150個價格分箱)
python main.py

# 自訂分析週期和解析度
python main.py --period 10d --bins 200

# 分析不同標的物 (例如黃金)
python main.py --symbol GC=F

# 使用英文輸出
python main.py --lang en

模式二: 互動式模式 / Interactive Mode

# 啟動互動式參數詢問
python main.py --interactive
#
python main.py -i

互動式模式會引導您選擇:

  1. 語言 / Language
  2. 標的物 / Symbol
  3. 回看時間段 / Period
  4. 價格分箱數 / Bins
  5. 確認設定 / Confirm Settings

📊 輸出範例 / Output Example

中文輸出 / Chinese Output

╭──────────────────────────────────────────────────────╮
│            📊 CL 選擇權區域分析器                      │
│            標的: CL=F | 週期: 5d                      │
╰──────────────────────────────────────────────────────╯

✅ 數據已載入: 1440 根K線。現價: 76.54

🛡️ 關鍵價位與區域
┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ 指標                 ┃ 價格        ┃ 與現價關係       ┃
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
│ 現價                 │       76.54 │ -                │
│ VAH (價值區高點)     │       77.20 │ +0.66            │
│ POC (控制點)         │       76.10 │ -0.44            │
│ VAL (價值區低點)     │       75.80 │ -0.74            │
└──────────────────────┴─────────────┴──────────────────┘

💪 支撐強度排名 (前15)
┏━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━┓
┃ 排名 ┃ 價格      ┃ 強度分數            ┃ Z分數    ┃ 距離    ┃
┡━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━┩
│ #1   │ 76.10 (POC)│  100.00 ██████████│    2.45  │ -0.44%  │
│ #2   │ 77.20 (VAH)│   85.32 ████████  │    1.89  │ +0.86%  │
│ #3   │ 75.50      │   72.15 ███████   │    1.32  │ -1.36%  │
└──────┴───────────┴────────────────────┴───────────┴─────────┘

╭──────────────────────────────────────────────────────╮
│  📊 量化分析                                         │
├──────────────────────────────────────────────────────┤
│  市場環境: 【區間內】                                 │
│                                                      │
│  🎯 策略傾向:                                        │
│  • POC 回歸目標: 76.10                               │
│  • VAH 阻力/突破點: 77.20                            │
│  • VAL 支撐/跌破點: 75.80                            │
│                                                      │
│  ⚠️ 高成交量節點 (結構性價位): 76.10, 75.50, 77.00   │
│  🚀 低成交量節點 (流動性真空): 76.80, 75.20           │
╰──────────────────────────────────────────────────────╯

🔧 參數說明 / Parameters

命令行參數 / Command Line Arguments

參數 / Argument 說明 / Description 預設值 / Default
--symbol, -s 標的物代碼 (例如 CL=F, GC=F) CL=F
--period, -p 回看時間段 (例如 5d, 1mo, 3mo) 5d
--bins, -b 價格分箱數量 (50-250) 150
--lang, -l 語言 (zh-TW, en) zh-TW
--interactive, -i 啟用互動式參數詢問 False

可用的標的物 / Available Symbols

代碼 / Code 名稱 / Name
CL=F WTI 原油 / Crude Oil WTI
GC=F 黃金 / Gold
ES=F S&P 500
NQ=F 納斯達克 100 / NASDAQ 100
YM=F 道瓊斯 / Dow Jones
SI=F 白銀 / Silver
NG=F 天然氣 / Natural Gas

可用的時間段 / Available Periods

代碼 / Code 說明 / Description
1d 1 天 / 1 Day
5d 5 天 / 5 Days
1mo 1 個月 / 1 Month
3mo 3 個月 / 3 Months
6mo 6 個月 / 6 Months
1y 1 年 / 1 Year

📂 專案架構 / Project Structure

cl-option-zone/
├── main.py                      # 主程式入口 / Main entry point
├── requirements.txt             # Python 依賴套件 / Python dependencies
├── SUPPORT_STRENGTH.md           # 支撐強度分析說明 / Support strength analysis docs
│
├── core/                         # 核心模組 / Core modules
│   ├── __init__.py
│   ├── data_loader.py           # 數據載入模組 (yfinance) / Data loader module
│   ├── volume_profile.py        # 成交量分布分析引擎 / Volume profile analysis engine
│   ├── support_strength.py      # 支撐強度計算引擎 / Support strength calculator
│   └── interactive_input.py     # 互動式輸入處理 / Interactive input handler
│
└── utils/                        # 工具函數 / Utility functions
    └── __init__.py

核心模組說明 / Core Modules Description

模組 / Module 功能 / Function
core/data_loader.py 從 yfinance 載入 OHLCV 資料 / Load OHLCV data from yfinance
core/volume_profile.py 計算 POC, VAH, VAL, HVN, LVN / Calculate POC, VAH, VAL, HVN, LVN
core/support_strength.py 計算支撐強度排名 / Calculate support strength ranking
core/interactive_input.py 處理互動式參數輸入 / Handle interactive parameter input

🧠 理論基礎 / Theory & Logic

成交量分布 / Volume Profile

本腳本建構指定期間內 (--period) 各價位的成交量直方圖:

  • Value Area (70%): 70% 交易量發生的價格區間,代表「聰明錢」的共識區間
  • POC (Point of Control): 「最公平」的價格,價格傾向回歸此點
  • HVN (High Volume Nodes): 強支撐/阻力區,價格通常會在此減速
  • LVN (Low Volume Nodes): 流動性真空區,價格通常會快速通過

支撐強度計算 / Support Strength Calculation

支撐強度透過以下三個維度計算:

  1. 成交量權重: 成交量越大的價位,支撐強度越強
  2. 歷史反彈調整: 價格在該區間附近反彈的次數,每次觸碰增加 10% 強度
  3. 距離衰減: 距離當前價格越近,指數衰減調整權重 (e^(-5 × 距離比率))

選擇權策略映射 / Option Strategy Mapping

市場環境 / Market Context 適合策略 / Suitable Strategy
Inside Value (區間內) 鐵鷹策略 (Iron Condor)、信用價差 (Credit Spreads) - 賣出 Vega/Theta
Outside Value (區間上/下) 方向性價差 (Directional Spreads)、買入選擇權 (Long Options) - 買入 Gamma

⚠️ 風險警告 / Disclaimer

本軟體僅供教育與研究目的使用。它不構成金融建議。

期貨與選擇權交易涉及重大風險,可能導致本金全部損失。過往表現不代表未來結果。

使用本工具前請確保您:

  • 了解期貨與選擇權交易的風險
  • 擁有足夠的風險承受能力
  • 建議在模擬帳戶中先進行測試

📝 更新日誌 / Changelog

v1.0.0 (2025-02-25)

  • 初始版本發布 / Initial release
  • 成交量分布分析 / Volume Profile analysis
  • 支撐強度排名 / Support Strength ranking
  • 互動式輸入模式 / Interactive input mode
  • 雙語言支援 / Bilingual support

🤝 貢獻者 / Contributors

作者 / Author: hi66724389
授權 / License: MIT


🔗 相關連結 / Related Links


Generated with ❤️ for quantitative trading enthusiasts

About

Automated Volume Profile & Option Zone Analyzer for Crude Oil Futures (CL)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages