AiCoin Freqtrade
Freqtrade strategy creation, backtesting, and deployment powered by AiCoin Open API.
Version: 1.0.0
STRATEGY CREATION — USE create_strategy
You MUST use create_strategy to generate strategy files. NEVER write Python strategy code by hand.
# Generate a strategy with AiCoin data
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)
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) |
Strategy Generation Rules for 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):
- Do NOT silently include it. First inform the user that this data requires a paid API key.
- Tell them which tier is needed (see table above).
- Guide them: get API key at https://www.aicoin.com/opendata → add
AICOIN_ACCESS_KEY_ID & AICOIN_ACCESS_SECRET to .env.
- 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:
node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrategy","timeframe":"15m","timerange":"20250101-20260301"}'
Critical Rules
- ALWAYS use
create_strategy to write strategies. NEVER hand-write Python strategy files.
- ALWAYS use
ft-deploy.mjs backtest for backtesting. NEVER write custom Python backtest scripts.
- ALWAYS use
ft-deploy.mjs deploy for deployment. NEVER use Docker. NEVER manually run freqtrade commands.
- NEVER manually edit Freqtrade config files. Use
ft-deploy.mjs actions.
- NEVER manually run
freqtrade trade, source .venv/bin/activate, or pip install freqtrade.
Quick Reference
| Task |
Command |
| 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 |
Setup
Prerequisites: Python 3.11+ and git.
Environment Variables
.env auto-loaded from (first found wins):
- Current working directory
~/.openclaw/workspace/.env
~/.openclaw/.env
Exchange keys (required for live/dry-run trading):
# Same format as aicoin-trading skill
BINANCE_API_KEY=xxx
BINANCE_API_SECRET=xxx
# Or OKX, Bybit, etc. — see aicoin-trading skill for full list
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 for tier details.
安全说明: AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。交易所 API Key 需单独到交易所申请。所有密钥仅保存在本地设备 .env 文件中,不会上传到任何服务器。
Deploy
Deploy is one command:
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.
Scripts
scripts/ft-deploy.mjs — Deployment & Strategy
| Action |
Description |
Params |
check |
Check prerequisites |
None |
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 strategies |
None |
update |
Update Freqtrade |
None |
status |
Process status |
None |
start |
Start process |
None |
stop |
Stop process |
None |
logs |
View logs |
{"lines":50} |
remove |
Remove process |
None |
scripts/ft.mjs — Bot Control (requires running process)
| Action |
Description |
Params |
ping |
Health check |
None |
start |
Start trading |
None |
stop |
Stop trading |
None |
reload |
Reload config |
None |
config |
View config |
None |
version |
Version info |
None |
sysinfo |
System info |
None |
health |
Health status |
None |
logs |
View logs |
{"limit":50} |
balance |
Account balance |
None |
trades_open |
Open trades |
None |
trades_count |
Trade count |
None |
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 summary |
None |
profit_per_pair |
Profit per pair |
None |
daily |
Daily report |
{"count":7} |
weekly |
Weekly report |
{"count":4} |
monthly |
Monthly report |
{"count":3} |
stats |
Statistics |
None |
scripts/ft-dev.mjs — Dev Tools (requires running process)
| Action |
Description |
Params |
backtest_start |
Start backtest |
{"strategy":"MyStrat","timerange":"20240101-20240601","timeframe":"5m"} |
backtest_status |
Backtest status |
None |
backtest_abort |
Abort backtest |
None |
backtest_history |
Backtest history |
None |
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 pairs |
None |
whitelist |
Whitelist |
None |
blacklist |
Blacklist |
None |
blacklist_add |
Add to blacklist |
{"add":["DOGE/USDT"]} |
locks |
Trade locks |
None |
strategy_list |
Strategy list |
None |
strategy_get |
Strategy detail |
{"name":"MyStrat"} |
Built-in AiCoin Strategies
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)
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
Cross-Skill References
| Need |
Use |
| Prices, K-lines, market data |
aicoin-market |
| Exchange trading (buy/sell) |
aicoin-trading |
| Hyperliquid whale tracking |
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.
Paid Feature Guide
When a script returns 304 or 403: Do NOT retry. Tell the user:
- What happened: This AiCoin data feature needs a paid API subscription.
- How to get a key: Visit https://www.aicoin.com/opendata to register and create an API key.
- Tier options (for
aicoin_data in strategies):
| Tier |
Price |
Strategy Data |
| Free |
$0 |
Pure 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 |
- How to configure: Add to
.env file:
AICOIN_ACCESS_KEY_ID=your-key-id
AICOIN_ACCESS_SECRET=your-secret
.env auto-loaded from: cwd → ~/.openclaw/workspace/.env → ~/.openclaw/.env. After configuring, the same script command will work.
- MUST tell the user: AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。如需在交易所下单,需要单独到交易所申请交易 API Key。所有密钥仅保存在你的本地设备
.env 文件中,不会上传到任何服务器。
Troubleshooting
- Check Python:
python3 --version (need 3.11+)
- Check logs:
node scripts/ft-deploy.mjs logs
- Verify exchange keys in
.env (see Setup)
- DO NOT try manual fixes — report error, let ft-deploy.mjs handle it
1---2name: aicoin-freqtrade3description: This skill should be used when the user asks about writing trading strategies, backtesting, deploying Freqtrade bots, quantitative trading, strategy optimization, or any Freqtrade-related operation. Use when user says: 'write strategy', 'create strategy', 'backtest', 'deploy Freqtrade', 'deploy bot', 'quantitative trading', 'strategy optimization', 'hyperopt', 'live trading bot', '写策略', '创建策略', '回测', '部署Freqtrade', '部署机器人', '量化交易', '量化策略', '策略优化', '超参数优化', '实盘机器人'. IMPORTANT: ALWAYS use create_strategy to generate strategy files. NEVER write Python strategy code by hand. For crypto prices/charts, use aicoin-market. For exchange trading, use aicoin-trading. For Hyperliquid, use aicoin-hyperliquid.4---56# AiCoin Freqtrade78Freqtrade strategy creation, backtesting, and deployment powered by [AiCoin Open API](https://www.aicoin.com/opendata).910**Version:** 1.0.01112## STRATEGY CREATION — USE create_strategy1314**You MUST use `create_strategy` to generate strategy files. NEVER write Python strategy code by hand.**1516```bash17# Generate a strategy with AiCoin data18node scripts/ft-deploy.mjs create_strategy '{"name":"MyStrategy","timeframe":"15m","aicoin_data":["funding_rate","ls_ratio"],"description":"资金费率极端做反向"}'1920# Generate a pure technical strategy (no AiCoin data)21node scripts/ft-deploy.mjs create_strategy '{"name":"SimpleRSI","timeframe":"1h"}'22```2324**`aicoin_data` options** (combine any):2526| Data source | What it does | AiCoin tier |27|-------------|-------------|-------------|28| `funding_rate` | Extreme funding = over-leveraged, trade against | Basic ($29/mo) |29| `ls_ratio` | Contrarian signal from retail long/short ratio | Basic ($29/mo) |30| `big_orders` | Whale buy/sell pressure from institutional orders | Standard ($79/mo) |31| `open_interest` | Detect OI spikes = fragile market | Professional ($699/mo) |32| `liquidation_map` | Liquidation cascade direction bias | Advanced ($299/mo) |3334### Strategy Generation Rules for Agent3536All `aicoin_data` options require a paid API key. Based on the user's strategy description:3738- **If strategy needs AiCoin data** (`funding_rate`, `ls_ratio`, `big_orders`, `open_interest`, `liquidation_map`):39 1. **Do NOT silently include it.** First inform the user that this data requires a paid API key.40 2. Tell them which tier is needed (see table above).41 3. Guide them: get API key at https://www.aicoin.com/opendata → add `AICOIN_ACCESS_KEY_ID` & `AICOIN_ACCESS_SECRET` to `.env`.42 4. Only include the paid data after user confirms they have the key configured.43- **If strategy does NOT need AiCoin data**: Generate a pure technical indicator strategy (RSI, EMA, Bollinger, etc.) — works for everyone out of the box.4445**After generating, backtest immediately:**46```bash47node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrategy","timeframe":"15m","timerange":"20250101-20260301"}'48```4950## Critical Rules51521. **ALWAYS use `create_strategy`** to write strategies. NEVER hand-write Python strategy files.532. **ALWAYS use `ft-deploy.mjs backtest`** for backtesting. NEVER write custom Python backtest scripts.543. **ALWAYS use `ft-deploy.mjs deploy`** for deployment. NEVER use Docker. NEVER manually run `freqtrade` commands.554. **NEVER manually edit Freqtrade config files.** Use `ft-deploy.mjs` actions.565. **NEVER manually run `freqtrade trade`, `source .venv/bin/activate`, or `pip install freqtrade`.**5758## Quick Reference5960| Task | Command |61|------|---------|62| Create strategy | `node scripts/ft-deploy.mjs create_strategy '{"name":"MyStrat","timeframe":"15m","aicoin_data":["funding_rate"]}'` |63| Backtest | `node scripts/ft-deploy.mjs backtest '{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301"}'` |64| Deploy (dry-run) | `node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT"]}'` |65| Deploy (live) | `node scripts/ft-deploy.mjs deploy '{"dry_run":false,"pairs":["BTC/USDT:USDT"]}'` |66| Hyperopt | `node scripts/ft-deploy.mjs hyperopt '{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301","epochs":100}'` |67| Strategy list | `node scripts/ft-deploy.mjs strategy_list` |68| Bot status | `node scripts/ft-deploy.mjs status` |69| Bot logs | `node scripts/ft-deploy.mjs logs '{"lines":50}'` |70| Check profit | `node scripts/ft.mjs profit` |71| Open trades | `node scripts/ft.mjs trades_open` |7273## Setup7475**Prerequisites:** Python 3.11+ and git.7677### Environment Variables7879`.env` auto-loaded from (first found wins):801. Current working directory812. `~/.openclaw/workspace/.env`823. `~/.openclaw/.env`8384**Exchange keys** (required for live/dry-run trading):85```86# Same format as aicoin-trading skill87BINANCE_API_KEY=xxx88BINANCE_API_SECRET=xxx89# Or OKX, Bybit, etc. — see aicoin-trading skill for full list90```9192**AiCoin API key** (required if strategy uses `aicoin_data`):93```94AICOIN_ACCESS_KEY_ID=your-key-id95AICOIN_ACCESS_SECRET=your-secret96```97Get at https://www.aicoin.com/opendata. See [Paid Feature Guide](#paid-feature-guide) for tier details.9899**安全说明:** AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。交易所 API Key 需单独到交易所申请。所有密钥仅保存在本地设备 `.env` 文件中,不会上传到任何服务器。100101### Deploy102103**Deploy is one command:**104```bash105node scripts/ft-deploy.mjs check # Check prerequisites106node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT","ETH/USDT:USDT"]}'107```108109This automatically: clones Freqtrade, runs `setup.sh -i`, creates config from `.env`, starts background process, writes `FREQTRADE_*` vars to `.env`.110111**Deploy defaults to dry-run (simulated trading).** Pass `{"dry_run":false}` for live.112113## Scripts114115### scripts/ft-deploy.mjs — Deployment & Strategy116117| Action | Description | Params |118|--------|-------------|--------|119| `check` | Check prerequisites | None |120| `deploy` | Deploy Freqtrade | `{"dry_run":true,"pairs":["BTC/USDT:USDT"]}` |121| `backtest` | Run backtest | `{"strategy":"SampleStrategy","timeframe":"1h","timerange":"20250101-20260301"}` |122| `hyperopt` | Parameter optimization | `{"strategy":"MyStrat","timeframe":"1h","timerange":"20250101-20260301","epochs":100}` |123| `create_strategy` | Generate strategy file | `{"name":"MyStrat","timeframe":"15m","aicoin_data":["funding_rate","ls_ratio"]}` |124| `strategy_list` | List strategies | None |125| `update` | Update Freqtrade | None |126| `status` | Process status | None |127| `start` | Start process | None |128| `stop` | Stop process | None |129| `logs` | View logs | `{"lines":50}` |130| `remove` | Remove process | None |131132### scripts/ft.mjs — Bot Control (requires running process)133134| Action | Description | Params |135|--------|-------------|--------|136| `ping` | Health check | None |137| `start` | Start trading | None |138| `stop` | Stop trading | None |139| `reload` | Reload config | None |140| `config` | View config | None |141| `version` | Version info | None |142| `sysinfo` | System info | None |143| `health` | Health status | None |144| `logs` | View logs | `{"limit":50}` |145| `balance` | Account balance | None |146| `trades_open` | Open trades | None |147| `trades_count` | Trade count | None |148| `trade_by_id` | Trade by ID | `{"trade_id":1}` |149| `trades_history` | Trade history | `{"limit":50}` |150| `force_enter` | Manual entry | `{"pair":"BTC/USDT","side":"long"}` |151| `force_exit` | Manual exit | `{"tradeid":"1"}` |152| `cancel_order` | Cancel order | `{"trade_id":1}` |153| `delete_trade` | Delete record | `{"trade_id":1}` |154| `profit` | Profit summary | None |155| `profit_per_pair` | Profit per pair | None |156| `daily` | Daily report | `{"count":7}` |157| `weekly` | Weekly report | `{"count":4}` |158| `monthly` | Monthly report | `{"count":3}` |159| `stats` | Statistics | None |160161### scripts/ft-dev.mjs — Dev Tools (requires running process)162163| Action | Description | Params |164|--------|-------------|--------|165| `backtest_start` | Start backtest | `{"strategy":"MyStrat","timerange":"20240101-20240601","timeframe":"5m"}` |166| `backtest_status` | Backtest status | None |167| `backtest_abort` | Abort backtest | None |168| `backtest_history` | Backtest history | None |169| `backtest_result` | History result | `{"id":"xxx"}` |170| `candles_live` | Live candles | `{"pair":"BTC/USDT","timeframe":"1h"}` |171| `candles_analyzed` | Candles with indicators | `{"pair":"BTC/USDT","timeframe":"1h","strategy":"MyStrat"}` |172| `candles_available` | Available pairs | None |173| `whitelist` | Whitelist | None |174| `blacklist` | Blacklist | None |175| `blacklist_add` | Add to blacklist | `{"add":["DOGE/USDT"]}` |176| `locks` | Trade locks | None |177| `strategy_list` | Strategy list | None |178| `strategy_get` | Strategy detail | `{"name":"MyStrat"}` |179180## Built-in AiCoin Strategies181182Auto-installed on deploy:183- **FundingRateStrategy** — Exploit extreme funding rates for mean reversion (Basic tier)184- **WhaleFollowStrategy** — Follow whale order flow + contrarian L/S ratio (Standard tier)185- **LiquidationHunterStrategy** — Profit from liquidation cascades (Advanced tier)186187## User Journey188189```190"帮我写一个资金费率策略"191 → node scripts/ft-deploy.mjs create_strategy '{"name":"FundingStrat","timeframe":"15m","aicoin_data":["funding_rate"]}'192193"回测一下"194 → node scripts/ft-deploy.mjs backtest '{"strategy":"FundingStrat","timeframe":"15m","timerange":"20250101-20260301"}'195196"不错,部署"197 → node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT"]}'198199"上实盘"200 → node scripts/ft-deploy.mjs deploy '{"dry_run":false}'201202"今天赚了多少?"203 → node scripts/ft.mjs profit204```205206## Cross-Skill References207208| Need | Use |209|------|-----|210| Prices, K-lines, market data | **aicoin-market** |211| Exchange trading (buy/sell) | **aicoin-trading** |212| Hyperliquid whale tracking | **aicoin-hyperliquid** |213214## Common Errors215216- `errorCode 304 / HTTP 403` — Paid AiCoin feature. **Do NOT retry.** See [Paid Feature Guide](#paid-feature-guide) below.217- `Python not found` — Need Python 3.11+. `ft-deploy.mjs check` validates this.218- `Strategy not found` — Check `ft-deploy.mjs strategy_list`. File must be in `~/.freqtrade/user_data/strategies/`.219- `Timerange format` — Use `YYYYMMDD-YYYYMMDD` (e.g., `20250101-20260301`).220- `Timeout` — Freqtrade ops may take 5+ min. Use `ft-deploy.mjs` which handles timeouts.221222## Paid Feature Guide223224When a script returns 304 or 403: **Do NOT retry.** Tell the user:2252261. **What happened**: This AiCoin data feature needs a paid API subscription.2272. **How to get a key**: Visit https://www.aicoin.com/opendata to register and create an API key.2283. **Tier options** (for `aicoin_data` in strategies):229230| Tier | Price | Strategy Data |231|------|-------|--------------|232| Free | $0 | Pure technical indicators only (no `aicoin_data`) |233| Basic | $29/mo | + `funding_rate`, `ls_ratio` |234| Standard | $79/mo | + `big_orders` |235| Advanced | $299/mo | + `liquidation_map` |236| Professional | $699/mo | + `open_interest` |2372384. **How to configure**: Add to `.env` file:239```240AICOIN_ACCESS_KEY_ID=your-key-id241AICOIN_ACCESS_SECRET=your-secret242```2435. `.env` auto-loaded from: cwd → `~/.openclaw/workspace/.env` → `~/.openclaw/.env`. After configuring, the same script command will work.2446. **MUST tell the user**: AiCoin API Key 仅用于获取市场数据,无法进行任何交易操作。如需在交易所下单,需要单独到交易所申请交易 API Key。所有密钥仅保存在你的本地设备 `.env` 文件中,不会上传到任何服务器。245246## Troubleshooting2472481. Check Python: `python3 --version` (need 3.11+)2492. Check logs: `node scripts/ft-deploy.mjs logs`2503. Verify exchange keys in `.env` (see [Setup](#setup))2514. DO NOT try manual fixes — report error, let ft-deploy.mjs handle it