Skip to content

NeuZhou/finclaw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

380 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

English | ?? | ??? | ???

FinClaw πŸ¦€

Self-Evolving Trading Intelligence β€” genetic algorithms discover strategies you never would.

PyPI CI codecov License Python 3.9+ 484 Factors 4900+ Tests Crypto + A-shares + US GitHub Stars

FinClaw β€” Self-Evolving Trading Intelligence

FinClaw Demo Video
▢️ Watch: How FinClaw's Self-Evolving Engine Works (2 min)

FinClaw doesn't need you to write strategies β€” its genetic algorithm discovers and evolves them autonomously across 484 factor dimensions, then validates them with walk-forward testing and Monte Carlo simulation.

Disclaimer

This project is for educational and research purposes only. Not financial advice. Past performance does not guarantee future results. Always paper trade first.


πŸš€ Quick Start

pip install finclaw-ai
finclaw demo          # See it in action
finclaw quote AAPL    # Real-time quotes
finclaw quote BTC/USDT # Crypto too

No API keys, no exchange accounts, no config files needed.


?? See it in action (click to expand)
$ finclaw demo

??? ?? Real-Time Quotes ???

Symbol        Price     Change        %          Trend
--------------------------------------------------------
AAPL         189.84    +2.31  +1.23%  ???????_??β–ˆ??
NVDA         875.28   +15.67  +1.82%  ?????_?????__
BTC/USDT  66,458.10    -1.24  -0.53%  ????__???_???

??? ?? Strategy Evolution Engine ???

FinClaw's core: genetic algorithms evolve strategies autonomously.
Population: 30  |  484 factor dimensions  |  Walk-forward validated

  Gen    Return    Fitness   Sharpe  Progress
  ---    ------    -------   ------  --------
    1     12.3%       45.2     1.2   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
   10     34.5%      123.7     2.1   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
   25     89.2%      456.3     3.4   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
   50    234.7%     1205.8     4.8   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
   75    567.3%     2890.4     5.6   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
   89   2756.4%     4487.8     6.6   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ ??

DNA evolved across 484 factors:
  Top weights: RSI ?0.34, Momentum ?0.25, MACD ?0.18, Volume ?0.12
  Walk-forward validated: ?  Monte Carlo robust: ?

??? ?? Backtest Results ???

Strategy:  +75.7%  (+32.5%/yr)    Buy&Hold:  +67.7%
Alpha:     +8.0%                  Sharpe:    1.85
MaxDD:     -8.3%                  Win Rate:  63%

??? ?? Paper Trading Portfolio ???

Symbol     Shares   Avg Cost      Price         P&L
----------------------------------------------------
AAPL           50     178.50     189.84  +$5,650.00
NVDA           20     810.00     875.28  +$1,305.60
BTC/USDT    0.015  66,458.00  66,458.00      $0.00
----------------------------------------------------
TOTAL                                   +$6,955.60

??? ?? AI Features ???

MCP Server  ? Expose FinClaw as tools for Claude, Cursor, VS Code
Copilot     ? Interactive AI financial assistant
Strategy AI ? Natural language ? trading code

Try it yourself:
  finclaw evolve --market crypto    # Run strategy evolution
  finclaw quote BTC/USDT            # Live crypto quote
  finclaw analyze TSLA              # Technical analysis
  finclaw copilot                   # AI financial chat

Why FinClaw?

Most quant tools make you write the strategy. FinClaw evolves strategies for you.

FinClaw Freqtrade Jesse FinRL / Qlib
Strategy design GA evolves 484-dim DNA You write rules You write rules DRL trains agent
Continuous evolution Strategy itself evolves Bot runs, strategy fixed Bot runs, strategy fixed Training offline
Walk-forward validation βœ… Built-in (70/30 + Monte Carlo) ❌ Plugin needed ❌ Plugin needed ⚠️ Partial
Anti-overfitting Arena + bias detection Basic cross-validation Basic Varies
Zero API keys to start βœ… pip install && finclaw demo ❌ Needs exchange keys ❌ Needs keys ❌ Needs data setup
Market coverage Crypto + A-shares + US Crypto only Crypto only A-shares (Qlib)
MCP server (AI agents) βœ… Claude / Cursor / VS Code ❌ ❌ ❌
Factor library 484 factors, auto-weighted ~50 manual indicators Manual indicators Alpha158 (Qlib)

πŸ“Š 484 Factor Dimensions

284 general factors + 200 crypto-native factors, organized by category:

Category Count Examples
Crypto-Native 200 Funding rate proxy, session effects, whale detection, liquidation cascade
Momentum 14 ROC, acceleration, trend strength, quality momentum
Volume & Flow 13 OBV, smart money, volume-price divergence, Wyckoff VSA
Volatility 13 ATR, Bollinger squeeze, regime detection, vol-of-vol
Mean Reversion 12 Z-score, rubber band, Keltner channel position
Trend Following 14 ADX, EMA golden cross, higher-highs/higher-lows, MA fan
Qlib Alpha158 11 KMID, KSFT, CNTD, CORD, SUMP (Microsoft Qlib compatible)
Quality Filter 11 Earnings momentum proxy, relative strength, resilience
Risk Warning 11 Consecutive losses, death cross, gap-down, limit-down
Top Escape 10 Distribution detection, climax volume, smart money exit
Price Structure 10 Candlestick patterns, support/resistance, pivot points
Davis Double Play 8 Revenue acceleration, tech moat, supply exhaustion
Gap Analysis 8 Gap fill, gap momentum, gap reversal
Market Breadth 5 Advance/decline, sector rotation, new highs/lows
News Sentiment 2 EN/ZH keyword sentiment score + momentum
DRL Signal 2 Q-learning buy probability + state value estimate

Design principle: Technical, sentiment, DRL, fundamental β€” all signals are unified as factors returning [0, 1]. Weights are determined by the evolution engine, eliminating human bias from signal synthesis.


🧬 Self-Evolution Engine

The genetic algorithm continuously discovers optimal strategies:

  1. Seed β€” Initialize population with diverse factor weight configurations
  2. Evaluate β€” Walk-forward backtest each DNA across all assets
  3. Select β€” Keep top performers by fitness (Sharpe Γ— Return / MaxDrawdown)
  4. Mutate β€” Random weight perturbation, crossover, factor add/drop
  5. Repeat β€” Runs 7Γ—24 on your machine
finclaw evolve --market crypto --generations 50   # Crypto (main use case)
finclaw evolve --market cn --generations 50       # A-shares
finclaw evolve --market crypto --population 50 --mutation-rate 0.2 --elite 10

Evolution Results

Market Generation Annual Return Sharpe Max Drawdown
A-Shares Gen 89 2,756% 6.56 26.5%
Crypto Gen 19 16,066% 12.19 7.2%

⚠️ These are in-sample backtest results on historical data. Real performance will be significantly lower. Walk-forward out-of-sample validation is enabled by default β€” always check OOS metrics before trusting any evolved strategy. Run finclaw check-backtest to verify, and finclaw paper to paper trade before risking real capital.


🏟️ Arena Mode (Anti-Overfitting)

Traditional backtests evaluate each strategy in isolation β€” overfitted strategies look great on history but fail live. FinClaw's Arena Mode fixes this:

  • Multiple DNA strategies trade simultaneously in the same simulated market
  • Crowding penalty: When >50% of DNAs buy on the same signal, price impact kicks in
  • Overfitted strategies that only work in isolation get penalized in Arena rankings

βœ… Quality Assurance

  • Walk-forward validation (70/30 train/test split)
  • Monte Carlo simulation (1,000 iterations, p-value < 0.05)
  • Bootstrap 95% confidence intervals
  • Arena competition (multi-DNA market simulation)
  • Bias detection (look-ahead, snooping, survivorship)
  • Factor IC/IR analysis with decay curves
  • Factor orthogonal matrix (auto-remove redundant factors)
  • Turnover penalty in fitness function
  • 4,900+ automated tests

πŸ’» CLI Reference

FinClaw ships with 170+ CLI commands. Here are the essentials:

Command Description
finclaw demo See all features in action
finclaw quote AAPL Real-time US stock quote
finclaw quote BTC/USDT Crypto quote via ccxt
finclaw evolve --market crypto Run genetic algorithm evolution
finclaw backtest -t AAPL Backtest a strategy on a stock
finclaw check-backtest Verify backtest results
finclaw analyze TSLA Technical analysis
finclaw screen Stock screener
finclaw risk-report Portfolio risk report
finclaw sentiment Market sentiment
finclaw copilot AI financial assistant
finclaw generate-strategy Natural language β†’ strategy code
finclaw mcp serve Start MCP server for AI agents
finclaw paper Paper trading mode
finclaw doctor Environment check

Run finclaw --help for the full list.


πŸ€– MCP Server (AI Agents)

Expose FinClaw as tools for Claude, Cursor, VS Code, or any MCP-compatible client:

{
  "mcpServers": {
    "finclaw": {
      "command": "finclaw",
      "args": ["mcp", "serve"]
    }
  }
}

Provides 10 tools: get_quote, get_history, list_exchanges, run_backtest, analyze_portfolio, get_indicators, screen_stocks, get_sentiment, compare_strategies, get_funding_rates.


πŸ“‘ Data Sources

Market Source API Key Required?
Crypto ccxt (100+ exchanges) No (public data)
US Stocks Yahoo Finance No
A-Shares AKShare + BaoStock No
News Sentiment CryptoCompare + AKShare No

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             Evolution Engine (Core)                   β”‚
β”‚      Genetic Algorithm β†’ Mutate β†’ Backtest β†’ Select   β”‚
β”‚                                                       β”‚
β”‚      Input: 484 factors Γ— weights = DNA               β”‚
β”‚      Output: Walk-forward validated strategy           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Technical(284) β”‚ Sentiment β”‚ DRL β”‚ Davis β”‚ Crypto(200)β”‚
β”‚       All β†’ compute() β†’ [0, 1]                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Arena Competition β”‚ Bias Detection β”‚ Monte Carlo     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Paper Trading β†’ Live Trading β†’ 100+ Exchanges       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Roadmap

  • 484-factor evolution engine
  • Walk-forward validation + Monte Carlo
  • Arena competition mode
  • Bias detection suite
  • News sentiment + DRL factors
  • Davis Double Play factors
  • Paper trading infrastructure
  • MCP server for AI agents
  • DEX execution (Uniswap V3 / Arbitrum)
  • Multi-timeframe support (1h/4h/1d)
  • Foundation model for price sequences

🌐 Ecosystem

FinClaw is part of the NeuZhou AI agent toolkit:

Project Description
FinClaw AI-native quantitative finance engine
ClawGuard AI Agent Immune System β€” 285+ threat patterns, zero dependencies
AgentProbe Playwright for AI Agents β€” test, record, replay agent behaviors

Contributing

git clone https://github.com/NeuZhou/finclaw.git
cd finclaw && pip install -e ".[dev]" && pytest

See CONTRIBUTING.md for guidelines. Report bugs Β· Request features


License

MIT


Star History

Star History