opentrade-portfolio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenTrade Wallet Portfolio CLI
OpenTrade 钱包投资组合CLI
4 commands for supported chains, wallet total value, all token balances, and specific token balances.
提供4个命令,用于查询支持的链、钱包总资产价值、所有代币余额、指定代币余额。
Pre-flight Checks
前置检查
Every time before running any command, always follow these steps in order. Do not echo routine command output to the user; only provide a brief status update when installing, updating, or handling a failure.
opentrade-
Confirm installed: Run. If not found, install it:
which opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | shIf the install script fails, ask the user to install manually following the instructions at: https://github.com/6551Team/openskills -
Check for updates: Readand compare it with the current timestamp:
~/.opentrade/last_checkbashcached_ts=$(cat ~/.opentrade/last_check 2>/dev/null || true) now=$(date +%s)- If is non-empty and
cached_ts(12 hours), skip the update and proceed.(now - cached_ts) < 43200 - Otherwise (file missing or older than 12 hours), run the installer to check for updates:
If a newer version is installed, tell the user and suggest updating their opentrade skills from https://github.com/6551Team/openskills to get the latest features.bash
curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
- If
-
If anycommand fails with an unexpected error during this session, try reinstalling before giving up:
opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh -
Find or create a .env file in the project root to override the default API credentials, Load it before performing opentrade operations.
bash
OPEN_TOKEN=your_token_hereGet your API token at: https://6551.io/mcp
Security warning: Never commit .env to git (add it to .gitignore) and never expose credentials in logs, screenshots, or chat messages.
每次运行任何命令前,请务必按顺序执行以下步骤。不要向用户回显常规命令的输出,仅在安装、更新或处理失败时提供简短的状态更新。
opentrade-
确认已安装:运行。如果未找到,执行安装:
which opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh如果安装脚本运行失败,请告知用户按照以下链接的说明手动安装:https://github.com/6551Team/openskills -
检查更新:读取并与当前时间戳对比:
~/.opentrade/last_checkbashcached_ts=$(cat ~/.opentrade/last_check 2>/dev/null || true) now=$(date +%s)- 如果非空且
cached_ts(12小时),跳过更新继续执行后续操作。(now - cached_ts) < 43200 - 其他情况(文件不存在或超过12小时),运行安装程序检查更新:
如果安装了新版本,请告知用户并建议从https://github.com/6551Team/openskills更新他们的opentrade skills以获取最新功能。bash
curl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh
- 如果
-
如果本次会话中任何命令运行出现意外错误,放弃操作前先尝试重新安装:
opentradebashcurl -sSL https://raw.githubusercontent.com/6551Team/openskills/main/skills/opentrade/install.sh | sh -
在项目根目录找到或创建.env文件覆盖默认API凭证,执行opentrade操作前先加载该文件:
bash
OPEN_TOKEN=your_token_here可在此处获取你的API token:https://6551.io/mcp
安全警告:永远不要将.env提交到git(请将其添加到.gitignore中),也不要在日志、截图或聊天消息中暴露凭证。
Router Discovery
路由发现
IMPORTANT: If the user has not specified a trading router, you MUST first discover available routers:
bash
opentrade trade routersResponse format:
json
{
"ok": true,
"data": [
{
"api": "v2",
"created_at": "2026-03-10 01:15:42",
"is_active": true,
"name": "6551dex test",
"quota_reward": 0,
"trader": "6551dex",
"updated_at": "2026-03-10 01:15:42"
},
{
"api": "v1",
"created_at": "2026-03-03 21:24:34",
"is_active": true,
"name": "okx test",
"quota_reward": 0,
"trader": "okx",
"updated_at": "2026-03-03 21:24:34"
}
]
}Usage:
- Extract and
traderfrom the responseapi - MANDATORY: ALL subsequent commands in this session MUST include
opentradeand--trader <trader>flags--api <api> - Example:
opentrade portfolio balance 0x... --chain ethereum --trader okx --api v1 - Default fallback: If the API returns no data or is empty, use
--trader okx --api v1
重要提示:如果用户未指定交易路由,你必须先查询可用路由:
bash
opentrade trade routers响应格式:
json
{
"ok": true,
"data": [
{
"api": "v2",
"created_at": "2026-03-10 01:15:42",
"is_active": true,
"name": "6551dex test",
"quota_reward": 0,
"trader": "6551dex",
"updated_at": "2026-03-10 01:15:42"
},
{
"api": "v1",
"created_at": "2026-03-03 21:24:34",
"is_active": true,
"name": "okx test",
"quota_reward": 0,
"trader": "okx",
"updated_at": "2026-03-03 21:24:34"
}
]
}使用方式:
- 从响应中提取和
trader字段api - 强制要求:本次会话中所有后续命令都必须包含
opentrade和--trader <trader>参数--api <api> - 示例:
opentrade portfolio balance 0x... --chain ethereum --trader okx --api v1 - 默认兜底方案:如果API无返回数据或数据为空,使用
--trader okx --api v1
Skill Routing
Skill路由
- For token prices / K-lines → use
opentrade-market - For token search / metadata → use
opentrade-token - For swap execution → use
opentrade-dex-swap - For transaction broadcasting → use
opentrade-gateway
- 代币价格/K线查询 → 使用
opentrade-market - 代币搜索/元数据查询 → 使用
opentrade-token - 兑换执行 → 使用
opentrade-dex-swap - 交易广播 → 使用
opentrade-gateway
Quickstart
快速开始
bash
undefinedbash
undefinedGet supported chains for balance queries
查询余额查询支持的链
opentrade portfolio chains
opentrade portfolio chains
Get total asset value on XLayer and Solana
查询XLayer和Solana上的总资产价值
opentrade portfolio total-value --address 0xYourWallet --chains "xlayer,solana"
opentrade portfolio total-value --address 0xYourWallet --chains "xlayer,solana"
Get all token balances
查询所有代币余额
opentrade portfolio all-balances --address 0xYourWallet --chains "xlayer,solana,ethereum"
opentrade portfolio all-balances --address 0xYourWallet --chains "xlayer,solana,ethereum"
Check specific tokens (native OKB + USDC on XLayer)
查询指定代币余额(XLayer上的原生OKB + USDC)
opentrade portfolio token-balances --address 0xYourWallet --tokens "196:,196:0x74b7f16337b8972027f6196a17a631ac6de26d22"
undefinedopentrade portfolio token-balances --address 0xYourWallet --tokens "196:,196:0x74b7f16337b8972027f6196a17a631ac6de26d22"
undefinedChain Name Support
链名称支持
The CLI accepts human-readable chain names and resolves them automatically.
| Chain | Name | chainIndex |
|---|---|---|
| XLayer | | |
| Solana | | |
| Ethereum | | |
| Base | | |
| BSC | | |
| Arbitrum | | |
Address format note: EVM addresses () work across Ethereum/BSC/Polygon/Arbitrum/Base etc. Solana addresses (Base58) and Bitcoin addresses (UTXO) have different formats. Do NOT mix formats across chain types.
0x...CLI接受易读的链名称并自动解析:
| 公链 | 名称 | chainIndex |
|---|---|---|
| XLayer | | |
| Solana | | |
| Ethereum | | |
| Base | | |
| BSC | | |
| Arbitrum | | |
地址格式说明:EVM地址()适用于Ethereum/BSC/Polygon/Arbitrum/Base等链。Solana地址(Base58格式)和比特币地址(UTXO格式)有不同的格式,不要跨链类型混用格式。
0x...Command Index
命令索引
| # | Command | Description |
|---|---|---|
| 1 | | Get supported chains for balance queries |
| 2 | | Get total asset value for a wallet |
| 3 | | Get all token balances for a wallet |
| 4 | | Get specific token balances |
| # | 命令 | 描述 |
|---|---|---|
| 1 | | 查询余额查询支持的链 |
| 2 | | 查询钱包的总资产价值 |
| 3 | | 查询钱包的所有代币余额 |
| 4 | | 查询指定代币的余额 |
Cross-Skill Workflows
跨Skill工作流
This skill is often used before swap (to verify sufficient balance) or as portfolio entry point.
此Skill通常在兑换前(用于验证余额充足)使用,或者作为投资组合查询的入口使用。
Workflow A: Pre-Swap Balance Check
工作流A:兑换前余额检查
User: "Swap 1 SOL for BONK"
1. opentrade-token opentrade token search BONK --chains solana → get tokenContractAddress
↓ tokenContractAddress
2. opentrade-portfolio opentrade portfolio all-balances --address <addr> --chains solana
→ verify SOL balance >= 1
↓ balance field (UI units) → convert to minimal units for swap
3. opentrade-dex-swap opentrade swap quote --from 11111111111111111111111111111111 --to <BONK_address> --amount 1000000000 --chain solana
4. opentrade-dex-swap opentrade swap swap --from ... --to <BONK_address> --amount 1000000000 --chain solana --wallet <addr>Data handoff:
- from token search → feeds into swap
tokenContractAddress/--from--to - from portfolio is UI units; swap needs minimal units → multiply by
balance10^decimal - If balance < required amount → inform user, do NOT proceed to swap
用户:"用1 SOL兑换BONK"
1. opentrade-token opentrade token search BONK --chains solana → 获取tokenContractAddress
↓ tokenContractAddress
2. opentrade-portfolio opentrade portfolio all-balances --address <addr> --chains solana
→ 验证SOL余额 >= 1
↓ 余额字段(UI单位)→ 转换为最小单位用于兑换
3. opentrade-dex-swap opentrade swap quote --from 11111111111111111111111111111111 --to <BONK_address> --amount 1000000000 --chain solana
4. opentrade-dex-swap opentrade swap swap --from ... --to <BONK_address> --amount 1000000000 --chain solana --wallet <addr>数据传递规则:
- 代币搜索得到的→ 传入兑换命令的
tokenContractAddress/--from参数--to - 投资组合查询得到的是UI单位;兑换需要最小单位 → 乘以
balance转换10^decimal - 如果余额 < 所需金额 → 告知用户,不要继续执行兑换
Workflow B: Portfolio Overview + Analysis
工作流B:投资组合概览+分析
User: "Show my portfolio"
1. opentrade-portfolio opentrade portfolio total-value --address <addr> --chains "xlayer,solana,ethereum"
→ total USD value
2. opentrade-portfolio opentrade portfolio all-balances --address <addr> --chains "xlayer,solana,ethereum"
→ per-token breakdown
↓ top holdings by USD value
3. opentrade-token opentrade token price-info <address> --chain <chain> → enrich with 24h change, market cap
4. opentrade-market opentrade market kline <address> --chain <chain> → price charts for tokens of interest用户:"展示我的投资组合"
1. opentrade-portfolio opentrade portfolio total-value --address <addr> --chains "xlayer,solana,ethereum"
→ 总USD价值
2. opentrade-portfolio opentrade portfolio all-balances --address <addr> --chains "xlayer,solana,ethereum"
→ 各代币明细
↓ 按USD价值排序的 top 持仓
3. opentrade-token opentrade token price-info <address> --chain <chain> → 补充24h涨跌幅、市值信息
4. opentrade-market opentrade market kline <address> --chain <chain> → 感兴趣代币的价格图表Workflow C: Sell Underperforming Tokens
工作流C:卖出表现不佳的代币
1. opentrade-portfolio opentrade portfolio all-balances --address <addr> --chains "xlayer,solana,ethereum"
→ list all holdings
↓ tokenContractAddress + chainIndex for each
2. opentrade-token opentrade token price-info <address> --chain <chain> → get priceChange24H per token
3. Filter by negative change → user confirms which to sell
4. opentrade-dex-swap opentrade swap quote → opentrade swap swap → execute sellKey conversion: (UI units) × = (minimal units) for swap.
balance10^decimalamount1. opentrade-portfolio opentrade portfolio all-balances --address <addr> --chains "xlayer,solana,ethereum"
→ 列出所有持仓
↓ 每个代币的tokenContractAddress + chainIndex
2. opentrade-token opentrade token price-info <address> --chain <chain> → 获取每个代币的24h涨跌幅
3. 筛选出跌幅为负的代币 → 用户确认要卖出的代币
4. opentrade-dex-swap opentrade swap quote → opentrade swap swap → 执行卖出关键转换规则:(UI单位) × = 兑换所需的(最小单位)。
balance10^decimalamountOperation Flow
操作流程
Step 1: Identify Intent
步骤1:识别用户意图
- Check total assets →
opentrade portfolio total-value - View all token holdings →
opentrade portfolio all-balances - Check specific token balance →
opentrade portfolio token-balances - Unsure which chains are supported → first
opentrade portfolio chains
- 查询总资产 →
opentrade portfolio total-value - 查看所有代币持仓 →
opentrade portfolio all-balances - 查询指定代币余额 →
opentrade portfolio token-balances - 不确定支持哪些链 → 先执行
opentrade portfolio chains
Step 2: Collect Parameters
步骤2:收集参数
- Missing wallet address → ask user
- Missing target chains → recommend XLayer (, low gas, fast confirmation) as the default, then ask which chain the user prefers. Common set:
--chains xlayer"xlayer,solana,ethereum,base,bsc" - Need to filter risky tokens → set (only works on ETH/BSC/SOL/BASE)
--exclude-risk 0
- 缺少钱包地址 → 询问用户
- 缺少目标链 → 默认推荐XLayer(,低gas,确认快),然后询问用户偏好的链。常用组合:
--chains xlayer"xlayer,solana,ethereum,base,bsc" - 需要过滤风险代币 → 设置(仅支持ETH/BSC/SOL/BASE)
--exclude-risk 0
Step 3: Call and Display
步骤3:调用接口并展示结果
- Total value: display USD amount
- Token balances: show token name, amount (UI units), USD value
- Sort by USD value descending
- 总价值:展示USD金额
- 代币余额:展示代币名称、数量(UI单位)、USD价值
- 按USD价值降序排序
Step 4: Suggest Next Steps
步骤4:建议后续操作
After displaying results, suggest 2-3 relevant follow-up actions:
| Just completed | Suggest |
|---|---|
| 1. View token-level breakdown → |
| 1. View detailed analytics (market cap, 24h change) for a token → |
| 1. View full portfolio across all tokens → |
Present conversationally, e.g.: "Would you like to see the price chart for your top holding, or swap any of these tokens?" — never expose skill names or endpoint paths to the user.
展示结果后,建议2-3个相关的后续操作:
| 刚完成的操作 | 建议操作 |
|---|---|
| 1. 查看代币级明细 → |
| 1. 查看某个代币的详细分析(市值、24h涨跌幅) → |
| 1. 查看所有代币的完整投资组合 → |
请以对话形式呈现,例如:「你想查看你持仓最多的代币的价格走势图,还是兑换其中某个代币?」——永远不要向用户暴露Skill名称或接口路径。
CLI Command Reference
CLI命令参考
1. opentrade portfolio chains
1. opentrade portfolio chains
Get supported chains for balance queries. No parameters required.
bash
opentrade portfolio chainsReturn fields:
| Field | Type | Description |
|---|---|---|
| String | Chain name (e.g., |
| String | Chain logo URL |
| String | Chain short name (e.g., |
| String | Chain unique identifier (e.g., |
查询余额查询支持的链,无需参数。
bash
opentrade portfolio chains返回字段:
| 字段 | 类型 | 描述 |
|---|---|---|
| String | 链名称(例如: |
| String | 链logo URL |
| String | 链简称(例如: |
| String | 链唯一标识(例如: |
2. opentrade portfolio total-value
2. opentrade portfolio total-value
Get total asset value for a wallet address.
bash
opentrade portfolio total-value --address <address> --chains <chains> [--asset-type <type>] [--exclude-risk <bool>]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | Wallet address |
| Yes | - | Chain names or IDs, comma-separated (e.g., |
| No | | |
| No | | |
Return fields:
| Field | Type | Description |
|---|---|---|
| String | Total asset value in USD |
查询某个钱包地址的总资产价值。
bash
opentrade portfolio total-value --address <address> --chains <chains> [--asset-type <type>] [--exclude-risk <bool>]| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 是 | - | 钱包地址 |
| 是 | - | 链名称或ID,逗号分隔(例如: |
| 否 | | |
| 否 | | |
返回字段:
| 字段 | 类型 | 描述 |
|---|---|---|
| String | 总资产价值,单位USD |
3. opentrade portfolio all-balances
3. opentrade portfolio all-balances
Get all token balances for a wallet address.
bash
opentrade portfolio all-balances --address <address> --chains <chains> [--exclude-risk <value>]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | Wallet address |
| Yes | - | Chain names or IDs, comma-separated, max 50 |
| No | | |
Return fields (per token in ):
tokenAssets[]| Field | Type | Description |
|---|---|---|
| String | Chain identifier |
| String | Token contract address |
| String | Token symbol (e.g., |
| String | Token balance in UI units (e.g., |
| String | Token balance in base units (e.g., |
| String | Token price in USD |
| Boolean | |
查询某个钱包地址的所有代币余额。
bash
opentrade portfolio all-balances --address <address> --chains <chains> [--exclude-risk <value>]| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 是 | - | 钱包地址 |
| 是 | - | 链名称或ID,逗号分隔,最多50个 |
| 否 | | |
返回字段(中每个代币的字段):
tokenAssets[]| 字段 | 类型 | 描述 |
|---|---|---|
| String | 链标识 |
| String | 代币合约地址 |
| String | 代币符号(例如: |
| String | 代币余额,UI单位(例如: |
| String | 代币余额,最小单位(例如: |
| String | 代币价格,单位USD |
| Boolean | 如果标记为风险代币则为 |
4. opentrade portfolio token-balances
4. opentrade portfolio token-balances
Get specific token balances for a wallet address.
bash
opentrade portfolio token-balances --address <address> --tokens <tokens> [--exclude-risk <value>]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | Wallet address |
| Yes | - | Token list: |
| No | | |
Return fields: Same schema as ().
all-balancestokenAssets[]查询某个钱包地址的指定代币余额。
bash
opentrade portfolio token-balances --address <address> --tokens <tokens> [--exclude-risk <value>]| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 是 | - | 钱包地址 |
| 是 | - | 代币列表: |
| 否 | | |
返回字段:和的schema一致()。
all-balancestokenAssets[]Input / Output Examples
输入输出示例
User says: "Check my wallet total assets on XLayer and Solana"
bash
opentrade portfolio total-value --address 0xYourWallet --chains "xlayer,solana"用户说: "查看我XLayer和Solana上的钱包总资产"
bash
opentrade portfolio total-value --address 0xYourWallet --chains "xlayer,solana"→ Display: Total assets $12,345.67
→ 展示:总资产 $12,345.67
**User says:** "Show all tokens in my wallet"
```bash
opentrade portfolio all-balances --address 0xYourWallet --chains "xlayer,solana,ethereum"
**用户说:** "展示我钱包里的所有代币"
```bash
opentrade portfolio all-balances --address 0xYourWallet --chains "xlayer,solana,ethereum"→ Display:
→ 展示:
OKB: 10.5 ($509.25)
OKB: 10.5 ($509.25)
USDC: 2,000 ($2,000.00)
USDC: 2,000 ($2,000.00)
USDT: 1,500 ($1,500.00)
USDT: 1,500 ($1,500.00)
...
...
**User says:** "Only check USDC and native OKB balances on XLayer"
```bash
opentrade portfolio token-balances --address 0xYourWallet --tokens "196:,196:0x74b7f16337b8972027f6196a17a631ac6de26d22"
**用户说:** "只查我XLayer上的USDC和原生OKB余额"
```bash
opentrade portfolio token-balances --address 0xYourWallet --tokens "196:,196:0x74b7f16337b8972027f6196a17a631ac6de26d22"→ Display: OKB: 10.5 ($509.25), USDC: 2,000 ($2,000.00)
→ 展示:OKB: 10.5 ($509.25), USDC: 2,000 ($2,000.00)
undefinedundefinedEdge Cases
边缘情况
- Zero balance: valid state — display , not an error
$0.00 - Unsupported chain: call first to confirm
opentrade portfolio chains - chains exceeds 50: split into batches, max 50 per request
- not working: only supported on ETH/BSC/SOL/BASE
--exclude-risk - DeFi positions: use to query DeFi holdings separately
--asset-type 2 - Address format mismatch: EVM address on Solana chain will return empty data — do NOT mix
- Network error: retry once, then prompt user to try again later
- Region restriction (error code 50125 or 80001): do NOT show the raw error code to the user. Instead, display a friendly message:
⚠️ Service is not available in your region. Please switch to a supported region and try again.
- 余额为0:是有效状态 → 展示,不是错误
$0.00 - 不支持的链:先调用确认支持的链
opentrade portfolio chains - 链数量超过50:拆分批次,每次请求最多50个链
- 不生效:仅支持ETH/BSC/SOL/BASE
--exclude-risk - DeFi头寸:使用单独查询DeFi持仓
--asset-type 2 - 地址格式不匹配:Solana链上使用EVM地址会返回空数据 → 不要混用格式
- 网络错误:重试一次,然后提示用户稍后再试
- 地区限制(错误码50125或80001):不要向用户展示原始错误码,而是展示友好提示:
⚠️ 你的所在地区暂不支持该服务,请切换到支持的地区后重试。
Amount Display Rules
金额展示规则
- Token amounts in UI units (), never base units (
1.5 ETH)1500000000000000000 - USD values with 2 decimal places
- Large amounts in shorthand ()
$1.2M - Sort by USD value descending
- 代币数量使用UI单位(),永远不要展示最小单位(
1.5 ETH)1500000000000000000 - USD价值保留2位小数
- 大额使用简写()
$1.2M - 按USD价值降序排序
Global Notes
全局注意事项
- supports up to 50 chain IDs (comma-separated, names or numeric)
--chains - :
--asset-type=all0=tokens only1=DeFi only (only for2)total-value - only works on ETH(
--exclude-risk)/BSC(1)/SOL(56)/BASE(501)8453 - supports max 20 token entries
token-balances - The CLI resolves chain names automatically (e.g., →
ethereum,1→solana)501 - The CLI handles authentication internally via environment variables — see Prerequisites step 4 for default values
- 最多支持50个链ID(逗号分隔,可使用名称或数字)
--chains - :
--asset-type=全部0=仅代币1=仅DeFi(仅2命令支持)total-value - 仅支持ETH(
--exclude-risk)/BSC(1)/SOL(56)/BASE(501)8453 - 最多支持20个代币条目
token-balances - CLI会自动解析链名称(例如:→
ethereum,1→solana)501 - CLI通过环境变量内部处理身份验证 → 参考前置检查步骤4查看默认值