Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 简体中文

Sector Compass

Turn an industry name and two small CSVs into a one-page brief with real math — HHI against the official DOJ/FTC thresholds, CR4/CR8, growth decomposition, and every number tagged with where it came from.

Python stdlib only tests local first BYOK license

Quick start · Demo · How it works · Limitations

Sector Compass market structure view

Problem

"Get up to speed on an industry, one page, by tomorrow" is an institutionalized ask — consultants, bankers, students, and PMs all face it — and the current options are broken at both ends. The incumbents are priced for enterprises: IBISWorld charges $2,850 per report ($800 for a 10–20 page spotlight), Statista's cheapest useful tier is ~€2,388/year on an annual contract. The free end is either PDF libraries (发现报告, 萝卜投研 — documents, not analysis: you still hand-extract every number) or LLM deep research, which writes fluent narratives around hallucinated figures with no reproducible math trail.

Why existing approaches are not enough

  • Paid databases (IBISWorld, Statista, 艾瑞, 头豹) — excellent data, enterprise paywalls, and still no computation over your numbers.
  • Free 研报 aggregators — solve document access, not analysis; no CR4/CR8, no HHI, no growth decomposition from user data.
  • ChatGPT deep research — reviewers log 2–6 hallucinations per query; aggregate tests claim up to 47% error on financial data; nothing is reproducible.
  • None of them compute concentration against the official 2023 DOJ/FTC merger-guideline thresholds, run a merger counterfactual, or label which numbers are measured vs declared vs scenario.

What this project does

Sector Compass is a local web app: a Python-stdlib backend does the math, your browser does the interaction, and nothing leaves your machine. Name an industry, import a market-size series (year,value[,segment]) and a company revenue table (company,revenue[,year]) — Chinese headers 年份/市场规模/公司/营收 and units 亿/万/million/billion normalize with provenance — and the tool reconciles them (company-sum coverage per year, flagged when >100% or <30%), then computes:

Market structure — CR4/CR8 per US Census disclosure practice, HHI classified against the official 2023 DOJ/FTC thresholds (unconcentrated <1000 / moderate 1000–1800 / high >1800, with a 2010-legacy toggle), delta-HHI, equivalent-firm count, rank churn, and a top-2 merger counterfactual with the structural-presumption check. Growth — CAGR with the correct interval count, YoY, per-segment contribution decomposition in percentage points, and a slider-driven scenario band explicitly labeled arithmetic what-if, not a forecast. Landscape — share evolution, movers, and a five-forces worksheet where rivalry is computed from HHI/churn/growth and the other four forces are your declared judgment, labeled as such. Sizing cross-check — a bottom-up worksheet (units × price) tested against the imported top-down series with a divergence verdict and TAM/SAM/SOM framing. A robustness pass checks whether the headline verdict survives listed-only vs +residual bases, unit-guess alternatives, and growth-window changes — flips are shown, not hidden.

The deliverable is a print-quality one-page decision record (决策简报): headline stats, HHI badge, share donut, growth decomposition, five forces, and a provenance footer citing the FTC 2023 PDF — every number tagged [measured], [declared], or [scenario]. Optionally — with your own API key — an AI model drafts exhibit bullets and an analyst note grounded strictly in the computed numbers (OpenAI, Anthropic, Gemini, DeepSeek, Kimi, GLM, or any OpenAI-compatible relay; mock mode works offline).

Key features

Mechanism What it does Question it answers
M1 Ingest & reconcile Bilingual headers, 亿/万/billion units with provenance, coverage cross-check Do my two files even agree?
M2 Market structure CR4/CR8, HHI vs official thresholds, merger counterfactual, churn Who holds this market — and what would a merger trigger?
M3 Growth engine Correct CAGR, YoY, segment contribution decomposition What actually drove growth?
M4 Landscape Share evolution, movers, five-forces worksheet (computed + declared) How is the pecking order shifting?
M5 Sizing cross-check Bottom-up vs top-down divergence, TAM/SAM/SOM Is the market-size number even plausible?
M6 Robustness Base/unit/window flips surfaced as chips Does the verdict survive my assumptions?
M7 One-pager Print-quality decision record with provenance tags + BYOK AI bullets What do I hand to the room tomorrow?

Demo / Screenshots

Three bundled synthetic industries (演示用合成数据) run end to end with zero keys: a concentrating EV-charging market that crosses HHI 1000, a fragmented specialty-coffee contrast case, and a duopoly cloud market that triggers the merger presumption.

One-page decision record preview

All screenshots come from the machine visual-integrity audit (4 viewports × 6 states, 24/24 runs passing — see qa/visual-integrity.json).

Quick start

git clone https://github.com/ZhenyuanPAN822/sector-compass.git
cd sector-compass
python server.py
# open http://127.0.0.1:8164 and click a bundled sample

Requires Python 3.8+. No pip installs — the backend is standard library only.

Example input / output

Input — two small CSVs:

年份,市场规模,细分          company,revenue,year
2023,29000,公共快充         特来电,3480,2023
2024,37500,公共快充         星星充电,2900,2023

Output (from the one-pager):

HHI 1,044 — moderately concentrated (2023 DOJ/FTC guidelines) [measured]
If 特来电 + 星星充电 merged: post-HHI 1,792 (Δ748) → presumption TRIGGERED [measured]
CAGR 2020→2025: 36.9% [measured] · scenario band ±3pp → 2028 range [scenario]
Robustness: listed-only vs +residual base — verdict FLIPS ⚠

Use cases

  • Consultants & analysts — a defensible first-pass structure read before the expensive database subscription.
  • Students & case-interview prep — the sizing cross-check worksheet mirrors the top-down/bottom-up discipline interviewers ask for.
  • PMs & founders — TAM/SAM/SOM framing with each level's source labeled instead of a hand-waved funnel.
  • China-market researchers — 年份/市场规模/亿元 exports parse natively.

How it works

flowchart LR
  A[market CSV + company CSV] --> B[M1 Ingest\nunits + reconcile]
  B --> C[M2 Structure\nCR/HHI/merger]
  B --> D[M3 Growth\nCAGR + decomposition]
  C --> E[M4 Landscape\nshares + five forces]
  D --> E
  B --> F[M5 Sizing\nbottom-up vs top-down]
  C --> G[M6 Robustness\nbase/unit/window flips]
  C --> H[M7 One-pager\ndecision record]
  D --> H
  E --> H
  F --> H
  G --> H
  H -.optional, your key.-> I[BYOK AI\nexhibit bullets + analyst note]
  I --> H
Loading

The backend is http.server + pure-Python domain modules; the frontend is vanilla JS served from web/. The AI gateway (provider.py) forwards your key per-request to the provider you chose and never stores or logs it.

Project structure

server.py            # local HTTP server, routes, AI job manager
provider.py          # BYOK gateway: presets + custom endpoint + mock
domain/
  ingest.py          # bilingual headers, unit provenance, reconciliation
  structure.py       # CR4/CR8, HHI vs DOJ/FTC thresholds, merger counterfactual
  growth.py          # CAGR, YoY, segment decomposition, scenario band
  landscape.py       # share table, churn, five-forces model
  sizing.py          # bottom-up worksheet vs top-down cross-check
  sensitivity.py     # base/unit/window robustness flips
  ai.py              # grounded exhibit bullets + analyst note (mock included)
  onepager.py        # print-quality decision record (md + html)
fixtures/            # 3 industries + 6 edge cases (committed, seed=64, synthetic)
tests/               # 118 unit + API tests, no network, no key needed
web/                 # frontend (consulting-exhibit design system)

Roadmap

  • Multi-industry comparison view (two briefs side by side)
  • Import preset for 国家统计局 yearbook table exports
  • Numerical-equivalence analysis for merger screens beyond top-2
  • Optional local model narration via Ollama-compatible endpoints

Limitations

  • Structure metrics are computed on the companies you list; the tool shows the residual share and flags thin coverage, but it cannot invent the firms you omitted.
  • The scenario band is arithmetic on CAGR — deliberately not a forecast, and labeled so everywhere.
  • Five forces other than rivalry are your declared judgment; the worksheet stores and labels them, it does not verify them.
  • Bundled fixtures are synthetic (演示用合成数据); they demonstrate the machinery, not real industries.
  • Nothing here is investment advice.

License

MIT — see LICENSE.

About

Local-first industry research assistant — CR4/CR8 + HHI vs official DOJ/FTC thresholds, merger counterfactual, growth decomposition, sizing cross-check, evidence-labeled one-page brief, BYOK AI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages