crypto-agent-trading
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: crypto-agent-trading
技能:crypto-agent-trading
Agent Capability Requirements
Agent 能力要求
This skill requires your agent platform to support the following capabilities. If your platform lacks any required capability, the skill will not function.
| Capability | Required | Details |
|---|---|---|
| Shell command execution | Yes | Must be able to run |
| Environment variables | Yes | Must read |
| JSON parsing | Yes | Must parse structured JSON from script stdout to extract fields |
| Multi-turn conversation | Yes | Trading uses a quote → confirm flow that spans multiple user turns |
| Persistent memory | No | Used for |
| Elapsed-time awareness | No | Used to check quote expiry ( |
本技能要求你的Agent平台支持以下能力。如果你的平台缺少任意必填能力,技能将无法正常运行。
| 能力 | 是否必填 | 详情 |
|---|---|---|
| Shell 命令执行 | 是 | 必须能够运行 |
| 环境变量 | 是 | 必须能够从Shell环境中读取 |
| JSON 解析 | 是 | 必须能够解析脚本标准输出的结构化JSON,提取对应字段 |
| 多轮对话 | 是 | 交易采用「报价→确认」的流程,需要跨多个用户轮次完成 |
| 持久化内存 | 否 | 用于存储 |
| 时长感知 | 否 | 用于检查报价有效期( |
CRITICAL: How This Skill Works
重要提示:本技能的运行逻辑
You MUST use the TypeScript scripts for ALL API interactions. NEVER call the API directly with , , or any other HTTP method.
curlfetchThe scripts handle request signing, error handling, and response formatting. If you bypass them:
- The request will fail (missing HMAC signature)
- The response won't be filtered or structured
For every user request, find the matching command below and run it via . Read the JSON output. Act on it.
npx tsx所有API交互必须使用TypeScript脚本完成。绝对不要直接用、或其他HTTP方法调用API。
curlfetch脚本会处理请求签名、错误处理和响应格式化。如果你绕过脚本:
- 请求会失败(缺少HMAC签名)
- 响应不会经过过滤或结构化处理
对于每一个用户请求,找到下方匹配的命令,通过运行,读取JSON输出后执行对应操作。
npx tsxConfigurations
配置项
- BASE_URL:
https://wapi.crypto.com - CDC_API_KEY:
{{env.CDC_API_KEY}} - CDC_API_SECRET:
{{env.CDC_API_SECRET}} - CONFIRMATION_REQUIRED: (Default: true)
{{memory.confirmation_required}} - SKILL_DIR: The directory containing this file. Resolve it from the path you loaded this file from (e.g. if you read
SKILL.md, then/home/user/skills/crypto-agent-trading/SKILL.mdisSKILL_DIR)./home/user/skills/crypto-agent-trading
- BASE_URL:
https://wapi.crypto.com - CDC_API_KEY:
{{env.CDC_API_KEY}} - CDC_API_SECRET:
{{env.CDC_API_SECRET}} - CONFIRMATION_REQUIRED: (默认值: true)
{{memory.confirmation_required}} - SKILL_DIR: 存储当前文件的目录。从你加载该文件的路径解析(比如你读取的是
SKILL.md,那么/home/user/skills/crypto-agent-trading/SKILL.md就是SKILL_DIR)。/home/user/skills/crypto-agent-trading
Environment Setup
环境配置
- Both and
CDC_API_KEYmust be set as environment variables before use.CDC_API_SECRET - If either is missing, instruct the user to set them via the terminal:
export CDC_API_KEY="your-api-key" export CDC_API_SECRET="your-api-secret" - Do NOT accept these values inline in chat or store them in files. Always direct users to set them via terminal for security.
- 使用前必须先设置 和
CDC_API_KEY两个环境变量。CDC_API_SECRET - 如果任意变量缺失,指导用户通过终端设置:
export CDC_API_KEY="your-api-key" export CDC_API_SECRET="your-api-secret" - 不要接受聊天中输入的这些值,也不要将它们存储在文件中。出于安全考虑,始终指导用户通过终端设置。
Script Commands
脚本命令
ALL API interactions MUST go through these scripts. They handle signing, execution, filtering, and error formatting. Run the appropriate command below via shell, then parse the JSON output.
Prerequisite: (Node.js 18+ required; is fetched automatically by ).
npx tsxtsxnpxImportant: All script paths below use as a placeholder for this skill's root directory. Resolve it from the path you loaded this SKILL.md from, or into the skill directory and use as the path. Either approach works.
$SKILL_DIRcd./scripts/...所有API交互必须通过这些脚本完成。 它们会处理签名、执行、过滤和错误格式化。通过Shell运行下方对应的命令,然后解析JSON输出。
前置依赖: (需要Node.js 18+版本;会被自动拉取)。
npx tsxtsxnpx注意: 下方所有脚本路径使用 作为本技能根目录的占位符。你可以从加载该SKILL.md的路径解析,或者cd到技能目录后使用 作为路径,两种方式都有效。
$SKILL_DIR./scripts/...Account Commands
账户相关命令
bash
undefinedbash
undefinedFiltered non-zero balances (scope: fiat | crypto | all)
过滤后的非零余额(范围: fiat | crypto | all)
npx tsx $SKILL_DIR/scripts/account.ts balances [fiat|crypto|all]
npx tsx $SKILL_DIR/scripts/account.ts balances [fiat|crypto|all]
Single token balance lookup
单个代币余额查询
npx tsx $SKILL_DIR/scripts/account.ts balance <SYMBOL>
npx tsx $SKILL_DIR/scripts/account.ts balance <SYMBOL>
Weekly trading limit
周交易限额
npx tsx $SKILL_DIR/scripts/account.ts trading-limit
npx tsx $SKILL_DIR/scripts/account.ts trading-limit
Find funded source wallets for a trade type
查询对应交易类型的已充值来源钱包
npx tsx $SKILL_DIR/scripts/account.ts resolve-source <purchase|sale|exchange>
npx tsx $SKILL_DIR/scripts/account.ts resolve-source <purchase|sale|exchange>
Kill switch — revoke API key
Kill开关 — 吊销API密钥
npx tsx $SKILL_DIR/scripts/account.ts revoke-key
undefinednpx tsx $SKILL_DIR/scripts/account.ts revoke-key
undefinedTrade Commands
交易相关命令
Trading follows a two-step flow: get a quotation first, then confirm the order.
bash
undefined交易遵循两步流程:先获取报价,再确认订单。
bash
undefinedStep 1 — Get quotation (type: purchase | sale | exchange)
步骤1 — 获取报价(类型: purchase | sale | exchange)
npx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>'
npx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>'
Returns: {"ok": true, "data": {"id": "<quotation-id>", "from_amount": {...}, "to_amount": {...}, "countdown": 15, ...}}
返回: {"ok": true, "data": {"id": "<quotation-id>", "from_amount": {...}, "to_amount": {...}, "countdown": 15, ...}}
Step 2 — Confirm order: pass the data.id from Step 1 as <quotation-id>
步骤2 — 确认订单:将步骤1返回的data.id作为<quotation-id>传入
npx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <quotation-id>
npx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <quotation-id>
View recent transactions
查看近期交易
npx tsx $SKILL_DIR/scripts/trade.ts history
**How to map user intent to trade type:**
| User says | Trade type | From | To |
|-----------|-----------|------|-----|
| "Buy CRO with 100 USD" | `purchase` | USD (fiat) | CRO (crypto) |
| "Sell 0.1 BTC" | `sale` | BTC (crypto) | USD (fiat) |
| "Swap 0.1 BTC to ETH" | `exchange` | BTC (crypto) | ETH (crypto) |
**Quotation JSON params by trade type:**
| Type | JSON fields |
|------|------------|
| purchase | `{"from_currency":"USD","to_currency":"CRO","from_amount":"100"}` or use `to_amount` instead |
| sale | `{"from_currency":"BTC","to_currency":"USD","from_amount":"0.1","fixed_side":"from"}` |
| exchange | `{"from_currency":"BTC","to_currency":"ETH","from_amount":"0.1","side":"buy"}` |
**Example — "Buy CRO with 100 USD":**
1. Run: `npx tsx $SKILL_DIR/scripts/trade.ts quote purchase '{"from_currency":"USD","to_currency":"CRO","from_amount":"100"}'`
2. Read `data.id`, `data.from_amount`, `data.to_amount`, `data.countdown` from the response.
3. **If confirmation required** (default): Ask user "Confirm: 100 USD for X CRO? Valid for {countdown}s. Reply 'YES' to proceed."
- If user says YES (within countdown): `npx tsx $SKILL_DIR/scripts/trade.ts confirm purchase <data.id>`
4. **If confirmation opted out** (`memory.confirmation_required` is `false`): Skip asking and immediately run `npx tsx $SKILL_DIR/scripts/trade.ts confirm purchase <data.id>`
**Opt-in / Opt-out:** Users can say "stop asking for confirmation" to auto-execute trades, or "require confirmation" to re-enable the prompt. See Section 3 below.npx tsx $SKILL_DIR/scripts/trade.ts history
**用户意图与交易类型的映射规则:**
| 用户表述 | 交易类型 | 转出 | 转入 |
|-----------|-----------|------|-----|
| "用100美元买CRO" | `purchase` | USD (法币) | CRO (加密货币) |
| "卖出0.1个BTC" | `sale` | BTC (加密货币) | USD (法币) |
| "把0.1个BTC换成ETH" | `exchange` | BTC (加密货币) | ETH (加密货币) |
**不同交易类型对应的报价JSON参数:**
| 类型 | JSON字段 |
|------|------------|
| purchase | `{"from_currency":"USD","to_currency":"CRO","from_amount":"100"}` 也可以使用`to_amount`代替 |
| sale | `{"from_currency":"BTC","to_currency":"USD","from_amount":"0.1","fixed_side":"from"}` |
| exchange | `{"from_currency":"BTC","to_currency":"ETH","from_amount":"0.1","side":"buy"}` |
**示例 — 「用100美元买CRO」:**
1. 运行:`npx tsx $SKILL_DIR/scripts/trade.ts quote purchase '{"from_currency":"USD","to_currency":"CRO","from_amount":"100"}'`
2. 从响应中读取 `data.id`、`data.from_amount`、`data.to_amount`、`data.countdown`。
3. **如果需要确认**(默认设置):询问用户「确认:用100美元兑换X CRO?报价有效期为{countdown}秒。回复「YES」继续。」
- 如果用户在倒计时内回复YES:运行 `npx tsx $SKILL_DIR/scripts/trade.ts confirm purchase <data.id>`
4. **如果已关闭确认要求**(`memory.confirmation_required` 为 `false`):跳过询问,直接运行 `npx tsx $SKILL_DIR/scripts/trade.ts confirm purchase <data.id>`
**开启/关闭确认:** 用户可以说「停止询问确认」来自动执行交易,或者说「需要确认」来重新开启提示。详情见下文第3部分。Coin Discovery Commands
币种发现命令
bash
undefinedbash
undefinedSearch coins
搜索币种
npx tsx $SKILL_DIR/scripts/coins.ts search '{"keyword":"BTC","sort_by":"rank","sort_direction":"asc","native_currency":"USD","page_size":10}'
**Required JSON parameters:**
| Parameter | Type | Allowed values |
|-----------|------|----------------|
| `sort_by` | string | `rank`, `market_cap`, `alphabetical`, `volume`, `performance` |
| `sort_direction` | string | `asc`, `desc` |
| `native_currency` | string | Uppercase currency code (e.g. `USD`) |
| `keyword` | string | Search string, 1–100 chars; matches coin name and symbol only |
| `page_size` | integer | Number of results per page |
**Optional:** `page_token` — opaque token for fetching the next page (see pagination below).
**Pagination:** The response includes a `pagination` object with `has_more` (boolean) and `next_page_token` (string). When `has_more` is `true`, pass `next_page_token` as `page_token` in the next request to fetch the next page.
**Key response fields per coin:** `rails_id` (identical to `currency_id` / `currency` in trade and account APIs — use this to cross-reference), `price_native`, `price_usd`, `percent_change_*_native` (price performance over past timeframes, e.g. `percent_change_24h_native`).npx tsx $SKILL_DIR/scripts/coins.ts search '{"keyword":"BTC","sort_by":"rank","sort_direction":"asc","native_currency":"USD","page_size":10}'
**必填JSON参数:**
| 参数 | 类型 | 允许值 |
|-----------|------|----------------|
| `sort_by` | string | `rank`、`market_cap`、`alphabetical`、`volume`、`performance` |
| `sort_direction` | string | `asc`、`desc` |
| `native_currency` | string | 大写货币代码(比如 `USD`) |
| `keyword` | string | 搜索字符串,长度1-100字符;仅匹配币种名称和代码 |
| `page_size` | 整数 | 每页返回的结果数量 |
**可选参数:** `page_token` — 用于获取下一页内容的不透明令牌(见下方分页说明)。
**分页:** 响应包含`pagination`对象,有`has_more`(布尔值)和`next_page_token`(字符串)两个字段。当`has_more`为`true`时,将`next_page_token`作为`page_token`传入下一次请求来获取下一页内容。
**每个币种的核心响应字段:** `rails_id`(和交易、账户API中的`currency_id`/`currency`一致,可用于跨接口关联)、`price_native`、`price_usd`、`percent_change_*_native`(过去时间段的价格表现,比如`percent_change_24h_native`)。Output Format
输出格式
Every script prints structured JSON to stdout:
Success:
json
{"ok": true, "data": { ... }}Error:
json
{"ok": false, "error": "ERROR_CODE", "error_message": "Human-readable message"}每个脚本都会向标准输出打印结构化JSON:
成功:
json
{"ok": true, "data": { ... }}错误:
json
{"ok": false, "error": "ERROR_CODE", "error_message": "可读性错误提示"}Constraints
约束
- Validation: Success requires in the script output.
ok: true - Confirmation Window: Quote validity is defined by the field in the quotation data.
countdown - Execution Warning: If order confirmation takes > 5s, notify: "Order submitted but taking longer than expected. Check order status with 'Show recent trades'".
- Rate Limits:
- Max 10 trades per minute.
- Max 100 API calls per minute.
- On HTTP 429 (error): wait 60 seconds before retrying the same request. Inform the user: "Rate limit reached — please wait 60 seconds before trying again."
RATE_LIMITED
- 校验规则: 脚本输出中包含才算执行成功。
ok: true - 确认窗口: 报价有效期由报价数据中的字段定义。
countdown - 执行提示: 如果订单确认耗时超过5秒,通知用户:「订单已提交,但耗时超出预期。你可以使用「显示近期交易」查询订单状态。」
- 频率限制:
- 每分钟最多10笔交易。
- 每分钟最多100次API调用。
- 收到HTTP 429(错误):等待60秒再重试相同请求。告知用户:「已达到频率限制,请等待60秒后再尝试。」
RATE_LIMITED
Error Handling
错误处理
All scripts return structured errors. Parse the field to determine the appropriate response.
error所有脚本都会返回结构化错误。解析字段来生成对应的回复。
errorScript Error Codes
脚本错误码
These are the values in the script's JSON output. They tell you what category of failure occurred.
error| Error Code | Meaning | Agent Response |
|---|---|---|
| | Tell user to set env vars via terminal |
| API returned non-200 or | Report: "Transaction failed: {error_message}" |
| Bad command-line arguments | Show correct usage from the |
| Quotation request rejected by API | Report the |
| Order confirmation failed | Report and suggest: "Check order status with 'Show recent trades'" |
| Key already revoked or does not exist | "API key not found — it may have already been revoked." |
| Too many requests (HTTP 429) | "Rate limit reached — please wait 60 seconds before trying again." |
| Unexpected error | Report the raw |
Rule: When is in the output, stop the current operation and report the error to the user using the guidance above. Never proceed to the next step after a failure.
okfalse这些是脚本JSON输出中的值,用于标识失败的类别。
error| 错误码 | 含义 | Agent回复 |
|---|---|---|
| 未设置 | 告知用户需要通过终端设置环境变量 |
| API返回非200状态码或 | 报告:「交易失败:{error_message}」 |
| 命令行参数错误 | 展示 |
| API拒绝了报价请求 | 向用户报告 |
| 订单确认失败 | 报告并建议:「你可以使用「显示近期交易」查询订单状态」 |
| 密钥已被吊销或不存在 | 「API密钥未找到,可能已经被吊销。」 |
| 请求过多(HTTP 429) | 「已达到频率限制,请等待60秒后再尝试。」 |
| 未知错误 | 报告原始的 |
规则: 当输出中为时,停止当前操作,按照上方指引向用户报告错误。失败后绝对不要继续执行下一步。
okfalseCommon API Errors (Quick Reference)
常见API错误(快速参考)
These are the specific API error codes that appear inside the of , , or responses. They tell you why the API rejected the request.
error_messageQUOTATION_FAILEDEXECUTION_FAILEDAPI_ERROR | Meaning | Recovery |
|---|---|---|
| Insufficient funds | Check balances, reduce trade amount |
| Currency code not recognized | Verify via coin search |
| Quote expired or already used | Request a new quotation |
| Quotation engine error | Retry shortly |
| Not eligible for Prime benefits | Proceed without Prime |
| Account not approved for trading | Contact support |
| Feature restricted on account | Report |
| An existing order is in progress | Wait or cancel existing order |
| Fiat-to-crypto not enabled | Account feature not available |
| Crypto-to-fiat not enabled | Account feature not available |
| Bank transfer not enabled | Account feature not available |
| Required parameter missing | Script bug — report it |
| Transaction creation failed | Retry or contact support |
| API key revoked or expired | Generate a new API key, update env vars |
| Key doesn't exist or belongs to another user | Verify correct key is set in |
For dynamic errors (limit exceeded, currency disabled, cooling-off, etc.), report the and directly to the user. For full details, see references/errors.md.
errorerror_message这些是出现在、或响应的中的特定API错误码,用于说明API拒绝请求的具体原因。
QUOTATION_FAILEDEXECUTION_FAILEDAPI_ERRORerror_message | 含义 | 恢复方案 |
|---|---|---|
| 余额不足 | 检查余额,减少交易金额 |
| 货币代码未被识别 | 通过币种搜索验证代码 |
| 报价已过期或已被使用 | 请求新的报价 |
| 报价引擎错误 | 稍后重试 |
| 不符合Prime权益资格 | 不使用Prime权益继续操作 |
| 账户未通过交易审核 | 联系客服 |
| 账户的该功能被限制 | 向用户报告 |
| 已有同币种订单正在处理中 | 等待或取消已有订单 |
| 法币兑加密货币功能未开启 | 账户功能不可用 |
| 加密货币兑法币功能未开启 | 账户功能不可用 |
| 银行转账功能未开启 | 账户功能不可用 |
| 缺少必填参数 | 脚本bug,请上报 |
| 交易创建失败 | 重试或联系客服 |
| API密钥已被吊销或过期 | 生成新的API密钥,更新环境变量 |
| 密钥不存在或属于其他用户 | 验证 |
对于动态错误(超出限额、货币禁用、冷却期等),直接向用户报告和。完整详情请参考 references/errors.md。
errorerror_messageLogic & Rules
逻辑与规则
1. Asset & Source Disambiguation
1. 资产与来源歧义处理
Determine the trade type first:
- Purchase — fiat → crypto
- Sale — crypto → fiat
- Exchange — crypto → crypto
Then resolve the source wallet:
- For purchase: run . The script returns only funded fiat entries.
npx tsx $SKILL_DIR/scripts/account.ts resolve-source purchase - For sale or exchange: run (or
npx tsx $SKILL_DIR/scripts/account.ts resolve-source sale). The script returns only funded crypto entries.exchange
Result (from ):
data.status- → auto-select
SELECTED.data.currency - → prompt user to choose from
AMBIGUOUS.data.options - → inform user "No funded wallets found" and stop.
EMPTY
"Sell All" Scenario: If user says "Sell all [TOKEN]", run . Use the amount (or ) as for the quotation.
npx tsx $SKILL_DIR/scripts/account.ts balance [TOKEN]data.availabledata.balancefrom_amount首先确定交易类型:
- 买入(Purchase) — 法币 → 加密货币
- 卖出(Sale) — 加密货币 → 法币
- 兑换(Exchange) — 加密货币 → 加密货币
然后解析来源钱包:
- 对于买入:运行 。脚本仅返回有余额的法币条目。
npx tsx $SKILL_DIR/scripts/account.ts resolve-source purchase - 对于卖出或兑换:运行 (或
npx tsx $SKILL_DIR/scripts/account.ts resolve-source sale)。脚本仅返回有余额的加密货币条目。exchange
结果(从获取):
data.status- → 自动选择
SELECTED。data.currency - → 提示用户从
AMBIGUOUS中选择。data.options - → 告知用户「未找到有余额的钱包」并停止操作。
EMPTY
「全部卖出」场景: 如果用户说「卖出全部[TOKEN]」,运行 。使用金额(或)作为报价的。
npx tsx $SKILL_DIR/scripts/account.ts balance [TOKEN]data.availabledata.balancefrom_amount2. Trading Process (Quotation → Confirmation → Execution)
2. 交易流程(报价→确认→执行)
When the user asks to buy, sell, or swap crypto, always follow this three-step flow:
-
Step A — Get Quotation: Build the JSON params from the user's request (see the "Quotation JSON params" table in Trade Commands) and run:Read
npx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>',data.id,data.from_amount, anddata.to_amountfrom the response.data.countdown -
Step B — Ask User to Confirm:
- IF is
memory.confirmation_required(or unset):true- Prompt: "Confirm: {from_amount} for {to_amount}? Valid for {countdown}s. Reply 'YES' to proceed."
- Expiration Logic: If the user replies "YES" after seconds have elapsed, reject: "Transaction rejected: The quotation rate has expired. Please request a new quote."
countdown - Execute Step C ONLY if user replies "YES" within the valid window.
- ELSE (Opted Out):
- Notify: "Quotation received. Proceeding to execution automatically..."
- Immediately proceed to Step C.
- IF
-
Step C — Execute Order: Run:using the
npx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <data.id>from Step A.id
当用户要求买入、卖出或swap加密货币时,必须遵循以下三步流程:
-
步骤A — 获取报价: 根据用户请求构建JSON参数(参考交易命令中的「报价JSON参数」表格),运行:从响应中读取
npx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>'、data.id、data.from_amount和data.to_amount。data.countdown -
步骤B — 询问用户确认:
- 如果 为
memory.confirmation_required(或未设置):true- 提示:「确认:用{from_amount}兑换{to_amount}?报价有效期为{countdown}秒。回复「YES」继续。」
- 过期逻辑: 如果用户在秒后才回复「YES」,拒绝请求:「交易已拒绝:报价已过期,请请求新的报价。」
countdown - 仅当用户在有效期内回复「YES」时才执行步骤C。
- 否则(已关闭确认):
- 通知:「已收到报价,自动执行交易中...」
- 直接进入步骤C。
- 如果
-
步骤C — 执行订单: 使用步骤A返回的运行:
id。npx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <data.id>
3. Memory Management (Opt-in/Out)
3. 内存管理(确认开关)
- To Opt-out: If user says "stop asking for confirmation" or "enable auto-trade", update to
memory.confirmation_required.false - To Opt-in: If user says "require confirmation" or "enable manual trade", update to
memory.confirmation_required.true - Platforms without persistent memory: If your platform does not support , treat
{{memory.*}}as alwaysconfirmation_required(safest default).true
- 关闭确认: 如果用户说「停止询问确认」或「开启自动交易」,将更新为
memory.confirmation_required。false - 开启确认: 如果用户说「需要确认」或「开启手动交易」,将更新为
memory.confirmation_required。true - 无持久化内存的平台: 如果你的平台不支持,将
{{memory.*}}始终视为confirmation_required(最安全的默认值)。true
4. Error Handling
4. 错误处理
- All script outputs include an field. Success is defined ONLY as
ok.ok: true - If is
ok, readfalseand respond per the Error Handling table above.error - Never proceed to the next step after a failed command.
- 所有脚本输出都包含字段。仅当
ok时才算执行成功。ok: true - 如果为
ok,读取false并按照上方错误处理表格的要求回复。error - 命令失败后绝对不要继续执行下一步。
5. Account & History
5. 账户与历史查询
- History: Run — display the entries from
npx tsx $SKILL_DIR/scripts/trade.ts history.data - Weekly Trading Limit: Run — display as: "📊 Weekly Trading Limit: {data.used} / {data.limit} USD (Remaining: {data.remaining} USD)".
npx tsx $SKILL_DIR/scripts/account.ts trading-limit - Balances (Categorized):
- If "List Fiat": run .
npx tsx $SKILL_DIR/scripts/account.ts balances fiat - If "List Crypto": run .
npx tsx $SKILL_DIR/scripts/account.ts balances crypto - If "List All": run . Crucial: Display Fiat category first, followed by Crypto balances below.
npx tsx $SKILL_DIR/scripts/account.ts balances all - The scripts automatically filter out zero-balance entries. If a category has no entries in the output, display "No holdings" under that header.
- If "List Fiat": run
- 交易历史: 运行 — 展示
npx tsx $SKILL_DIR/scripts/trade.ts history中的条目。data - 周交易限额: 运行 — 展示为:「📊 周交易限额:{data.used} / {data.limit} 美元(剩余:{data.remaining} 美元)」。
npx tsx $SKILL_DIR/scripts/account.ts trading-limit - 余额(分类展示):
- 如果是「列出法币余额」:运行 。
npx tsx $SKILL_DIR/scripts/account.ts balances fiat - 如果是「列出加密货币余额」:运行 。
npx tsx $SKILL_DIR/scripts/account.ts balances crypto - 如果是「列出全部余额」:运行 。重要: 先展示法币分类,再展示加密货币余额。
npx tsx $SKILL_DIR/scripts/account.ts balances all - 脚本会自动过滤余额为0的条目。如果输出中某个分类没有条目,在该标题下展示「暂无持仓」。
- 如果是「列出法币余额」:运行
6. Kill Switch
6. Kill开关
- Trigger: User says "STOP ALL TRADING", "kill switch", or similar emergency stop command.
- ALWAYS require explicit confirmation regardless of :
memory.confirmation_required- Prompt: "⚠️ WARNING: This will immediately revoke your API key and disable all trading. A new API key must be generated to resume. Type 'CONFIRM KILL SWITCH' to proceed."
- Execute ONLY if user replies with the exact phrase.
- Execution: Run .
npx tsx $SKILL_DIR/scripts/account.ts revoke-key - On success (): Notify: "🛑 Kill switch activated. API key has been revoked. All trading is disabled. Generate a new API key and update your environment variables to resume."
ok: true - On error: Notify: "API key not found — it may have already been revoked or does not exist."
API_KEY_NOT_FOUND - Idempotency: Revoking an already-revoked key is not an error; treat it the same as a successful revocation.
- 触发条件: 用户说「停止所有交易」、「kill开关」或类似的紧急停止命令。
- 无论设置如何,必须要求显式确认:
memory.confirmation_required- 提示:「⚠️ 警告:该操作会立即吊销你的API密钥,禁用所有交易功能。你需要生成新的API密钥才能恢复交易。输入「CONFIRM KILL SWITCH」继续。」
- 仅当用户回复完全匹配的短语时才执行操作。
- 执行: 运行 。
npx tsx $SKILL_DIR/scripts/account.ts revoke-key - 执行成功(): 通知:「🛑 Kill开关已激活。API密钥已被吊销,所有交易功能已禁用。你需要生成新的API密钥并更新环境变量才能恢复交易。」
ok: true - 返回错误: 通知:「API密钥未找到,可能已经被吊销或不存在。」
API_KEY_NOT_FOUND - 幂等性: 吊销已被吊销的密钥不算错误,按照成功吊销处理即可。
7. Balance Display Format
7. 余额展示格式
- Fiat Header: "🏦 Fiat Balances"
- Crypto Header: "🪙 Crypto Balances"
- Always list Fiat section before Crypto section when both are requested.
- Never display zero-balance assets. Only show assets with a balance greater than 0. If all assets in a category are zero, show "No holdings" under that header.
- 法币标题: 「🏦 法币余额」
- 加密货币标题: 「🪙 加密货币余额」
- 同时请求两类余额时,始终先展示法币部分,再展示加密货币部分。
- 绝对不要展示余额为0的资产。 仅展示余额大于0的资产。如果某个分类下所有资产余额都是0,在该标题下展示「暂无持仓」。