---
title: Concentration
description: "Measure how diversified your portfolio really is. Firma computes the Herfindahl-Hirschman Index (HHI) across four dimensions: ticker, currency, sector, and country."
---

export const tiers = [
  { cmd: '< 1500',      desc: <span style={{ color: 'var(--green)'  }}>Low: well diversified</span> },
  { cmd: '1500 – 2500', desc: <span style={{ color: 'var(--cyan)'   }}>Moderate: some concentration</span> },
  { cmd: '2500 – 5000', desc: <span style={{ color: 'var(--yellow)' }}>High: consider rebalancing</span> },
  { cmd: '> 5000',      desc: <span style={{ color: 'var(--red)'    }}>Very high: heavily concentrated</span> },
];

export const hintRows = [
  { cmd: 'sell ≈428 TSLA @ $350.40', desc: 'How many shares to sell and around what price. The share count is estimated from the last synced price, so the actual execution price will differ.' },
  { cmd: 'TSLA: 74% → 50%',          desc: "Your dominant ticker's portfolio weight before and after the suggested sale." },
  { cmd: 'HHI → <2500',              desc: 'The target after the sale. The boundary between "high" and "moderate" concentration.' },
];

export const optionsRows = [
  { cmd: <code>firma show concentration</code>,        desc: 'HHI across all four dimensions' },
  { cmd: <code>firma show concentration --json</code>, desc: 'Machine-readable output with top slices per dimension' },
];

export const claudeExchange = [{
  user: 'Am I too concentrated in any one stock?',
  ai: <p>
    Yes. Ticker HHI is <code>5,841</code> (very high). TSLA is{' '}
    <code>74%</code> of the portfolio. A 10% move swings your total
    value by roughly <code>$15,000</code>.
    Currency and country both score 10,000 because the portfolio is entirely USD and entirely US.
    Sector concentration mirrors ticker concentration, with Automobiles at 74%.
  </p>,
}];

<Section label="What is HHI?">
The HHI is the sum of squared market-share fractions, scaled to 0-10,000.
A portfolio with a single holding scores 10,000, which is maximum concentration.
Equal weights across many holdings approach 0.

  <CommandTable rows={tiers} />
</Section>

<Section label="firma show concentration">
Shows the HHI score and severity for each dimension, along with
the top contributors by market value weight.

<div className="terminal">
  <div className="terminal-line">
    <span className="term-prompt">$</span>
    <span className="term-cmd">firma show concentration</span>
  </div>
  <table className="term-table">
    <thead>
      <tr><th>DIMENSION</th><th>HHI</th><th>SEVERITY</th><th>TOP HOLDINGS</th></tr>
    </thead>
    <tbody>
      <tr className="sep"><td colSpan={4}/></tr>
      <tr><td className="td-bold">Ticker</td><td className="td-orange">5841</td><td className="td-orange">very high</td><td className="td-muted">TSLA 74%, NVDA 16%, AAPL 6%, MSFT 4%</td></tr>
      <tr><td className="td-bold">Currency</td><td className="td-orange">10000</td><td className="td-orange">very high</td><td className="td-muted">USD 100%</td></tr>
      <tr><td className="td-bold">Sector</td><td className="td-orange">5884</td><td className="td-orange">very high</td><td className="td-muted">Automobiles 74%, Semiconductors 16%, Technology 10%</td></tr>
      <tr><td className="td-bold">Country</td><td className="td-orange">10000</td><td className="td-orange">very high</td><td className="td-muted">US 100%</td></tr>
      <tr className="sep"><td colSpan={4}/></tr>
    </tbody>
    <tfoot>
      <tr><td className="td-muted" colSpan={4}>&lt;1500 low · 1500–2500 moderate · 2500–5000 high · &gt;5000 very high</td></tr>
    </tfoot>
  </table>
  <pre className="term-pre" style={{ marginTop: '0.5rem' }}>
    {'  '}
    <span className="td-muted">Rebalance hint</span>
    {'  '}
    <span style={{ color: 'var(--yellow)' }}>→  sell ≈428 TSLA @ $350.40</span>
    {'  ·  '}
    <span className="td-muted">TSLA: 74% → 50%  ·  HHI → &lt;2500</span>
  </pre>
</div>

  <Note>
    Sector and country data comes from Finnhub via <code>firma sync</code>.
    Tickers without price data are excluded from the calculation.
  </Note>
</Section>

<Section label="Reading the Rebalance Hint">
When ticker HHI exceeds 2500, firma appends a one-line rebalance suggestion
below the table. It finds the minimum amount to sell from the most concentrated
position to bring ticker HHI below 2500.

  <CommandTable rows={hintRows} />

  <Note>
    This is a mechanical heuristic, not financial advice. The hint only considers
    ticker-level HHI and targets a single threshold. Whether to act on it depends
    on your tax situation, conviction in the position, and the transaction costs involved.
  </Note>
</Section>

<Section label="Options">
  <CommandTable rows={optionsRows} />
</Section>

<Section label="With Claude">
  <ChatDemo header="Claude Desktop · firma MCP connected" exchanges={claudeExchange} />
</Section>
