Loading...
Loading...
Compare original and translation side by side
| 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 ( |
| 能力 | 是否必填 | 详情 |
|---|---|---|
| Shell 命令执行 | 是 | 必须能够运行 |
| 环境变量 | 是 | 必须能够从Shell环境中读取 |
| JSON 解析 | 是 | 必须能够解析脚本标准输出的结构化JSON,提取对应字段 |
| 多轮对话 | 是 | 交易采用「报价→确认」的流程,需要跨多个用户轮次完成 |
| 持久化内存 | 否 | 用于存储 |
| 时长感知 | 否 | 用于检查报价有效期( |
curlfetchnpx tsxcurlfetchnpx tsxhttps://wapi.crypto.com{{env.CDC_API_KEY}}{{env.CDC_API_SECRET}}{{memory.confirmation_required}}SKILL.md/home/user/skills/crypto-agent-trading/SKILL.mdSKILL_DIR/home/user/skills/crypto-agent-tradinghttps://wapi.crypto.com{{env.CDC_API_KEY}}{{env.CDC_API_SECRET}}{{memory.confirmation_required}}SKILL.md/home/user/skills/crypto-agent-trading/SKILL.mdSKILL_DIR/home/user/skills/crypto-agent-tradingCDC_API_KEYCDC_API_SECRETexport CDC_API_KEY="your-api-key"
export CDC_API_SECRET="your-api-secret"CDC_API_KEYCDC_API_SECRETexport CDC_API_KEY="your-api-key"
export CDC_API_SECRET="your-api-secret"npx tsxtsxnpx$SKILL_DIRcd./scripts/...npx tsxtsxnpx$SKILL_DIR./scripts/...undefinedundefinedundefinedundefinedundefinedundefined
**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.
**用户意图与交易类型的映射规则:**
| 用户表述 | 交易类型 | 转出 | 转入 |
|-----------|-----------|------|-----|
| "用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部分。undefinedundefined
**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`).
**必填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`)。{"ok": true, "data": { ... }}{"ok": false, "error": "ERROR_CODE", "error_message": "Human-readable message"}{"ok": true, "data": { ... }}{"ok": false, "error": "ERROR_CODE", "error_message": "可读性错误提示"}ok: truecountdownRATE_LIMITEDok: truecountdownRATE_LIMITEDerrorerrorerror| 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 |
okfalseerror| 错误码 | 含义 | Agent回复 |
|---|---|---|
| 未设置 | 告知用户需要通过终端设置环境变量 |
| API返回非200状态码或 | 报告:「交易失败:{error_message}」 |
| 命令行参数错误 | 展示 |
| API拒绝了报价请求 | 向用户报告 |
| 订单确认失败 | 报告并建议:「你可以使用「显示近期交易」查询订单状态」 |
| 密钥已被吊销或不存在 | 「API密钥未找到,可能已经被吊销。」 |
| 请求过多(HTTP 429) | 「已达到频率限制,请等待60秒后再尝试。」 |
| 未知错误 | 报告原始的 |
okfalseerror_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 |
errorerror_messageQUOTATION_FAILEDEXECUTION_FAILEDAPI_ERRORerror_message | 含义 | 恢复方案 |
|---|---|---|
| 余额不足 | 检查余额,减少交易金额 |
| 货币代码未被识别 | 通过币种搜索验证代码 |
| 报价已过期或已被使用 | 请求新的报价 |
| 报价引擎错误 | 稍后重试 |
| 不符合Prime权益资格 | 不使用Prime权益继续操作 |
| 账户未通过交易审核 | 联系客服 |
| 账户的该功能被限制 | 向用户报告 |
| 已有同币种订单正在处理中 | 等待或取消已有订单 |
| 法币兑加密货币功能未开启 | 账户功能不可用 |
| 加密货币兑法币功能未开启 | 账户功能不可用 |
| 银行转账功能未开启 | 账户功能不可用 |
| 缺少必填参数 | 脚本bug,请上报 |
| 交易创建失败 | 重试或联系客服 |
| API密钥已被吊销或过期 | 生成新的API密钥,更新环境变量 |
| 密钥不存在或属于其他用户 | 验证 |
errorerror_messagenpx tsx $SKILL_DIR/scripts/account.ts resolve-source purchasenpx tsx $SKILL_DIR/scripts/account.ts resolve-source saleexchangedata.statusSELECTEDdata.currencyAMBIGUOUSdata.optionsEMPTYnpx tsx $SKILL_DIR/scripts/account.ts balance [TOKEN]data.availabledata.balancefrom_amountnpx tsx $SKILL_DIR/scripts/account.ts resolve-source purchasenpx tsx $SKILL_DIR/scripts/account.ts resolve-source saleexchangedata.statusSELECTEDdata.currencyAMBIGUOUSdata.optionsEMPTYnpx tsx $SKILL_DIR/scripts/account.ts balance [TOKEN]data.availabledata.balancefrom_amountnpx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>'data.iddata.from_amountdata.to_amountdata.countdownmemory.confirmation_requiredtruecountdownnpx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <data.id>idnpx tsx $SKILL_DIR/scripts/trade.ts quote <type> '<json-params>'data.iddata.from_amountdata.to_amountdata.countdownmemory.confirmation_requiredtruecountdownidnpx tsx $SKILL_DIR/scripts/trade.ts confirm <type> <data.id>memory.confirmation_requiredfalsememory.confirmation_requiredtrue{{memory.*}}confirmation_requiredtruememory.confirmation_requiredfalsememory.confirmation_requiredtrue{{memory.*}}confirmation_requiredtrueokok: trueokfalseerrorokok: trueokfalseerrornpx tsx $SKILL_DIR/scripts/trade.ts historydatanpx tsx $SKILL_DIR/scripts/account.ts trading-limitnpx tsx $SKILL_DIR/scripts/account.ts balances fiatnpx tsx $SKILL_DIR/scripts/account.ts balances cryptonpx tsx $SKILL_DIR/scripts/account.ts balances allnpx tsx $SKILL_DIR/scripts/trade.ts historydatanpx tsx $SKILL_DIR/scripts/account.ts trading-limitnpx tsx $SKILL_DIR/scripts/account.ts balances fiatnpx tsx $SKILL_DIR/scripts/account.ts balances cryptonpx tsx $SKILL_DIR/scripts/account.ts balances allmemory.confirmation_requirednpx tsx $SKILL_DIR/scripts/account.ts revoke-keyok: trueAPI_KEY_NOT_FOUNDmemory.confirmation_requirednpx tsx $SKILL_DIR/scripts/account.ts revoke-keyok: trueAPI_KEY_NOT_FOUND