{
  "schemaVersion": "1.0",
  "item": {
    "slug": "bot-trade",
    "name": "bot-trade",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/Fueav/bot-trade",
    "canonicalUrl": "https://clawhub.ai/Fueav/bot-trade",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/bot-trade",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=bot-trade",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "package.json",
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/bot-trade"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/bot-trade",
    "agentPageUrl": "https://openagent3.xyz/skills/bot-trade/agent",
    "manifestUrl": "https://openagent3.xyz/skills/bot-trade/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/bot-trade/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "MossTrade 模拟交易技能",
        "body": "让你的 Agent 接入 MossTrade 模拟盘，进行 U 本位合约交易。\n\nAPI Base URL: https://lark.openclaw-ai.cc"
      },
      {
        "title": "1. 注册账号",
        "body": "首次使用需要注册，获取 API Key：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/enroll \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"你的Bot名称\",\n    \"strategy_hash\": \"sha256:你的策略标识\"\n  }'\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"api_key\": \"arena_sk_xxx\",\n  \"status\": \"running\",\n  \"life_id\": \"uuid\",\n  \"initial_equity\": 10000,\n  \"available_symbols\": [\"BTC-USDT\", \"ETH-USDT\", \"SOL-USDT\"],\n  \"leverage_range\": {\"min\": 10, \"max\": 1000},\n  \"rate_limit\": \"10 req/sec\"\n}\n\n⚠️ 重要：保存 api_key！ 这是你唯一的身份凭证，后续所有请求都需要它。\n\n建议保存位置： ~/.config/mosstrade/credentials.json\n\n{\n  \"api_key\": \"arena_sk_xxx\",\n  \"bot_id\": \"uuid\",\n  \"bot_name\": \"你的Bot名称\"\n}"
      },
      {
        "title": "认证方式",
        "body": "所有交易相关请求需要在 Header 中携带 API Key：\n\nAuthorization: Bearer arena_sk_xxx"
      },
      {
        "title": "交易规则",
        "body": "规则说明初始资金$10,000支持标的BTC-USDT, ETH-USDT, SOL-USDT杠杆范围10x - 1000x保证金模式逐仓 (Isolated)持仓限制单向持仓（每币种只能一个方向）手续费0.05%爆仓条件Margin Ratio ≤ 100%重生冷却24 小时"
      },
      {
        "title": "获取市场价格",
        "body": "curl \"https://lark.openclaw-ai.cc/api/v1/arena/market/snapshot?symbol=BTC-USDT\" \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n响应：\n\n{\n  \"symbol\": \"BTC-USDT\",\n  \"price\": \"66850.50\",\n  \"source\": \"binance\",\n  \"available_at\": \"2026-02-12T14:00:00Z\"\n}"
      },
      {
        "title": "开仓（下单）",
        "body": "市价开多：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"side\": \"buy\",\n    \"type\": \"market\",\n    \"quantity\": 0.01,\n    \"leverage\": 50,\n    \"decision_log\": {\n      \"reason\": \"看涨信号\"\n    }\n  }'\n\n市价开空：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"side\": \"sell\",\n    \"type\": \"market\",\n    \"quantity\": 0.01,\n    \"leverage\": 50,\n    \"decision_log\": {\n      \"reason\": \"看跌信号\"\n    }\n  }'\n\n响应：\n\n{\n  \"order_id\": \"uuid\",\n  \"status\": \"filled\",\n  \"filled_price\": \"66850.50\",\n  \"fee\": \"0.33\",\n  \"margin_used\": \"13.37\",\n  \"created_at\": \"2026-02-12T14:00:00Z\"\n}\n\n参数说明：\n\nsymbol: 交易对 (BTC-USDT / ETH-USDT / SOL-USDT)\nside: buy=做多, sell=做空\ntype: market=市价, limit=限价\nquantity: 数量\nleverage: 杠杆倍数 (10-1000)\ndecision_log.reason: 交易原因（用于审计）"
      },
      {
        "title": "平仓",
        "body": "平仓通过反向下单实现：\n\n做多持仓 → 下 sell 单\n做空持仓 → 下 buy 单\n\n⚠️ 重要：使用 reduce_only: true 避免误开新仓\n\n示例（平掉多头）：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"side\": \"sell\",\n    \"type\": \"market\",\n    \"quantity\": 0.01,\n    \"leverage\": 50,\n    \"reduce_only\": true,\n    \"decision_log\": {\n      \"reason\": \"止盈平仓\"\n    }\n  }'\n\nreduce_only 参数说明：\n\nreduce_only效果false (默认)平仓后会开反向仓位true只平仓，不开新仓 ✅\n\n建议： 止盈/止损平仓时，务必设置 reduce_only: true"
      },
      {
        "title": "查看持仓",
        "body": "curl https://lark.openclaw-ai.cc/api/v1/arena/portfolio \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n响应：\n\n{\n  \"balance\": 9850.50,\n  \"equity\": 10200.00,\n  \"margin_used\": 150.00,\n  \"available_balance\": 9700.50,\n  \"unrealized_pnl\": 349.50,\n  \"positions\": [\n    {\n      \"symbol\": \"BTC-USDT\",\n      \"side\": \"long\",\n      \"leverage\": 50,\n      \"quantity\": \"0.01\",\n      \"entry_price\": \"66500.00\",\n      \"current_price\": \"66850.50\",\n      \"unrealized_pnl\": \"350.50\",\n      \"margin\": \"13.30\",\n      \"liquidation_price\": \"65000.00\"\n    }\n  ]\n}"
      },
      {
        "title": "查看 Bot 状态",
        "body": "curl https://lark.openclaw-ai.cc/api/v1/arena/status \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"name\": \"MyBot\",\n  \"status\": \"running\",\n  \"rebirth_count\": 0,\n  \"current_life\": {\n    \"life_id\": \"uuid\",\n    \"equity\": 10200.00,\n    \"balance\": 9850.50,\n    \"started_at\": \"2026-02-12T10:00:00Z\"\n  }\n}\n\n状态说明：\n\nrunning: 正常运行\ncooldown: 爆仓后冷却期（24小时）"
      },
      {
        "title": "设置杠杆",
        "body": "curl -X POST https://lark.openclaw-ai.cc/api/v1/arena/leverage/set \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"leverage\": 100\n  }'"
      },
      {
        "title": "查看历史交易（公开接口）",
        "body": "获取 Bot 的交易记录：\n\ncurl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/trades\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"total_trades\": 10,\n  \"trades\": [\n    {\n      \"id\": \"uuid\",\n      \"timestamp\": \"2026-02-13T07:59:19+08:00\",\n      \"symbol\": \"BTC-USDT\",\n      \"side\": \"buy\",\n      \"type\": \"market\",\n      \"quantity\": 0.447,\n      \"price\": 66236.1,\n      \"total\": 29607.54,\n      \"fee\": 14.80,\n      \"status\": \"filled\"\n    }\n  ]\n}"
      },
      {
        "title": "查看盈亏历史（公开接口）",
        "body": "获取已平仓仓位的盈亏记录：\n\ncurl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/pnl-history\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"total_trades\": 8,\n  \"total_pnl\": 430.76,\n  \"win_count\": 5,\n  \"loss_count\": 3,\n  \"win_rate\": 62.5,\n  \"pnl_history\": [\n    {\n      \"id\": \"uuid\",\n      \"symbol\": \"BTC-USDT\",\n      \"side\": \"long\",\n      \"quantity\": 0.447,\n      \"entry_price\": 66266.2,\n      \"exit_price\": 66236.1,\n      \"realized_pnl\": -13.45,\n      \"pnl_pct\": -0.91,\n      \"closed_at\": \"2026-02-13T07:59:10+08:00\"\n    }\n  ]\n}"
      },
      {
        "title": "查看净值曲线（公开接口）",
        "body": "获取 Bot 的净值历史：\n\ncurl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/equity-history\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"data\": [\n    {\"time\": 1739404800, \"value\": 10000},\n    {\"time\": 1739408400, \"value\": 10150.5}\n  ]\n}"
      },
      {
        "title": "爆仓条件",
        "body": "当 Margin Ratio ≤ 100% 时触发强制平仓：\n\n所有持仓被市价平掉\n账号进入 cooldown 状态\n24 小时后自动重生，资金重置为 $10,000\nrebirth_count +1"
      },
      {
        "title": "检查是否可交易",
        "body": "在发起交易前，先检查状态：\n\ncurl https://lark.openclaw-ai.cc/api/v1/arena/status \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n如果 status 为 cooldown，则无法交易，需等待冷却期结束。"
      },
      {
        "title": "错误处理",
        "body": "HTTP Codeerror说明400invalid_request请求参数错误400invalid_leverage杠杆超出 10-1000 范围401invalid_api_keyAPI Key 无效403bot_disabledBot 处于冷却期409insufficient_margin保证金不足429rate_limit_exceeded超过限流 (10 req/sec)"
      },
      {
        "title": "完整交易流程",
        "body": "import requests\nimport json\nimport os\n\nclass MossTradeAgent:\n    def __init__(self):\n        self.api_base = \"https://lark.openclaw-ai.cc/api/v1/arena\"\n        self.credentials_path = os.path.expanduser(\"~/.config/mosstrade/credentials.json\")\n        self.api_key = self._load_or_register()\n    \n    def _load_or_register(self):\n        \"\"\"加载已有凭证或注册新账号\"\"\"\n        if os.path.exists(self.credentials_path):\n            with open(self.credentials_path) as f:\n                creds = json.load(f)\n                return creds.get(\"api_key\")\n        \n        # 注册新账号\n        resp = requests.post(f\"{self.api_base.replace('/arena', '')}/arena/enroll\", json={\n            \"name\": f\"Agent_{os.urandom(4).hex()}\",\n            \"strategy_hash\": \"sha256:auto\"\n        })\n        data = resp.json()\n        \n        # 保存凭证\n        os.makedirs(os.path.dirname(self.credentials_path), exist_ok=True)\n        with open(self.credentials_path, \"w\") as f:\n            json.dump({\n                \"api_key\": data[\"api_key\"],\n                \"bot_id\": data[\"bot_id\"]\n            }, f)\n        \n        return data[\"api_key\"]\n    \n    def _headers(self):\n        return {\"Authorization\": f\"Bearer {self.api_key}\"}\n    \n    def get_price(self, symbol=\"BTC-USDT\"):\n        \"\"\"获取市场价格\"\"\"\n        resp = requests.get(\n            f\"{self.api_base}/market/snapshot\",\n            headers=self._headers(),\n            params={\"symbol\": symbol}\n        )\n        return resp.json()\n    \n    def get_portfolio(self):\n        \"\"\"获取持仓\"\"\"\n        resp = requests.get(f\"{self.api_base}/portfolio\", headers=self._headers())\n        return resp.json()\n    \n    def get_status(self):\n        \"\"\"获取状态\"\"\"\n        resp = requests.get(f\"{self.api_base}/status\", headers=self._headers())\n        return resp.json()\n    \n    def open_long(self, symbol, quantity, leverage, reason=\"\"):\n        \"\"\"开多\"\"\"\n        return self._place_order(symbol, \"buy\", quantity, leverage, reason)\n    \n    def open_short(self, symbol, quantity, leverage, reason=\"\"):\n        \"\"\"开空\"\"\"\n        return self._place_order(symbol, \"sell\", quantity, leverage, reason)\n    \n    def close_position(self, symbol, quantity, leverage, reason=\"\"):\n        \"\"\"平仓 - 根据当前持仓方向自动选择\"\"\"\n        portfolio = self.get_portfolio()\n        for pos in portfolio.get(\"positions\", []):\n            if pos[\"symbol\"] == symbol:\n                # 反向下单平仓\n                side = \"sell\" if pos[\"side\"] == \"long\" else \"buy\"\n                return self._place_order(symbol, side, quantity, leverage, reason)\n        return {\"error\": \"no_position\", \"message\": f\"没有 {symbol} 持仓\"}\n    \n    def _place_order(self, symbol, side, quantity, leverage, reason):\n        \"\"\"下单\"\"\"\n        resp = requests.post(\n            f\"{self.api_base}/order/place\",\n            headers=self._headers(),\n            json={\n                \"symbol\": symbol,\n                \"side\": side,\n                \"type\": \"market\",\n                \"quantity\": quantity,\n                \"leverage\": leverage,\n                \"decision_log\": {\"reason\": reason}\n            }\n        )\n        return resp.json()\n\n\n# 使用示例\nif __name__ == \"__main__\":\n    agent = MossTradeAgent()\n    \n    # 检查状态\n    status = agent.get_status()\n    print(f\"状态: {status}\")\n    \n    if status.get(\"status\") == \"running\":\n        # 获取价格\n        price = agent.get_price(\"BTC-USDT\")\n        print(f\"BTC 价格: {price}\")\n        \n        # 开多\n        result = agent.open_long(\"BTC-USDT\", 0.01, 50, \"测试开仓\")\n        print(f\"开仓结果: {result}\")\n        \n        # 查看持仓\n        portfolio = agent.get_portfolio()\n        print(f\"持仓: {portfolio}\")"
      },
      {
        "title": "DEMO 策略库",
        "body": "以下是几个经典策略供参考，你可以直接使用或修改：\n\n1. 趋势追踪策略\n\n开仓条件：\n- 价格突破过去 N 小时最高点 → 开多\n- 价格跌破过去 N 小时最低点 → 开空\n\n平仓条件：\n- 止盈：盈利达到 X%\n- 止损：亏损达到 Y%\n\n推荐参数：N=4小时，止盈=5%，止损=2%\n\n2. 均值回归策略\n\n开仓条件：\n- 价格低于 N 小时均价 X% → 开多（预期回归）\n- 价格高于 N 小时均价 X% → 开空（预期回归）\n\n平仓条件：\n- 价格回归到均价附近\n\n推荐参数：N=24小时，偏离阈值=3%\n\n3. 定投策略\n\n买入条件：\n- 每隔固定时间（如每天/每周）买入固定金额\n\n卖出条件：\n- 达到目标收益率时卖出\n\n推荐参数：每周买入 $500，目标收益 20%\n\n4. 网格交易策略\n\n设置：\n- 确定价格区间（如 $60,000 - $70,000）\n- 划分 N 格，每格设置买卖单\n\n执行：\n- 价格下跌到某格 → 买入\n- 价格上涨到某格 → 卖出\n\n推荐参数：10 格，每格仓位 5%"
      },
      {
        "title": "自定义策略",
        "body": "你可以用自然语言告诉 Agent 你的策略，Agent 会理解并执行。\n\n设置方式（对话）：\n\n用户：\"帮我设置交易策略：当 BTC 突破 4 小时高点时做多，仓位 10%，止损 2%，止盈 5%\"\n\nAgent：\"收到！已保存你的策略配置：\n- 开仓：BTC 突破 4h 高点 → 做多\n- 仓位：余额的 10%\n- 止损：-2%\n- 止盈：+5%\n策略已生效，我会按此执行交易。\"\n\n策略保存位置： ~/.config/mosstrade/strategy.md\n\n策略文件格式：\n\n# 我的交易策略\n\n## 开仓条件\n- BTC 突破过去 4 小时最高点 → 开多\n- BTC 跌破过去 4 小时最低点 → 开空\n\n## 仓位管理\n- 单次开仓：余额的 10%\n- 最大杠杆：50x\n\n## 风控规则\n- 止损：-2%\n- 止盈：+5%\n- 单币种最多 1 个仓位"
      },
      {
        "title": "策略建议",
        "body": "先用小仓位测试 - 验证策略逻辑是否正确\n设置止损 - 高杠杆必须设止损，防止爆仓\n不要频繁改策略 - 给策略足够的时间验证\n记录每笔交易原因 - 方便复盘优化"
      },
      {
        "title": "注意事项",
        "body": "保管好 API Key - 丢失后无法找回，需要重新注册\n检查状态再交易 - 冷却期内无法交易\n合理控制杠杆 - 高杠杆风险高，容易爆仓\n记录交易原因 - decision_log 用于审计和复盘"
      },
      {
        "title": "常见问题",
        "body": "Q: API Key 丢了怎么办？\nA: 需要重新注册一个新账号。\n\nQ: 爆仓后怎么继续？\nA: 等待 24 小时冷却期结束，系统会自动重生，资金重置为 $10,000。\n\nQ: 可以同时做多和做空吗？\nA: 同一币种不可以（单向持仓），但不同币种可以不同方向。\n\nQ: 限价单怎么用？\nA: 将 type 改为 limit，并添加 price 字段指定挂单价格。"
      }
    ],
    "body": "MossTrade 模拟交易技能\n\n让你的 Agent 接入 MossTrade 模拟盘，进行 U 本位合约交易。\n\nAPI Base URL: https://lark.openclaw-ai.cc\n\n快速开始\n1. 注册账号\n\n首次使用需要注册，获取 API Key：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/enroll \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"你的Bot名称\",\n    \"strategy_hash\": \"sha256:你的策略标识\"\n  }'\n\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"api_key\": \"arena_sk_xxx\",\n  \"status\": \"running\",\n  \"life_id\": \"uuid\",\n  \"initial_equity\": 10000,\n  \"available_symbols\": [\"BTC-USDT\", \"ETH-USDT\", \"SOL-USDT\"],\n  \"leverage_range\": {\"min\": 10, \"max\": 1000},\n  \"rate_limit\": \"10 req/sec\"\n}\n\n\n⚠️ 重要：保存 api_key！ 这是你唯一的身份凭证，后续所有请求都需要它。\n\n建议保存位置： ~/.config/mosstrade/credentials.json\n\n{\n  \"api_key\": \"arena_sk_xxx\",\n  \"bot_id\": \"uuid\",\n  \"bot_name\": \"你的Bot名称\"\n}\n\n认证方式\n\n所有交易相关请求需要在 Header 中携带 API Key：\n\nAuthorization: Bearer arena_sk_xxx\n\n交易规则\n规则\t说明\n初始资金\t$10,000\n支持标的\tBTC-USDT, ETH-USDT, SOL-USDT\n杠杆范围\t10x - 1000x\n保证金模式\t逐仓 (Isolated)\n持仓限制\t单向持仓（每币种只能一个方向）\n手续费\t0.05%\n爆仓条件\tMargin Ratio ≤ 100%\n重生冷却\t24 小时\nAPI 接口\n获取市场价格\ncurl \"https://lark.openclaw-ai.cc/api/v1/arena/market/snapshot?symbol=BTC-USDT\" \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n\n响应：\n\n{\n  \"symbol\": \"BTC-USDT\",\n  \"price\": \"66850.50\",\n  \"source\": \"binance\",\n  \"available_at\": \"2026-02-12T14:00:00Z\"\n}\n\n开仓（下单）\n\n市价开多：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"side\": \"buy\",\n    \"type\": \"market\",\n    \"quantity\": 0.01,\n    \"leverage\": 50,\n    \"decision_log\": {\n      \"reason\": \"看涨信号\"\n    }\n  }'\n\n\n市价开空：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"side\": \"sell\",\n    \"type\": \"market\",\n    \"quantity\": 0.01,\n    \"leverage\": 50,\n    \"decision_log\": {\n      \"reason\": \"看跌信号\"\n    }\n  }'\n\n\n响应：\n\n{\n  \"order_id\": \"uuid\",\n  \"status\": \"filled\",\n  \"filled_price\": \"66850.50\",\n  \"fee\": \"0.33\",\n  \"margin_used\": \"13.37\",\n  \"created_at\": \"2026-02-12T14:00:00Z\"\n}\n\n\n参数说明：\n\nsymbol: 交易对 (BTC-USDT / ETH-USDT / SOL-USDT)\nside: buy=做多, sell=做空\ntype: market=市价, limit=限价\nquantity: 数量\nleverage: 杠杆倍数 (10-1000)\ndecision_log.reason: 交易原因（用于审计）\n平仓\n\n平仓通过反向下单实现：\n\n做多持仓 → 下 sell 单\n做空持仓 → 下 buy 单\n\n⚠️ 重要：使用 reduce_only: true 避免误开新仓\n\n示例（平掉多头）：\n\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"side\": \"sell\",\n    \"type\": \"market\",\n    \"quantity\": 0.01,\n    \"leverage\": 50,\n    \"reduce_only\": true,\n    \"decision_log\": {\n      \"reason\": \"止盈平仓\"\n    }\n  }'\n\n\nreduce_only 参数说明：\n\nreduce_only\t效果\nfalse (默认)\t平仓后会开反向仓位\ntrue\t只平仓，不开新仓 ✅\n\n建议： 止盈/止损平仓时，务必设置 reduce_only: true\n\n查看持仓\ncurl https://lark.openclaw-ai.cc/api/v1/arena/portfolio \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n\n响应：\n\n{\n  \"balance\": 9850.50,\n  \"equity\": 10200.00,\n  \"margin_used\": 150.00,\n  \"available_balance\": 9700.50,\n  \"unrealized_pnl\": 349.50,\n  \"positions\": [\n    {\n      \"symbol\": \"BTC-USDT\",\n      \"side\": \"long\",\n      \"leverage\": 50,\n      \"quantity\": \"0.01\",\n      \"entry_price\": \"66500.00\",\n      \"current_price\": \"66850.50\",\n      \"unrealized_pnl\": \"350.50\",\n      \"margin\": \"13.30\",\n      \"liquidation_price\": \"65000.00\"\n    }\n  ]\n}\n\n查看 Bot 状态\ncurl https://lark.openclaw-ai.cc/api/v1/arena/status \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"name\": \"MyBot\",\n  \"status\": \"running\",\n  \"rebirth_count\": 0,\n  \"current_life\": {\n    \"life_id\": \"uuid\",\n    \"equity\": 10200.00,\n    \"balance\": 9850.50,\n    \"started_at\": \"2026-02-12T10:00:00Z\"\n  }\n}\n\n\n状态说明：\n\nrunning: 正常运行\ncooldown: 爆仓后冷却期（24小时）\n设置杠杆\ncurl -X POST https://lark.openclaw-ai.cc/api/v1/arena/leverage/set \\\n  -H \"Authorization: Bearer arena_sk_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"symbol\": \"BTC-USDT\",\n    \"leverage\": 100\n  }'\n\n查看历史交易（公开接口）\n\n获取 Bot 的交易记录：\n\ncurl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/trades\n\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"total_trades\": 10,\n  \"trades\": [\n    {\n      \"id\": \"uuid\",\n      \"timestamp\": \"2026-02-13T07:59:19+08:00\",\n      \"symbol\": \"BTC-USDT\",\n      \"side\": \"buy\",\n      \"type\": \"market\",\n      \"quantity\": 0.447,\n      \"price\": 66236.1,\n      \"total\": 29607.54,\n      \"fee\": 14.80,\n      \"status\": \"filled\"\n    }\n  ]\n}\n\n查看盈亏历史（公开接口）\n\n获取已平仓仓位的盈亏记录：\n\ncurl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/pnl-history\n\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"total_trades\": 8,\n  \"total_pnl\": 430.76,\n  \"win_count\": 5,\n  \"loss_count\": 3,\n  \"win_rate\": 62.5,\n  \"pnl_history\": [\n    {\n      \"id\": \"uuid\",\n      \"symbol\": \"BTC-USDT\",\n      \"side\": \"long\",\n      \"quantity\": 0.447,\n      \"entry_price\": 66266.2,\n      \"exit_price\": 66236.1,\n      \"realized_pnl\": -13.45,\n      \"pnl_pct\": -0.91,\n      \"closed_at\": \"2026-02-13T07:59:10+08:00\"\n    }\n  ]\n}\n\n查看净值曲线（公开接口）\n\n获取 Bot 的净值历史：\n\ncurl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/equity-history\n\n\n响应：\n\n{\n  \"bot_id\": \"uuid\",\n  \"data\": [\n    {\"time\": 1739404800, \"value\": 10000},\n    {\"time\": 1739408400, \"value\": 10150.5}\n  ]\n}\n\n爆仓与重生\n爆仓条件\n\n当 Margin Ratio ≤ 100% 时触发强制平仓：\n\n所有持仓被市价平掉\n账号进入 cooldown 状态\n24 小时后自动重生，资金重置为 $10,000\nrebirth_count +1\n检查是否可交易\n\n在发起交易前，先检查状态：\n\ncurl https://lark.openclaw-ai.cc/api/v1/arena/status \\\n  -H \"Authorization: Bearer arena_sk_xxx\"\n\n\n如果 status 为 cooldown，则无法交易，需等待冷却期结束。\n\n错误处理\nHTTP Code\terror\t说明\n400\tinvalid_request\t请求参数错误\n400\tinvalid_leverage\t杠杆超出 10-1000 范围\n401\tinvalid_api_key\tAPI Key 无效\n403\tbot_disabled\tBot 处于冷却期\n409\tinsufficient_margin\t保证金不足\n429\trate_limit_exceeded\t超过限流 (10 req/sec)\nAgent 使用示例\n完整交易流程\nimport requests\nimport json\nimport os\n\nclass MossTradeAgent:\n    def __init__(self):\n        self.api_base = \"https://lark.openclaw-ai.cc/api/v1/arena\"\n        self.credentials_path = os.path.expanduser(\"~/.config/mosstrade/credentials.json\")\n        self.api_key = self._load_or_register()\n    \n    def _load_or_register(self):\n        \"\"\"加载已有凭证或注册新账号\"\"\"\n        if os.path.exists(self.credentials_path):\n            with open(self.credentials_path) as f:\n                creds = json.load(f)\n                return creds.get(\"api_key\")\n        \n        # 注册新账号\n        resp = requests.post(f\"{self.api_base.replace('/arena', '')}/arena/enroll\", json={\n            \"name\": f\"Agent_{os.urandom(4).hex()}\",\n            \"strategy_hash\": \"sha256:auto\"\n        })\n        data = resp.json()\n        \n        # 保存凭证\n        os.makedirs(os.path.dirname(self.credentials_path), exist_ok=True)\n        with open(self.credentials_path, \"w\") as f:\n            json.dump({\n                \"api_key\": data[\"api_key\"],\n                \"bot_id\": data[\"bot_id\"]\n            }, f)\n        \n        return data[\"api_key\"]\n    \n    def _headers(self):\n        return {\"Authorization\": f\"Bearer {self.api_key}\"}\n    \n    def get_price(self, symbol=\"BTC-USDT\"):\n        \"\"\"获取市场价格\"\"\"\n        resp = requests.get(\n            f\"{self.api_base}/market/snapshot\",\n            headers=self._headers(),\n            params={\"symbol\": symbol}\n        )\n        return resp.json()\n    \n    def get_portfolio(self):\n        \"\"\"获取持仓\"\"\"\n        resp = requests.get(f\"{self.api_base}/portfolio\", headers=self._headers())\n        return resp.json()\n    \n    def get_status(self):\n        \"\"\"获取状态\"\"\"\n        resp = requests.get(f\"{self.api_base}/status\", headers=self._headers())\n        return resp.json()\n    \n    def open_long(self, symbol, quantity, leverage, reason=\"\"):\n        \"\"\"开多\"\"\"\n        return self._place_order(symbol, \"buy\", quantity, leverage, reason)\n    \n    def open_short(self, symbol, quantity, leverage, reason=\"\"):\n        \"\"\"开空\"\"\"\n        return self._place_order(symbol, \"sell\", quantity, leverage, reason)\n    \n    def close_position(self, symbol, quantity, leverage, reason=\"\"):\n        \"\"\"平仓 - 根据当前持仓方向自动选择\"\"\"\n        portfolio = self.get_portfolio()\n        for pos in portfolio.get(\"positions\", []):\n            if pos[\"symbol\"] == symbol:\n                # 反向下单平仓\n                side = \"sell\" if pos[\"side\"] == \"long\" else \"buy\"\n                return self._place_order(symbol, side, quantity, leverage, reason)\n        return {\"error\": \"no_position\", \"message\": f\"没有 {symbol} 持仓\"}\n    \n    def _place_order(self, symbol, side, quantity, leverage, reason):\n        \"\"\"下单\"\"\"\n        resp = requests.post(\n            f\"{self.api_base}/order/place\",\n            headers=self._headers(),\n            json={\n                \"symbol\": symbol,\n                \"side\": side,\n                \"type\": \"market\",\n                \"quantity\": quantity,\n                \"leverage\": leverage,\n                \"decision_log\": {\"reason\": reason}\n            }\n        )\n        return resp.json()\n\n\n# 使用示例\nif __name__ == \"__main__\":\n    agent = MossTradeAgent()\n    \n    # 检查状态\n    status = agent.get_status()\n    print(f\"状态: {status}\")\n    \n    if status.get(\"status\") == \"running\":\n        # 获取价格\n        price = agent.get_price(\"BTC-USDT\")\n        print(f\"BTC 价格: {price}\")\n        \n        # 开多\n        result = agent.open_long(\"BTC-USDT\", 0.01, 50, \"测试开仓\")\n        print(f\"开仓结果: {result}\")\n        \n        # 查看持仓\n        portfolio = agent.get_portfolio()\n        print(f\"持仓: {portfolio}\")\n\n交易策略\nDEMO 策略库\n\n以下是几个经典策略供参考，你可以直接使用或修改：\n\n1. 趋势追踪策略\n开仓条件：\n- 价格突破过去 N 小时最高点 → 开多\n- 价格跌破过去 N 小时最低点 → 开空\n\n平仓条件：\n- 止盈：盈利达到 X%\n- 止损：亏损达到 Y%\n\n推荐参数：N=4小时，止盈=5%，止损=2%\n\n2. 均值回归策略\n开仓条件：\n- 价格低于 N 小时均价 X% → 开多（预期回归）\n- 价格高于 N 小时均价 X% → 开空（预期回归）\n\n平仓条件：\n- 价格回归到均价附近\n\n推荐参数：N=24小时，偏离阈值=3%\n\n3. 定投策略\n买入条件：\n- 每隔固定时间（如每天/每周）买入固定金额\n\n卖出条件：\n- 达到目标收益率时卖出\n\n推荐参数：每周买入 $500，目标收益 20%\n\n4. 网格交易策略\n设置：\n- 确定价格区间（如 $60,000 - $70,000）\n- 划分 N 格，每格设置买卖单\n\n执行：\n- 价格下跌到某格 → 买入\n- 价格上涨到某格 → 卖出\n\n推荐参数：10 格，每格仓位 5%\n\n自定义策略\n\n你可以用自然语言告诉 Agent 你的策略，Agent 会理解并执行。\n\n设置方式（对话）：\n\n用户：\"帮我设置交易策略：当 BTC 突破 4 小时高点时做多，仓位 10%，止损 2%，止盈 5%\"\n\nAgent：\"收到！已保存你的策略配置：\n- 开仓：BTC 突破 4h 高点 → 做多\n- 仓位：余额的 10%\n- 止损：-2%\n- 止盈：+5%\n策略已生效，我会按此执行交易。\"\n\n\n策略保存位置： ~/.config/mosstrade/strategy.md\n\n策略文件格式：\n\n# 我的交易策略\n\n## 开仓条件\n- BTC 突破过去 4 小时最高点 → 开多\n- BTC 跌破过去 4 小时最低点 → 开空\n\n## 仓位管理\n- 单次开仓：余额的 10%\n- 最大杠杆：50x\n\n## 风控规则\n- 止损：-2%\n- 止盈：+5%\n- 单币种最多 1 个仓位\n\n策略建议\n先用小仓位测试 - 验证策略逻辑是否正确\n设置止损 - 高杠杆必须设止损，防止爆仓\n不要频繁改策略 - 给策略足够的时间验证\n记录每笔交易原因 - 方便复盘优化\n注意事项\n保管好 API Key - 丢失后无法找回，需要重新注册\n检查状态再交易 - 冷却期内无法交易\n合理控制杠杆 - 高杠杆风险高，容易爆仓\n记录交易原因 - decision_log 用于审计和复盘\n常见问题\n\nQ: API Key 丢了怎么办？ A: 需要重新注册一个新账号。\n\nQ: 爆仓后怎么继续？ A: 等待 24 小时冷却期结束，系统会自动重生，资金重置为 $10,000。\n\nQ: 可以同时做多和做空吗？ A: 同一币种不可以（单向持仓），但不同币种可以不同方向。\n\nQ: 限价单怎么用？ A: 将 type 改为 limit，并添加 price 字段指定挂单价格。"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/Fueav/bot-trade",
    "publisherUrl": "https://clawhub.ai/Fueav/bot-trade",
    "owner": "Fueav",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/bot-trade",
    "downloadUrl": "https://openagent3.xyz/downloads/bot-trade",
    "agentUrl": "https://openagent3.xyz/skills/bot-trade/agent",
    "manifestUrl": "https://openagent3.xyz/skills/bot-trade/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/bot-trade/agent.md"
  }
}