← 返回
未分类 Key 中文

Freqtrade Backtester

Run Freqtrade backtests for cryptocurrency trading strategies, interpret results, and iterate. Use when downloading historical data, running a backtest, read...
运行 Freqtrade 回测加密货币交易策略,解读结果并迭代。用于下载历史数据、运行回测、阅读...
djc00p djc00p 来源
未分类 clawhub v1.0.3 1 版本 100000 Key: 需要
★ 0
Stars
📥 530
下载
💾 3
安装
1
版本
#latest

概述

Freqtrade Backtester

Run backtests on your trading strategies, interpret results, and iterate safely before going live.

What Backtesting Does

Backtesting runs your strategy against historical market data to see how it would have performed. It shows you win rates, losses, drawdowns, and exit reasons — everything you need to decide if a strategy is worth trading with real money.

Download Data

Historical data is cached, so download once and reuse it for many backtests.

⚠️ Download one pair at a time — passing multiple pairs to --pairs can cause errors. Run the command separately for each pair:

docker-compose run --rm freqtrade download-data \
  --exchange kraken \
  --pairs BTC/USDT \
  --timeframe 5m \
  --timerange 20240101-

Replace the pair, timeframe, and timerange as needed. The --timerange format is YYYYMMDD-YYYYMMDD; omit the end date to download through today.

Run a Backtest

docker-compose run --rm freqtrade backtesting \
  --strategy YourStrategy \
  --timerange 20240101-20260101 \
  --export trades \
  --export-filename user_data/backtest_results/my_backtest.json

Replace YourStrategy with your actual strategy class name. The --export trades flag creates a JSON file with detailed trade logs.

Key Metrics

  • Win rate — Percentage of winning trades. >55% is decent; >60% is strong.
  • Max drawdown — Largest peak-to-trough decline. Keep it <20%; above 25% indicates excessive risk.
  • Sharpe ratio — Risk-adjusted return. >1.0 is acceptable; >2.0 is excellent.
  • Avg profit per trade — Average win/loss size. Wins should be larger than losses.
  • Exit reasons — Breakdown of why trades closed (ROI, stop-loss, trailing stop, etc.).

The Key Insight

High win rate ≠ profitability. A 70% win rate with 5% average loss per trade loses money. A 40% win rate with 2% average wins and 1% average loss is profitable. Control your losses; the wins take care of themselves.

Example: A strategy with tight stops (-3%) outperforms one with loose stops (-7% or -8%), even if the loose version has more winners.

Iteration Pattern

  1. Run a backtest on a fixed time period (e.g., 6 months of data).
  2. Change one parameter (e.g., RSI threshold, stop-loss percentage).
  3. Backtest the same period again.
  4. Compare results — did it improve?
  5. If yes, keep it; if no, revert.
  6. Repeat until satisfied.

Always test across multiple market conditions (bull runs, bear markets, sideways consolidation) before going live. A strategy that works in one environment often fails in another.

Environment Variables

Freqtrade reads secrets from environment variables at runtime. Use the double-underscore format:

export FREQTRADE__EXCHANGE__KEY=your-api-key
export FREQTRADE__EXCHANGE__SECRET=your-api-secret

In your config.json, set these fields to empty strings:

{
  "exchange": {
    "key": "",
    "secret": ""
  }
}

Freqtrade will populate them from the environment at startup.

References

  • Reading Resultsreferences/reading-results.md
  • Iteration Guidereferences/iteration-guide.md

版本历史

共 1 个版本

  • v1.0.3 当前
    2026-03-30 13:48 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

professional

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 194 📥 63,282
professional

All-Market Financial Data Hub

financial-ai-analyst
基于东方财富数据库,支持自然语言查询金融数据,覆盖A股、港股、美股、基金、债券等资产,提供实时行情、公司信息、估值、财务报表等,适用于投资研究、交易复盘、市场监控、行业分析、信用研究、财报审计、资产配置等场景,满足机构与个人需求。返回结果为
★ 129 📥 42,326
professional

Stock Analysis

udiedrichsen
{"answer":"基于雅虎财经数据,分析股票与加密货币。支持投资组合管理、自选股预警、股息分析、8维评分、热门趋势扫描及传闻/早期信号探测。适用于股票分析、持仓追踪、财报异动、加密监控、热门股追踪或提前发掘非主流传闻。"}
★ 279 📥 57,784