当前位置: 首页 > Skill >

Quant Trader

Quant Trader

Quant Trader

专业的加密货币量化交易系统——支持回测、模拟交易、实盘交易及策略优化

1.0.0 2026.11.22 908
获取Skill文件查看使用说明
作 者:陆川 许可证: 更新时间:2026.11.22
本文目录展开

Quantitative Trading Skill

Professional quantitative trading system designed for cryptocurrency markets, featuring backtesting, paper trading, live trading, and advanced strategy optimization.

Installation

Step 1: Install the Skill

clawhub install quant-trader

Step 2: Clone & Setup the Project

# Clone repository
git clone https://github.com/ZhenRobotics/openclaw-quant.git ~/openclaw-quant
cd ~/openclaw-quant

# Install dependencies
pip install -r requirements.txt

# Set API keys (optional for backtesting)
export BINANCE_API_KEY="your-key"
export BINANCE_API_SECRET="your-secret"

Step 3: Verify Installation

cd ~/openclaw-quant
python -m openclaw_quant --help

Core Features

  • Backtesting Engine: Test strategies on historical data with realistic simulation
  • Paper Trading: Real-time simulation with live market data
  • Live Trading: Automated trading on real exchanges (Binance, OKX, etc.)
  • Strategy Optimization: Parameter optimization using Bayesian methods
  • Technical Indicators: 50+ built-in indicators (MA, RSI, MACD, Bollinger, etc.)
  • Risk Management: Position sizing, stop-loss, take-profit
  • Performance Analytics: Sharpe ratio, max drawdown, win rate, profit factor
  • Multi-Exchange Support: Via ccxt library (100+ exchanges)

When to Use This Skill

AUTO-TRIGGER when user's message contains:

  • Keywords: backtest, trading strategy, quant, cryptocurrency trading, optimize strategy
  • Requests like: "test this trading strategy", "backtest MA cross", "paper trade bitcoin"
  • Strategy descriptions: "buy when RSI < 30, sell when RSI > 70"
  • Performance questions: "what's the sharpe ratio", "calculate max drawdown"

TRIGGER EXAMPLES:

  • "Backtest a moving average crossover strategy on Bitcoin"
  • "Optimize RSI parameters for the last 6 months"
  • "Start paper trading with my momentum strategy"
  • "What's the win rate of this strategy?"

DO NOT USE when:

  • Only portfolio tracking (use portfolio-tracker skill)
  • Only price alerts (use price-alert skill)
  • General crypto news or information

Quick Start Examples

Example 1: Simple Moving Average Strategy

from openclaw_quant import Strategy, Backtest

class MAStrategy(Strategy):
    # Parameters (can be optimized)
    fast_period = 10
    slow_period = 30

    def init(self):
        # Vectorized indicator calculation
        self.fast_ma = self.I(SMA, self.data.Close, self.fast_period)
        self.slow_ma = self.I(SMA, self.data.Close, self.slow_period)

    def next(self):
        # Event-driven logic
        if self.fast_ma[-1] > self.slow_ma[-1]:
            if not self.position:
                self.buy()
        else:
            if self.position:
                self.sell()

# Backtest
bt = Backtest(MAStrategy, data, cash=10000, commission=0.001)
result = bt.run()
print(result)
result.plot()

Example 2: RSI Mean Reversion

class RSIStrategy(Strategy):
    rsi_period = 14
    oversold = 30
    overbought = 70

    def init(self):
        self.rsi = self.I(RSI, self.data.Close, self.rsi_period)

    def next(self):
        if self.rsi[-1] < self.oversold:
            if not self.position:
                self.buy()
        elif self.rsi[-1] > self.overbought:
            if self.position:
                self.sell()

bt = Backtest(RSIStrategy, data, cash=10000)
result = bt.run()

Example 3: Parameter Optimization

# Optimize parameters automatically
result = bt.optimize(
    fast_period=range(5, 20, 2),
    slow_period=range(20, 60, 5),
    maximize='sharpe_ratio'  # or 'total_return', 'profit_factor'
)

print(f"Best parameters: {result.best_params}")
print(f"Sharpe Ratio: {result.sharpe_ratio:.2f}")

Example 4: Paper Trading

from openclaw_quant import LiveTrading

# Paper trading with real-time data
live = LiveTrading(
    strategy=MAStrategy,
    exchange='binance',
    symbol='BTC/USDT',
    paper=True  # Simulation mode
)

live.run()

Example 5: Live Trading

# Real trading (use with caution!)
live = LiveTrading(
    strategy=MAStrategy,
    exchange='binance',
    symbol='BTC/USDT',
    paper=False,  # Real mode
    api_key=os.getenv('BINANCE_API_KEY'),
    api_secret=os.getenv('BINANCE_API_SECRET')
)

live.run()

Agent Usage Guide

Command-Line Interface

# Backtest a strategy
openclaw-quant backtest --strategy ma_cross --symbol BTCUSDT --days 365

# Optimize parameters
openclaw-quant optimize --strategy rsi --symbol ETHUSDT --metric sharpe_ratio

# Paper trading
openclaw-quant paper --strategy ma_cross --symbol BTCUSDT

# Live trading
openclaw-quant live --strategy ma_cross --symbol BTCUSDT --confirm

# View results
openclaw-quant results --backtest-id abc123

Natural Language (via OpenClaw Agent)

Agent can understand requests like:

  • "Backtest a moving average crossover on Bitcoin for the last year"
  • "Optimize RSI parameters to maximize Sharpe ratio"
  • "Start paper trading with 10k USDT using my momentum strategy"
  • "Show me the performance metrics of the last backtest"
  • "What's the max drawdown of my live trading account?"

Performance Metrics

The system calculates comprehensive performance metrics:

Metric Description
Total Return Overall profit/loss percentage
Annualized Return Return extrapolated to one year
Sharpe Ratio Risk-adjusted return (higher is better)
Sortino Ratio Downside risk-adjusted return
Max Drawdown Largest peak-to-trough decline
Win Rate Percentage of profitable trades
Profit Factor Gross profit / Gross loss
Calmar Ratio Return / Max drawdown
Average Win/Loss Mean profit/loss per trade
Expectancy Expected value per trade

Built-in Strategies

The system includes several ready-to-use strategies:

  1. MA Cross: Moving average crossover
  2. RSI Mean Reversion: Buy oversold, sell overbought
  3. MACD Momentum: MACD line and signal crossover
  4. Bollinger Bounce: Trade Bollinger band touches
  5. Breakout: Support/resistance breakouts
  6. Grid Trading: Buy low, sell high in range
  7. DCA (Dollar Cost Average): Regular accumulation
  8. Mean Reversion: Statistical arbitrage

Technical Indicators

50+ indicators available via self.I() method:

Trend Indicators:

  • SMA, EMA, WMA, DEMA, TEMA
  • MACD, ADX, Aroon, Supertrend

Momentum Indicators:

  • RSI, Stochastic, CCI, Williams %R
  • ROC (Rate of Change), Momentum

Volatility Indicators:

  • Bollinger Bands, ATR, Keltner Channels
  • Standard Deviation, Historical Volatility

Volume Indicators:

  • OBV, Volume SMA, MFI, VWAP
  • Accumulation/Distribution, CMF

Risk Management

Built-in risk management features:

class MyStrategy(Strategy):
    def init(self):
        # Set risk parameters
        self.risk_per_trade = 0.02  # 2% of capital
        self.stop_loss = 0.05       # 5% stop loss
        self.take_profit = 0.10     # 10% take profit

        self.ma = self.I(SMA, self.data.Close, 20)

    def next(self):
        if self.ma[-1] > self.data.Close[-1]:
            if not self.position:
                # Calculate position size based on risk
                size = self.calculate_position_size(
                    risk=self.risk_per_trade,
                    stop_loss=self.stop_loss
                )
                self.buy(size=size)
                self.set_stop_loss(self.stop_loss)
                self.set_take_profit(self.take_profit)

Data Sources

Supports multiple data sources:

  1. Exchange APIs: Binance, OKX, Bybit, etc. (via ccxt)
  2. CSV Files: Load historical data from files
  3. Database: PostgreSQL, SQLite for caching
  4. Real-time WebSocket: Live market data
# Example: Load data from Binance
from openclaw_quant import DataFetcher

fetcher = DataFetcher('binance')
data = fetcher.fetch_candles(
    symbol='BTC/USDT',
    timeframe='1h',
    since='2023-01-01',
    limit=1000
)

Configuration

Example configuration file (config.yaml):

backtest:
  initial_capital: 10000
  commission: 0.001  # 0.1%
  slippage: 0.0005   # 0.05%

strategy:
  name: ma_cross
  parameters:
    fast_period: 10
    slow_period: 30

exchange:
  name: binance
  testnet: false

risk:
  max_position_size: 0.1  # 10% of capital
  max_drawdown: 0.2       # Stop if 20% drawdown
  daily_loss_limit: 0.05  # Stop if 5% daily loss

notification:
  telegram:
    enabled: true
    bot_token: "your-token"
    chat_id: "your-chat-id"

Project Structure

openclaw-quant/
├── src/
│   ├── openclaw_quant/
│   │   ├── __init__.py
│   │   ├── strategy.py         # Strategy base class
│   │   ├── backtest.py         # Backtest engine
│   │   ├── live.py             # Live trading engine
│   │   ├── broker.py           # Order execution
│   │   ├── data.py             # Data fetching
│   │   ├── indicators.py       # Technical indicators
│   │   ├── optimizer.py        # Parameter optimization
│   │   ├── metrics.py          # Performance metrics
│   │   └── risk.py             # Risk management
│   └── strategies/
│       ├── ma_cross.py
│       ├── rsi.py
│       └── ...
├── examples/
│   ├── backtest_example.py
│   ├── optimization_example.py
│   └── paper_trading_example.py
├── tests/
├── docs/
├── requirements.txt
└── README.md

Requirements

Python >= 3.9
pandas >= 2.0.0
numpy >= 1.24.0
ccxt >= 4.0.0
optuna >= 3.0.0
matplotlib >= 3.7.0
pydantic >= 2.0.0

Troubleshooting

Issue 1: API Connection Error

Error: ccxt.NetworkError or connection timeout

Solution:

# Check internet connection
# Verify API keys are correct
# Use testnet for testing:
exchange = ccxt.binance({'enableRateLimit': True, 'options': {'defaultType': 'future', 'testnet': True}})

Issue 2: Insufficient Data

Error: Not enough candles for strategy

Solution:

# Increase warmup period
bt = Backtest(strategy, data, warmup=100)  # Skip first 100 candles

# Or fetch more historical data
data = fetcher.fetch_candles(symbol='BTC/USDT', limit=5000)

Issue 3: Optimization Takes Too Long

Solution:

# Reduce search space
result = bt.optimize(
    fast_period=range(5, 20, 5),  # Larger step
    slow_period=range(20, 60, 10),
    max_tries=50  # Limit iterations
)

Safety Guidelines

Backtesting

  • Always test on historical data first
  • Use realistic commission and slippage
  • Beware of overfitting
  • Walk-forward validation recommended

Paper Trading

  • Test for at least 1-2 weeks
  • Monitor slippage and fills
  • Check strategy behavior in different market conditions

Live Trading

  • Start with small capital
  • Set strict risk limits
  • Monitor continuously for first week
  • Have emergency stop mechanism
  • Never risk more than you can afford to lose

Performance Tips

  1. Vectorization: Use self.I() for indicators (computed once)
  2. Data Caching: Cache historical data to avoid repeated API calls
  3. Optimization: Use Bayesian optimization, not grid search
  4. Parallel Backtesting: Test multiple symbols simultaneously
  5. WebSocket: Use WebSocket for real-time data (faster than REST)

Documentation

  • GitHub: https://github.com/ZhenRobotics/openclaw-quant
  • Quick Start: ~/openclaw-quant/QUICKSTART.md
  • API Reference: ~/openclaw-quant/docs/API.md
  • Strategy Guide: ~/openclaw-quant/docs/STRATEGIES.md
  • Full README: ~/openclaw-quant/README.md

Roadmap

Version 0.1.0 (Current)

  • Basic backtesting engine
  • Simple strategies (MA, RSI)
  • Binance support

Version 0.2.0

  • Paper trading
  • Parameter optimization
  • More indicators

Version 0.3.0

  • Live trading
  • Multi-exchange support
  • Advanced risk management

Version 1.0.0

  • Production-ready
  • Web dashboard
  • Strategy marketplace

Cost

  • Development: Free and open source (MIT License)
  • Data: Free (using exchange APIs)
  • Trading Fees: Varies by exchange (typically 0.1%)
  • API Costs: Free tier available on most exchanges

License

MIT License - Free for personal and commercial use

Support

  • Issues: https://github.com/ZhenRobotics/openclaw-quant/issues
  • Discussions: https://github.com/ZhenRobotics/openclaw-quant/discussions
  • ClawHub: https://clawhub.ai/ZhenStaff/openclaw-quant

Agent Behavior Guidelines

When using this skill, agents should:

DO:

  • Check if project is installed before use
  • Warn about risks in live trading mode
  • Validate strategy parameters
  • Show clear performance metrics
  • Explain optimization results

DON'T:

  • Execute live trades without explicit confirmation
  • Recommend specific trading strategies
  • Guarantee profits or returns
  • Ignore risk warnings
  • Make financial advice

Status: Under Development (Alpha)

Author: @ZhenStaff

Last Updated: 2026-03-05

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,013
Skill 文件
  • SKILL.md
    • Quantitative Trading Skill
    • Installation
      • Step 1: Install the Skill
      • Step 2: Clone & Setup the Project
      • Step 3: Verify Installation
    • Core Features
    • When to Use This Skill
    • Quick Start Examples
      • Example 1: Simple Moving Average Strategy
      • Example 2: RSI Mean Reversion
      • Example 3: Parameter Optimization
      • Example 4: Paper Trading
      • Example 5: Live Trading
    • Agent Usage Guide
      • Command-Line Interface
      • Natural Language (via OpenClaw Agent)
    • Performance Metrics
    • Built-in Strategies
    • Technical Indicators
    • Risk Management
    • Data Sources
    • Configuration
    • Project Structure
    • Requirements
    • Troubleshooting
      • Issue 1: API Connection Error
      • Issue 2: Insufficient Data
      • Issue 3: Optimization Takes Too Long
    • Safety Guidelines
      • Backtesting
      • Paper Trading
      • Live Trading
    • Performance Tips
    • Documentation
    • Roadmap
      • Version 0.1.0 (Current)
      • Version 0.2.0
      • Version 0.3.0
      • Version 1.0.0
    • Cost
    • License
    • Support
    • Agent Behavior Guidelines
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期