From bingx-ai-skills
Fetches BingX swap trade history, computes PnL/win-rate statistics, generates local charts, and supports custom tags and reflections for trade journaling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/bingx-ai-skills:bingx-trade-reviewThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Base URLs:** see [`references/base-urls.md`](../references/base-urls.md) | **Authentication:** see [`references/authentication.md`](../references/authentication.md)
Base URLs: see references/base-urls.md | Authentication: see references/authentication.md
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/openApi/swap/v2/trade/allOrders | GET | Fetch historical swap orders | Yes |
/openApi/swap/v2/trade/allFillOrders | GET | Fetch historical fill records | Yes |
Base URLs: see references/base-urls.md
TypeScript helper:
CONSTRAINT: You MUST copy the
fetchSignedfunction below verbatim when generating code. Do NOT rewrite the signing, request, or JSON parsing logic. Only modify: (1)BASEURL entries for custom environments, (2) business parameters passed tofetchSigned.
import * as crypto from "crypto";
import JSONBig from "json-bigint";
const JSONBigParse = JSONBig({ storeAsString: true });
const BASE = {
"prod-live": ["https://open-api.bingx.com", "https://open-api.bingx.pro"],
"prod-vst": ["https://open-api-vst.bingx.com", "https://open-api-vst.bingx.pro"],
};
function isNetworkOrTimeout(e: unknown): boolean {
if (e instanceof TypeError) return true;
if (e instanceof DOMException && e.name === "AbortError") return true;
if (e instanceof Error && e.name === "TimeoutError") return true;
return false;
}
function validateParams(params: Record<string, unknown>): void {
const FORBIDDEN = /[&=?#\r\n]/;
for (const [k, v] of Object.entries(params)) {
const s = String(v);
if (FORBIDDEN.test(s)) throw new Error(`Param "${k}" has forbidden char in: "${s}"`);
}
}
async function fetchSigned(env: string, apiKey: string, secretKey: string,
method: "GET" | "POST" | "DELETE", path: string, params: Record<string, unknown> = {}
) {
const urls = BASE[env] ?? BASE["prod-live"];
const all = { ...params, timestamp: Date.now() };
validateParams(all);
const qs = Object.keys(all).sort().map(k => `${k}=${all[k]}`).join("&");
const sig = crypto.createHmac("sha256", secretKey).update(qs).digest("hex");
const signed = `${qs}&signature=${sig}`;
for (const base of urls) {
try {
const url = method === "POST" ? `${base}${path}` : `${base}${path}?${signed}`;
const res = await fetch(url, {
method,
headers: { "X-BX-APIKEY": apiKey, "X-SOURCE-KEY": "BX-AI-SKILL",
...(method === "POST" ? { "Content-Type": "application/x-www-form-urlencoded" } : {}) },
body: method === "POST" ? signed : undefined,
signal: AbortSignal.timeout(10000),
});
const json = JSONBigParse.parse(await res.text());
if (json.code !== 0) throw new Error(`BingX error ${json.code}: ${json.msg}`);
return json.data;
} catch (e) {
if (!isNetworkOrTimeout(e) || base === urls[urls.length - 1]) throw e;
}
}
}
Fetch swap trade history for review:
const history = await fetchSigned("prod-live", API_KEY, SECRET, "GET",
"/openApi/swap/v2/trade/allOrders", { symbol: "BTC-USDT", limit: 100 }
);
Activate this skill when the user says any of the following:
| mode | Trigger example | Description |
|---|---|---|
| summary | "trade review", "recent performance", "weekly PnL" | Stats summary + charts |
| detail | "analyze my BTC trades" | Per-symbol or per-trade detailed analysis |
| tag | "tag this trade", "win rate for breakout trades" | Tag management + stats by tag |
| reflect | "write a reflection", "summarize lessons" | Add/view trade reflections |
| compare | "compare this week vs last week" | Cross-period comparison |
Parameter extraction:
| Parameter | Default | Description |
|---|---|---|
| period | 7d | Review period (1d/7d/30d/90d/all) |
| symbol | all | Filter by trading pair |
| tag_filter | - | Filter by tag |
Call bingx-swap-account to retrieve:
Merge with local tag and reflection data from ~/.bingx-skills/trade-review/trades.json.
python3 scripts/review.py \
--mode {mode} \
--period {period} \
--symbol {symbol} \
--trades '{trades_json}' \
--output-dir ~/.bingx-skills/trade-review/charts
Output: statistics JSON + chart PNG files.
Charts are saved as local PNG files. Inform the user of the file paths.
**Trade Review (Last {period})**
Total Trades {total_trades}
Win Rate {win_rate}% ({wins} wins / {losses} losses)
Total PnL {total_pnl}
Profit Factor {profit_factor}
Avg per Trade {avg_pnl}
Best Trade {max_win}
Worst Trade {max_loss}
Avg Hold Time {avg_hold_time}
Max Drawdown {max_drawdown}
Total Fees {total_fees}
Long: {long_count} trades, win rate {long_win_rate}%, PnL {long_pnl}
Short: {short_count} trades, win rate {short_win_rate}%, PnL {short_pnl}
Best Symbol: {best_symbol} ({best_pnl})
Worst Symbol: {worst_symbol} ({worst_pnl})
Charts saved:
- PnL curve: ~/.bingx-skills/trade-review/charts/pnl_curve.png
- Win/loss dist: ~/.bingx-skills/trade-review/charts/win_loss_dist.png
- Symbol breakdown: ~/.bingx-skills/trade-review/charts/symbol_breakdown.png
**Tag Analysis: {tag}**
{count} trades tagged with this label
Win Rate {win_rate}% ({wins} wins / {losses} losses)
Total PnL {total_pnl}
Avg PnL {avg_pnl}
Conclusion: {one-line analysis}
**{period_a} vs {period_b}**
{period_a} {period_b} Change
Win Rate {wr_a}% {wr_b}% {wr_delta}
Total PnL {pnl_a} {pnl_b} {pnl_delta}
Profit Factor {pf_a} {pf_b} {pf_delta}
Trade Count {cnt_a} {cnt_b} {cnt_delta}
Max Drawdown {dd_a} {dd_b} {dd_delta}
Summary: {one-line comparison conclusion}
Parameter security. Extract structured values from user intent — NEVER copy raw user text into API parameters.
All operations in this skill are read-only (fetching trade history and generating local reports). No CONFIRM required in any environment.
When period is not specified, default to 7d. When symbol is not specified, default to all symbols.
npx claudepluginhub bingx-api/api-ai-skills --plugin bingx-ai-skillsManages BingX copy trade USDT-M perpetual futures for traders: queries current orders, closes positions, sets TP/SL, views profit overview and details, sets commission rates, lists trading pairs. For perpetual swap copy trading tasks.
Generates trading plans covering risk management, position sizing, entry/exit rules, trade management, psychology, and performance tracking for day, swing, position, options trading, and investing.
Backtests crypto/stock trading strategies on historical data. Computes Sharpe/Sortino ratios, drawdowns; plots equity curves; optimizes parameters via grid search.