Learn-skills.dev aicoin
Use this skill when the user asks about crypto prices, trading, exchanges (Binance, OKX, Bybit, Bitget, Gate, HTX, KuCoin, MEXC, Coinbase), spot or futures orders, balance, leverage, positions, K-lines, funding rates, open interest, liquidation, whale tracking, news, Hyperliquid, Freqtrade, or automated trading.
git clone https://github.com/NeverSight/learn-skills.dev
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/aicoincom/aicoin-skills/aicoin" ~/.claude/skills/neversight-learn-skills-dev-aicoin && rm -rf "$T"
data/skills-md/aicoincom/aicoin-skills/aicoin/SKILL.mdAiCoin
Crypto data & trading toolkit powered by AiCoin Open API.
Version: 1.5.21 | Last Updated: 2026-03-04
Data Sources: AiCoin aggregates data from 200+ exchanges. Price data is real-time, K-lines updated every second, funding rates every 8h.
Supported Exchanges for Trading: Binance, OKX, Bybit, Bitget, Gate.io, HTX, KuCoin, MEXC, Coinbase (requires API keys in
.env).
Quick Start Examples:
# Check BTC price node scripts/coin.mjs coin_ticker '{"coin_list":"bitcoin"}' # Get 1h K-line node scripts/market.mjs kline '{"symbol":"btcusdt:okex","period":"3600","size":"10"}' # Check balance (requires exchange API keys) node scripts/exchange.mjs balance '{"exchange":"okx"}'
Quick Reference — Most Common Commands
Run all scripts from the aicoin skill directory. Use
tool, NOTexec. API keys are pre-configured. Do NOT ask the user for keys. Do NOT runprocess/env. Do NOT use curl, web_fetch, or browser for crypto data. Always use these scripts. 🚨 TRADING SAFETY: NEVER place orders without user confirmation. ALWAYS show order details and ask "确认下单?" FIRST. NEVER auto-adjust order size or parameters. ⚡ PERFORMANCE: Use batch queries when possible.printenvsupports multiple coins in one call (e.g.,coin_ticker)."coin_list":"bitcoin,ethereum,solana"
| Task | Command |
|---|---|
| BTC price | |
| Multi price | |
| K-line | |
| Funding rate | (BTC only, 8h default) |
| Funding rate (other coins) | |
| Open interest | |
| Long/short ratio | |
| Whale orders | |
| News flash | |
| HL whale | |
| Balance | |
| Ticker | |
| Orderbook | |
| Buy/Sell | → returns preview only |
| Positions | |
| Market list | |
| Deploy Freqtrade | (dry-run by default) |
| Backtest | ⚠️ MUST use this script |
Symbol shortcuts:
BTC, ETH, SOL, DOGE, XRP auto-resolve to AiCoin format (e.g. btcswapusdt:binance) in coin.mjs. For exchange.mjs, use CCXT format: BTC/USDT, BTC/USDT:USDT (swap).
Chinese Slang Recognition: Understand common crypto slang: 大饼=BTC, 姨太=ETH, 狗狗=DOGE, 瑞波=XRP, 索拉纳=SOL, 做多=long, 做空=short, 爆仓=liquidation, 合约=futures/swap.
Common Errors & Solutions:
→ Check symbol format (AiCoin:Error: Invalid symbol
, CCXT:btcusdt:okex
)BTC/USDT
→ Check balance first withError: Insufficient balance
, don't auto-adjust order sizeexchange.mjs balance
→ Keys are inError: API key invalid
, never pass inline. Check if user configured exchange keys..env
→ Freqtrade operations may take 5+ minutes, increase timeout or useTimeout
which handles thisft-deploy.mjs
→ Wait 1-2 seconds between requests. Use batch queries when possible to reduce API calls.Rate limit exceeded
Response Format Best Practices:
- Use tables for structured data (prices, K-lines, balances)
- Include units (USDT, BTC, %) and directions (📈/📉) for clarity
- For analysis: show data first, then interpretation
- Keep responses concise - users can ask for details if needed
- Always fetch fresh data - NEVER use cached or memorized prices
Setup Checklist
✅ Good News: The skill works out of the box! Scripts auto-load
.env files from these locations (earlier paths take priority):
- Current working directory (
).env ~/.openclaw/workspace/.env~/.openclaw/.env
Before asking the user for ANY credentials, first check if
already exists:.env
grep -c "AICOIN_ACCESS_KEY_ID" ~/.openclaw/workspace/.env 2>/dev/null || echo "0"
- If output is
or more →1
has AiCoin key configured. Skip setup, just run scripts directly..env - If output is
→ No AiCoin key, but the built-in free key works automatically. Just run scripts.0
Only ask setup questions when the user explicitly requests features that need configuration:
- Exchange trading (Binance, OKX, etc.) → needs exchange API keys +
into the aicoin skill directory and runcd
for ccxtnpm install - Freqtrade bot → MUST use
(auto-configures everything, needs Python 3.11+ + exchange keys in .env). NEVER manually configure Freqtrade, NEVER use Docker, NEVER write custom install scripts.node scripts/ft-deploy.mjs deploy - Proxy access → needs
PROXY_URL
Do NOT block the user from running commands. The skill works out of the box with the built-in free key.
How to Configure Environment Variables
The
.env file location is ~/.openclaw/workspace/.env. When adding new variables:
-
Check if
already exists:.envtest -f ~/.openclaw/workspace/.env && echo "EXISTS" || echo "NOT_FOUND" -
If EXISTS → append (do NOT overwrite):
echo 'PROXY_URL=socks5://127.0.0.1:7890' >> ~/.openclaw/workspace/.env -
If NOT_FOUND → create:
echo 'PROXY_URL=socks5://127.0.0.1:7890' > ~/.openclaw/workspace/.env -
If a key already exists and needs updating, replace the specific line:
sed -i '' 's|^PROXY_URL=.*|PROXY_URL=socks5://127.0.0.1:7890|' ~/.openclaw/workspace/.env
NEVER overwrite the entire
file — it may contain other credentials the user has already configured..env
SECURITY: How to Run Scripts
Scripts auto-load
— NEVER pass credentials inline. Just run:.env
node scripts/coin.mjs coin_ticker '{"coin_list":"bitcoin"}'
NEVER do this — it exposes secrets in conversation logs:
# WRONG! DO NOT DO THIS! AICOIN_ACCESS_KEY_ID=xxx node scripts/coin.mjs coin_ticker '{"coin_list":"bitcoin"}'
Additional security rules:
- NEVER run
,env
, orprintenv
— leaks gateway tokens and API secrets into session logsenv | grep - NEVER use curl to call exchange REST APIs directly (Binance, OKX, etc.) — use
which handles auth, broker tags, and proxyexchange.mjs - NEVER use web_fetch, web_search, or browser for crypto data — always use the scripts in this skill
- NEVER fabricate or guess data from memory — always fetch real-time data via scripts
If a script fails due to missing env vars, guide the user to update their
.env file instead of injecting variables into the command.
Environment Variables
Create a
.env file in the OpenClaw workspace directory (recommended):
# AiCoin API (optional — built-in free key works with IP rate limits) # Mapping: AiCoin website "API Key" → AICOIN_ACCESS_KEY_ID # AiCoin website "API Secret" → AICOIN_ACCESS_SECRET AICOIN_ACCESS_KEY_ID=your-api-key AICOIN_ACCESS_SECRET=your-api-secret # Exchange trading — only if needed (requires: npm install -g ccxt) BINANCE_API_KEY=xxx BINANCE_API_SECRET=xxx # Supported: BINANCE, OKX, BYBIT, BITGET, GATE, HTX, KUCOIN, MEXC, COINBASE # For OKX also set OKX_PASSWORD=xxx # Proxy for exchange access — only if needed # Supports http, https, socks5, socks4 PROXY_URL=socks5://127.0.0.1:7890 # Or standard env vars: HTTPS_PROXY=http://127.0.0.1:7890 # Freqtrade — auto-configured by ft-deploy.mjs, no manual setup needed # FREQTRADE_URL=http://localhost:8080 # FREQTRADE_USERNAME=freqtrader # FREQTRADE_PASSWORD=auto-generated
IMPORTANT — AiCoin API Key Configuration:
-
The user may provide two values without labels (just two strings copied from the AiCoin website). Do NOT guess which is which. Ask the user to confirm: "哪个是 API Key,哪个是 API Secret?" Or look for the labels in the user's message.
-
After writing keys to
, ALWAYS verify by running a test call:.envnode scripts/coin.mjs coin_ticker '{"coin_list":"bitcoin"}' -
If the test returns error code
(signature verification failed), the keys are swapped. Fix by swapping them:1001# Read current values, swap them OLD_KEY=$(grep '^AICOIN_ACCESS_KEY_ID=' ~/.openclaw/workspace/.env | cut -d= -f2) OLD_SECRET=$(grep '^AICOIN_ACCESS_SECRET=' ~/.openclaw/workspace/.env | cut -d= -f2) sed -i '' "s|^AICOIN_ACCESS_KEY_ID=.*|AICOIN_ACCESS_KEY_ID=${OLD_SECRET}|" ~/.openclaw/workspace/.env sed -i '' "s|^AICOIN_ACCESS_SECRET=.*|AICOIN_ACCESS_SECRET=${OLD_KEY}|" ~/.openclaw/workspace/.envThen re-run the test to confirm it works.
Or configure in
~/.openclaw/openclaw.json:
{ "skills": { "entries": { "aicoin": { "enabled": true, "apiKey": "your-aicoin-access-key-id", "env": { "AICOIN_ACCESS_SECRET": "your-secret" } } } } }
Prerequisites
- Node.js — required for all scripts
- ccxt — required only for exchange trading. Run
in the aicoin skill directory to install.npm install
Scripts
All scripts follow:
node scripts/<name>.mjs <action> [json-params]
scripts/coin.mjs — Coin Data
| Action | Description | Params |
|---|---|---|
| List all coins | None |
| Real-time prices | |
| Coin profile | |
| AI analysis & prediction | |
| Funding rate | Weighted: |
| Liquidation heatmap | |
| Liquidation history | |
| Estimated liquidation | |
| Open interest | Coin-margined: add |
| Historical depth | |
| Large order depth (>$10k) | |
| Trade data | |
scripts/market.mjs — Market Data
Market Info
| Action | Description | Params |
|---|---|---|
| Exchange list | None |
| Exchange tickers | |
| Trending coins | key: gamefi/anonymous/market/web/newcoin/stable/defi |
| Futures OI ranking | |
K-Line
| Action | Description | Params |
|---|---|---|
| Standard K-line | period in seconds: 900=15m, 3600=1h, 14400=4h, 86400=1d |
| Indicator K-line | |
| Indicator available pairs | |
Index
| Action | Description | Params |
|---|---|---|
| Index list | None |
| Index price | |
| Index details | |
Crypto Stocks
| Action | Description | Params |
|---|---|---|
| Stock quotes | |
| Top gainers | |
| Company details | |
Treasury (Corporate Holdings)
| Action | Description | Params |
|---|---|---|
| Holding entities | |
| Transaction history | |
| Accumulated holdings | |
| Latest entities | |
| Latest history | |
| Holdings overview | |
Order Book Depth
| Action | Description | Params |
|---|---|---|
| Real-time snapshot | |
| Full order book | |
| Grouped depth | |
scripts/news.mjs — News & Content
| Action | Description | Params |
|---|---|---|
| News list | |
| News detail | |
| RSS news | |
| AiCoin flash news | |
| Industry flash news | |
| Exchange listing announcements | (477=Binance, 1509=Bitget) |
scripts/twitter.mjs — Twitter/X Crypto Tweets
| Action | Description | Params |
|---|---|---|
| Latest crypto tweets (cursor-paginated) | |
| Search tweets by keyword | |
| Search Twitter KOL/users | |
| Tweet engagement stats | (max 50 IDs) |
scripts/newsflash.mjs — Newsflash (OpenData)
| Action | Description | Params |
|---|---|---|
| Search newsflash by keyword | |
| Newsflash list with filters | |
| Newsflash full content | |
scripts/features.mjs — Features & Signals
Market Overview
| Action | Description | Params |
|---|---|---|
| Market navigation | |
| Long/short ratio | None |
| Liquidation data | type: 1=by coin, 2=by exchange |
| Grayscale trust | None |
| Grayscale holdings | |
| Crypto stocks | None |
Whale Order Tracking
| Action | Description | Params |
|---|---|---|
| Large/whale orders | |
| Aggregated large trades | |
Trading Pairs
| Action | Description | Params |
|---|---|---|
| Pair ticker | |
| Pairs by exchange | |
| Pair list | |
Signals
| Action | Description | Params |
|---|---|---|
| Strategy signal | |
| Signal alerts | None |
| Alert config | |
| Alert list | None |
| Anomaly signal | |
| Delete alert | |
scripts/hl-market.mjs — Hyperliquid Market
Tickers
| Action | Description | Params |
|---|---|---|
| All tickers | None |
| Single coin ticker | |
Whales
| Action | Description | Params |
|---|---|---|
| Whale positions | |
| Whale events | |
| Long/short direction | |
| Historical long ratio | |
Liquidations
| Action | Description | Params |
|---|---|---|
| Liquidation history | |
| Liquidation stats | None |
| Stats by coin | |
| Large liquidations | |
Open Interest
| Action | Description | Params |
|---|---|---|
| OI overview | None |
| OI ranking | |
| OI history | |
Taker
| Action | Description | Params |
|---|---|---|
| Taker delta | |
| Taker K-lines | |
scripts/hl-trader.mjs — Hyperliquid Trader
Trader Analytics
| Action | Description | Params |
|---|---|---|
| Trader statistics | |
| Best trades | |
| Performance by coin | |
| Completed trades | |
| Batch accounts | |
| Batch statistics | |
Fills
| Action | Description | Params |
|---|---|---|
| Address fills | |
| By order ID | |
| By TWAP ID | |
| Large trades | |
Orders
| Action | Description | Params |
|---|---|---|
| Latest orders | |
| By order ID | |
| Filled orders | |
| Filled by ID | |
| Large open orders | |
| Active stats | |
| TWAP states | |
Positions
| Action | Description | Params |
|---|---|---|
| Current position history | |
| Closed position history | |
| Current PnL | |
| Closed PnL | |
| Current executions | |
| Closed executions | |
Portfolio
| Action | Description | Params |
|---|---|---|
| Account curve | window: day/week/month/allTime |
| PnL curve | |
| Max drawdown | |
| Net flow | |
Advanced
| Action | Description | Params |
|---|---|---|
| Info API | |
| Smart money discovery | |
| Trader discovery | |
scripts/exchange.mjs — Exchange Trading (CCXT)
⚠️ MANDATORY: All exchange operations MUST go through
.exchange.mjs
- NEVER write custom CCXT/Python code to interact with exchanges. Always use
.node scripts/exchange.mjs <action> '<params>' - NEVER import ccxt directly in custom scripts. The exchange.mjs wrapper handles broker attribution, proxy config, and API key management.
automatically sets AiCoin broker tags for order attribution. Custom CCXT code will NOT have these tags, causing orders to be mis-attributed.exchange.mjs- For automated trading workflows, use
which wrapsauto-trade.mjs
with risk management.exchange.mjs
Requires
npm install ccxt and exchange API keys.
Public (no API key required)
| Action | Description | Params |
|---|---|---|
| Supported exchanges | None |
| Market list | |
| Real-time ticker | |
| Order book | |
| Recent trades | |
| OHLCV candles | |
Account (API key required)
| Action | Description | Params |
|---|---|---|
| Account balance | |
| Open positions | |
| Open orders | |
Trading (API key required)
🚨 SAFETY RULES — MANDATORY for ALL trading operations:
- NEVER execute a buy/sell/trade without explicit user confirmation.
returns a preview by default. Show the preview to the user, wait for them to say "确认" / "yes" / "go ahead", THEN re-run withcreate_order
. Do NOT add confirmed=true on the first call."confirmed":"true" - NEVER sell or close the user's existing positions unless the user specifically asks to sell/close.
- NEVER write custom CCXT, Python, or curl code to interact with exchanges. ALL exchange operations MUST go through
.exchange.mjs - NEVER auto-adjust order parameters (size, leverage, etc.) without asking the user first. If balance is insufficient, tell the user and let them decide.
- ALWAYS verify order details before confirmation: Show coin, direction (buy/sell/long/short), quantity, estimated cost, and ask "确认下单?"
⚠️ CRITICAL —
units differ between spot and futures:amount
- Spot:
is in base currency (e.g.,amount
= 0.01 BTC)amount: 0.01 - Futures/Swap:
is in contracts (e.g.,amount
= 1 contract). Getamount: 1
fromcontractSize
to convert.markets
User intent →
conversion (you MUST get this right):amount
| User says | Spot | Swap (OKX BTC, contractSize=0.01) |
|---|---|---|
| "0.01 BTC" / "0.01个BTC" | | (1 contract) |
| "1张合约" / "1 contract" | N/A | (直接用) |
| "0.01张" | N/A | (0.01 contract = 0.0001 BTC) |
| "100U" / "100 USDT" | | |
NEVER pass the user's number directly as
without checking the unit context!amount
Before placing any order, you MUST:
- Run
to get the trading pair'smarkets
(minimum order size) andlimits.amount.min
— do NOT guess or assume minimumscontractSize - Run
to check available fundsbalance - Convert user's quantity to the correct unit using the table above
- For futures/swap: calculate actual buying power = balance × leverage
- Verify: buying power ≥ order value
- Confirm with user: "You want to buy X contracts (= Y BTC ≈ Z USDT), correct?" before placing the order
- Show clear summary: Coin, Direction, Quantity, Est. Cost, Leverage (if applicable)
Example pre-trade check for BTC/USDT perpetual on OKX:
# Step 1: Check minimum order size AND contract size node scripts/exchange.mjs markets '{"exchange":"okx","market_type":"swap","base":"BTC"}' # → look for limits.amount.min (e.g. 1 contract) and contractSize (e.g. 0.01 BTC) # → This means: 1 contract = 0.01 BTC, min order = 1 contract = 0.01 BTC # Step 2: Check balance node scripts/exchange.mjs balance '{"exchange":"okx"}' # → e.g. 7 USDT free # Step 3: Calculate — 7 USDT × 10x = 70 USDT ÷ $68000 ≈ 0.001 BTC ÷ 0.01 = 0.1 contracts → below min 1 contract → cannot trade # With more capital: 100 USDT × 10x = 1000 ÷ $68000 ≈ 0.0147 BTC ÷ 0.01 = 1.47 → round to 1 contract → OK
| Action | Description | Params |
|---|---|---|
| Place order | Spot: (amount in BTC). Swap: (amount in contracts) |
| Cancel order | |
| Set leverage | |
| Margin mode | |
| Transfer funds | |
Notes on
:transfer
- OKX unified account (重要): OKX uses a unified trading account — spot and derivatives share the SAME balance. Do NOT ask the user to transfer funds between accounts. If transfer returns error 58123, tell the user: "你的 OKX 是统一账户,现货和合约共用同一个余额,不需要划转。" Do NOT suggest manual transfer in the app.
- Binance: Requires explicit transfer between spot/futures accounts.
scripts/ft.mjs — Freqtrade Bot Control
| Action | Description | Params |
|---|---|---|
| Health check | None |
| Start trading | None |
| Stop trading | None |
| Reload config | None |
| View config | None |
| Version info | None |
| System info | None |
| Health status | None |
| View logs | |
| Account balance | None |
| Open trades | None |
| Trade count | None |
| Trade by ID | |
| Trade history | |
| Manual entry | |
| Manual exit | |
| Cancel order | |
| Delete record | |
| Profit summary | None |
| Profit per pair | None |
| Daily report | |
| Weekly report | |
| Monthly report | |
| Statistics | None |
scripts/ft-dev.mjs — Freqtrade Dev Tools
| Action | Description | Params |
|---|---|---|
| Start backtest | |
| Backtest status | None |
| Abort backtest | None |
| Backtest history | None |
| History result | |
| Live candles | |
| Candles with indicators | |
| Available pairs | None |
| Whitelist | None |
| Blacklist | None |
| Add to blacklist | |
| Trade locks | None |
| Strategy list | None |
| Strategy detail | |
scripts/auto-trade.mjs — Automated Trading
Config + execution helper. The AI agent makes all strategy decisions — this script only handles config, risk management, and order execution.
Config is stored at
~/.openclaw/workspace/aicoin-trade-config.json.
| Action | Description | Params |
|---|---|---|
| Save trading config | |
| Show config + balance + positions + open orders | |
| Open a position (agent decides direction) | or |
| Close current position + cancel orders | |
The
open action automatically:
- Checks balance and market minimums
- Calculates position size from config (capital_pct × balance × leverage)
- Sets leverage
- Places market order
- Places stop-loss and take-profit limit orders
scripts/ft-deploy.mjs — Freqtrade Deployment
🚨 CRITICAL: For ALL Freqtrade operations (deploy, backtest, update), ALWAYS use ft-deploy.mjs. NEVER manually run freqtrade commands, NEVER write custom Python scripts, NEVER use Docker.
One-click Freqtrade deployment via
+ official git clone
(no Docker). Clones the Freqtrade repo, runs setup.sh
setup.sh -i to install all dependencies (including TA-Lib), generates config from .env exchange keys, starts as background process, auto-writes FREQTRADE_* vars to .env.
| Action | Description | Params |
|---|---|---|
| Check prerequisites (Python 3.11+, git, exchange keys) | None |
| Deploy Freqtrade (clone, setup.sh, config, start) | |
| Run backtest (no running process needed) | |
| Update Freqtrade to latest version | None |
| Process status | None |
| Start stopped process | None |
| Stop process | None |
| View process logs | |
| Remove process (preserves config) | None |
Deploy defaults to dry-run mode (simulated trading, no real money). Pass
{"dry_run":false} for live trading.
IMPORTANT: NEVER use Docker for Freqtrade. The deploy script uses
git clone + setup.sh -i (official Freqtrade installation method). Do NOT fall back to Docker, do NOT write custom install scripts, do NOT try pip install freqtrade directly. Just run node scripts/ft-deploy.mjs deploy — it handles everything.
IMPORTANT: Do NOT manually edit Freqtrade config files, do NOT manually run
commands, do NOT manually freqtrade trade
. Always use source .venv/bin/activate
ft-deploy.mjs actions. If deploy fails, check logs with ft-deploy.mjs logs and report the error — do NOT attempt manual workarounds.
Automated Trading Guide
When the user asks to set up automated trading, follow this workflow. Do NOT write custom scripts.
How It Works
The AI agent is the strategist. On each cycle:
- Fetch data using existing scripts:
(funding, OI, liquidation),coin.mjs
(klines, volume),market.mjs
(whale orders, long/short ratio),features.mjs
(Hyperliquid data)hl-market.mjs - Analyze the data — trend, momentum, risk signals. Use your own judgment.
- Decide: open long, open short, close position, or hold
- Execute via
— handles position sizing, leverage, stop-loss/take-profit automaticallyauto-trade.mjs open '{"direction":"long"}'
Quick Setup
# 1. Configure risk params node scripts/auto-trade.mjs setup '{"exchange":"okx","symbol":"BTC/USDT:USDT","leverage":10,"capital_pct":0.5}' # 2. Check status node scripts/auto-trade.mjs status
OpenClaw Cron (Recommended)
Use OpenClaw's built-in cron, NOT system crontab. This gives the user visibility in the web UI.
openclaw cron add \ --name "BTC auto trade" \ --every 10m \ --session isolated \ --message "You are a crypto trader. Use the aicoin skill to: 1) Fetch BTC market data (price, funding rate, OI, whale orders, liquidation). 2) Analyze the data and decide: open long, open short, close, or hold. 3) If trading, run: node scripts/auto-trade.mjs open '{\"direction\":\"long\"}'. 4) Report your analysis briefly."
When User Asks "帮我自动交易"
- Ask: which exchange? which coin? how much capital? what leverage?
- Run
with their paramsauto-trade.mjs setup - Run
to verify exchange connectionauto-trade.mjs status - Set up OpenClaw cron with their preferred interval
- Done — tell them they can check status anytime via
auto-trade.mjs status
Freqtrade Guide
🚨 CRITICAL: When user asks to deploy/setup Freqtrade, ALWAYS use
. NEVER manually configure, NEVER use Docker, NEVER write custom scripts.ft-deploy.mjs
When the user asks about backtesting, professional strategies, quantitative trading, or deploying a trading bot, guide them to Freqtrade.
Freqtrade vs auto-trade.mjs:
- auto-trade.mjs = simple AI-driven, good for testing, small capital
- Freqtrade = professional, backtestable, risk-managed, production-grade
Deployment (One Command)
# Check prerequisites first node scripts/ft-deploy.mjs check # Deploy (dry-run mode by default — safe) node scripts/ft-deploy.mjs deploy '{"pairs":["BTC/USDT:USDT","ETH/USDT:USDT"]}'
This automatically:
- Ensures Python 3.11+ is available (auto-installs via brew if needed on macOS)
- Clones Freqtrade repo to
~/.freqtrade/source/ - Runs official
(installs TA-Lib, creates venv, installs all dependencies)setup.sh -i - Creates config from exchange keys in
.env - Includes a sample RSI+EMA strategy (pure pandas, no TA-Lib import needed)
- Starts Freqtrade as a background process with API server
- Writes
,FREQTRADE_URL
,FREQTRADE_USERNAME
toFREQTRADE_PASSWORD.env - Ready to use via
andft.mjsft-dev.mjs
Prerequisites: Python 3.11+ and git. Exchange API keys must be in
.env. Everything else is auto-installed — do NOT install manually or use Docker.
User Journey
"帮我部署Freqtrade" → node scripts/ft-deploy.mjs deploy → "已部署,dry-run模式,用模拟资金运行" "帮我回测BTC策略" → node scripts/ft-deploy.mjs backtest '{"strategy":"SampleStrategy","timeframe":"1h","timerange":"20250101-20260301"}' → "回测结果: 胜率62%, 最大回撤-8%, 总收益+45%" "不错,上实盘" → node scripts/ft-deploy.mjs deploy '{"dry_run":false}' → "⚠️ 已切换到实盘模式,使用真实资金" "今天赚了多少?" → node scripts/ft.mjs profit → node scripts/ft.mjs daily '{"count":7}' "暂停交易" → node scripts/ft.mjs stop
When User Mentions These Keywords → Use Freqtrade
- 回测 / backtest → MUST use
(does NOT require Freqtrade to be running). NEVER write custom Python backtest scripts, NEVER manually run freqtrade commands.ft-deploy.mjs backtest - 写策略 / write strategy → Write a
file to.py
, then~/.freqtrade/user_data/strategies/ft-deploy.mjs backtest - 量化策略 / strategy →
(requires running process)ft-dev.mjs strategy_list - 部署机器人 / deploy bot →
ft-deploy.mjs deploy - 实盘 / live trading →
ft-deploy.mjs deploy '{"dry_run":false}' - 盈亏 / profit →
ft.mjs profit - 停止机器人 / stop bot →
orft.mjs stopft-deploy.mjs stop
IMPORTANT: For backtesting, use
. Do NOT write custom Python backtest scripts. The Freqtrade backtester is production-grade with proper slippage, fees, and position sizing simulation.ft-deploy.mjs backtest
Troubleshooting
If deployment fails:
- Check Python version:
(need 3.11+)python3 --version - Check logs:
node scripts/ft-deploy.mjs logs - Verify exchange keys in
~/.openclaw/workspace/.env - DO NOT try manual fixes - report error and let ft-deploy.mjs handle it
If backtest fails:
- Verify strategy file exists in
~/.freqtrade/user_data/strategies/ - Check timerange format:
(e.g.,YYYYMMDD-YYYYMMDD
)20250101-20260301 - Ensure data is downloaded (ft-deploy.mjs auto-downloads on first backtest)