Skip to content

About

docker-openclaw

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

OpenClaw Docker — China Stock Analysis

Automated China A-share & HK stock analysis system powered by OpenClaw gateway. Combines three investment methodologies (CANSLIM, Value Investing, Growth) with macro cycle analysis, delivering actionable insights via WeChat.

✨ Features

  • Multi-Master Scoring — CANSLIM (O'Neil) + Value (Duan Yongping) + Growth (Peter Lynch)
  • Market Screener — 全市场 CANSLIM 扫描 (中证800 + 创业板综), 双路线筛选 (底部蓄势 + 强势创新高), 6 个基本面反转信号 + 走势确认 + 爆量豁免
  • Technical Analysis — MA, RSI, MACD, Bollinger Bands, volume analysis
  • Fundamental Analysis — PE, PB, ROE, PEG, 10-year financial history
  • Macro Cycle Analysis — Howard Marks 14-dimension market cycle positioning
  • Trading Signals — Multi-dimension buy/sell signals with pattern recognition
  • Automated Reports — Morning briefing, midday update, closing summary, weekly report
  • Price Alerts — Configurable thresholds checked every 30 minutes during trading hours
  • WeChat Delivery — Auto-split long messages, supports WeCom App/Bot, Server酱, PushPlus, Telegram

🚀 Quick Start

Prerequisites

  • Docker & Docker Compose
  • An OpenClaw account and gateway token

1. Clone & Configure

git clone <repo-url> && cd openclaw-docker

# Copy example config
cp openclaw.example.json data/openclaw.json
# Edit data/openclaw.json — set your gateway token

# Configure notifications
cp data/stock-data/notifier.example.json data/stock-data/notifier.json
# Edit data/stock-data/notifier.json — set your WeChat webhook key

# Enable security hook
git config core.hooksPath .githooks

2. Start

docker compose up -d

3. Install Dependencies (first time)

Dependencies are installed into the host-mounted ./pip-user directory so they survive container rebuilds (the directory is mapped to /home/node/.local):

# pip is bootstrapped from Debian repos (use root)
docker exec --user root openclaw apt-get update && \
  docker exec --user root openclaw apt-get install -y --no-install-recommends python3-pip

# Install project deps as the `node` user (writes to ./pip-user/)
docker exec --user node openclaw \
  python3 -m pip install -r /home/node/.openclaw/skills/china-stock/requirements.txt

4. Configure Watchlist

Edit data/stock-data/watchlist.json to add your stocks:

{
  "groups": {
    "核心持仓": ["600519", "000858"],
    "科技成长": ["300750", "hk00700"],
    "金融地产": ["601318", "000002"]
  }
}

5. Test

# Run a closing report
docker exec -w /home/node/.openclaw/skills/china-stock openclaw python3 runner.py close

# Run market cycle analysis
docker exec -w /home/node/.openclaw/skills/china-stock openclaw python3 market_cycle.py

# Force refresh + send to WeChat
docker exec -w /home/node/.openclaw/skills/china-stock openclaw python3 market_cycle.py --refresh --send

# Run full-market CANSLIM screener (first run ~5min, cached run ~40s)
docker exec --user node -w /home/node/.openclaw/skills/china-stock openclaw \
  python3 runner.py screen

# Dry-run with 3 sample stocks (smoke test)
docker exec --user node -w /home/node/.openclaw/skills/china-stock openclaw \
  python3 runner.py screen --dry-run

⏰ Cron Schedule

Job Time Command
早盘简报 9:00 Mon-Fri python3 runner.py morning
午盘快报 11:35 Mon-Fri python3 runner.py midday
收盘总结 15:05 Mon-Fri python3 runner.py close
价格预警 Every 30min (trading hours) python3 runner.py alert
周报 Sat 10:00 python3 runner.py weekly
周期分析 Sat 10:30 python3 market_cycle.py --send
全市场扫描 Manual on-demand python3 runner.py screen

All jobs auto-skip weekends and Chinese public holidays via TradingCalendar. The screener is manual on-demand (3-5 min runtime). To schedule it weekly, use openclaw cron add to register a weekend slot.

📊 Data Sources

Data Source
Real-time Quotes Sina Finance API
Daily K-lines (A-share) Baostock
Daily K-lines (HK) AKShare
Financials (latest) Baostock
Financials (10yr history) AKShare
GDP / PMI / CPI / M2 AKShare (NBS)
Bond Yields AKShare (10Y gov bonds)
Margin Trading AKShare: stock_margin_sse
FX Rate (USD/CNY) AKShare: currency_boc_sina
IPO Pipeline AKShare: stock_ipo_info
Stock Buybacks AKShare: stock_repurchase_em
Market Indices Baostock: SH/CSI300/ChiNext

� Market Screener

The screener scans the configured universe (default CSI 800 + ChiNext composite, ~700 stocks after liquidity prefilter) on demand and produces two tracks of candidates:

Track Pattern Use case
A \u2014 Bottom Accumulation 周线底部温和放量 + 走势已启动 + 基本面反转 Left-side, patient
B \u2014 New-High Momentum 距 52 周高 \u22645% + RS\u226580 + MA \u591a\u5934\u6392\u5217 + \u91cf\u80fd\u7a81\u7834 Right-side, momentum

Run

# Full scan (~5 min cold cache, ~40s warm cache)
docker exec --user node -w /home/node/.openclaw/skills/china-stock openclaw \
  python3 runner.py screen

# Outputs:
#   data/stock-data/reports/screen-{YYYYMMDD-HHMM}.md      ← full markdown report
#   data/stock-data/reports/skipped-{YYYYMMDD-HHMM}.json   ← skipped breakdown
#   WeChat summary (Top 10) sent automatically

�🔧 Manual Commands

# View 10-year financials
docker exec -w /home/node/.openclaw/skills/china-stock openclaw python3 -c "
from stock_data import get_provider
p = get_provider()
for f in p.get_financial_history('600519'):
    print(f'{f[\"year\"]} ROE:{f[\"roe\"]:.1f}% 毛利:{f[\"gross_margin\"]:.1f}% 净利增:{f[\"profit_growth\"]:+.1f}%')
p.cleanup()
"

# Manually run any cron job
docker exec -w /home/node/.openclaw/skills/china-stock openclaw python3 runner.py close

# Check cron status
docker exec openclaw cat /home/node/.openclaw/cron/jobs.json

📋 Logs

# Gateway logs
docker compose logs -f

# Stock analysis logs (daily)
docker exec openclaw cat /home/node/.openclaw/stock-data/logs/stock-$(date +%Y%m%d).log

🔒 Security

Measure Details
Network Gateway listens on 127.0.0.1 only
Auth Token-based authentication
Container no-new-privileges, dropped NET_RAW/NET_ADMIN
Git .gitignore + pre-commit hook blocks secrets
Secrets data/openclaw.json, data/identity/, data/devices/, data/stock-data/notifier.json
# Verify no secrets will be committed
git diff --cached --name-only | grep -E "data/(openclaw|identity|devices)" && echo "⚠️ SECRETS!"

🏗️ Architecture

┌─────────────────────────────────────────────────┐
│                   Cron Scheduler                 │
│  morning │ midday │ close │ alert │ weekly │ cycle│
└────┬─────┴───┬────┴───┬───┴───┬───┴───┬────┴──┬──┘
     │         │        │       │       │       │
     ▼         ▼        ▼       ▼       ▼       ▼
┌─────────────────────┐  ┌──────────────────────────┐
│     runner.py        │  │    market_cycle.py        │
│  + TradingCalendar   │  │  Howard Marks 14-dim      │
└─────────┬───────────┘  └────────────┬─────────────┘
          │                           │
          ▼                           ▼
┌───────────────────────────────────────────────────┐
│              analyzers.py                          │
│  CANSLIM │ Value │ Growth │ TechCalc │ Signals    │
└─────────────────────┬─────────────────────────────┘
                      │
                      ▼
┌───────────────────────────────────────────────────┐
│              stock_data.py                         │
│                                                   │
│  Quotes:  Sina Finance (real-time A+HK)           │
│  History: Baostock    (A-share daily K-lines)     │
│           AKShare     (HK stock daily K-lines)    │
│  Finance: Baostock    (A-share latest quarter)    │
│           AKShare     (A/HK multi-year history)   │
│                                                   │
│  Cache: file-based + in-memory, auto TTL          │
└─────────────────────┬───────────────────────────┘
                      │
                      ▼
              ┌───────────────┐
              │  notifier.py   │
              │  WeCom webhook │
              │  (auto-split)  │
              └───────────────┘

Key Files

stock_data.py      → Data layer (Sina/Tencent/Baostock/AKShare + cache)
analyzers.py       → CANSLIM + Value + Growth scoring + screener helpers
report.py          → Deep-dive report with 10yr financials + technicals
market_cycle.py    → Howard Marks 14-dim macro analysis (real GDP/PMI/M2/Bonds)
trading.py         → Multi-dimension trading signals (trend/momentum/volume/pattern)
runner.py          → Cron entry + China trading calendar (auto skip holidays)
screener.py        → 全市场 CANSLIM 扫描 (双路线, A=底部蓄势, B=创新高动量)
screen_report.py   → 扫描报告生成 (企业微信摘要 + markdown 完整报告)
notifier.py        → WeChat sender (auto-split long messages)

Stock Code Format

  • A-shares: 6-digit (e.g., 600519 for 茅台)
  • HK stocks: prefix hk (e.g., hk00700 for 腾讯)
  • Indices: 000001 (上证), 000300 (沪深300), 399006 (创业板指)

📖 Documentation

License

Private project. Not for redistribution.

About

docker-openclaw

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages