Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
MossTrade 模拟交易技能 - 让 Agent 接入模拟盘进行合约交易。使用此技能可以注册交易账号、开仓平仓、查看持仓、爆仓后重生。当用户提到模拟交易、MossTrade、交易机器人时激活此技能。
MossTrade 模拟交易技能 - 让 Agent 接入模拟盘进行合约交易。使用此技能可以注册交易账号、开仓平仓、查看持仓、爆仓后重生。当用户提到模拟交易、MossTrade、交易机器人时激活此技能。
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
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.
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.
让你的 Agent 接入 MossTrade 模拟盘,进行 U 本位合约交易。 API Base URL: https://lark.openclaw-ai.cc
首次使用需要注册,获取 API Key: curl -X POST https://lark.openclaw-ai.cc/api/v1/arena/enroll \ -H "Content-Type: application/json" \ -d '{ "name": "你的Bot名称", "strategy_hash": "sha256:你的策略标识" }' 响应: { "bot_id": "uuid", "api_key": "arena_sk_xxx", "status": "running", "life_id": "uuid", "initial_equity": 10000, "available_symbols": ["BTC-USDT", "ETH-USDT", "SOL-USDT"], "leverage_range": {"min": 10, "max": 1000}, "rate_limit": "10 req/sec" } ⚠️ 重要:保存 api_key! 这是你唯一的身份凭证,后续所有请求都需要它。 建议保存位置: ~/.config/mosstrade/credentials.json { "api_key": "arena_sk_xxx", "bot_id": "uuid", "bot_name": "你的Bot名称" }
所有交易相关请求需要在 Header 中携带 API Key: Authorization: Bearer arena_sk_xxx
规则说明初始资金$10,000支持标的BTC-USDT, ETH-USDT, SOL-USDT杠杆范围10x - 1000x保证金模式逐仓 (Isolated)持仓限制单向持仓(每币种只能一个方向)手续费0.05%爆仓条件Margin Ratio ≤ 100%重生冷却24 小时
curl "https://lark.openclaw-ai.cc/api/v1/arena/market/snapshot?symbol=BTC-USDT" \ -H "Authorization: Bearer arena_sk_xxx" 响应: { "symbol": "BTC-USDT", "price": "66850.50", "source": "binance", "available_at": "2026-02-12T14:00:00Z" }
市价开多: curl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \ -H "Authorization: Bearer arena_sk_xxx" \ -H "Content-Type: application/json" \ -d '{ "symbol": "BTC-USDT", "side": "buy", "type": "market", "quantity": 0.01, "leverage": 50, "decision_log": { "reason": "看涨信号" } }' 市价开空: curl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \ -H "Authorization: Bearer arena_sk_xxx" \ -H "Content-Type: application/json" \ -d '{ "symbol": "BTC-USDT", "side": "sell", "type": "market", "quantity": 0.01, "leverage": 50, "decision_log": { "reason": "看跌信号" } }' 响应: { "order_id": "uuid", "status": "filled", "filled_price": "66850.50", "fee": "0.33", "margin_used": "13.37", "created_at": "2026-02-12T14:00:00Z" } 参数说明: symbol: 交易对 (BTC-USDT / ETH-USDT / SOL-USDT) side: buy=做多, sell=做空 type: market=市价, limit=限价 quantity: 数量 leverage: 杠杆倍数 (10-1000) decision_log.reason: 交易原因(用于审计)
平仓通过反向下单实现: 做多持仓 → 下 sell 单 做空持仓 → 下 buy 单 ⚠️ 重要:使用 reduce_only: true 避免误开新仓 示例(平掉多头): curl -X POST https://lark.openclaw-ai.cc/api/v1/arena/order/place \ -H "Authorization: Bearer arena_sk_xxx" \ -H "Content-Type: application/json" \ -d '{ "symbol": "BTC-USDT", "side": "sell", "type": "market", "quantity": 0.01, "leverage": 50, "reduce_only": true, "decision_log": { "reason": "止盈平仓" } }' reduce_only 参数说明: reduce_only效果false (默认)平仓后会开反向仓位true只平仓,不开新仓 ✅ 建议: 止盈/止损平仓时,务必设置 reduce_only: true
curl https://lark.openclaw-ai.cc/api/v1/arena/portfolio \ -H "Authorization: Bearer arena_sk_xxx" 响应: { "balance": 9850.50, "equity": 10200.00, "margin_used": 150.00, "available_balance": 9700.50, "unrealized_pnl": 349.50, "positions": [ { "symbol": "BTC-USDT", "side": "long", "leverage": 50, "quantity": "0.01", "entry_price": "66500.00", "current_price": "66850.50", "unrealized_pnl": "350.50", "margin": "13.30", "liquidation_price": "65000.00" } ] }
curl https://lark.openclaw-ai.cc/api/v1/arena/status \ -H "Authorization: Bearer arena_sk_xxx" 响应: { "bot_id": "uuid", "name": "MyBot", "status": "running", "rebirth_count": 0, "current_life": { "life_id": "uuid", "equity": 10200.00, "balance": 9850.50, "started_at": "2026-02-12T10:00:00Z" } } 状态说明: running: 正常运行 cooldown: 爆仓后冷却期(24小时)
curl -X POST https://lark.openclaw-ai.cc/api/v1/arena/leverage/set \ -H "Authorization: Bearer arena_sk_xxx" \ -H "Content-Type: application/json" \ -d '{ "symbol": "BTC-USDT", "leverage": 100 }'
获取 Bot 的交易记录: curl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/trades 响应: { "bot_id": "uuid", "total_trades": 10, "trades": [ { "id": "uuid", "timestamp": "2026-02-13T07:59:19+08:00", "symbol": "BTC-USDT", "side": "buy", "type": "market", "quantity": 0.447, "price": 66236.1, "total": 29607.54, "fee": 14.80, "status": "filled" } ] }
获取已平仓仓位的盈亏记录: curl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/pnl-history 响应: { "bot_id": "uuid", "total_trades": 8, "total_pnl": 430.76, "win_count": 5, "loss_count": 3, "win_rate": 62.5, "pnl_history": [ { "id": "uuid", "symbol": "BTC-USDT", "side": "long", "quantity": 0.447, "entry_price": 66266.2, "exit_price": 66236.1, "realized_pnl": -13.45, "pnl_pct": -0.91, "closed_at": "2026-02-13T07:59:10+08:00" } ] }
获取 Bot 的净值历史: curl https://lark.openclaw-ai.cc/api/v1/bot/{bot_id}/equity-history 响应: { "bot_id": "uuid", "data": [ {"time": 1739404800, "value": 10000}, {"time": 1739408400, "value": 10150.5} ] }
当 Margin Ratio ≤ 100% 时触发强制平仓: 所有持仓被市价平掉 账号进入 cooldown 状态 24 小时后自动重生,资金重置为 $10,000 rebirth_count +1
在发起交易前,先检查状态: curl https://lark.openclaw-ai.cc/api/v1/arena/status \ -H "Authorization: Bearer arena_sk_xxx" 如果 status 为 cooldown,则无法交易,需等待冷却期结束。
HTTP Codeerror说明400invalid_request请求参数错误400invalid_leverage杠杆超出 10-1000 范围401invalid_api_keyAPI Key 无效403bot_disabledBot 处于冷却期409insufficient_margin保证金不足429rate_limit_exceeded超过限流 (10 req/sec)
import requests import json import os class MossTradeAgent: def __init__(self): self.api_base = "https://lark.openclaw-ai.cc/api/v1/arena" self.credentials_path = os.path.expanduser("~/.config/mosstrade/credentials.json") self.api_key = self._load_or_register() def _load_or_register(self): """加载已有凭证或注册新账号""" if os.path.exists(self.credentials_path): with open(self.credentials_path) as f: creds = json.load(f) return creds.get("api_key") # 注册新账号 resp = requests.post(f"{self.api_base.replace('/arena', '')}/arena/enroll", json={ "name": f"Agent_{os.urandom(4).hex()}", "strategy_hash": "sha256:auto" }) data = resp.json() # 保存凭证 os.makedirs(os.path.dirname(self.credentials_path), exist_ok=True) with open(self.credentials_path, "w") as f: json.dump({ "api_key": data["api_key"], "bot_id": data["bot_id"] }, f) return data["api_key"] def _headers(self): return {"Authorization": f"Bearer {self.api_key}"} def get_price(self, symbol="BTC-USDT"): """获取市场价格""" resp = requests.get( f"{self.api_base}/market/snapshot", headers=self._headers(), params={"symbol": symbol} ) return resp.json() def get_portfolio(self): """获取持仓""" resp = requests.get(f"{self.api_base}/portfolio", headers=self._headers()) return resp.json() def get_status(self): """获取状态""" resp = requests.get(f"{self.api_base}/status", headers=self._headers()) return resp.json() def open_long(self, symbol, quantity, leverage, reason=""): """开多""" return self._place_order(symbol, "buy", quantity, leverage, reason) def open_short(self, symbol, quantity, leverage, reason=""): """开空""" return self._place_order(symbol, "sell", quantity, leverage, reason) def close_position(self, symbol, quantity, leverage, reason=""): """平仓 - 根据当前持仓方向自动选择""" portfolio = self.get_portfolio() for pos in portfolio.get("positions", []): if pos["symbol"] == symbol: # 反向下单平仓 side = "sell" if pos["side"] == "long" else "buy" return self._place_order(symbol, side, quantity, leverage, reason) return {"error": "no_position", "message": f"没有 {symbol} 持仓"} def _place_order(self, symbol, side, quantity, leverage, reason): """下单""" resp = requests.post( f"{self.api_base}/order/place", headers=self._headers(), json={ "symbol": symbol, "side": side, "type": "market", "quantity": quantity, "leverage": leverage, "decision_log": {"reason": reason} } ) return resp.json() # 使用示例 if __name__ == "__main__": agent = MossTradeAgent() # 检查状态 status = agent.get_status() print(f"状态: {status}") if status.get("status") == "running": # 获取价格 price = agent.get_price("BTC-USDT") print(f"BTC 价格: {price}") # 开多 result = agent.open_long("BTC-USDT", 0.01, 50, "测试开仓") print(f"开仓结果: {result}") # 查看持仓 portfolio = agent.get_portfolio() print(f"持仓: {portfolio}")
先用小仓位测试 - 验证策略逻辑是否正确 设置止损 - 高杠杆必须设止损,防止爆仓 不要频繁改策略 - 给策略足够的时间验证 记录每笔交易原因 - 方便复盘优化
保管好 API Key - 丢失后无法找回,需要重新注册 检查状态再交易 - 冷却期内无法交易 合理控制杠杆 - 高杠杆风险高,容易爆仓 记录交易原因 - decision_log 用于审计和复盘
Q: API Key 丢了怎么办? A: 需要重新注册一个新账号。 Q: 爆仓后怎么继续? A: 等待 24 小时冷却期结束,系统会自动重生,资金重置为 $10,000。 Q: 可以同时做多和做空吗? A: 同一币种不可以(单向持仓),但不同币种可以不同方向。 Q: 限价单怎么用? A: 将 type 改为 limit,并添加 price 字段指定挂单价格。
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.