returns

returns is a command for coding agents from wbh604/UZI-Skill. It costs 36 tokens per session (917 once invoked), scanned A, original, MIT.

A command that breaks a portfolio's total return into contributions from individual holdings, industries, and optional investment styles, then compares the result with a benchmark.

In plain words
What is it for?
Use it with holdings data containing weights, returns, and industries to calculate contribution tables, industry and style attribution, top contributors and detractors, and performance versus a benchmark.
Why use it?
It shows where gains and losses came from instead of reporting only one overall portfolio percentage.

Command

Part of the UZI-Skill plugin — 5 skills, 20 commands, 1 agent, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/wbh604/uzi-skill/returns
Clone the repo
git clone --depth 1 https://github.com/wbh604/UZI-Skill

Or install UZI-Skill, the plugin that ships this one along with the rest of its 5 skills, 20 commands, 1 agent, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for returns

README.md
[![agentmods](https://agentmods.dev/badge/commands/wbh604/uzi-skill/returns.svg)](https://agentmods.dev/commands/wbh604/uzi-skill/returns)
Your own site
<a href="https://agentmods.dev/commands/wbh604/uzi-skill/returns"><img src="https://agentmods.dev/badge/commands/wbh604/uzi-skill/returns.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 917 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00036 $0.00917
Opus 5 $0.00018 $0.00458
Sonnet 5 $0.00007 $0.00183
Haiku 4.5 $0.00004 $0.00092

Measured 4d ago against content hash f339ab2db3d3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

returns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/returns.md · 72 lines

What it actually says

/returns <holdings.csv | 组合> [benchmark=6.0]

把一个组合的区间总收益拆开:谁赚的钱、哪类资产赚的、谁是英雄谁是猪队友。 配合 UZI 的 --portfolio 组合功能 —— portfolio_runner 负责打分/健康度,本命令负责"涨跌从哪来"。

改编自 anthropics/financial-services · private-equity/returns-analysis,适配二级市场组合。 方法详见 skills/deep-analysis/references/fin-methods/returns-attribution.md

输入

--portfolio 同款 holdings 结构,每行再带 return_pct / industry

ticker,weight,return_pct,industry,name
600519.SH,0.40,10.0,白酒,贵州茅台
000858.SZ,0.30,-5.0,白酒,五粮液
002594.SZ,0.30,20.0,电动车,比亚迪
  • weight 0-1 或 0-100 都行,自动归一化;缺失则等权。
  • return_pct 个股区间收益率(%)。拿不到则留空 → 标注"需补价格区间",按 0 计(可先从 K 线维度补区间收益再回填)。
  • school 可选 · 带上就多出一维流派归因。

工作流

from lib.tier1.returns_attrib import build_returns_attribution

result = build_returns_attribution(holdings, benchmark_return=6.0)  # 基准可选

输出

模块 内容
总收益 total_return = Σ(权重×个股收益),单位 pp
加权贡献表 逐持仓:仓位 / 收益 / 贡献(pp) / 是否需补价
行业归因 各行业贡献(降序),加总 == 总收益
流派归因 仅当 holdings 带 school
Top3 贡献 / Top3 拖累 正/负贡献排序
vs 基准 超额 = 总收益 − 基准,跑赢/跑输
一句话点评 verdict

展示示例

组合区间总收益 +8.50%(vs 基准 +6.00% · 超额 +2.50pp · 🟢 跑赢)

加权贡献表:
  比亚迪    电动车  30%  +20.0%  贡献 +6.00pp  ←主升
  贵州茅台   白酒   40%  +10.0%  贡献 +4.00pp
  五粮液    白酒   30%   -5.0%  贡献 -1.50pp  ✕拖累

行业归因:电动车 +6.00pp · 白酒 +2.50pp
Top 贡献:比亚迪 +6.00 / 贵州茅台 +4.00
Top 拖累:五粮液 -1.50

一句话:组合总收益 +8.50%,主升由比亚迪贡献 +6.00pp,主要拖累五粮液 -1.50pp,跑赢基准 +2.50pp。

注意

  • 贡献单位是百分点 (pp)(已乘权重),不是个股收益率本身。
  • 分组归因只是重排,加总必须等于总收益。
  • return_pct 不报错,但 verdict 会提示"⚠️ N 只缺区间收益需补价格"。
  • 实绩归因(已发生区间收益),不做情景/敏感性预测。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 72 lines · 36 tokens per session scan A f339ab2db3d3

Subscribe to this mod's changes

returns is a command published in the GitHub repository wbh604/UZI-Skill (6,737 stars, last pushed 7d ago), licensed MIT. It adds 36 tokens to every session and 917 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.