工具子命令¶
除了实盘交易和模拟运行模式、回测与超参数优化子命令,以及用于准备历史数据的download-data子命令外,机器人还包含多个实用工具子命令。本节将介绍这些子命令。
创建用户目录¶
创建用于存放 Freqtrade 文件的目录结构。同时会为你生成策略和超参数优化的示例文件,帮助你快速上手。可多次使用 —— 使用--reset参数会将示例策略和超参数优化文件重置为默认状态。
usage: freqtrade create-userdir [-h] [--userdir PATH] [--reset]
options:
-h, --help show this help message and exit
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
--reset Reset sample files to their original state.
警告
使用--reset可能导致数据丢失,因为这将不提示确认直接覆盖所有示例文件。
├── backtest_results
├── data
├── hyperopt_results
├── hyperopts
│ ├── sample_hyperopt_loss.py
├── notebooks
│ └── strategy_analysis_example.ipynb
├── plot
└── strategies
└── sample_strategy.py
创建新配置¶
创建一个新的配置文件,并询问一些配置中的关键选项。
usage: freqtrade new-config [-h] [-c PATH]
options:
-h, --help show this help message and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
警告
仅会询问必要的问题。Freqtrade 提供了更多配置选项,详见配置文档。
创建配置示例¶
$ freqtrade new-config --config user_data/config_binance.json
? Do you want to enable Dry-run (simulated trades)? Yes
? Please insert your stake currency: BTC
? Please insert your stake amount: 0.05
? Please insert max_open_trades (Integer or -1 for unlimited open trades): 3
? Please insert your desired timeframe (e.g. 5m): 5m
? Please insert your display Currency (for reporting): USD
? Select exchange binance
? Do you want to enable Telegram? No
显示配置¶
显示配置文件(默认情况下敏感值已被屏蔽)。在使用拆分配置文件或环境变量时特别有用,此命令将显示合并后的配置。

usage: freqtrade show-config [-h] [--userdir PATH] [-c PATH]
[--show-sensitive]
options:
-h, --help show this help message and exit
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
--show-sensitive Show secrets in the output.
Your combined configuration is:
{
"exit_pricing": {
"price_side": "other",
"use_order_book": true,
"order_book_top": 1
},
"stake_currency": "USDT",
"exchange": {
"name": "binance",
"key": "REDACTED",
"secret": "REDACTED",
"ccxt_config": {},
"ccxt_async_config": {},
}
// ...
}
分享此命令提供的信息
我们已尽力从默认输出(不带 --show-sensitive 参数)中移除所有已知的敏感信息。但请务必仔细检查输出内容,确保不会意外泄露任何私人信息。
创建新策略¶
基于类似 SampleStrategy 的模板创建一个新策略。文件名将与你的类名一致,且不会覆盖已存在的文件。
结果将位于 user_data/strategies/<strategyclassname>.py。
usage: freqtrade new-strategy [-h] [--userdir PATH] [-s NAME]
[--strategy-path PATH]
[--template {full,minimal,advanced}]
options:
-h, --help show this help message and exit
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
-s NAME, --strategy NAME
Specify strategy class name which will be used by the
bot.
--strategy-path PATH Specify additional strategy lookup path.
--template {full,minimal,advanced}
Use a template which is either `minimal`, `full`
(containing multiple sample indicators) or `advanced`.
Default: `full`.
new-strategy 的使用示例¶
freqtrade new-strategy --strategy AwesomeStrategy
使用自定义用户目录
freqtrade new-strategy --userdir ~/.freqtrade/ --strategy AwesomeStrategy
使用高级模板(填充所有可选函数和方法)
freqtrade new-strategy --strategy AwesomeStrategy --template advanced
列出策略¶
使用 list-strategies 子命令查看某一特定目录中的所有策略。
此子命令有助于发现环境中加载策略时的问题:包含错误而加载失败的策略模块将以红色显示(LOAD FAILED),名称重复的策略将以黄色显示(DUPLICATE NAME)。
usage: freqtrade list-strategies [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
[--strategy-path PATH] [-1]
[--recursive-strategy-search]
options:
-h, --help show this help message and exit
--strategy-path PATH Specify additional strategy lookup path.
-1, --one-column Print output in one column.
--recursive-strategy-search
Recursively search for a strategy in the strategies
folder.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
警告
这些命令会尝试加载目录中的所有 Python 文件。如果该目录中存在不受信任的文件,可能会带来安全风险,因为所有模块级别的代码都会被执行。
示例:搜索默认策略目录(位于默认用户目录内)。
freqtrade list-strategies
示例:搜索用户目录内的策略目录。
freqtrade list-strategies --userdir ~/.freqtrade/
示例:搜索指定的策略路径。
freqtrade list-strategies --strategy-path ~/.freqtrade/strategies/
列出 Hyperopt-Loss 函数¶
使用 list-hyperoptloss 子命令查看环境中所有可用的 hyperopt 损失函数。
它会快速列出当前环境中所有可用的损失函数。
此子命令有助于发现环境中加载损失函数时的问题:包含错误而加载失败的 Hyperopt-Loss 函数模块将以红色显示(LOAD FAILED),名称重复的函数将以黄色显示(DUPLICATE NAME)。
usage: freqtrade list-hyperoptloss [-h] [-v] [--no-color] [--logfile FILE]
[-V] [-c PATH] [-d PATH] [--userdir PATH]
[--hyperopt-path PATH] [-1]
options:
-h, --help show this help message and exit
--hyperopt-path PATH Specify additional lookup path for Hyperopt Loss
functions.
-1, --one-column Print output in one column.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
列出 freqAI 模型¶
使用 list-freqaimodels 子命令查看所有可用的 freqAI 模型。
此子命令有助于发现环境中加载 freqAI 模型时的问题:包含错误而加载失败的模型模块将以红色显示(LOAD FAILED),名称重复的模型将以黄色显示(DUPLICATE NAME)。
usage: freqtrade list-freqaimodels [-h] [-v] [--no-color] [--logfile FILE]
[-V] [-c PATH] [-d PATH] [--userdir PATH]
[--freqaimodel-path PATH] [-1]
options:
-h, --help show this help message and exit
--freqaimodel-path PATH
Specify additional lookup path for freqaimodels.
-1, --one-column Print output in one column.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
列出交易所¶
使用 list-exchanges 子命令查看机器人支持的交易所。
usage: freqtrade list-exchanges [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH] [-1] [-a]
[--trading-mode {spot,margin,futures}]
[--dex-exchanges]
options:
-h, --help show this help message and exit
-1, --one-column Print output in one column.
-a, --all Print all exchanges known to the ccxt library.
--trading-mode {spot,margin,futures}, --tradingmode {spot,margin,futures}
Select Trading mode
--dex-exchanges Print only DEX exchanges.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
示例:查看机器人可用的交易所:
$ freqtrade list-exchanges
Exchanges available for Freqtrade:
Exchange name Supported Markets Reason
------------------ ----------- ---------------------- ------------------------------------------------------------------------
binance Official spot, isolated futures
bitmart Official spot
bybit spot, isolated futures
gate Official spot, isolated futures
htx Official spot
huobi spot
kraken Official spot
okx Official spot, isolated futures
为清晰起见已简化输出——支持的交易所可能会随时间变化。
缺少 opt 交易所
标有 "missing opt:" 的条目可能需要特殊配置(例如,当 fetchTickers 缺失时使用 orderbook),理论上应可运行(但我们无法保证一定可用)。
示例:查看 ccxt 库支持的所有交易所(包括“不可用”的交易所,即已知无法与 Freqtrade 正常工作的交易所)
$ freqtrade list-exchanges -a
All exchanges supported by the ccxt library:
Exchange name Valid Supported Markets Reason
------------------ ------- ----------- ---------------------- ---------------------------------------------------------------------------------
binance True Official spot, isolated futures
bitflyer False spot missing: fetchOrder. missing opt: fetchTickers.
bitmart True Official spot
bybit True spot, isolated futures
gate True Official spot, isolated futures
htx True Official spot
kraken True Official spot
okx True Official spot, isolated futures
输出已简化——支持和可用的交易所可能会随时间变化。
列出时间周期¶
使用 list-timeframes 子命令查看交易所支持的时间周期列表。
usage: freqtrade list-timeframes [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
[--exchange EXCHANGE] [-1]
options:
-h, --help show this help message and exit
--exchange EXCHANGE Exchange name. Only valid if no config is provided.
-1, --one-column Print output in one column.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
- 示例:查看配置文件中设置的 'binance' 交易所的时间周期:
$ freqtrade list-timeframes -c config_binance.json
...
Timeframes available for the exchange `binance`: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
- 示例:枚举 Freqtrade 可用的交易所,并打印每个交易所支持的时间周期:
$ for i in `freqtrade list-exchanges -1`; do freqtrade list-timeframes --exchange $i; done
列出交易对/列出市场¶
list-pairs 和 list-markets 子命令可用于查看交易所在支持的交易对/市场。
交易对是指在市场符号中,基础货币部分和报价货币部分之间用 '/' 字符分隔的市场。例如,在 'ETH/BTC' 交易对中,'ETH' 是基础货币,而 'BTC' 是报价货币。
对于 Freqtrade 交易的交易对,其报价货币由配置设置 stake_currency 的值定义。
您可以使用这些子命令打印任意交易对/市场的详细信息——并且可以分别使用 --quote BTC 按报价货币或 --base ETH 按基础货币来过滤输出结果。
这些子命令具有相同的用法和相同的可用选项集:
usage: freqtrade list-pairs [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
[--exchange EXCHANGE] [--print-list]
[--print-json] [-1] [--print-csv]
[--base BASE_CURRENCY [BASE_CURRENCY ...]]
[--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]] [-a]
[--trading-mode {spot,margin,futures}]
options:
-h, --help show this help message and exit
--exchange EXCHANGE Exchange name. Only valid if no config is provided.
--print-list Print list of pairs or market symbols. By default data
is printed in the tabular format.
--print-json Print list of pairs or market symbols in JSON format.
-1, --one-column Print output in one column.
--print-csv Print exchange pair or market data in the csv format.
--base BASE_CURRENCY [BASE_CURRENCY ...]
Specify base currency(-ies). Space-separated list.
--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]
Specify quote currency(-ies). Space-separated list.
-a, --all Print all pairs or market symbols. By default only
active ones are shown.
--trading-mode {spot,margin,futures}, --tradingmode {spot,margin,futures}
Select Trading mode
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
默认情况下,仅显示活跃的交易对/市场。活跃的交易对/市场是指当前可以在交易所进行交易的市场。您可以使用 -a/--all 选项查看所有交易对/市场的列表,包括不活跃的。如果某个市场的最小可交易价格非常小(例如小于 1e-11(0.00000000001)),则该交易对可能被标记为不可交易。
交易对/市场在输出结果中按其符号字符串排序。
示例¶
- 以 JSON 格式打印默认配置文件中指定交易所(即“Binance”交易所)上报价货币为 USD 的活跃交易对列表:
$ freqtrade list-pairs --quote USD --print-json
- 打印在
config_binance.json配置文件中指定的交易所(即“Binance”交易所)上所有交易对的列表,基础货币为 BTC 或 ETH,报价货币为 USDT 或 USD,并以可读列表格式显示汇总信息:
$ freqtrade list-pairs -c config_binance.json --all --base BTC ETH --quote USDT USD --print-list
- 以表格格式打印交易所 "Kraken" 上的所有市场:
$ freqtrade list-markets --exchange kraken --all
测试交易对列表¶
使用 test-pairlist 子命令测试动态交易对列表的配置。
需要配置文件中包含指定的 pairlists 属性。可用于生成静态交易对列表,供回测 / 超参数优化时使用。
usage: freqtrade test-pairlist [-h] [--userdir PATH] [-v] [-c PATH]
[--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]]
[-1] [--print-json] [--exchange EXCHANGE]
options:
-h, --help show this help message and exit
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
--quote QUOTE_CURRENCY [QUOTE_CURRENCY ...]
Specify quote currency(-ies). Space-separated list.
-1, --one-column Print output in one column.
--print-json Print list of pairs or market symbols in JSON format.
--exchange EXCHANGE Exchange name. Only valid if no config is provided.
示例¶
当使用动态交易对列表时,显示白名单。
freqtrade test-pairlist --config config.json --quote USDT BTC
转换数据库¶
freqtrade convert-db 可用于将数据库从一个系统迁移到另一个系统(例如 sqlite -> postgres,postgres -> 其他 postgres),迁移所有交易、订单和交易对锁定信息。
请参考相应文档了解不同数据库系统的要求。
usage: freqtrade convert-db [-h] [--db-url PATH] [--db-url-from PATH]
options:
-h, --help show this help message and exit
--db-url PATH Override trades database URL, this is useful in custom
deployments (default: `sqlite:///tradesv3.sqlite` for
Live Run mode, `sqlite:///tradesv3.dryrun.sqlite` for
Dry Run).
--db-url-from PATH Source db url to use when migrating a database.
警告
请确保仅在空的目标数据库上使用此命令。Freqtrade 将执行常规迁移,但如果目标数据库中已存在数据,可能会失败。
Web 服务器模式¶
实验性功能
Webserver 模式是一种实验性模式,旨在提高回测和策略开发的效率。该模式可能仍存在一些漏洞,因此如果您恰好遇到问题,请将其作为 GitHub issue 提交,谢谢。
以 Webserver 模式运行 freqtrade。Freqtrade 将启动 Web 服务器,并允许 FreqUI 启动并控制回测进程。这样做的好处是,在多次回测运行之间(只要时间框架和时间范围保持一致),数据将不会被重新加载。FreqUI 还会显示回测结果。
usage: freqtrade webserver [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
options:
-h, --help show this help message and exit
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
Webserver 模式 - Docker¶
您也可以通过 Docker 使用 Webserver 模式。启动一次性容器时需要显式配置端口,因为默认情况下端口不会被暴露。您可以使用 docker compose run --rm -p 127.0.0.1:8080:8080 freqtrade webserver 命令来启动一个临时容器,停止后该容器将被自动删除。此操作假设 8080 端口仍然可用,且没有其他机器人正在使用该端口。
或者,您可以重新配置 docker-compose 文件,更新其中的命令:
command: >
webserver
--config /freqtrade/user_data/config.json
现在您可以使用 docker compose up 来启动 Web 服务器。此操作假设配置中已启用 Webserver 并针对 Docker 进行了配置(监听地址为 0.0.0.0)。
提示
如果您想启动实盘或模拟运行的机器人,请记得将命令重置回交易命令。
显示之前的回测结果¶
允许您查看之前保存的回测结果。添加 --show-pair-list 参数可输出一个已排序的交易对列表,您可以轻松复制粘贴到配置文件中(排除表现不佳的交易对)。
策略过拟合
仅使用盈利的交易对可能导致策略过拟合,从而在未来的数据上表现不佳。在投入真实资金前,请务必在模拟模式下充分测试您的策略。
usage: freqtrade backtesting-show [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
[--backtest-filename PATH]
[--backtest-directory PATH]
[--show-pair-list]
[--breakdown {day,week,month,year} [{day,week,month,year} ...]]
options:
-h, --help show this help message and exit
--backtest-filename PATH, --export-filename PATH
Use this filename for backtest results.Example:
`--backtest-
filename=backtest_results_2020-09-27_16-20-48.json`.
Assumes either `user_data/backtest_results/` or
`--export-directory` as base directory.
--backtest-directory PATH, --export-directory PATH
Directory to use for backtest results. Example:
`--export-directory=user_data/backtest_results/`.
--show-pair-list Show backtesting pairlist sorted by profit.
--breakdown {day,week,month,year} [{day,week,month,year} ...]
Show backtesting breakdown per [day, week, month,
year].
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
详细回测分析¶
对回测结果进行高级分析。
更多细节请参见 回测分析 章节。
usage: freqtrade backtesting-analysis [-h] [-v] [--no-color] [--logfile FILE]
[-V] [-c PATH] [-d PATH]
[--userdir PATH]
[--backtest-filename PATH]
[--backtest-directory PATH]
[--analysis-groups {0,1,2,3,4,5} [{0,1,2,3,4,5} ...]]
[--enter-reason-list ENTER_REASON_LIST [ENTER_REASON_LIST ...]]
[--exit-reason-list EXIT_REASON_LIST [EXIT_REASON_LIST ...]]
[--indicator-list INDICATOR_LIST [INDICATOR_LIST ...]]
[--entry-only] [--exit-only]
[--timerange TIMERANGE]
[--rejected-signals] [--analysis-to-csv]
[--analysis-csv-path ANALYSIS_CSV_PATH]
options:
-h, --help show this help message and exit
--backtest-filename PATH, --export-filename PATH
Use this filename for backtest results.Example:
`--backtest-
filename=backtest_results_2020-09-27_16-20-48.json`.
Assumes either `user_data/backtest_results/` or
`--export-directory` as base directory.
--backtest-directory PATH, --export-directory PATH
Directory to use for backtest results. Example:
`--export-directory=user_data/backtest_results/`.
--analysis-groups {0,1,2,3,4,5} [{0,1,2,3,4,5} ...]
grouping output - 0: simple wins/losses by enter tag,
1: by enter_tag, 2: by enter_tag and exit_tag, 3: by
pair and enter_tag, 4: by pair, enter_ and exit_tag
(this can get quite large), 5: by exit_tag
--enter-reason-list ENTER_REASON_LIST [ENTER_REASON_LIST ...]
Space separated list of entry signals to analyse.
Default: all. e.g. 'entry_tag_a entry_tag_b'
--exit-reason-list EXIT_REASON_LIST [EXIT_REASON_LIST ...]
Space separated list of exit signals to analyse.
Default: all. e.g. 'exit_tag_a roi stop_loss
trailing_stop_loss'
--indicator-list INDICATOR_LIST [INDICATOR_LIST ...]
Space separated list of indicators to analyse. e.g.
'close rsi bb_lowerband profit_abs'
--entry-only Only analyze entry signals.
--exit-only Only analyze exit signals.
--timerange TIMERANGE
Specify what timerange of data to use.
--rejected-signals Analyse rejected signals
--analysis-to-csv Save selected analysis tables to individual CSVs
--analysis-csv-path ANALYSIS_CSV_PATH
Specify a path to save the analysis CSVs if
--analysis-to-csv is enabled. Default:
user_data/basktesting_results/
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
列出 Hyperopt 结果¶
您可以使用 hyperopt-list 子命令列出 Hyperopt 模块之前评估过的优化轮次(epochs)。
usage: freqtrade hyperopt-list [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH] [--best]
[--profitable] [--min-trades INT]
[--max-trades INT] [--min-avg-time FLOAT]
[--max-avg-time FLOAT] [--min-avg-profit FLOAT]
[--max-avg-profit FLOAT]
[--min-total-profit FLOAT]
[--max-total-profit FLOAT]
[--min-objective FLOAT] [--max-objective FLOAT]
[--print-json] [--no-details]
[--hyperopt-filename FILENAME]
[--export-csv FILE]
options:
-h, --help show this help message and exit
--best Select only best epochs.
--profitable Select only profitable epochs.
--min-trades INT Select epochs with more than INT trades.
--max-trades INT Select epochs with less than INT trades.
--min-avg-time FLOAT Select epochs above average time.
--max-avg-time FLOAT Select epochs below average time.
--min-avg-profit FLOAT
Select epochs above average profit.
--max-avg-profit FLOAT
Select epochs below average profit.
--min-total-profit FLOAT
Select epochs above total profit.
--max-total-profit FLOAT
Select epochs below total profit.
--min-objective FLOAT
Select epochs above objective.
--max-objective FLOAT
Select epochs below objective.
--print-json Print output in JSON format.
--no-details Do not print best epoch details.
--hyperopt-filename FILENAME
Hyperopt result filename.Example: `--hyperopt-
filename=hyperopt_results_2020-09-27_16-20-48.pickle`
--export-csv FILE Export to CSV-File. This will disable table print.
Example: --export-csv hyperopt.csv
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
注意
hyperopt-list 将自动使用最新可用的 hyperopt 结果文件。您可以通过 --hyperopt-filename 参数覆盖此设置,并指定另一个可用的文件名(无需路径!)。
示例¶
列出所有结果,并在末尾打印最佳结果的详细信息:
freqtrade hyperopt-list
仅列出具有正收益的轮次。不打印最佳轮次的详细信息,以便可在脚本中遍历该列表:
freqtrade hyperopt-list --profitable --no-details
显示 Hyperopt 结果的详细信息¶
您可以使用 hyperopt-show 子命令查看 Hyperopt 模块之前评估过的任意一轮优化的详细信息。
usage: freqtrade hyperopt-show [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH] [--best]
[--profitable] [-n INT] [--print-json]
[--hyperopt-filename FILENAME] [--no-header]
[--disable-param-export]
[--breakdown {day,week,month,year} [{day,week,month,year} ...]]
options:
-h, --help show this help message and exit
--best Select only best epochs.
--profitable Select only profitable epochs.
-n INT, --index INT Specify the index of the epoch to print details for.
--print-json Print output in JSON format.
--hyperopt-filename FILENAME
Hyperopt result filename.Example: `--hyperopt-
filename=hyperopt_results_2020-09-27_16-20-48.pickle`
--no-header Do not print epoch details header.
--disable-param-export
Disable automatic hyperopt parameter export.
--breakdown {day,week,month,year} [{day,week,month,year} ...]
Show backtesting breakdown per [day, week, month,
year].
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
注意
hyperopt-show 将自动使用最新可用的 hyperopt 结果文件。您可以通过 --hyperopt-filename 参数覆盖此设置,并指定另一个可用的文件名(无需路径!)。
示例¶
打印第 168 轮的详细信息(轮次编号由 hyperopt-list 子命令或 Hyperopt 在优化过程中显示):
freqtrade hyperopt-show -n 168
以 JSON 格式打印最后一轮最佳结果(即所有轮次中最佳结果)的详细信息:
freqtrade hyperopt-show --best -n -1 --print-json --no-header
显示交易记录¶
将数据库中选定的(或全部)交易记录打印到屏幕上。
usage: freqtrade show-trades [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
[--db-url PATH]
[--trade-ids TRADE_IDS [TRADE_IDS ...]]
[--print-json]
options:
-h, --help show this help message and exit
--db-url PATH Override trades database URL, this is useful in custom
deployments (default: `sqlite:///tradesv3.sqlite` for
Live Run mode, `sqlite:///tradesv3.dryrun.sqlite` for
Dry Run).
--trade-ids TRADE_IDS [TRADE_IDS ...]
Specify the list of trade ids.
--print-json Print output in JSON format.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.
示例¶
以 JSON 格式打印 ID 为 2 和 3 的交易记录
freqtrade show-trades --db-url sqlite:///tradesv3.sqlite --trade-ids 2 3 --print-json
策略更新器¶
更新策略列表或策略文件夹中的所有策略,使其符合 v3 规范。如果运行命令时未使用 --strategy-list 参数,则会转换策略文件夹内的所有策略。您的原始策略将保留在 user_data/strategies_orig_updater/ 目录中。
转换结果
策略更新器将以“尽最大努力”的方式工作。请仔细检查并验证转换结果。我们还建议运行 Python 格式化工具(例如 black),以合理的方式格式化输出结果。
usage: freqtrade strategy-updater [-h] [-v] [--no-color] [--logfile FILE] [-V]
[-c PATH] [-d PATH] [--userdir PATH]
[--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]]
[--strategy-path PATH]
[--recursive-strategy-search]
options:
-h, --help show this help message and exit
--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]
Provide a space-separated list of strategies to
backtest. Please note that timeframe needs to be set
either in config or via command line. When using this
together with `--export trades`, the strategy-name is
injected into the filename (so `backtest-data.json`
becomes `backtest-data-SampleStrategy.json`
--strategy-path PATH Specify additional strategy lookup path.
--recursive-strategy-search
Recursively search for a strategy in the strategies
folder.
Common arguments:
-v, --verbose Verbose mode (-vv for more, -vvv to get all messages).
--no-color Disable colorization of hyperopt results. May be
useful if you are redirecting output to a file.
--logfile FILE, --log-file FILE
Log to the file specified. Special values are:
'syslog', 'journald'. See the documentation for more
details.
-V, --version show program's version number and exit
-c PATH, --config PATH
Specify configuration file (default:
`userdir/config.json` or `config.json` whichever
exists). Multiple --config options may be used. Can be
set to `-` to read config from stdin.
-d PATH, --datadir PATH, --data-dir PATH
Path to the base directory of the exchange with
historical backtesting data. To see futures data, use
trading-mode additionally.
--userdir PATH, --user-data-dir PATH
Path to userdata directory.