[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76YX61JMXND97ABW99SYP96":3,"skill-same:01M76YX61JMXND97ABW99SYP96":55},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":37,"ownerHtmlUrl":38,"ownerBlogUrl":6,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M76YX61JMXND97ABW99SYP96","aicoin-freqtrade",null,"Use when user asks about Freqtrade — strategy creation, backtest, hyperopt, switching strategies \u002F pairs \u002F dry-run mode, querying live bot status \u002F balance \u002F open positions \u002F 盈亏. Trigger words: 'write strategy', 'create strategy', 'backtest', 'switch strategy', 'switch to live', 'open positions', 'P&L', '写策略', '创建策略', '回测', '部署策略', '切策略', '切实盘', '当前持仓', '今天赚多少', '盈亏'. In CoinClaw containers (OpenClaw \u002F Hermes \u002F Claude Code) freqtrade is a supervisord-managed daemon on :8080 — this skill auto-detects engine + paths via lib\u002Fcoinclaw-env.mjs and never spawns competing freqtrade processes. Outside CoinClaw it falls back to host mode (clone freqtrade + nohup). For prices\u002Fcharts use aicoin-market. For exchange trading use aicoin-trading. For Hyperliquid use aicoin-hyperliquid.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fa\u002Faicoin-freqtrade\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: aicoin-freqtrade\ndescription: \"Use when user asks about Freqtrade — strategy creation, backtest, hyperopt, switching strategies \u002F pairs \u002F dry-run mode, querying live bot status \u002F balance \u002F open positions \u002F 盈亏. Trigger words: 'write strategy', 'create strategy', 'backtest', 'switch strategy', 'switch to live', 'open positions', 'P&L', '写策略', '创建策略', '回测', '部署策略', '切策略', '切实盘', '当前持仓', '今天赚多少', '盈亏'. In CoinClaw containers (OpenClaw \u002F Hermes \u002F Claude Code) freqtrade is a supervisord-managed daemon on :8080 — this skill auto-detects engine + paths via lib\u002Fcoinclaw-env.mjs and never spawns competing freqtrade processes. Outside CoinClaw it falls back to host mode (clone freqtrade + nohup). For prices\u002Fcharts use aicoin-market. For exchange trading use aicoin-trading. For Hyperliquid use aicoin-hyperliquid.\"\nmetadata: { \"openclaw\": { \"primaryEnv\": \"AICOIN_ACCESS_KEY_ID\", \"requires\": { \"bins\": [\"node\"] }, \"homepage\": \"https:\u002F\u002Fwww.aicoin.com\u002Fopendata\", \"source\": \"https:\u002F\u002Fgithub.com\u002Faicoincom\u002Fcoinos-skills\", \"license\": \"MIT\" } }\n---\n\n# AiCoin Freqtrade\n\nFreqtrade 策略 \u002F 回测 \u002F 部署 \u002F 实时控制 — 跨 CoinClaw 三引擎自动适配。\n\n## 关键原则(读完再动手)\n\n### 一、CoinClaw 容器里 freqtrade 是常驻 daemon\n\nOpenClaw \u002F Hermes \u002F Claude Code 三个引擎容器都通过 supervisord 把 freqtrade 起为常驻进程, 监听 `127.0.0.1:8080`, 默认跑 `NoOpStrategy`(空跑). **不要自己起 freqtrade 进程** — 会跟 daemon 抢端口, dashboard 立刻 offline.\n\n正确流程是: 写策略文件 → 调 `ft-deploy.mjs deploy {\"strategy\":\"...\"}` → 脚本改 config + 重启 daemon. dashboard 会自动刷出新策略.\n\n`scripts\u002Fft.mjs` + `scripts\u002Fft-deploy.mjs` 内置三引擎自动识别(`lib\u002Fcoinclaw-env.mjs`), 路径 \u002F auth \u002F supervisord socket 都自动解析, **agent 不用关心是哪个引擎**.\n\n### 二、永远先调 freqtrade REST API, 不要\"自己计算\"\n\n| 用户问 | 必须先调 |\n|---|---|\n| 现在赚多少 \u002F 总盈亏 \u002F 今天涨了多少 | `ft.mjs profit` (`\u002Fapi\u002Fv1\u002Fprofit`) |\n| 持仓 \u002F 现在开了哪些 | `ft.mjs trades_open` (`\u002Fapi\u002Fv1\u002Fstatus`) |\n| 余额 \u002F 资金多少 | `ft.mjs balance` (`\u002Fapi\u002Fv1\u002Fbalance`) |\n| 跑的什么策略 \u002F 当前模式 | `ft.mjs daemon_info` 或 `config` |\n| 历史交易 \u002F 已平仓 | `ft.mjs trades_history` |\n| 单交易对绩效 | `ft.mjs profit_per_pair` |\n\n**dashboard 数字对齐规则(关键)**: 用户问\"赚了多少\"必须报告**两个数字**:\n- **已平仓累计盈亏** = `profit_closed_coin` (USDT) — **dashboard 顶栏的累计盈亏 = 这个**\n- **含浮动总盈亏** = `profit_all_coin` (USDT) — 已平仓 + 当前持仓的浮动盈亏\n\n只调 `\u002Fstatus` 拿持仓浮动盈亏会漏掉已平仓部分, 导致跟 dashboard 数字不一致 — 用户立刻发现, 信任度归零.\n\n### 三、切策略 \u002F 切实盘 \u002F 切交易对必须走脚本\n\nconfig.json 是 daemon 启动时读一次, 手动改完不会自动生效. 必须用:\n\n| 操作 | 命令 | 是否需要 daemon 重启 |\n|---|---|---|\n| 切策略 | `ft.mjs set_strategy {\"strategy\":\"X\"}` | 必须重启 (~30s) |\n| 切交易对 | `ft.mjs set_pairs {\"pairs\":[...]}` | 不重启, `reload_config` 即可 |\n| 切实盘\u002F模拟 | `ft.mjs set_dry_run {\"dry_run\":false}` | 必须重启 |\n| reload 配置 | `ft.mjs reload` | 不重启 |\n\n或者一次完成所有变更: `ft-deploy.mjs deploy {\"strategy\":\"X\",\"pairs\":[\"BTC\u002FUSDT:USDT\"],\"dry_run\":false}`.\n\n**任何直接修改 config.json 的操作(包括手动编辑 pair_whitelist \u002F minimal_roi \u002F stoploss 等), 改完后必须立即调 `ft.mjs reload`** — 否则 daemon 仍用内存里的旧配置运行, 白名单\u002F止损等改动不会生效. 忘了 reload 是最常见的\"改了但没用\"的原因.\n\n**chat 主动发起的高 stake 操作必须强 confirm**(违反即错):\n\n适用: 用户在 chat 里说\"平掉\"、\"切实盘\"、\"卖了\"、\"开仓\"等 — 通过 agent 调用 `force_exit` \u002F `force_enter` \u002F `set_dry_run` 的操作.\n\n流程:\n1. **先列预览**: 动哪个 trade \u002F pair \u002F 当前盈亏 \u002F 估算损益 \u002F dry_run vs live \u002F 余额状况\n2. **明确等用户输\"确认\"或\"yes\"** 才真调 `force_exit` \u002F `set_dry_run` \u002F `force_enter`\n3. 即使用户语气笃定(\"平了\",\"直接切\"), 也必须先预览等确认\n\n**不需要 confirm 的**:\n- 查询类(查持仓 \u002F 盈亏 \u002F 状态) — 直接读\n- **freqtrade daemon 自己根据策略信号自动开\u002F平仓** — 这是 daemon 本职工作, 用户切实盘那一刻就授权了, agent 不在这个链路里, 不要拦也不需要 confirm\n- 非破坏性配置(`set_pairs` 加币对、`reload`) — 列改动表然后直接执行\n\n**违反规则的反例**:\n- ❌ 用户说\"平掉\", 你直接调 `force_exit` 平了真持仓 (K-Live-3 dogfood 抓到的真 bug)\n- ❌ 用户说\"切实盘\", 你不列 .env key \u002F 余额 \u002F 风险就直接 `set_dry_run {\"dry_run\":false}`\n- ✅ 用户说\"平掉\", 你列\"持仓: BNB\u002FUSDT 0.05 +$1.07, 平这单吗? dry_run=true 模拟盘\", 等用户确认\n\n**写策略 + 切策略 倾向分两轮**(create_strategy 一轮, set_strategy 一轮). 不是技术限制,是 UX 选择:\n1. 第一轮: 写完策略文件 → 告诉用户\"已生成 X.py, 要切上去吗?\"\n2. 用户确认后第二轮: `set_strategy` 切策略 + 重启 daemon (~30s)\n\n这样用户切策略前能 review 生成文件; daemon 重启 30s 期间用户对状态有预期, 不会误判 chat 卡死. 用户明确说\"一气呵成做完\"也可以单 turn 跑完两步, 但默认分轮.\n\n### 四、Freqtrade 不支持网格策略 (grid)\n\n用户问网格时直接说明限制 + 建议趋势跟踪 \u002F 区间策略 \u002F 网格回报模拟器替代. 不要硬写一个伪网格.\n\n## 快速参考\n\n| 任务 | 命令 |\n|------|------|\n| 看 daemon 状态 + 配置 | `node scripts\u002Fft-deploy.mjs check` 或 `ft.mjs daemon_info` |\n| 看策略列表 | `node scripts\u002Fft-deploy.mjs strategy_list` |\n| 创建策略(快速生成器) | `node scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"MyStrat\",\"timeframe\":\"15m\",\"indicators\":[\"rsi\",\"macd\",\"ema\"],\"aicoin_data\":[\"funding_rate\"]}'` |\n| 部署策略到 daemon | `node scripts\u002Fft-deploy.mjs deploy '{\"strategy\":\"MyStrat\"}'` |\n| 部署+切实盘 | `node scripts\u002Fft-deploy.mjs deploy '{\"strategy\":\"MyStrat\",\"dry_run\":false}'` |\n| 回测 | `node scripts\u002Fft-deploy.mjs backtest '{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"timerange\":\"20250101-20260301\"}'` |\n| Hyperopt 调参 | `node scripts\u002Fft-deploy.mjs hyperopt '{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"epochs\":100}'` |\n| 看盈亏 | `node scripts\u002Fft.mjs profit` |\n| 看持仓 | `node scripts\u002Fft.mjs trades_open` |\n| 看余额 | `node scripts\u002Fft.mjs balance` |\n| 切交易对 | `node scripts\u002Fft.mjs set_pairs '{\"pairs\":[\"BTC\u002FUSDT:USDT\",\"ETH\u002FUSDT:USDT\"]}'` |\n| 重启 daemon | `node scripts\u002Fft.mjs restart` |\n| 看日志 | `node scripts\u002Fft-deploy.mjs logs '{\"lines\":100}'` |\n\n## 创建策略：先判断走哪条路\n\n**判断规则**：\n- 用户只给了笼统描述（\"RSI 策略\"、\"均线交叉\"、\"布林带回归\"）且没指定具体参数细节 → **A. 快速生成器**\n- 用户给了具体逻辑（自定义入场\u002F出场条件、跨周期共振、多币种轮动、复合指标、自定义仓位管理）→ **B. 直接写 Python**\n- 用 A 生成后用户要改细节 → 直接编辑生成的 .py 文件，不要重新 create_strategy 覆盖\n\n### A. 快速生成器(简单策略)\n\n`create_strategy` 一条命令生成一个可跑的策略文件。适合\"先跑起来再调\"的场景：\n\n```bash\nnode scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"MACDStrategy\",\"timeframe\":\"15m\",\"indicators\":[\"macd\",\"rsi\",\"atr\"]}'\nnode scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"RSILong\",\"timeframe\":\"1h\",\"indicators\":[\"rsi\"],\"direction\":\"long\"}'\nnode scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"WhaleStrat\",\"timeframe\":\"15m\",\"indicators\":[\"rsi\",\"macd\"],\"aicoin_data\":[\"funding_rate\",\"ls_ratio\"]}'\n```\n\n可选 `indicators`: `rsi`, `bb`, `ema`, `sma`, `macd`, `stochastic`\u002F`kdj`, `atr`, `adx`, `cci`, `williams_r`, `vwap`, `ichimoku`, `volume_sma`, `obv`.\n\n可选 `direction`: `\"long\"` (默认,只做多) | `\"short\"` (只做空) | `\"both\"` (双向)。\n**用户说\"RSI\u003C30 买入, RSI>70 卖出\"→ direction=\"long\"**(RSI>70 = 平多, 不是开空)。只有用户明确说\"做空 \u002F 双向 \u002F 多空都做\"时才用 `\"both\"` 或 `\"short\"`。\n\n可选 `aicoin_data`: `funding_rate`、`ls_ratio`、`big_orders`、`liquidation_map`（都需付费套餐），`open_interest`（v3 聚合 OI 历史暂未接通，会自动降级到默认值）。\n\n**生成器的局限**：只能组合预设指标，不支持跨周期、多币种轮动、自定义复合指标。遇到这些需求直接走 B。\n\n### B. 自定义 Python 策略 (复杂逻辑)\n\n直接写 `.py` 文件到 daemon 的 strategy 目录。用这条路可以实现任何 freqtrade 支持的策略逻辑（跨周期 informative pairs、自定义仓位管理、多指标复合条件等）。\n\n三引擎该目录不同, **从 `daemon_info` 拿**或用 `Write` 工具写到下面任一路径(脚本会自动用 `\u002Fapi\u002Fv1\u002Fshow_config` 验证):\n\n| 引擎 | strategy 目录 |\n|---|---|\n| OpenClaw | `~\u002F.openclaw\u002Fworkspace\u002Fstrategies\u002F` |\n| Hermes | `\u002Fworkspace\u002Fstrategies\u002F` |\n| Claude Code | `\u002Fworkspace\u002Fstrategies\u002F` |\n\n用 AiCoin Python SDK (`aicoin_data.py`, image build 时已复制到上面目录, 也由 `create_strategy` 兜底拷贝):\n\n它封装了 AiCoin Open API v3：\n\n```python\nfrom aicoin_data import AiCoinData\n\nac = AiCoinData(cache_ttl=300)   # 自动从 .env 读 key，内置 5 分钟缓存\n\n# 高层信号 —— 直接返回能用的数字，丢进策略即可\nac.whale_signal(\"BTC\u002FUSDT:USDT\", \"binance\")        # 大单买卖压力 -1..+1\nac.ls_ratio_norm()                                 # 多空比 0..1（>0.5 偏多）\nac.funding_rate_pct(\"BTC\u002FUSDT:USDT\", \"binance\")    # 最新资金费率（百分比）\nac.liq_bias(\"BTC\u002FUSDT:USDT\", \"binance\")            # 清算图方向偏向 -1..+1\n\n# 原始数据\nac.coin_ticker(\"bitcoin,ethereum\")                 # 实时行情\nac.klines(\"BTC\u002FUSDT\", \"binance\", interval=\"1h\", limit=100)\n\n# 任意 v3 接口 —— path 是 \u002Fapi\u002Fv3\u002F 后那段，清单见 https:\u002F\u002Fopen.aicoin.com\u002Fapi\u002Fv3\u002F_catalog\nac.get(\"markets\u002Fhot-coins\", {\"tab_key\": \"defi\"})\nac.get(\"hyperliquid\u002Fwhales\u002Fopen-positions\", {\"coin\": \"BTC\"})\n```\n\n回测期 AiCoin 实时数据不可用，高层信号会抛异常 —— 策略里要 `try\u002Fexcept` 兜底用默认值。资金费率、大单、清算等需要付费套餐，没权限同样抛异常（一样兜底）。\n\n#### 完整模板\n\n```python\nfrom freqtrade.strategy import IStrategy, IntParameter, DecimalParameter\nfrom pandas import DataFrame\nimport logging, time\n\nlogger = logging.getLogger(__name__)\n\n\nclass MyStrategy(IStrategy):\n    INTERFACE_VERSION = 3\n    timeframe = '15m'\n    can_short = True\n\n    minimal_roi = {\"0\": 0.05, \"60\": 0.03, \"120\": 0.01}\n    stoploss = -0.05\n    trailing_stop = True\n    trailing_stop_positive = 0.02\n    trailing_stop_positive_offset = 0.03\n\n    rsi_buy = IntParameter(20, 40, default=30, space='buy')\n    rsi_sell = IntParameter(60, 80, default=70, space='sell')\n\n    _ac_funding_rate = 0.0\n    _ac_last_update = 0.0\n\n    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:\n        # RSI\n        delta = dataframe['close'].diff()\n        gain = delta.clip(lower=0).rolling(window=14).mean()\n        loss = (-delta.clip(upper=0)).rolling(window=14).mean()\n        rs = gain \u002F loss\n        dataframe['rsi'] = 100 - (100 \u002F (1 + rs))\n\n        # AiCoin 数据 (live\u002Fdry_run only, backtest 用默认值 0.0)\n        dataframe['funding_rate'] = 0.0\n        if self.dp and self.dp.runmode.value in ('live', 'dry_run'):\n            now = time.time()\n            if now - self._ac_last_update > 300:\n                self._update_aicoin_data(metadata)\n                self._ac_last_update = now\n            dataframe.iloc[-1, dataframe.columns.get_loc('funding_rate')] = self._ac_funding_rate\n\n        return dataframe\n\n    def _update_aicoin_data(self, metadata: dict):\n        try:\n            import sys, os\n            _sd = os.path.dirname(os.path.abspath(__file__))\n            if _sd not in sys.path:\n                sys.path.insert(0, _sd)\n            from aicoin_data import AiCoinData\n            ac = AiCoinData(cache_ttl=300)\n            pair = metadata.get('pair', 'BTC\u002FUSDT:USDT')\n            exchange = self.config.get('exchange', {}).get('name', 'binance')\n            self._ac_funding_rate = ac.funding_rate_pct(pair, exchange)\n        except Exception as e:\n            logger.warning(f\"AiCoin data error: {e}\")\n\n    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:\n        dataframe.loc[\n            (dataframe['rsi'] \u003C self.rsi_buy.value) &\n            (dataframe['volume'] > 0),\n            'enter_long'] = 1\n        dataframe.loc[\n            (dataframe['rsi'] > self.rsi_sell.value) &\n            (dataframe['volume'] > 0),\n            'enter_short'] = 1\n        return dataframe\n\n    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:\n        dataframe.loc[(dataframe['rsi'] > 70), 'exit_long'] = 1\n        dataframe.loc[(dataframe['rsi'] \u003C 30), 'exit_short'] = 1\n        return dataframe\n```\n\n写完后用 `deploy {\"strategy\":\"MyStrategy\"}` 让 daemon 切到这个策略.\n\n### AiCoin 数据集成模式\n\n| AiCoin 数据 | 信号逻辑 | 套餐 |\n|---|---|---|\n| `funding_rate` | 大于 0.01% → 多头过度 → 空信号; 小于 -0.01% → 多信号 | 基础版 |\n| `ls_ratio` | 小于 0.45 (空头多) → 反向做多; 大于 0.55 → 反向做空 | 基础版 |\n| `big_orders` | `(buy_vol-sell_vol)\u002Ftotal > 0.3` → 鲸鱼买入做多 | 标准版 |\n| `open_interest` | OI 涨 + 价涨 = 健康趋势; OI 涨 + 价跌 = 反转 | 专业版 |\n| `liquidation_map` | 上方爆仓多 → 多头挤压 → 做多 | 高级版 |\n\n### 回测注意事项\n\nAiCoin 实时数据**不在历史区间内可用**. 回测时:\n\n- AiCoin 列用默认值 (`funding_rate=0.0`, `ls_ratio=0.5`, `whale_signal=0.0`)\n- 回测结果只反映**技术指标**部分\n- live\u002Fdry_run 跑的时候才用真实 AiCoin 数据, 表现应该比回测好\n\n向用户报告回测结果时必须主动说明这点, 不要让用户以为回测包含了 AiCoin 信号.\n\n## 脚本 API\n\n### `scripts\u002Fft-deploy.mjs` — 策略 \u002F 回测 \u002F 部署\n\n| Action | 参数示例 |\n|---|---|\n| `check` | (无) — 返回 daemon 状态 + 配置 + 余额 |\n| `daemon_info`(在 ft.mjs) | (无) — 单调用拿全 |\n| `deploy` | `{\"strategy\":\"MyStrat\"}` 或 `{\"strategy\":\"MyStrat\",\"dry_run\":false,\"pairs\":[\"BTC\u002FUSDT:USDT\"]}` |\n| `create_strategy` | `{\"name\":\"MyStrat\",\"timeframe\":\"15m\",\"indicators\":[\"rsi\",\"macd\"],\"direction\":\"long\",\"aicoin_data\":[\"funding_rate\"]}` |\n| `backtest` | `{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"timerange\":\"20250101-20260301\",\"pairs\":[\"ETH\u002FUSDT:USDT\"]}` |\n| `hyperopt` | `{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"epochs\":100}` |\n| `download_data` | `{\"timeframe\":\"1h\",\"timerange\":\"20250101-\"}` |\n| `strategy_list` | (无) |\n| `backtest_results` | (无) — 列最近 10 个回测结果文件名 |\n| `start` \u002F `stop` | (无) — coinclaw 模式调 supervisorctl, host 模式管 PID |\n| `status` \u002F `logs` | `{\"lines\":100}` |\n| `update` \u002F `remove` | coinclaw 模式 no-op (提示用 helm upgrade \u002F web UI 删 instance) |\n\n### `scripts\u002Fft.mjs` — 实时控制 (REST + 配置变更)\n\n| Action | 用途 |\n|---|---|\n| `daemon_info` | 一次拿 strategy \u002F mode \u002F pairs \u002F open trades 数量 |\n| `profit` | 已平仓累计 + 含浮动总盈亏 (回答盈亏类问题必须先调) |\n| `trades_open` | 当前持仓 (调 \u002Fstatus) |\n| `trades_history` | 已平仓交易 |\n| `balance` | 余额 |\n| `profit_per_pair` | 每交易对绩效 |\n| `daily` \u002F `weekly` \u002F `monthly` | 时间维度统计 |\n| `force_enter` \u002F `force_exit` | 手动开\u002F平仓 |\n| `set_strategy` | 切策略 (改 config + 重启 daemon) |\n| `set_pairs` | 改交易对白名单 (reload, 不重启) |\n| `set_dry_run` | 切实盘\u002F模拟 (改 config + 重启 daemon) |\n| `restart` | 重启 freqtrade daemon (supervisorctl + kill 兜底) |\n| `reload` | reload_config 而不重启 |\n| `start` \u002F `stop` \u002F `ping` \u002F `version` \u002F `health` | 标准 REST |\n| `logs` | freqtrade 自带 \u002Flogs 接口 |\n\n### `scripts\u002Fft-dev.mjs` — 调试 (回测 \u002F 蜡烛 \u002F 策略详情)\n\n`backtest_start` \u002F `backtest_status` \u002F `backtest_history` \u002F `candles_live` \u002F `candles_analyzed` \u002F `strategy_list` \u002F `strategy_get` \u002F `whitelist` \u002F `blacklist` 等.\n\n## 环境变量与认证\n\n`.env` 自动加载顺序:\n\n- coinclaw 容器内: `\u002Fworkspace\u002F.env` (Hermes\u002FCC) 或 `\u002Fhome\u002Fnode\u002F.openclaw\u002Fworkspace\u002F.env` (OpenClaw)\n- host 模式: cwd → `~\u002F.openclaw\u002Fworkspace\u002F.env` → `~\u002F.openclaw\u002F.env`\n\nfreqtrade REST 认证: `freqtrade-api.mjs` 自动从容器内 `.ft_api_pass` 文件读密码, **agent 不用配 FREQTRADE_USERNAME \u002F FREQTRADE_PASSWORD**. 用户也可以通过 `.env` 覆盖.\n\n交易所 key 在 web UI 的 EnvSection 里配置, 写到 .env 后 entrypoint 会自动 patch 进 freqtrade `config.json`. **agent 不要直接读 .env 给用户看交易所 key**.\n\nAiCoin Open API key (用于策略集成 AiCoin 数据):\n```\nAICOIN_ACCESS_KEY_ID=your-key-id\nAICOIN_ACCESS_SECRET=your-secret\n```\n\n## 付费功能引导\n\n返回 304 \u002F 403 时 **不要重试**, 直接告诉用户:\n\n| 套餐 | 价格 | 用途 |\n|---|---|---|\n| 免费版 | $0 | 纯技术指标 |\n| 基础版 | $29\u002Fmo | + `funding_rate`, `ls_ratio` |\n| 标准版 | $79\u002Fmo | + `big_orders`, `agg_trades` |\n| 高级版 | $299\u002Fmo | + `liquidation_map` |\n| 专业版 | $699\u002Fmo | + `open_interest`, `ai_analysis` |\n\n获取地址: https:\u002F\u002Fwww.aicoin.com\u002Fopendata\n\n## 跨 skill 引用\n\n| 用户问 | 用 |\n|---|---|\n| 单纯查行情 \u002F K 线 \u002F 新闻 \u002F 资金费率 (不开仓) | **aicoin-market** |\n| 直接下单 \u002F 开仓 \u002F 平仓 (不通过 freqtrade) | **aicoin-trading** |\n| Hyperliquid 鲸鱼 \u002F 持仓 \u002F 清算 | **aicoin-hyperliquid** |\n| 链上 DEX swap \u002F 钱包余额 \u002F gas | **aicoin-onchain** |\n| 余额 \u002F 持仓 \u002F 注册 \u002F API key 配置 (账户类) | **aicoin-account** |\n\n## 常见 pitfall\n\n- **不要 `cat \u002Fworkspace\u002F.ft_api_pass`** 把内部 daemon 密码贴到 chat — 直接用 `ft.mjs` 调 REST, 脚本内部读密码不会泄漏.\n- **不要在 chat 里 echo 用户的交易所 key** — 这些是高敏数据, 引导用户去 EnvSection 配置.\n- **不要自己心算 RSI \u002F MACD \u002F EMA** — freqtrade 算出的值跟你心算结果会差, 用 `ft-dev.mjs candles_analyzed` 拿 daemon 的真实指标.\n- **不要\"先 stop daemon 再 freqtrade trade ... &\"** — 那是绕过 supervisord, 下次 dashboard 看到的还是老的 daemon 状态. 必须用 `set_strategy` \u002F `deploy` \u002F `restart`.\n- **回测拿不到 AiCoin 数据是正常的** — 不要造假 CSV 喂回测, 直接告诉用户回测只反映技术指标. 见根 AGENTS.md 的\"数据准确性铁则\".\n","# AiCoin Freqtrade\n\nFreqtrade 策略 \u002F 回测 \u002F 部署 \u002F 实时控制 — 跨 CoinClaw 三引擎自动适配。\n\n## 关键原则(读完再动手)\n\n### 一、CoinClaw 容器里 freqtrade 是常驻 daemon\n\nOpenClaw \u002F Hermes \u002F Claude Code 三个引擎容器都通过 supervisord 把 freqtrade 起为常驻进程, 监听 `127.0.0.1:8080`, 默认跑 `NoOpStrategy`(空跑). **不要自己起 freqtrade 进程** — 会跟 daemon 抢端口, dashboard 立刻 offline.\n\n正确流程是: 写策略文件 → 调 `ft-deploy.mjs deploy {\"strategy\":\"...\"}` → 脚本改 config + 重启 daemon. dashboard 会自动刷出新策略.\n\n`scripts\u002Fft.mjs` + `scripts\u002Fft-deploy.mjs` 内置三引擎自动识别(`lib\u002Fcoinclaw-env.mjs`), 路径 \u002F auth \u002F supervisord socket 都自动解析, **agent 不用关心是哪个引擎**.\n\n### 二、永远先调 freqtrade REST API, 不要\"自己计算\"\n\n| 用户问 | 必须先调 |\n|---|---|\n| 现在赚多少 \u002F 总盈亏 \u002F 今天涨了多少 | `ft.mjs profit` (`\u002Fapi\u002Fv1\u002Fprofit`) |\n| 持仓 \u002F 现在开了哪些 | `ft.mjs trades_open` (`\u002Fapi\u002Fv1\u002Fstatus`) |\n| 余额 \u002F 资金多少 | `ft.mjs balance` (`\u002Fapi\u002Fv1\u002Fbalance`) |\n| 跑的什么策略 \u002F 当前模式 | `ft.mjs daemon_info` 或 `config` |\n| 历史交易 \u002F 已平仓 | `ft.mjs trades_history` |\n| 单交易对绩效 | `ft.mjs profit_per_pair` |\n\n**dashboard 数字对齐规则(关键)**: 用户问\"赚了多少\"必须报告**两个数字**:\n- **已平仓累计盈亏** = `profit_closed_coin` (USDT) — **dashboard 顶栏的累计盈亏 = 这个**\n- **含浮动总盈亏** = `profit_all_coin` (USDT) — 已平仓 + 当前持仓的浮动盈亏\n\n只调 `\u002Fstatus` 拿持仓浮动盈亏会漏掉已平仓部分, 导致跟 dashboard 数字不一致 — 用户立刻发现, 信任度归零.\n\n### 三、切策略 \u002F 切实盘 \u002F 切交易对必须走脚本\n\nconfig.json 是 daemon 启动时读一次, 手动改完不会自动生效. 必须用:\n\n| 操作 | 命令 | 是否需要 daemon 重启 |\n|---|---|---|\n| 切策略 | `ft.mjs set_strategy {\"strategy\":\"X\"}` | 必须重启 (~30s) |\n| 切交易对 | `ft.mjs set_pairs {\"pairs\":[...]}` | 不重启, `reload_config` 即可 |\n| 切实盘\u002F模拟 | `ft.mjs set_dry_run {\"dry_run\":false}` | 必须重启 |\n| reload 配置 | `ft.mjs reload` | 不重启 |\n\n或者一次完成所有变更: `ft-deploy.mjs deploy {\"strategy\":\"X\",\"pairs\":[\"BTC\u002FUSDT:USDT\"],\"dry_run\":false}`.\n\n**任何直接修改 config.json 的操作(包括手动编辑 pair_whitelist \u002F minimal_roi \u002F stoploss 等), 改完后必须立即调 `ft.mjs reload`** — 否则 daemon 仍用内存里的旧配置运行, 白名单\u002F止损等改动不会生效. 忘了 reload 是最常见的\"改了但没用\"的原因.\n\n**chat 主动发起的高 stake 操作必须强 confirm**(违反即错):\n\n适用: 用户在 chat 里说\"平掉\"、\"切实盘\"、\"卖了\"、\"开仓\"等 — 通过 agent 调用 `force_exit` \u002F `force_enter` \u002F `set_dry_run` 的操作.\n\n流程:\n1. **先列预览**: 动哪个 trade \u002F pair \u002F 当前盈亏 \u002F 估算损益 \u002F dry_run vs live \u002F 余额状况\n2. **明确等用户输\"确认\"或\"yes\"** 才真调 `force_exit` \u002F `set_dry_run` \u002F `force_enter`\n3. 即使用户语气笃定(\"平了\",\"直接切\"), 也必须先预览等确认\n\n**不需要 confirm 的**:\n- 查询类(查持仓 \u002F 盈亏 \u002F 状态) — 直接读\n- **freqtrade daemon 自己根据策略信号自动开\u002F平仓** — 这是 daemon 本职工作, 用户切实盘那一刻就授权了, agent 不在这个链路里, 不要拦也不需要 confirm\n- 非破坏性配置(`set_pairs` 加币对、`reload`) — 列改动表然后直接执行\n\n**违反规则的反例**:\n- ❌ 用户说\"平掉\", 你直接调 `force_exit` 平了真持仓 (K-Live-3 dogfood 抓到的真 bug)\n- ❌ 用户说\"切实盘\", 你不列 .env key \u002F 余额 \u002F 风险就直接 `set_dry_run {\"dry_run\":false}`\n- ✅ 用户说\"平掉\", 你列\"持仓: BNB\u002FUSDT 0.05 +$1.07, 平这单吗? dry_run=true 模拟盘\", 等用户确认\n\n**写策略 + 切策略 倾向分两轮**(create_strategy 一轮, set_strategy 一轮). 不是技术限制,是 UX 选择:\n1. 第一轮: 写完策略文件 → 告诉用户\"已生成 X.py, 要切上去吗?\"\n2. 用户确认后第二轮: `set_strategy` 切策略 + 重启 daemon (~30s)\n\n这样用户切策略前能 review 生成文件; daemon 重启 30s 期间用户对状态有预期, 不会误判 chat 卡死. 用户明确说\"一气呵成做完\"也可以单 turn 跑完两步, 但默认分轮.\n\n### 四、Freqtrade 不支持网格策略 (grid)\n\n用户问网格时直接说明限制 + 建议趋势跟踪 \u002F 区间策略 \u002F 网格回报模拟器替代. 不要硬写一个伪网格.\n\n## 快速参考\n\n| 任务 | 命令 |\n|------|------|\n| 看 daemon 状态 + 配置 | `node scripts\u002Fft-deploy.mjs check` 或 `ft.mjs daemon_info` |\n| 看策略列表 | `node scripts\u002Fft-deploy.mjs strategy_list` |\n| 创建策略(快速生成器) | `node scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"MyStrat\",\"timeframe\":\"15m\",\"indicators\":[\"rsi\",\"macd\",\"ema\"],\"aicoin_data\":[\"funding_rate\"]}'` |\n| 部署策略到 daemon | `node scripts\u002Fft-deploy.mjs deploy '{\"strategy\":\"MyStrat\"}'` |\n| 部署+切实盘 | `node scripts\u002Fft-deploy.mjs deploy '{\"strategy\":\"MyStrat\",\"dry_run\":false}'` |\n| 回测 | `node scripts\u002Fft-deploy.mjs backtest '{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"timerange\":\"20250101-20260301\"}'` |\n| Hyperopt 调参 | `node scripts\u002Fft-deploy.mjs hyperopt '{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"epochs\":100}'` |\n| 看盈亏 | `node scripts\u002Fft.mjs profit` |\n| 看持仓 | `node scripts\u002Fft.mjs trades_open` |\n| 看余额 | `node scripts\u002Fft.mjs balance` |\n| 切交易对 | `node scripts\u002Fft.mjs set_pairs '{\"pairs\":[\"BTC\u002FUSDT:USDT\",\"ETH\u002FUSDT:USDT\"]}'` |\n| 重启 daemon | `node scripts\u002Fft.mjs restart` |\n| 看日志 | `node scripts\u002Fft-deploy.mjs logs '{\"lines\":100}'` |\n\n## 创建策略：先判断走哪条路\n\n**判断规则**：\n- 用户只给了笼统描述（\"RSI 策略\"、\"均线交叉\"、\"布林带回归\"）且没指定具体参数细节 → **A. 快速生成器**\n- 用户给了具体逻辑（自定义入场\u002F出场条件、跨周期共振、多币种轮动、复合指标、自定义仓位管理）→ **B. 直接写 Python**\n- 用 A 生成后用户要改细节 → 直接编辑生成的 .py 文件，不要重新 create_strategy 覆盖\n\n### A. 快速生成器(简单策略)\n\n`create_strategy` 一条命令生成一个可跑的策略文件。适合\"先跑起来再调\"的场景：\n\n```bash\nnode scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"MACDStrategy\",\"timeframe\":\"15m\",\"indicators\":[\"macd\",\"rsi\",\"atr\"]}'\nnode scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"RSILong\",\"timeframe\":\"1h\",\"indicators\":[\"rsi\"],\"direction\":\"long\"}'\nnode scripts\u002Fft-deploy.mjs create_strategy '{\"name\":\"WhaleStrat\",\"timeframe\":\"15m\",\"indicators\":[\"rsi\",\"macd\"],\"aicoin_data\":[\"funding_rate\",\"ls_ratio\"]}'\n```\n\n可选 `indicators`: `rsi`, `bb`, `ema`, `sma`, `macd`, `stochastic`\u002F`kdj`, `atr`, `adx`, `cci`, `williams_r`, `vwap`, `ichimoku`, `volume_sma`, `obv`.\n\n可选 `direction`: `\"long\"` (默认,只做多) | `\"short\"` (只做空) | `\"both\"` (双向)。\n**用户说\"RSI\u003C30 买入, RSI>70 卖出\"→ direction=\"long\"**(RSI>70 = 平多, 不是开空)。只有用户明确说\"做空 \u002F 双向 \u002F 多空都做\"时才用 `\"both\"` 或 `\"short\"`。\n\n可选 `aicoin_data`: `funding_rate`、`ls_ratio`、`big_orders`、`liquidation_map`（都需付费套餐），`open_interest`（v3 聚合 OI 历史暂未接通，会自动降级到默认值）。\n\n**生成器的局限**：只能组合预设指标，不支持跨周期、多币种轮动、自定义复合指标。遇到这些需求直接走 B。\n\n### B. 自定义 Python 策略 (复杂逻辑)\n\n直接写 `.py` 文件到 daemon 的 strategy 目录。用这条路可以实现任何 freqtrade 支持的策略逻辑（跨周期 informative pairs、自定义仓位管理、多指标复合条件等）。\n\n三引擎该目录不同, **从 `daemon_info` 拿**或用 `Write` 工具写到下面任一路径(脚本会自动用 `\u002Fapi\u002Fv1\u002Fshow_config` 验证):\n\n| 引擎 | strategy 目录 |\n|---|---|\n| OpenClaw | `~\u002F.openclaw\u002Fworkspace\u002Fstrategies\u002F` |\n| Hermes | `\u002Fworkspace\u002Fstrategies\u002F` |\n| Claude Code | `\u002Fworkspace\u002Fstrategies\u002F` |\n\n用 AiCoin Python SDK (`aicoin_data.py`, image build 时已复制到上面目录, 也由 `create_strategy` 兜底拷贝):\n\n它封装了 AiCoin Open API v3：\n\n```python\nfrom aicoin_data import AiCoinData\n\nac = AiCoinData(cache_ttl=300)   # 自动从 .env 读 key，内置 5 分钟缓存\n\n# 高层信号 —— 直接返回能用的数字，丢进策略即可\nac.whale_signal(\"BTC\u002FUSDT:USDT\", \"binance\")        # 大单买卖压力 -1..+1\nac.ls_ratio_norm()                                 # 多空比 0..1（>0.5 偏多）\nac.funding_rate_pct(\"BTC\u002FUSDT:USDT\", \"binance\")    # 最新资金费率（百分比）\nac.liq_bias(\"BTC\u002FUSDT:USDT\", \"binance\")            # 清算图方向偏向 -1..+1\n\n# 原始数据\nac.coin_ticker(\"bitcoin,ethereum\")                 # 实时行情\nac.klines(\"BTC\u002FUSDT\", \"binance\", interval=\"1h\", limit=100)\n\n# 任意 v3 接口 —— path 是 \u002Fapi\u002Fv3\u002F 后那段，清单见 https:\u002F\u002Fopen.aicoin.com\u002Fapi\u002Fv3\u002F_catalog\nac.get(\"markets\u002Fhot-coins\", {\"tab_key\": \"defi\"})\nac.get(\"hyperliquid\u002Fwhales\u002Fopen-positions\", {\"coin\": \"BTC\"})\n```\n\n回测期 AiCoin 实时数据不可用，高层信号会抛异常 —— 策略里要 `try\u002Fexcept` 兜底用默认值。资金费率、大单、清算等需要付费套餐，没权限同样抛异常（一样兜底）。\n\n#### 完整模板\n\n```python\nfrom freqtrade.strategy import IStrategy, IntParameter, DecimalParameter\nfrom pandas import DataFrame\nimport logging, time\n\nlogger = logging.getLogger(__name__)\n\n\nclass MyStrategy(IStrategy):\n    INTERFACE_VERSION = 3\n    timeframe = '15m'\n    can_short = True\n\n    minimal_roi = {\"0\": 0.05, \"60\": 0.03, \"120\": 0.01}\n    stoploss = -0.05\n    trailing_stop = True\n    trailing_stop_positive = 0.02\n    trailing_stop_positive_offset = 0.03\n\n    rsi_buy = IntParameter(20, 40, default=30, space='buy')\n    rsi_sell = IntParameter(60, 80, default=70, space='sell')\n\n    _ac_funding_rate = 0.0\n    _ac_last_update = 0.0\n\n    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:\n        # RSI\n        delta = dataframe['close'].diff()\n        gain = delta.clip(lower=0).rolling(window=14).mean()\n        loss = (-delta.clip(upper=0)).rolling(window=14).mean()\n        rs = gain \u002F loss\n        dataframe['rsi'] = 100 - (100 \u002F (1 + rs))\n\n        # AiCoin 数据 (live\u002Fdry_run only, backtest 用默认值 0.0)\n        dataframe['funding_rate'] = 0.0\n        if self.dp and self.dp.runmode.value in ('live', 'dry_run'):\n            now = time.time()\n            if now - self._ac_last_update > 300:\n                self._update_aicoin_data(metadata)\n                self._ac_last_update = now\n            dataframe.iloc[-1, dataframe.columns.get_loc('funding_rate')] = self._ac_funding_rate\n\n        return dataframe\n\n    def _update_aicoin_data(self, metadata: dict):\n        try:\n            import sys, os\n            _sd = os.path.dirname(os.path.abspath(__file__))\n            if _sd not in sys.path:\n                sys.path.insert(0, _sd)\n            from aicoin_data import AiCoinData\n            ac = AiCoinData(cache_ttl=300)\n            pair = metadata.get('pair', 'BTC\u002FUSDT:USDT')\n            exchange = self.config.get('exchange', {}).get('name', 'binance')\n            self._ac_funding_rate = ac.funding_rate_pct(pair, exchange)\n        except Exception as e:\n            logger.warning(f\"AiCoin data error: {e}\")\n\n    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:\n        dataframe.loc[\n            (dataframe['rsi'] \u003C self.rsi_buy.value) &\n            (dataframe['volume'] > 0),\n            'enter_long'] = 1\n        dataframe.loc[\n            (dataframe['rsi'] > self.rsi_sell.value) &\n            (dataframe['volume'] > 0),\n            'enter_short'] = 1\n        return dataframe\n\n    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:\n        dataframe.loc[(dataframe['rsi'] > 70), 'exit_long'] = 1\n        dataframe.loc[(dataframe['rsi'] \u003C 30), 'exit_short'] = 1\n        return dataframe\n```\n\n写完后用 `deploy {\"strategy\":\"MyStrategy\"}` 让 daemon 切到这个策略.\n\n### AiCoin 数据集成模式\n\n| AiCoin 数据 | 信号逻辑 | 套餐 |\n|---|---|---|\n| `funding_rate` | 大于 0.01% → 多头过度 → 空信号; 小于 -0.01% → 多信号 | 基础版 |\n| `ls_ratio` | 小于 0.45 (空头多) → 反向做多; 大于 0.55 → 反向做空 | 基础版 |\n| `big_orders` | `(buy_vol-sell_vol)\u002Ftotal > 0.3` → 鲸鱼买入做多 | 标准版 |\n| `open_interest` | OI 涨 + 价涨 = 健康趋势; OI 涨 + 价跌 = 反转 | 专业版 |\n| `liquidation_map` | 上方爆仓多 → 多头挤压 → 做多 | 高级版 |\n\n### 回测注意事项\n\nAiCoin 实时数据**不在历史区间内可用**. 回测时:\n\n- AiCoin 列用默认值 (`funding_rate=0.0`, `ls_ratio=0.5`, `whale_signal=0.0`)\n- 回测结果只反映**技术指标**部分\n- live\u002Fdry_run 跑的时候才用真实 AiCoin 数据, 表现应该比回测好\n\n向用户报告回测结果时必须主动说明这点, 不要让用户以为回测包含了 AiCoin 信号.\n\n## 脚本 API\n\n### `scripts\u002Fft-deploy.mjs` — 策略 \u002F 回测 \u002F 部署\n\n| Action | 参数示例 |\n|---|---|\n| `check` | (无) — 返回 daemon 状态 + 配置 + 余额 |\n| `daemon_info`(在 ft.mjs) | (无) — 单调用拿全 |\n| `deploy` | `{\"strategy\":\"MyStrat\"}` 或 `{\"strategy\":\"MyStrat\",\"dry_run\":false,\"pairs\":[\"BTC\u002FUSDT:USDT\"]}` |\n| `create_strategy` | `{\"name\":\"MyStrat\",\"timeframe\":\"15m\",\"indicators\":[\"rsi\",\"macd\"],\"direction\":\"long\",\"aicoin_data\":[\"funding_rate\"]}` |\n| `backtest` | `{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"timerange\":\"20250101-20260301\",\"pairs\":[\"ETH\u002FUSDT:USDT\"]}` |\n| `hyperopt` | `{\"strategy\":\"MyStrat\",\"timeframe\":\"1h\",\"epochs\":100}` |\n| `download_data` | `{\"timeframe\":\"1h\",\"timerange\":\"20250101-\"}` |\n| `strategy_list` | (无) |\n| `backtest_results` | (无) — 列最近 10 个回测结果文件名 |\n| `start` \u002F `stop` | (无) — coinclaw 模式调 supervisorctl, host 模式管 PID |\n| `status` \u002F `logs` | `{\"lines\":100}` |\n| `update` \u002F `remove` | coinclaw 模式 no-op (提示用 helm upgrade \u002F web UI 删 instance) |\n\n### `scripts\u002Fft.mjs` — 实时控制 (REST + 配置变更)\n\n| Action | 用途 |\n|---|---|\n| `daemon_info` | 一次拿 strategy \u002F mode \u002F pairs \u002F open trades 数量 |\n| `profit` | 已平仓累计 + 含浮动总盈亏 (回答盈亏类问题必须先调) |\n| `trades_open` | 当前持仓 (调 \u002Fstatus) |\n| `trades_history` | 已平仓交易 |\n| `balance` | 余额 |\n| `profit_per_pair` | 每交易对绩效 |\n| `daily` \u002F `weekly` \u002F `monthly` | 时间维度统计 |\n| `force_enter` \u002F `force_exit` | 手动开\u002F平仓 |\n| `set_strategy` | 切策略 (改 config + 重启 daemon) |\n| `set_pairs` | 改交易对白名单 (reload, 不重启) |\n| `set_dry_run` | 切实盘\u002F模拟 (改 config + 重启 daemon) |\n| `restart` | 重启 freqtrade daemon (supervisorctl + kill 兜底) |\n| `reload` | reload_config 而不重启 |\n| `start` \u002F `stop` \u002F `ping` \u002F `version` \u002F `health` | 标准 REST |\n| `logs` | freqtrade 自带 \u002Flogs 接口 |\n\n### `scripts\u002Fft-dev.mjs` — 调试 (回测 \u002F 蜡烛 \u002F 策略详情)\n\n`backtest_start` \u002F `backtest_status` \u002F `backtest_history` \u002F `candles_live` \u002F `candles_analyzed` \u002F `strategy_list` \u002F `strategy_get` \u002F `whitelist` \u002F `blacklist` 等.\n\n## 环境变量与认证\n\n`.env` 自动加载顺序:\n\n- coinclaw 容器内: `\u002Fworkspace\u002F.env` (Hermes\u002FCC) 或 `\u002Fhome\u002Fnode\u002F.openclaw\u002Fworkspace\u002F.env` (OpenClaw)\n- host 模式: cwd → `~\u002F.openclaw\u002Fworkspace\u002F.env` → `~\u002F.openclaw\u002F.env`\n\nfreqtrade REST 认证: `freqtrade-api.mjs` 自动从容器内 `.ft_api_pass` 文件读密码, **agent 不用配 FREQTRADE_USERNAME \u002F FREQTRADE_PASSWORD**. 用户也可以通过 `.env` 覆盖.\n\n交易所 key 在 web UI 的 EnvSection 里配置, 写到 .env 后 entrypoint 会自动 patch 进 freqtrade `config.json`. **agent 不要直接读 .env 给用户看交易所 key**.\n\nAiCoin Open API key (用于策略集成 AiCoin 数据):\n```\nAICOIN_ACCESS_KEY_ID=your-key-id\nAICOIN_ACCESS_SECRET=your-secret\n```\n\n## 付费功能引导\n\n返回 304 \u002F 403 时 **不要重试**, 直接告诉用户:\n\n| 套餐 | 价格 | 用途 |\n|---|---|---|\n| 免费版 | $0 | 纯技术指标 |\n| 基础版 | $29\u002Fmo | + `funding_rate`, `ls_ratio` |\n| 标准版 | $79\u002Fmo | + `big_orders`, `agg_trades` |\n| 高级版 | $299\u002Fmo | + `liquidation_map` |\n| 专业版 | $699\u002Fmo | + `open_interest`, `ai_analysis` |\n\n获取地址: https:\u002F\u002Fwww.aicoin.com\u002Fopendata\n\n## 跨 skill 引用\n\n| 用户问 | 用 |\n|---|---|\n| 单纯查行情 \u002F K 线 \u002F 新闻 \u002F 资金费率 (不开仓) | **aicoin-market** |\n| 直接下单 \u002F 开仓 \u002F 平仓 (不通过 freqtrade) | **aicoin-trading** |\n| Hyperliquid 鲸鱼 \u002F 持仓 \u002F 清算 | **aicoin-hyperliquid** |\n| 链上 DEX swap \u002F 钱包余额 \u002F gas | **aicoin-onchain** |\n| 余额 \u002F 持仓 \u002F 注册 \u002F API key 配置 (账户类) | **aicoin-account** |\n\n## 常见 pitfall\n\n- **不要 `cat \u002Fworkspace\u002F.ft_api_pass`** 把内部 daemon 密码贴到 chat — 直接用 `ft.mjs` 调 REST, 脚本内部读密码不会泄漏.\n- **不要在 chat 里 echo 用户的交易所 key** — 这些是高敏数据, 引导用户去 EnvSection 配置.\n- **不要自己心算 RSI \u002F MACD \u002F EMA** — freqtrade 算出的值跟你心算结果会差, 用 `ft-dev.mjs candles_analyzed` 拿 daemon 的真实指标.\n- **不要\"先 stop daemon 再 freqtrade trade ... &\"** — 那是绕过 supervisord, 下次 dashboard 看到的还是老的 daemon 状态. 必须用 `set_strategy` \u002F `deploy` \u002F `restart`.\n- **回测拿不到 AiCoin 数据是正常的** — 不要造假 CSV 喂回测, 直接告诉用户回测只反映技术指标. 见根 AGENTS.md 的\"数据准确性铁则\".\n",{"name":5,"metadata":24,"description":7},{"openclaw":25},{"source":26,"license":15,"homepage":27,"requires":28,"primaryEnv":31},"https:\u002F\u002Fgithub.com\u002Faicoincom\u002Fcoinos-skills","https:\u002F\u002Fwww.aicoin.com\u002Fopendata",{"bins":29},[30],"node","AICOIN_ACCESS_KEY_ID","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fa\u002Faicoin-freqtrade",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill aicoin-freqtrade",{"tool":47,"command":48},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill aicoin-freqtrade",{"tool":50,"command":51},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill aicoin-freqtrade","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fa\u002Faicoin-freqtrade\u002FSKILL.md",true,[],[56,64,71,78,85,92],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":63},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":63},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":63},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":63},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":63},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":63},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]