Correlation Aware Exposure Limits 标志

Correlation Aware Exposure Limits

社区
HimanshuJ16
correlation-aware-exposure-limits

当投资组合持有多个受同一行业或宏观因子驱动的金融工具,而按单个证券设置的限额掩盖了实际集中度时使用。本技能会依据两两相关性对金融工具进行聚类,并限制每个集群的总敞口。

Add to TypingMind

概览

发布者HimanshuJ16
代码仓库Algo-Trading-Skills
技能名称correlation-aware-exposure-limits
星标数
50
复刻数
7
附带文件
5
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 5 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 HimanshuJ16 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Correlation Aware Exposure Limits AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/correlation-aware-exposure-limits
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/correlation-aware-exposure-limits .claude/skills/correlation-aware-exposure-limits
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Correlation Aware Exposure Limits,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Correlation Aware Exposure Limits。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Correlation Aware Exposure Limits 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

When to Use

Invoke this whenever a portfolio trades multiple instruments within the same sector, asset class, or macro factor (e.g., holding multiple tech stocks NVDA, AMD, MSFT, or crypto assets BTC, ETH, SOL). Setting individual position limits per ticker alone creates hidden concentration risk: when correlated instruments fall in tandem during market sell-offs, total portfolio drawdown spikes unexpectedly. Estimating rolling return correlation matrices ($C_{i,j}$), grouping instruments into correlated clusters ($\rho \ge 0.70$), and capping total cluster exposure (e.g. $\le 30%$ NAV) before approving order executions is mandatory.

When NOT to Use

  • As the only pre-trade control. Cluster caps bound concentration, not leverage, margin adequacy, drawdown, or per-symbol size. Compose with the risk skills under Related Skills; SEC Rule 15c3-5 expects a control suite, not a single check.
  • When the correlation estimate cannot be trusted. Fewer than ~30 overlapping returns, a newly listed instrument, or a regime break makes the Pearson estimate too noisy to cluster on. The module fails closed on a missing matrix, but it cannot detect a statistically weak one — widen the lookback or fall back to sector-only clustering.
  • For linear factor-risk budgeting. Connected-component clustering answers "which names move together enough to share a cap," not "how much of my variance is one factor." Use a factor/covariance model for the latter; a single 0.70 edge can chain a long clustering chain into one pocket.
  • As a substitute for netting-aware margin math. Exposure here is deliberately GROSS, so it will not match broker margin, which does grant offsets. Do not drive collateral decisions from these numbers.
  • For a single-instrument or deliberately paired mandate, unless caps are set to what the mandate actually authorises.

Prerequisites

  • Historical return series for portfolio instruments over rolling lookback window (e.g. 60 days).
  • Defined correlation threshold $\rho_{\text{threshold}}$ (default 0.70).
  • Defined maximum allowed cluster exposure cap, expressed as an absolute notional (default 1,000,000; convert a NAV-percentage policy to notional as $\text{cap} = \text{pct} \times \text{NAV}$ at construction time).

Workflow

  1. Estimate Rolling Correlation Matrix:

    • Compute pairwise Pearson correlation matrix $C$ over historical return vectors $R_1, R_2, \dots, R_K$: $$C_{i,j} = \frac{\text{Cov}(R_i, R_j)}{\sigma_i \cdot \sigma_j}$$
    • Price series must be chronological, positive, finite, and date-aligned at their most recent point; differing lengths are correlated over their most recent overlapping returns. Bad data (zero/negative/NaN prices) is rejected, never silently correlated.
  2. Form Correlation Clusters:

    • Group assets into connected clusters $G_1, G_2, \dots, G_m$ where pairwise correlation $C_{i,j} \ge \rho_{\text{threshold}}$ (transitively: A–B and B–C at threshold join A, B, C even if A–C is below). Symbols sharing a sector_mapping label are forced into one cluster regardless of measured correlation — sector co-membership is treated as one risk pocket.
  3. Compute Current Cluster Exposures:

    • Calculate current GROSS dollar exposure for cluster $k$ (sum of absolute notionals; netting longs against shorts inside a correlated cluster is deliberately not done, because correlations converge in stress and the hedge fails exactly when it matters): $$\text{Exposure}(G_k) = \sum_{i \in G_k} |w_i \cdot \text{Position}_i|$$ where $w_i$ is the underlying delta (options delta-adjusted to underlying-equivalent exposure). Divide by NAV for a percentage view.
  4. Validate Proposed Order Execution:

    • Fail closed: if no correlation matrix has been built, evaluation raises — never approve orders against silently-empty clusters. A stale matrix (default > 7 days) either warns or blocks, per stale_matrix_policy.
    • Check the aggregate portfolio cap on post-trade GROSS notional, counting the proposed leg even when the symbol is not yet in the book — an opening order in a fresh symbol must consume portfolio headroom like any other. This cap is raw notional (not delta-adjusted); the cluster cap below is delta-adjusted.
    • For a proposed signed increment $V_{\text{proposed}}$ on symbol $i$, compute the exact post-trade cluster exposure: $\text{Exposure}(G_k) + |V_{\text{proposed}}|$ for a new position, or $|\text{Position}i + V{\text{proposed}}|$ netting against an existing one — risk-REDUCING orders are never vetoed, even when a cluster is already over cap (they are approved with a remediation flag).
    • If post-trade exposure exceeds the cap and the order does not reduce it, veto with RiskCheckResult(approved=False); allowed_notional carries the indicative downsized size.

Full step-by-step procedure with broker-specific detail: see references/workflows.md. Broker/framework coverage table for this skill: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Per-Ticker Limit Blind Spot: Assuming single-ticker limits (e.g. 5% per stock) prevent risk concentration across 8 tech stocks (40% total tech exposure).
  • Static Correlation Assumptions: Using static historical correlations without updating rolling matrices, missing correlation breakdown during market crashes.
  • Fail-Open Risk Gates: Approving orders when the correlation matrix is missing or stale turns every symbol into an uncorrelated singleton and silently disables cluster limits. Missing matrix must block; stale matrix should block in production (stale_matrix_policy="block").
  • Vetoing De-Risking Orders: Adding $|V_{\text{proposed}}|$ on top of current exposure vetoes position REDUCTIONS when a cluster sits near its cap. Net the increment against the existing position and only block exposure-increasing orders.
  • Asymmetric Delta Treatment: Delta-adjusting the proposed option order but counting existing options at full notional overstates exposure — apply underlying delta weights to both sides.
  • Netting Longs Against Shorts in a Cluster: Netted cluster exposure assumes the correlation hedge holds through the crash; gross (sum of absolute) exposure is the conservative basis for concentration caps.
  • Misaligned Return Windows: Correlating truncated prefixes of different-length histories compares returns from different dates. Align on the most recent overlapping returns, and reject (don't skip) bad price data.
  • Aggregate Cap Blind to New Positions: Computing the post-trade portfolio total by iterating only over symbols already held silently exempts every opening order from the aggregate cap — the book grows past the limit one new symbol at a time while each individual cluster check still passes. Count the proposed leg explicitly when the symbol is absent from the current book.
  • Check-Then-Trade Races: two concurrent orders can each pass against the same cap and jointly breach it. The manager serializes its own matrix/audit state, but the caller must serialize check-then-place sequences when orders can arrive from multiple threads.

Verification

  • Submit returns for highly correlated assets (NVDA & AMD, $\rho = 0.85$) and verify CorrelationExposureManager groups them into the same cluster.
  • Submit proposed order that breaches the cluster notional limit and verify it is vetoed: RiskCheckResult(approved=False) with the indicative allowed_notional for downsizing.
  • Verify an opening order in a symbol not yet held is vetoed when it would push post-trade portfolio gross notional past max_portfolio_notional.
  • Verify a risk-reducing order on an at-cap cluster is approved, and that evaluating any order before update_correlation_matrix() raises CorrelationMatrixUnavailableError.
  • Run unit test suite python -m unittest discover -s skills/correlation-aware-exposure-limits/scripts and confirm 100% pass rate.

Related Skills

  • broker-account-margin-call-handling
  • survivorship-bias-free-universe-construction
  • ensemble-signal-combination-without-overfitting

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Correlation Aware Exposure Limits AI 技能有什么作用?

当投资组合持有多个受同一行业或宏观因子驱动的金融工具,而按单个证券设置的限额掩盖了实际集中度时使用。本技能会依据两两相关性对金融工具进行聚类,并限制每个集群的总敞口。

为什么在 TypingMind 中使用 Correlation Aware Exposure Limits?

因为您只需安装一次,就能搭配任何模型使用。Correlation Aware Exposure Limits 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Correlation Aware Exposure Limits?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/correlation-aware-exposure-limits。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Correlation Aware Exposure Limits?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Correlation Aware Exposure Limits 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Correlation Aware Exposure Limits 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Correlation Aware Exposure Limits AI 技能免费吗?

是的。HimanshuJ16 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇