跳到正文
Skillpedia
分析与电子表格81k · #1669

trader-explain

它能做什么

这项技能通过排列对模型预测影响最大的特征,来解释交易信号。适合需要为自动化交易信号提供明确理由的人。

适用场景

  • ✓当交易信号需要有明确、有排序的理由以供审查时。
  • ✓当规则要求模型输出能够向监管机构解释时。
  • ✓当你想检查哪些输入推动了某个预测时。

技能链接

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-neural-trader/skills/trader-explain/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-neural-trader/skills/trader-explain/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请解释模型为什么发出信号 118,并显示背后影响最大的特征。”

每周 5 个新技能,1 分钟读完。

工作原理

这项技能获取该信号,从模型中得到每个特征的贡献分数,并用基于图的方法对影响最大的特征排序。它以表格形式显示排序,并保存结果的签名记录。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Explain a trading signal by building a feature-contribution graph and running single-entry forward-push PageRank from the signal output node. Top-K ranked features are returned as a markdown table AND persisted to trading-analysis as a SignedAttributionArtifact (ADR-126 Phase 6).

Why this skill matters:

  • EU AI Act + SEC Reg-AI guidance require interpretable model output for any algorithmic trading system that touches retail capital. This is the regulator-grade attribution path the rest of the substrate has been waiting for.
  • The same call site picks up the full native-WASM PageRank from mcp__ruflo-sublinear__page-rank-entry once that tool is registered in the runtime — until then, the local power-iteration kernel ships in signed-attribution.mjs and produces the same ordering (seeded mulberry32).

Steps:

  1. Retrieve the signal from the canonical trading-signals namespace (ADR-126 Phase 1 + Phase 2 lifecycle):

    mcp__plugin_ruflo-core_ruflo__memory_retrieve({
      key: "SIGNAL_ID",
      namespace: "trading-signals"
    })
    

    The signal entry includes modelId, prediction, and the feature vector at the time of inference.

  2. Extract per-feature contribution scores from the model:

    npx neural-trader --predict --signal "$SIGNAL_ID" --explain --json
    

    The expected output shape:

    {
      features: Array<{ name: string; contribution: number }>;
      // for Transformers, also includes per-head attention co-occurrence:
      attention?: Array<{ head: string; cooccur: Array<[number, number, number]> }>;
    }
    

    Fallback path — if --explain is not shipped on the installed neural-trader build (older versions; the flag was scoped for a follow-up upstream PR), the skill degrades to a deterministic feature-importance heuristic over the signal's input vector: contribution_i = |input_i - μ_i| / σ_i (z-score magnitude). This is a known proxy — not as faithful as attention/SHAP — and the resulting artifact is tagged attribution_method: "input-zscore-fallback" so downstream consumers can filter it out for regulator filings. Document the fallback path in the resulting markdown summary so the agent surfaces it to the user.

  3. Build the feature-contribution graph:

    • Nodes: one node per feature + one source node __signal_output__ for the prediction.
    • Edges: outgoing edges from __signal_output__ to each feature node, weighted by contribution_i. When attention co-occurrence data is available, also add edges between feature nodes weighted by cooccur — this is what makes the PageRank single-entry rather than degenerating to plain top-K.
    • Source: __signal_output__ (index 0 by convention so the smoke can assert reproducibility).
  4. Run single-entry PageRank — preferred path when mcp__ruflo-sublinear__page-rank-entry is registered:

    mcp__ruflo-sublinear__page-rank-entry({
      nodes: GRAPH_NODES,
      edges: GRAPH_EDGES,
      sourceIndex: 0,
      damping: 0.85,
      maxIterations: 100,
      tolerance: 1e-8,
      seed: 42
    })
    

    The local fallback (localSingleEntryPageRank in plugins/ruflo-neural-trader/src/signed-attribution.mjs) runs ~30 LOC of seeded power-iteration when the MCP tool is not available — same math, same result up to floating-point tolerance, same ordering for the same seed (the Phase 6 smoke asserts this).

  5. Build the top-K AttributionFeature[] via topKFeatures(graph, scores, k=10, excludeIndex=0) — excludes the source node from the ranked output. Ties broken by node index (lower index wins) so the ranking is deterministic.

  6. Sign the artifact (reuses the Phase 4 signing primitives — same Ed25519 + canonicalization):

    • Build the SignedAttributionArtifact body:
      {
        signalId: SIGNAL_ID,
        modelId: SIGNAL.modelId,
        features: TOP_K_FEATURES,             // from step 5
        graphMetadata: {
          nodeCount: GRAPH.nodes.length,
          edgeCount: COUNT_EDGES,
          pageRankIterations: PR_RESULT.iterations,
          seed: SEED                          // load-bearing for reproducibility
        },
        generatedAt: NEW_DATE_ISO
      }
      
    • Resolve the witness signing key — same lookup order as Phase 4:
      1. RUFLO_WITNESS_KEY_PATH env var — JSON file with { "privateKey": "<hex>" }.
      2. verification/witness-key.json (the ADR-103 default path).
    • If a key resolves: `signAttributionArtifact(
常见问题

为什么被称为“监管级”?

该技能的说明称,它旨在提供某些交易系统规则所要求的可解释输出。

它需要特别的库吗?

它使用该技能自带的本地计算,因此即使没有原生工具也能运行。

结果保存在哪里?

它以签名的归因记录形式保存到 trading-analysis 记忆中。

详情

作者的原始描述

Regulator-grade feature attribution for any LSTM/Transformer signal — single-entry PageRank ranks the top-K features that drove the prediction (ADR-126 Phase 6, ADR-123 single-entry PR)

repo: ruvnet/ruflo

热度

GitHub 星标
81k
排名
#1669
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能