aicoin-freqtrade

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AiCoin Freqtrade

AiCoin Freqtrade

Freqtrade strategy creation, backtesting, and deployment powered by AiCoin Open API.
Version: 1.0.0
AiCoin Open API提供支持的Freqtrade策略创建、回测与部署工具。
版本: 1.0.0

STRATEGY CREATION — USE create_strategy

策略创建 — 请使用create_strategy

You MUST use
create_strategy
to generate strategy files. NEVER write Python strategy code by hand.
bash
undefined
你必须使用
create_strategy
生成策略文件,绝对不要手动编写Python策略代码。
bash
undefined

Generate a strategy with AiCoin data

Generate a strategy with AiCoin data

node scripts/ft-deploy.mjs create_strategy '{"name":"MyStrategy","timeframe":"15m","aicoin_data":["funding_rate","ls_ratio"],"description":"资金费率极端做反向"}'
node scripts/ft-deploy.mjs create_strategy '{"name":"MyStrategy","timeframe":"15m","aicoin_data":["funding_rate","ls_ratio"],"description":"资金费率极端做反向"}'

Generate a pure technical strategy (no AiCoin data)

Generate a pure technical strategy (no AiCoin data)

node scripts/ft-deploy.mjs create_strategy '{"name":"SimpleRSI","timeframe":"1h"}'

**`aicoin_data` options** (combine any):

| Data source | What it does | AiCoin tier |
|-------------|-------------|-------------|
| `funding_rate` | Extreme funding = over-leveraged, trade against | Basic ($29/mo) |
| `ls_ratio` | Contrarian signal from retail long/short ratio | Basic ($29/mo) |
| `big_orders` | Whale buy/sell pressure from institutional orders | Standard ($79/mo) |
| `open_interest` | Detect OI spikes = fragile market | Professional ($699/mo) |
| `liquidation_map` | Liquidation cascade direction bias | Advanced ($299/mo) |
node scripts/ft-deploy.mjs create_strategy '{"name":"SimpleRSI","timeframe":"1h"}'

**`aicoin_data`可选参数**(可任意组合):

| 数据源 | 功能说明 | AiCoin套餐等级 |
|-------------|-------------|-------------|
| `funding_rate` | 极端资金费率 = 过度杠杆,可反向交易 | 基础版($29/月) |
| `ls_ratio` | 散户多空比衍生的反向信号 | 基础版($29/月) |
| `big_orders` | 机构订单带来的巨鲸买卖压力 | 标准版($79/月) |
| `open_interest` | 识别未平仓合约激增 = 市场脆弱 | 专业版($699/月) |
| `liquidation_map` | 清算瀑布的方向偏向 | 高级版($299/月) |

Strategy Generation Rules for Agent

Agent 策略生成规则

All
aicoin_data
options require a paid API key. Based on the user's strategy description:
  • If strategy needs AiCoin data (
    funding_rate
    ,
    ls_ratio
    ,
    big_orders
    ,
    open_interest
    ,
    liquidation_map
    ):
    1. Do NOT silently include it. First inform the user that this data requires a paid API key.
    2. Tell them which tier is needed (see table above).
    3. Guide them: get API key at https://www.aicoin.com/opendata → add
      AICOIN_ACCESS_KEY_ID
      &
      AICOIN_ACCESS_SECRET
      to
      .env
      .
    4. Only include the paid data after user confirms they have the key configured.
  • If strategy does NOT need AiCoin data: Generate a pure technical indicator strategy (RSI, EMA, Bollinger, etc.) — works for everyone out of the box.
After generating, backtest immediately:
bash
node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrategy","timeframe":"15m","timerange":"20250101-20260301"}'
所有
aicoin_data
参数都需要付费API密钥。根据用户的策略描述:
  • 如果策略需要AiCoin数据
    funding_rate
    ls_ratio
    big_orders
    open_interest
    liquidation_map
    ):
    1. 不要静默添加该参数。 首先告知用户该数据需要付费API密钥。
    2. 告知用户所需的套餐等级(见上表)。
    3. 引导用户操作:前往https://www.aicoin.com/opendata获取API密钥 → 将
      AICOIN_ACCESS_KEY_ID
      AICOIN_ACCESS_SECRET
      添加到
      .env
      文件中。
    4. 仅在用户确认已配置好密钥后再添加付费数据参数。
  • 如果策略不需要AiCoin数据:生成纯技术指标策略(RSI、EMA、布林带等)——所有用户开箱即可使用。
生成策略后立即进行回测:
bash
node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrategy","timeframe":"15m","timerange":"20250101-20260301"}'

Critical Rules

核心规则

  1. ALWAYS use
    create_strategy
    to write strategies. NEVER hand-write Python strategy files.
  2. ALWAYS use
    ft-deploy.mjs backtest
    for backtesting. NEVER write custom Python backtest scripts.
  3. ALWAYS use
    ft-deploy.mjs deploy
    for deployment. NEVER use Docker. NEVER manually run
    freqtrade
    commands.
  4. NEVER manually edit Freqtrade config files. Use
    ft-deploy.mjs
    actions.
  5. NEVER manually run
    freqtrade trade
    ,
    source .venv/bin/activate
    , or
    pip install freqtrade
    .
  1. **必须使用
    create_strategy
    **编写策略,绝对不要手动编写Python策略文件。
  2. **必须使用
    ft-deploy.mjs backtest
    **进行回测,绝对不要编写自定义Python回测脚本。
  3. **必须使用
    ft-deploy.mjs deploy
    **进行部署,绝对不要使用Docker,绝对不要手动运行
    freqtrade
    命令。
  4. 绝对不要手动编辑Freqtrade配置文件,请使用
    ft-deploy.mjs
    提供的操作。
  5. 绝对不要手动运行
    freqtrade trade
    source .venv/bin/activate
    pip install freqtrade
    命令。

Quick Reference

快速参考

TaskCommand
Create strategy
node scripts/ft-deploy.mjs create_strategy '{"name":"MyStrat","timeframe":"15m","aicoin_data":["funding_rate"]}'
Backtest
node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301"}'
Deploy (dry-run)
node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT"]}'
Deploy (live)
node scripts/ft-deploy.mjs deploy '{"dry_run":false,"pairs":["BTC/USDT:USDT"]}'
Hyperopt
node scripts/ft-deploy.mjs hyperopt '{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301","epochs":100}'
Strategy list
node scripts/ft-deploy.mjs strategy_list
Bot status
node scripts/ft-deploy.mjs status
Bot logs
node scripts/ft-deploy.mjs logs '{"lines":50}'
Check profit
node scripts/ft.mjs profit
Open trades
node scripts/ft.mjs trades_open
任务命令
创建策略
node scripts/ft-deploy.mjs create_strategy '{"name":"MyStrat","timeframe":"15m","aicoin_data":["funding_rate"]}'
回测
node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301"}'
部署(模拟盘)
node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT"]}'
部署(实盘)
node scripts/ft-deploy.mjs deploy '{"dry_run":false,"pairs":["BTC/USDT:USDT"]}'
超参数优化
node scripts/ft-deploy.mjs hyperopt '{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301","epochs":100}'
策略列表
node scripts/ft-deploy.mjs strategy_list
机器人状态
node scripts/ft-deploy.mjs status
机器人日志
node scripts/ft-deploy.mjs logs '{"lines":50}'
查看收益
node scripts/ft.mjs profit
未平仓交易
node scripts/ft.mjs trades_open

Setup

环境配置

Prerequisites: Python 3.11+ and git.
前置要求: Python 3.11+ 和 git。

Environment Variables

环境变量

.env
auto-loaded from (first found wins):
  1. Current working directory
  2. ~/.openclaw/workspace/.env
  3. ~/.openclaw/.env
Exchange keys (required for live/dry-run trading):
undefined
.env
文件按以下优先级自动加载(先找到的生效):
  1. 当前工作目录
  2. ~/.openclaw/workspace/.env
  3. ~/.openclaw/.env
交易所密钥(实盘/模拟盘交易必需):
undefined

Same format as aicoin-trading skill

和aicoin-trading skill格式一致

BINANCE_API_KEY=xxx BINANCE_API_SECRET=xxx
BINANCE_API_KEY=xxx BINANCE_API_SECRET=xxx

Or OKX, Bybit, etc. — see aicoin-trading skill for full list

也支持OKX、Bybit等 — 完整列表见aicoin-trading skill


**AiCoin API key** (required if strategy uses `aicoin_data`):
AICOIN_ACCESS_KEY_ID=your-key-id AICOIN_ACCESS_SECRET=your-secret
Get at https://www.aicoin.com/opendata. See [Paid Feature Guide](#paid-feature-guide) for tier details.

**安全说明:** AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。交易所 API Key 需单独到交易所申请。所有密钥仅保存在本地设备 `.env` 文件中,不会上传到任何服务器。

**AiCoin API密钥**(如果策略使用`aicoin_data`则必需):
AICOIN_ACCESS_KEY_ID=your-key-id AICOIN_ACCESS_SECRET=your-secret
前往https://www.aicoin.com/opendata获取。套餐详情见[付费功能指南](#paid-feature-guide)。

**安全说明:** AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。交易所 API Key 需单独到交易所申请。所有密钥仅保存在本地设备 `.env` 文件中,不会上传到任何服务器。

Deploy

部署

Deploy is one command:
bash
node scripts/ft-deploy.mjs check    # Check prerequisites
node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT","ETH/USDT:USDT"]}'
This automatically: clones Freqtrade, runs
setup.sh -i
, creates config from
.env
, starts background process, writes
FREQTRADE_*
vars to
.env
.
Deploy defaults to dry-run (simulated trading). Pass
{"dry_run":false}
for live.
部署仅需一条命令:
bash
node scripts/ft-deploy.mjs check    # 检查前置依赖
node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT","ETH/USDT:USDT"]}'
该命令会自动完成:克隆Freqtrade仓库、运行
setup.sh -i
、从
.env
生成配置、启动后台进程、将
FREQTRADE_*
变量写入
.env
文件。
部署默认使用模拟盘(模拟交易)。 实盘交易请传入
{"dry_run":false}
参数。

Scripts

脚本说明

scripts/ft-deploy.mjs — Deployment & Strategy

scripts/ft-deploy.mjs — 部署与策略管理

ActionDescriptionParams
check
Check prerequisitesNone
deploy
Deploy Freqtrade
{"dry_run":true,"pairs":["BTC/USDT:USDT"]}
backtest
Run backtest
{"strategy":"SampleStrategy","timeframe":"1h","timerange":"20250101-20260301"}
hyperopt
Parameter optimization
{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301","epochs":100}
create_strategy
Generate strategy file
{"name":"MyStrat","timeframe":"15m","aicoin_data":["funding_rate","ls_ratio"]}
strategy_list
List strategiesNone
update
Update FreqtradeNone
status
Process statusNone
start
Start processNone
stop
Stop processNone
logs
View logs
{"lines":50}
remove
Remove processNone
操作描述参数
check
检查前置依赖
deploy
部署Freqtrade
{"dry_run":true,"pairs":["BTC/USDT:USDT"]}
backtest
运行回测
{"strategy":"SampleStrategy","timeframe":"1h","timerange":"20250101-20260301"}
hyperopt
参数优化
{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301","epochs":100}
create_strategy
生成策略文件
{"name":"MyStrat","timeframe":"15m","aicoin_data":["funding_rate","ls_ratio"]}
strategy_list
列出所有策略
update
更新Freqtrade
status
进程状态
start
启动进程
stop
停止进程
logs
查看日志
{"lines":50}
remove
删除进程

scripts/ft.mjs — Bot Control (requires running process)

scripts/ft.mjs — 机器人控制(需要进程正在运行)

ActionDescriptionParams
ping
Health checkNone
start
Start tradingNone
stop
Stop tradingNone
reload
Reload configNone
config
View configNone
version
Version infoNone
sysinfo
System infoNone
health
Health statusNone
logs
View logs
{"limit":50}
balance
Account balanceNone
trades_open
Open tradesNone
trades_count
Trade countNone
trade_by_id
Trade by ID
{"trade_id":1}
trades_history
Trade history
{"limit":50}
force_enter
Manual entry
{"pair":"BTC/USDT","side":"long"}
force_exit
Manual exit
{"tradeid":"1"}
cancel_order
Cancel order
{"trade_id":1}
delete_trade
Delete record
{"trade_id":1}
profit
Profit summaryNone
profit_per_pair
Profit per pairNone
daily
Daily report
{"count":7}
weekly
Weekly report
{"count":4}
monthly
Monthly report
{"count":3}
stats
StatisticsNone
操作描述参数
ping
健康检查
start
开始交易
stop
停止交易
reload
重载配置
config
查看配置
version
版本信息
sysinfo
系统信息
health
健康状态
logs
查看日志
{"limit":50}
balance
账户余额
trades_open
未平仓交易
trades_count
交易数量
trade_by_id
根据ID查询交易
{"trade_id":1}
trades_history
交易历史
{"limit":50}
force_enter
手动开仓
{"pair":"BTC/USDT","side":"long"}
force_exit
手动平仓
{"tradeid":"1"}
cancel_order
取消订单
{"trade_id":1}
delete_trade
删除交易记录
{"trade_id":1}
profit
收益汇总
profit_per_pair
各交易对收益
daily
日报
{"count":7}
weekly
周报
{"count":4}
monthly
月报
{"count":3}
stats
统计数据

scripts/ft-dev.mjs — Dev Tools (requires running process)

scripts/ft-dev.mjs — 开发工具(需要进程正在运行)

ActionDescriptionParams
backtest_start
Start backtest
{"strategy":"MyStrat","timerange":"20240101-20240601","timeframe":"5m"}
backtest_status
Backtest statusNone
backtest_abort
Abort backtestNone
backtest_history
Backtest historyNone
backtest_result
History result
{"id":"xxx"}
candles_live
Live candles
{"pair":"BTC/USDT","timeframe":"1h"}
candles_analyzed
Candles with indicators
{"pair":"BTC/USDT","timeframe":"1h","strategy":"MyStrat"}
candles_available
Available pairsNone
whitelist
WhitelistNone
blacklist
BlacklistNone
blacklist_add
Add to blacklist
{"add":["DOGE/USDT"]}
locks
Trade locksNone
strategy_list
Strategy listNone
strategy_get
Strategy detail
{"name":"MyStrat"}
操作描述参数
backtest_start
启动回测
{"strategy":"MyStrat","timerange":"20240101-20240601","timeframe":"5m"}
backtest_status
回测状态
backtest_abort
终止回测
backtest_history
回测历史
backtest_result
历史回测结果
{"id":"xxx"}
candles_live
实时K线
{"pair":"BTC/USDT","timeframe":"1h"}
candles_analyzed
带指标的K线
{"pair":"BTC/USDT","timeframe":"1h","strategy":"MyStrat"}
candles_available
可用交易对
whitelist
白名单
blacklist
黑名单
blacklist_add
添加到黑名单
{"add":["DOGE/USDT"]}
locks
交易锁
strategy_list
策略列表
strategy_get
策略详情
{"name":"MyStrat"}

Built-in AiCoin Strategies

内置AiCoin策略

Auto-installed on deploy:
  • FundingRateStrategy — Exploit extreme funding rates for mean reversion (Basic tier)
  • WhaleFollowStrategy — Follow whale order flow + contrarian L/S ratio (Standard tier)
  • LiquidationHunterStrategy — Profit from liquidation cascades (Advanced tier)
部署时自动安装:
  • FundingRateStrategy — 利用极端资金费率进行均值回归(基础版套餐)
  • WhaleFollowStrategy — 跟随巨鲸订单流+多空比反向交易(标准版套餐)
  • LiquidationHunterStrategy — 从清算瀑布中获利(高级版套餐)

User Journey

用户使用流程示例

"帮我写一个资金费率策略"
  → node scripts/ft-deploy.mjs create_strategy '{"name":"FundingStrat","timeframe":"15m","aicoin_data":["funding_rate"]}'

"回测一下"
  → node scripts/ft-deploy.mjs backtest '{"strategy":"FundingStrat","timeframe":"15m","timerange":"20250101-20260301"}'

"不错,部署"
  → node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT"]}'

"上实盘"
  → node scripts/ft-deploy.mjs deploy '{"dry_run":false}'

"今天赚了多少?"
  → node scripts/ft.mjs profit
"帮我写一个资金费率策略"
  → node scripts/ft-deploy.mjs create_strategy '{"name":"FundingStrat","timeframe":"15m","aicoin_data":["funding_rate"]}'

"回测一下"
  → node scripts/ft-deploy.mjs backtest '{"strategy":"FundingStrat","timeframe":"15m","timerange":"20250101-20260301"}'

"不错,部署"
  → node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT"]}'

"上实盘"
  → node scripts/ft-deploy.mjs deploy '{"dry_run":false}'

"今天赚了多少?"
  → node scripts/ft.mjs profit

Cross-Skill References

跨skill引用

NeedUse
Prices, K-lines, market dataaicoin-market
Exchange trading (buy/sell)aicoin-trading
Hyperliquid whale trackingaicoin-hyperliquid
需求使用的skill
价格、K线、市场数据aicoin-market
交易所交易(买卖)aicoin-trading
Hyperliquid巨鲸追踪aicoin-hyperliquid

Common Errors

常见错误

  • errorCode 304 / HTTP 403
    — Paid AiCoin feature. Do NOT retry. See Paid Feature Guide below.
  • Python not found
    — Need Python 3.11+.
    ft-deploy.mjs check
    validates this.
  • Strategy not found
    — Check
    ft-deploy.mjs strategy_list
    . File must be in
    ~/.freqtrade/user_data/strategies/
    .
  • Timerange format
    — Use
    YYYYMMDD-YYYYMMDD
    (e.g.,
    20250101-20260301
    ).
  • Timeout
    — Freqtrade ops may take 5+ min. Use
    ft-deploy.mjs
    which handles timeouts.
  • errorCode 304 / HTTP 403
    — AiCoin付费功能。不要重试。 见下方付费功能指南
  • Python not found
    — 需要Python 3.11+版本。可运行
    ft-deploy.mjs check
    验证。
  • Strategy not found
    — 请检查
    ft-deploy.mjs strategy_list
    输出,策略文件必须放在
    ~/.freqtrade/user_data/strategies/
    目录下。
  • Timerange format
    — 请使用
    YYYYMMDD-YYYYMMDD
    格式(例如
    20250101-20260301
    )。
  • Timeout
    — Freqtrade操作可能需要5分钟以上,使用
    ft-deploy.mjs
    可自动处理超时。

Paid Feature Guide

付费功能指南

When a script returns 304 or 403: Do NOT retry. Tell the user:
  1. What happened: This AiCoin data feature needs a paid API subscription.
  2. How to get a key: Visit https://www.aicoin.com/opendata to register and create an API key.
  3. Tier options (for
    aicoin_data
    in strategies):
TierPriceStrategy Data
Free$0Pure technical indicators only (no
aicoin_data
)
Basic$29/mo+
funding_rate
,
ls_ratio
Standard$79/mo+
big_orders
Advanced$299/mo+
liquidation_map
Professional$699/mo+
open_interest
  1. How to configure: Add to
    .env
    file:
AICOIN_ACCESS_KEY_ID=your-key-id
AICOIN_ACCESS_SECRET=your-secret
  1. .env
    auto-loaded from: cwd →
    ~/.openclaw/workspace/.env
    ~/.openclaw/.env
    . After configuring, the same script command will work.
  2. MUST tell the user: AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。如需在交易所下单,需要单独到交易所申请交易 API Key。所有密钥仅保存在你的本地设备
    .env
    文件中,不会上传到任何服务器。
当脚本返回304或403错误时:不要重试。 告知用户以下内容:
  1. 发生了什么:该AiCoin数据功能需要付费API订阅。
  2. 如何获取密钥:访问https://www.aicoin.com/opendata注册并创建API密钥。
  3. 套餐选项(策略中
    aicoin_data
    对应的套餐):
套餐价格可用策略数据
免费版$0仅纯技术指标(无
aicoin_data
基础版$29/月+
funding_rate
ls_ratio
标准版$79/月+
big_orders
高级版$299/月+
liquidation_map
专业版$699/月+
open_interest
  1. 如何配置:添加到
    .env
    文件:
AICOIN_ACCESS_KEY_ID=your-key-id
AICOIN_ACCESS_SECRET=your-secret
  1. .env
    按以下路径自动加载:当前工作目录 →
    ~/.openclaw/workspace/.env
    ~/.openclaw/.env
    。配置完成后,重新运行相同的脚本命令即可生效。
  2. 必须告知用户:AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。如需在交易所下单,需要单独到交易所申请交易 API Key。所有密钥仅保存在你的本地设备
    .env
    文件中,不会上传到任何服务器。

Troubleshooting

故障排除

  1. Check Python:
    python3 --version
    (need 3.11+)
  2. Check logs:
    node scripts/ft-deploy.mjs logs
  3. Verify exchange keys in
    .env
    (see Setup)
  4. DO NOT try manual fixes — report error, let ft-deploy.mjs handle it
  1. 检查Python版本:
    python3 --version
    (需要3.11+)
  2. 查看日志:
    node scripts/ft-deploy.mjs logs
  3. 验证
    .env
    中的交易所密钥(见环境配置
  4. 不要尝试手动修复 — 上报错误,让ft-deploy.mjs处理