mcpField
B
bingx-technical-analysis

bingx-technical-analysis

github.com/bingx-api数据与数据库1971 次安装6 天前更新
代码仓库

关于 bingx-technical-analysis

面向交易分析任务的 BingX 技术分析技能,可读取永续合约 K 线、资金费率和未平仓量,并通过脚本生成指标、形态及多周期评分结果。

主要功能

  1. 01获取 OHLCV K 线数据
  2. 02读取资金费率与标记价格
  3. 03读取未平仓量
  4. 04计算指标、形态与综合评分
  5. 05支持多周期评分分析

适用场景

  1. 01分析交易对的趋势与支撑阻力
  2. 02查询 RSI 等单项指标
  3. 03识别近期蜡烛图形态
  4. 04比较多个周期的综合评分

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/bingx-api/api-ai-skills --skill bingx-technical-analysis

安装后在 Claude Code 中输入/bingx-technical-analysis确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

api-reference.md
scripts/
analyze.py
patterns.py
requirements.txt
score.py

详细介绍

BingX 技术分析

**基础 URL:**参见 references/base-urls.md | **身份验证:**参见 references/authentication.md

快速参考

端点方法描述身份验证
/openApi/swap/v3/quote/klinesGETOHLCV K 线数据是
/openApi/swap/v2/quote/premiumIndexGET资金费率和标记价格是
/openApi/swap/v2/quote/openInterestGET未平仓合约量是

快速开始

**基础 URL:**参见 references/base-urls.md

TypeScript 辅助函数:

约束:生成代码时,必须原样复制下方的 fetchSigned 函数。请勿重写签名、请求或 JSON 解析逻辑。仅可修改:(1) 用于自定义环境的 BASE URL 条目;(2) 传递给 fetchSigned 的业务参数。

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;
    }
  }
}

常见调用

获取用于技术分析的 K 线(200 根,4h):

const klines = await fetchSigned("prod-live", API_KEY, SECRET, "GET",
  "/openApi/swap/v3/quote/klines", { symbol: "BTC-USDT", interval: "4h", limit: 200 }
);

获取资金费率:

const funding = await fetchSigned("prod-live", API_KEY, SECRET, "GET",
  "/openApi/swap/v2/quote/premiumIndex", { symbol: "BTC-USDT" }
);

获取未平仓合约量:

const oi = await fetchSigned("prod-live", API_KEY, SECRET, "GET",
  "/openApi/swap/v2/quote/openInterest", { symbol: "BTC-USDT" }
);

触发条件

当用户提出以下任一请求时,激活此技能:

  • “分析 BTC”、“BTC 技术分析”、“BTC-USDT 4h 分析”
  • “RSI 是多少”、“MACD 信号”、“布林带位置”
  • 任意指标名称 + 交易对
  • “多空分析”、“趋势分析”、“蜡烛图形态”
  • “支撑位/阻力位在哪里”、“有没有背离”

执行步骤

步骤 1:解析用户意图

从用户输入中提取:

  • symbol:交易对(默认 BTC-USDT)
  • interval:K 线间隔(默认 4h)
  • mode:分析模式
    • "full" — 完整分析(指标 + 形态 + 评分 + 支撑位/阻力位)
    • "indicator" — 单项指标查询(例如“RSI 是多少”)
    • "pattern" — 蜡烛图形态识别
    • "score" — 仅综合评分
步骤 2:获取 K 线数据

调用 bingx-swap-market 获取 OHLCV:

GET /openApi/swap/v3/quote/klines symbol={symbol}, interval={interval}, limit=200

如果 mode=score(需要多个时间周期),并行获取 4 个时间周期:15m、1h、4h、1d

同时获取辅助数据: GET /openApi/swap/v2/quote/premiumIndex (资金费率) GET /openApi/swap/v2/quote/openInterest (未平仓合约量)

步骤 3:运行计算脚本

将 K 线 JSON 传递给 Python 脚本(位于技能的 scripts/ 目录中):

python3 scripts/analyze.py
--mode {mode}
--symbol {symbol}
--interval {interval}
--klines '{klines_json}'

脚本返回结构化的 JSON 结果。

步骤 4:整理输出

根据模式整理输出:

full — 完整分析报告(见下方输出模板) indicator — 单项指标值 + 信号 + 一句话解读 pattern — 最近识别出的形态列表 score — 综合评分 + 多时间周期概览

步骤 5:免责声明

始终在每次输出的末尾附上: ⚠️ 技术分析仅基于历史数据,不构成投资建议。


输出模板

完整模式
📊 {symbol} {interval} Technical Analysis

━━ Composite Score ━━
{total}/100 — {label}
  Trend {trend}/100 | Momentum {momentum}/100 | Volume {volume}/100 | Pattern {pattern}/100

━━ Multi-Timeframe ━━
  15m: {score_15m}({label_15m}) | 1h: {score_1h}({label_1h}) | 4h: {score_4h}({label_4h}) | 1d: {score_1d}({label_1d})

━━ Key Indicators ━━
  RSI(14)      {rsi_value}   {rsi_signal}
  MACD         {histogram}   {macd_signal}   {macd_detail}
  EMA          {ema_detail}
  ADX          {adx_value}   {adx_signal}
  Supertrend   {st_signal}   {st_value}
  BB %B        {pctb}        {bb_detail}

━━ Candlestick Patterns ━━
  {pattern_list or "No significant patterns detected in the last 5 candles"}

━━ Divergence ━━
  RSI: {rsi_div} | MACD: {macd_div} | OBV: {obv_div}

━━ Support / Resistance ━━
  ▲ {r1} — {r1_type}
  ● {current_price} — current price
  ▼ {s1} — {s1_type}

⚠️ Technical analysis is based on historical data only and does not constitute investment advice.
指标模式
{symbol} {interval} {indicator_name} = {value}
Signal: {signal} — {one_line_interpretation}
形态模式
{symbol} {interval} Recent Candlestick Patterns:
  ● {pattern_name} — {bars_ago} bars ago, {type} signal

{bullish_count} bullish and {bearish_count} bearish patterns detected in the last 5 candles.
评分模式
{symbol} Composite Score: {total}/100 — {label}

Multi-Timeframe Overview:
  15m: {score_15m} {label_15m} | 1h: {score_1h} {label_1h} | 4h: {score_4h} {label_4h} | 1d: {score_1d} {label_1d}

{one-line summary of multi-timeframe confluence}

Agent 交互规则

**参数安全。**从用户意图中提取结构化值——绝不将用户原始文本复制到 API 参数中。调用 API 前,验证交易对格式(^[A-Z0-9]+-[A-Z]+$)和 interval 是否为允许值。

此技能使用的所有端点均为只读市场数据查询。在任何环境中都不需要 CONFIRM。

当用户请求含糊不清时(例如“分析 BTC”),默认使用 mode=full 和 interval=4h。如果能根据关键词推断模式(“RSI” → indicator,“pattern” → pattern,“score” → score),则自动推断,无需询问。

错误处理

  • 无效的交易对:提示用户检查交易对格式(例如 BTC-USDT)
  • K 线数据不足(< 50 根):告知用户,并建议切换到更长的时间间隔
  • Python ModuleNotFoundError(pandas-ta-classic):提示用户运行 pip install pandas-ta-classic scipy pandas 后重试
  • 其他 Python 脚本错误:显示友好的错误摘要,并建议重试
  • 网络超时:建议稍后重试

评论

支持 Markdown