Skip to main content

AI-Powered Financial Intelligence Engine โ€” 8 Master Strategies, 5 Markets, 100+ Tests.

Project description

๐Ÿ‹ FinClaw

CI PyPI License: AGPL v3 Python 3.9+ GitHub Stars

AI-Powered Financial Intelligence Engine โ€” 8 Master Strategies, 5 Markets, 100+ Tests

English | ไธญๆ–‡ | ๆ—ฅๆœฌ่ชž | ํ•œ๊ตญ์–ด | Franรงais

ยฅ100ไธ‡ โ†’ ยฅ354ไธ‡ (5 years, 29.1% annualized)
Tested on 100+ real stocks across US, China, Hong Kong
30/34 individual backtests outperform buy-and-hold

๐ŸŽฏ What is FinClaw?

FinClaw is a complete AI trading intelligence system that scans stocks, picks winners, manages risk, and validates everything with real data. Unlike most "AI trading" projects that stop at signal generation, FinClaw covers the full lifecycle: Selection โ†’ Entry โ†’ Position Management โ†’ Exit โ†’ Portfolio โ†’ Validation.

โšก Quick Start

Install from PyPI

pip install finclaw-ai

Install from Source

git clone https://github.com/NeuZhou/finclaw.git
cd finclaw
pip install -r requirements.txt

Your First Scan (30 seconds)

# Scan US market with Soros-style momentum strategy
python finclaw.py scan --market us --style soros

# Backtest NVIDIA over 5 years
python finclaw.py backtest --ticker NVDA --period 5y

# See all available strategies
python finclaw.py info

Run Tests

pip install pytest pytest-asyncio
python -m pytest tests/ -v

๐Ÿ“Š Performance

5-Year Real Data Backtest (2020โ€“2025)

Strategy Annual Return 5Y Total Risk Level
v10 Unified Top-5 +29.1%/y +254% High
LLM-Enhanced Top-10 +24.8%/y +202% Medium-High
Balanced Top-10 +19.5%/y +142% Medium
Conservative Top-15 +11.8%/y +74% Low

All tests run on real Yahoo Finance data. No synthetic data. No cherry-picking.

vs Competitor (AHF)

FinClaw wins: 30/34 stocks (88%)
Average alpha: +10.8% per year

๐Ÿง  8 Built-in Strategies

Strategy Philosophy Risk Target
druckenmiller Momentum โ€” "When you see it, bet big" Very High 25โ€“40%/y
soros Reflexivity โ€” self-reinforcing trends High 25โ€“35%/y
lynch Growth/vol ratio โ€” "boring" winners High 20โ€“27%/y
buffett Quality + value โ€” buy fear, hold forever Medium-High 20โ€“30%/y
dalio All-weather โ€” low correlation, risk parity Medium 15โ€“20%/y
aggressive Top-5 by return High 25โ€“35%/y
balanced Top-10 grade-weighted Medium 10โ€“15%/y
conservative Top-15 low-vol โ€” capital preservation Low 8โ€“12%/y

๐Ÿ—๏ธ Architecture

graph TB
    subgraph CLI["๐Ÿ–ฅ๏ธ CLI / Interfaces"]
        FC[finclaw.py]
        MCP[MCP Server]
        TG[Telegram Bot]
        DA[Daily Alert]
    end

    subgraph Selection["๐Ÿ“Š Stock Selection (3 Layers)"]
        L1[Layer 1: Quantitative<br/>Momentum, EMA, RSI, Vol]
        L2[Layer 2: Fundamental<br/>P/E, Growth, ROE]
        L3[Layer 3: AI Disruption<br/>LLM Analysis]
    end

    subgraph Engine["โš™๏ธ Signal Engine"]
        RD[Regime Detection<br/>7 market regimes]
        SG[Signal Generation<br/>Multi-timeframe]
        PM[Position Management<br/>Trailing, pyramiding]
    end

    subgraph Validation["โœ… Validation"]
        BT[Backtester v7]
        ST[Statistics<br/>Sharpe, Monte Carlo]
        TS[Test Suite<br/>100+ tests]
    end

    subgraph Data["๐Ÿ“ก Data"]
        YF[Yahoo Finance]
        UV[Universe<br/>US, CN, HK, JP, KR]
        MA[Macro Analyzer<br/>VIX, Rates, DXY]
    end

    FC --> Selection
    MCP --> Selection
    TG --> Selection
    DA --> Selection

    Selection --> Engine
    Engine --> Validation
    Data --> Selection
    Data --> Engine
    MA --> RD

Signal Engine โ€” 7 Market Regimes

Regime Max Position Strategy
CRASH 0% Emergency exit
STRONG_BEAR 10% Defensive bounces only
BEAR 15% Small counter-trend
RANGING 45โ€“68% Mean reversion
VOLATILE 65% Direction-dependent
BULL 80% Trend following
STRONG_BULL 92% Maximum conviction

๐Ÿ“ Project Structure

finclaw/
โ”œโ”€โ”€ finclaw.py                  # CLI entry point (scan, backtest, info)
โ”œโ”€โ”€ main.py                     # Alternative entry
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ signal_engine_v7.py     # 6-factor signal engine, 7 regimes
โ”‚   โ”œโ”€โ”€ signal_engine_v9.py     # Asset scoring & grading (A+ โ†’ F)
โ”‚   โ”œโ”€โ”€ backtester_v7.py        # Full lifecycle backtester
โ”‚   โ”œโ”€โ”€ stock_picker.py         # Multi-factor picker (quant + fundamental)
โ”‚   โ”œโ”€โ”€ macro_analyzer.py       # 6-layer macro environment analyzer
โ”‚   โ”œโ”€โ”€ deep_macro.py           # Deep macro with Kondratieff wave
โ”‚   โ”œโ”€โ”€ llm_analyzer.py         # LLM-powered AI disruption analysis
โ”‚   โ”œโ”€โ”€ statistics.py           # Sharpe, Monte Carlo, walk-forward
โ”‚   โ”œโ”€โ”€ universe.py             # Stock universes + sector linkage
โ”‚   โ”œโ”€โ”€ registry.py             # Agent profiles (Warren, Soros, etc.)
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ strategies/
โ”‚   โ””โ”€โ”€ strategy_spec.py        # Strategy template definitions
โ”œโ”€โ”€ tests/                      # 100+ pytest tests
โ”‚   โ”œโ”€โ”€ test_signal_engine.py   # Signal engine & regime tests
โ”‚   โ”œโ”€โ”€ test_backtester.py      # Backtester lifecycle tests
โ”‚   โ”œโ”€โ”€ test_asset_selector.py  # Asset scoring tests
โ”‚   โ”œโ”€โ”€ test_stock_picker.py    # Multi-factor picker tests
โ”‚   โ”œโ”€โ”€ test_cli.py             # CLI strategy & universe tests
โ”‚   โ”œโ”€โ”€ test_engine.py          # Golden threshold tests
โ”‚   โ”œโ”€โ”€ test_strategy.py        # Strategy integration tests
โ”‚   โ”œโ”€โ”€ test_exhaustive.py      # Exhaustive QA tests
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ mcp_server.py               # MCP protocol server (4 tools)
โ”œโ”€โ”€ telegram_bot.py             # Telegram bot interface
โ”œโ”€โ”€ daily_alert.py              # Daily scanner & alerts
โ”œโ”€โ”€ .github/workflows/ci.yml    # CI: Python 3.9โ€“3.12
โ”œโ”€โ”€ pyproject.toml              # PyPI package config
โ””โ”€โ”€ docs/                       # Multi-language documentation

๐Ÿ”Œ API Reference

CLI Commands

# Scan a market with a strategy
python finclaw.py scan --market <us|china|hk|japan|korea|all> \
                       --style <strategy> \
                       --capital <amount> \
                       --period <1y|2y|5y|10y>

# Backtest a single ticker
python finclaw.py backtest --ticker <SYMBOL> --period <period> --capital <amount>

# Show available strategies and markets
python finclaw.py info

# Run test suite
python finclaw.py test

MCP Server (for AI assistants)

python mcp_server.py

Exposes 4 tools:

  • finclaw_scan โ€” Scan market with strategy โ†’ JSON
  • finclaw_backtest โ€” Backtest a ticker โ†’ JSON
  • finclaw_macro โ€” Current macro environment โ†’ JSON
  • finclaw_info โ€” List strategies โ†’ JSON

Python API

import asyncio
from finclaw import scan_universe, run_strategy, fetch_data, UNIVERSES, STRATEGIES
from agents.backtester_v7 import BacktesterV7
from agents.signal_engine_v7 import SignalEngineV7
from agents.signal_engine_v9 import AssetSelector

# Score an asset
selector = AssetSelector()
prices = [100, 102, 105, 103, 108, ...]  # daily prices
score = selector.score_asset(prices)
print(f"Grade: {score.grade}, Composite: {score.composite:.2f}")

# Generate a trading signal
engine = SignalEngineV7()
signal = engine.generate_signal(prices)
print(f"Signal: {signal.signal}, Regime: {signal.regime}")

# Backtest
bt = BacktesterV7(initial_capital=100_000)
history = [{"date": d, "price": p, "volume": v} for d, p, v in zip(dates, prices, volumes)]
result = asyncio.run(bt.run("NVDA", "v7", history))
print(f"Return: {result.total_return:+.1%}, MaxDD: {result.max_drawdown:+.1%}")

๐ŸŒ Supported Markets

Market Stocks Examples
US 50+ NVDA, AAPL, MSFT, TSLA, META
China (A-shares) 80+ ่ดตๅทž่Œ…ๅฐ, ๅฎๅพทๆ—ถไปฃ, ๆฏ”ไบš่ฟช
Hong Kong 25+ Tencent, Alibaba, Meituan
Japan 8 Toyota, Sony, SoftBank
Korea 6 Samsung, SK Hynix

๐Ÿ› ๏ธ Development

Prerequisites

  • Python 3.9+
  • pip install -r requirements.txt (aiohttp, yfinance)
  • pip install pytest pytest-asyncio (for testing)

Running Tests

# All tests
python -m pytest tests/ -v

# Specific test file
python -m pytest tests/test_signal_engine.py -v

# With coverage (if installed)
python -m pytest tests/ --cov=agents --cov-report=term-missing

Test Coverage

Test Suite Tests What It Covers
test_signal_engine 17 Regime detection, signals, edge cases
test_backtester 14 Lifecycle, metrics, config, warmup
test_asset_selector 10 Asset scoring, grading, bounds
test_stock_picker 5 Multi-factor analysis, conviction
test_cli 13 Strategies, universes, selection
test_engine 7 Golden thresholds, alpha targets
test_strategy 17 Strategy integration
test_exhaustive 6 Exhaustive QA combos
+ more ... Registry, universe, macro, MCP

๐Ÿ“‹ Comparison with Alternatives

Feature FinClaw ai-hedge-fund FinRL Freqtrade
Stock Selection โœ… 3-layer โŒ Manual โŒ Manual โŒ Manual
Backtesting โœ… Full lifecycle โš ๏ธ Basic โœ… Train/test โœ… Advanced
Risk Management โœ… 7 regimes โŒ None โš ๏ธ Basic โš ๏ธ Basic
AI Integration โœ… LLM + Quant โœ… LLM only โœ… RL โŒ None
Multi-market โœ… 5 markets โŒ US only โš ๏ธ Limited โœ… Crypto
Test Suite โœ… 100+ tests โŒ None โš ๏ธ Few โœ… Good
MCP Support โœ… 4 tools โŒ โŒ โŒ

๐Ÿ—บ๏ธ Roadmap

Done โœ…

  • 6-factor signal engine with 7 regimes
  • Full lifecycle backtester
  • Multi-factor stock picker (quant + fundamental + AI)
  • 8 master strategy presets
  • Multi-market support (US, CN, HK, JP, KR)
  • MCP server for AI assistant integration
  • 100+ automated tests
  • PyPI package (pip install finclaw-ai)

Next ๐Ÿ”จ

  • Live market data streaming
  • Paper trading mode
  • Web dashboard
  • Options/futures support
  • Walk-forward validation
  • QuantStats HTML report integration

โ“ FAQ

Q: Is this financial advice? A: No. This is a research and educational tool. Use at your own risk.

Q: Can it trade automatically? A: Not yet. Currently analysis and backtesting only. Paper trading is planned.

Q: What data does it need? A: Just an internet connection. Uses Yahoo Finance (free) for all price data.

Q: Can I add my own stocks? A: Yes. Any ticker supported by Yahoo Finance works with backtest --ticker.


๐Ÿ“œ License

AGPL-3.0 โ€” Free for open-source use. Contact for commercial licensing.

Disclaimer: Past performance does not guarantee future results. Not financial advice.


๐ŸŒ Related Projects

Project Description
ClawGuard ๐Ÿ›ก๏ธ AI Agent Security Scanner โ€” scan FinClaw for prompt injection risks
repo2skill ๐Ÿ”„ Convert any GitHub repo into an AI agent skill
AgentProbe ๐Ÿงช AI Agent Testing Framework โ€” test FinClaw's MCP tools
awesome-llm-security ๐Ÿ“š Curated LLM security resources

Built by an engineer who believes trading systems should be engineered, not hoped. ๐Ÿ‹

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finclaw_ai-1.4.0.tar.gz (154.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finclaw_ai-1.4.0-py3-none-any.whl (141.4 kB view details)

Uploaded Python 3

File details

Details for the file finclaw_ai-1.4.0.tar.gz.

File metadata

  • Download URL: finclaw_ai-1.4.0.tar.gz
  • Upload date:
  • Size: 154.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for finclaw_ai-1.4.0.tar.gz
Algorithm Hash digest
SHA256 72d38295f0387759dad709fec3ef1331806a62b5019e7245ccd837d6344e727c
MD5 c3285771350bbfedde03317571674327
BLAKE2b-256 494b62a0788db8c85817a4a2a7fc1cf052fec4b8f95cef0990c3a7a0684cac2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for finclaw_ai-1.4.0.tar.gz:

Publisher: publish.yml on NeuZhou/finclaw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file finclaw_ai-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: finclaw_ai-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 141.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for finclaw_ai-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f956f0847cac761d870169a75cdbab1d31bc41f4752fb2f073213353348bada
MD5 25135b50f3143a60060ae94ac0bf173d
BLAKE2b-256 115e68c0c38e318aff2bcab2a879cdecf98eb3f3f75c1098f82c7546df974a44

See more details on using hashes here.

Provenance

The following attestation bundles were made for finclaw_ai-1.4.0-py3-none-any.whl:

Publisher: publish.yml on NeuZhou/finclaw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page