# wbh604/fund-guy-skill architecture

> Architecture diagram of the GitHub repository wbh604/fund-guy-skill, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wbh604/fund-guy-skill
- Repository: https://github.com/wbh604/fund-guy-skill

## Overview

#### Purpose and entry points
Fund Guy Skill is a Python-backed agent skill for auditing Chinese mutual-fund manager behavior from public disclosures, rather than judging raw NAV returns. Its primary CLI entry point is `run.py`; agent-specific invocation is defined by `skills/fund-manager-alpha/SKILL.md` and exposed to Claude through `commands/analyze-fund.md`, `commands/quick-check.md`, and `commands/find-similar.md`.

#### Orchestration and audit contract
`run.py` coordinates a fund-code-specific pipeline: fetch source evidence, compute behavioral analyses, and emit an offline single-file HTML report. The skill document is the methodological control plane: it requires manager-tenure segmentation, excludes passive position reductions from sell judgments, separates beta from alpha, and labels unavailable evidence rather than inventing it.
Paths: `run.py`, `skills/fund-manager-alpha/SKILL.md`, `AGENTS.md`.

#### Evidence acquisition and cache boundary
Fetch scripts gather fund NAV/history, quarterly holdings, manager metadata, subscriptions/redemptions, peer funds, market comparisons, gate announcements, stock industries, and price series. Raw source responses are intended to persist in an untracked `.cache/` evidence store, isolating volatile external APIs from reproducible downstream analysis.
Paths: `scripts/fetch_fund.py`, `scripts/fetch_stock_klines.py`, `scripts/fetch_pingzhong.py`.

#### Holdings and market-data enrichment
The pipeline enriches disclosed holdings with A-share/HK weekly K-lines and industry classification, then builds comparison universes: same-house funds, market-wide similar holders, and current top-performing funds. This creates the benchmark boundary needed for behavior attribution rather than standalone portfolio description.
Paths: `scripts/fetch_stock_industry.py`, `scripts/fetch_house.py`, `scripts/fetch_market_similar.py`.

#### Core behavioral analytics
Fund analysis reconstructs buy/add/reduce/exit behavior from periodic holdings and evaluates subsequent returns, timing, drawdown handling, passive-reduction cases, and score components. House analysis measures manager divergence from firm peers and tests whether independent decisions subsequently outperformed. Gate analysis separately evaluates subscription restrictions/openings against market levels and later outcomes; these are contextual cards, not behavior-score inputs.
Paths: `scripts/analyze_fund.py`, `scripts/analyze_house.py`, `scripts/analyze_gates.py`.

#### Supplemental forensic modules
Add-on analysis covers year-end ranking behavior, overlap among products managed by the same person, post-opening subscription cohorts, “star manager” red-flag screening, and K-line scenarios. Replay-data generation and K-line renderers transform analysis output into visual event timelines.
Paths: `scripts/analyze_addons.py`, `scripts/build_replay_data.py`, `scripts/render_kline_interactive.py`.

#### Report assembly and runtime dependencies
`build_fund_report.py` composes all data and analyses into `assets/fund-`.html`, a self-contained interactive report designed to work offline. Static prototype HTML files are presentation references, while the production builder is the report boundary. Runtime is Python 3.9+ with dependencies in `requirements.txt`; upstream services include Eastmoney/东方财富 (often through AkShare), Baostock, Sina Finance, and TradingView Lightweight Charts.
Paths: `scripts/build_fund_report.py`, `assets/fund-163417.html`, `requirements.txt`.

Main entry points: [`run.py`](https://github.com/wbh604/fund-guy-skill/blob/main/run.py) (Pipeline CLI), [`scripts/build_fund_report.py`](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/build_fund_report.py) (Offline report builder), [`scripts/analyze_fund.py`](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_fund.py) (Holdings behavior), [`scripts/fetch_fund.py`](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_fund.py) (Fund disclosures)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Invocation"]
  node_skill_contract["Audit methodology<br/>skill contract<br/>[SKILL.md]"]
  node_agent_guidance["Agent guidance<br/>agent instructions<br/>[AGENTS.md]"]
  node_agent_commands["Claude commands<br/>agent entrypoints"]
  node_run["Pipeline CLI<br/>Python orchestrator<br/>[run.py]"]
end

subgraph group_evidence["Evidence &amp; Enrichment"]
  node_external_sources(("Market data providers<br/>external APIs"))
  node_fund_evidence["Fund disclosures<br/>fetchers<br/>[fetch_fund.py]"]
  node_market_enrichment["Prices &amp; industries<br/>fetchers"]
  node_comparison_universes["Comparison universes<br/>fetchers<br/>[fetch_house.py]"]
  node_evidence_cache[("Raw evidence cache<br/>volatile evidence store")]
end

subgraph group_analytics["Behavior Analytics"]
  node_fund_analysis["Holdings behavior<br/>behavior analysis<br/>[analyze_fund.py]"]
  node_house_analysis["House divergence<br/>peer analysis<br/>[analyze_house.py]"]
  node_gate_analysis["Subscription gates<br/>context analysis<br/>[analyze_gates.py]"]
  node_forensics["Supplemental forensics<br/>addon analysis<br/>[analyze_addons.py]"]
  node_replay_data["Replay timelines<br/>visualization data"]
end

subgraph group_reporting["Report Output"]
  node_report_builder["Offline report builder<br/>report assembly"]
  node_html_report["Fund HTML report<br/>offline artifact<br/>[fund-163417.html]"]
  node_runtime["Python runtime<br/>runtime dependencies<br/>[requirements.txt]"]
end

node_skill_contract -.->|"governs"| node_run
node_agent_guidance -.->|"guides"| node_run
node_agent_commands -->|"invokes"| node_run
node_run -->|"fetches"| node_fund_evidence
node_run -->|"fetches"| node_market_enrichment
node_run -->|"builds"| node_comparison_universes
node_external_sources -->|"disclosures"| node_fund_evidence
node_external_sources -->|"prices and sectors"| node_market_enrichment
node_external_sources -->|"peer data"| node_comparison_universes
node_fund_evidence -->|"persists raw data"| node_evidence_cache
node_market_enrichment -->|"persists enrichment"| node_evidence_cache
node_comparison_universes -->|"persists benchmarks"| node_evidence_cache
node_evidence_cache -->|"holdings and market evidence"| node_fund_analysis
node_evidence_cache -->|"house benchmark evidence"| node_house_analysis
node_evidence_cache -->|"gate and market evidence"| node_gate_analysis
node_evidence_cache -->|"supplemental evidence"| node_forensics
node_fund_analysis -->|"events"| node_replay_data
node_fund_analysis -->|"behavior results"| node_report_builder
node_house_analysis -->|"peer results"| node_report_builder
node_gate_analysis -->|"context cards"| node_report_builder
node_forensics -->|"forensic cards"| node_report_builder
node_replay_data -->|"timeline data"| node_report_builder
node_report_builder -->|"emits"| node_html_report
node_runtime -.->|"runs"| node_run

click node_skill_contract "https://github.com/wbh604/fund-guy-skill/blob/main/skills/fund-manager-alpha/SKILL.md"
click node_agent_guidance "https://github.com/wbh604/fund-guy-skill/blob/main/AGENTS.md"
click node_run "https://github.com/wbh604/fund-guy-skill/blob/main/run.py"
click node_fund_evidence "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_fund.py"
click node_market_enrichment "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_stock_klines.py"
click node_comparison_universes "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_house.py"
click node_fund_analysis "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_fund.py"
click node_house_analysis "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_house.py"
click node_gate_analysis "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_gates.py"
click node_forensics "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_addons.py"
click node_replay_data "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/build_replay_data.py"
click node_report_builder "https://github.com/wbh604/fund-guy-skill/blob/main/scripts/build_fund_report.py"
click node_html_report "https://github.com/wbh604/fund-guy-skill/blob/main/assets/fund-163417.html"
click node_runtime "https://github.com/wbh604/fund-guy-skill/blob/main/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_skill_contract,node_agent_guidance,node_agent_commands,node_run toneBlue
class node_external_sources,node_fund_evidence,node_market_enrichment,node_comparison_universes,node_evidence_cache toneAmber
class node_fund_analysis,node_house_analysis,node_gate_analysis,node_forensics,node_replay_data toneMint
class node_report_builder,node_html_report,node_runtime toneRose
```

## Components

### Invocation

- [Audit methodology](https://github.com/wbh604/fund-guy-skill/blob/main/skills/fund-manager-alpha/SKILL.md): skill contract · Defines tenure, attribution, and evidence-availability rules. · `skills/fund-manager-alpha/SKILL.md`
- [Agent guidance](https://github.com/wbh604/fund-guy-skill/blob/main/AGENTS.md): agent instructions · `AGENTS.md`
- **Claude commands**: agent entrypoints · Analyze, quick-check, and similar-fund invocations.
- [Pipeline CLI](https://github.com/wbh604/fund-guy-skill/blob/main/run.py): Python orchestrator · Runs the fund-code-specific evidence-to-report pipeline. · `run.py`

### Evidence & Enrichment

- **Market data providers**: external APIs · Eastmoney, AkShare, Baostock, Sina Finance, and chart data services.
- [Fund disclosures](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_fund.py): fetchers · Retrieves NAV, holdings, managers, flows, peers, and gate evidence. · `scripts/fetch_fund.py`
- [Prices & industries](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_stock_klines.py): fetchers · Retrieves stock K-lines and industry classifications. · `scripts/fetch_stock_klines.py`
- [Comparison universes](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/fetch_house.py): fetchers · Builds house-peer and market-similar holder benchmarks. · `scripts/fetch_house.py`
- **Raw evidence cache**: volatile evidence store · Untracked cache isolates external responses from downstream analysis.

### Behavior Analytics

- [Holdings behavior](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_fund.py): behavior analysis · Reconstructs trades, attribution, timing, drawdowns, and score components. · `scripts/analyze_fund.py`
- [House divergence](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_house.py): peer analysis · Measures manager independence and subsequent peer-relative outcomes. · `scripts/analyze_house.py`
- [Subscription gates](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_gates.py): context analysis · Evaluates gate events separately from behavior scoring. · `scripts/analyze_gates.py`
- [Supplemental forensics](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/analyze_addons.py): addon analysis · Covers ranking behavior, manager overlap, cohorts, and red flags. · `scripts/analyze_addons.py`
- [Replay timelines](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/build_replay_data.py): visualization data · Transforms analysis output into event timeline data. · `scripts/build_replay_data.py`

### Report Output

- [Offline report builder](https://github.com/wbh604/fund-guy-skill/blob/main/scripts/build_fund_report.py): report assembly · Composes evidence and analyses into a self-contained interactive report. · `scripts/build_fund_report.py`
- [Fund HTML report](https://github.com/wbh604/fund-guy-skill/blob/main/assets/fund-163417.html): offline artifact · Self-contained interactive audit report. · `assets/fund-163417.html`
- [Python runtime](https://github.com/wbh604/fund-guy-skill/blob/main/requirements.txt): runtime dependencies · Python 3.9+ dependencies for the pipeline. · `requirements.txt`

## Connections

- Audit methodology → Pipeline CLI: governs
- Agent guidance → Pipeline CLI: guides
- Claude commands → Pipeline CLI: invokes
- Pipeline CLI → Fund disclosures: fetches
- Pipeline CLI → Prices & industries: fetches
- Pipeline CLI → Comparison universes: builds
- Market data providers → Fund disclosures: disclosures
- Market data providers → Prices & industries: prices and sectors
- Market data providers → Comparison universes: peer data
- Fund disclosures → Raw evidence cache: persists raw data
- Prices & industries → Raw evidence cache: persists enrichment
- Comparison universes → Raw evidence cache: persists benchmarks
- Raw evidence cache → Holdings behavior: holdings and market evidence
- Raw evidence cache → House divergence: house benchmark evidence
- Raw evidence cache → Subscription gates: gate and market evidence
- Raw evidence cache → Supplemental forensics: supplemental evidence
- Holdings behavior → Replay timelines: events
- Holdings behavior → Offline report builder: behavior results
- House divergence → Offline report builder: peer results
- Subscription gates → Offline report builder: context cards
- Supplemental forensics → Offline report builder: forensic cards
- Replay timelines → Offline report builder: timeline data
- Offline report builder → Fund HTML report: emits
- Python runtime → Pipeline CLI: runs
