# PEG Ratio

`D18-F03-A04` · Fundamental Analysis and Valuation → Relative Valuation · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/fundamental-analysis-and-valuation/relative-valuation/peg-ratio/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { pegRatio } from "fintech-algorithms/fundamental-analysis-and-valuation/relative-valuation/peg-ratio";
```

## Signature

```ts
pegRatio(rawInputs)
```

Divides forward P/E by expected EPS growth measured in percentage points for the target and for every peer, compares the target's PEG against the peer median, and re-prices the target at that median PEG when a forward EPS is supplied.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `rawInputs` | `unknown` | yes | Declared `unknown` and narrowed at runtime. It must be a plain object with a `target` object and a `peers` array. `target` supplies a positive `forward_pe` and a positive `expected_eps_growth_percent` (percentage points, not a decimal), plus an optional positive `forward_earnings_per_share` and an optional `current_price`. `peers` holds at least three objects, each with a nonempty and unique string `id`, a positive `forward_pe` and a positive `expected_eps_growth_percent`. |

## Returns

`Record<string, unknown>`

`model`, `growth_unit` fixed at `percentage-points`, `peer_count`, `peer_ratios` (per peer: `id`, `forward_pe`, `expected_eps_growth_percent`, `peg_ratio`), `peg_summary` with `minimum`, `median`, `maximum` and `range`, `target_forward_pe`, `target_growth_percent`, `target_peg_ratio`, `selected_peer_peg` which is the peer median, `relative_peg` (target PEG over that median), `implied_forward_pe` (median peer PEG times the target's growth), `forward_earnings_per_share`, `implied_price` — both null when no forward EPS was supplied — `premium_discount_to_current`, and `state`, either `valuation-complete` or `ratio-only`.

## Errors

- When rawInputs, target or a peer row is not a plain object, or a numeric field is not a finite number — throws TypeError
- When peers is not an array of at least three rows, or a peer id is missing, blank or duplicated — throws RangeError
- When a target or peer forward_pe or expected_eps_growth_percent, or a supplied forward_earnings_per_share or current_price, is not greater than zero — throws RangeError

## Complexity

Time `O(n log n)`, space `O(n)`.

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`rawInputs`:

```json
{
  "target": {
    "forward_pe": 24,
    "expected_eps_growth_percent": 12,
    "forward_earnings_per_share": 2.5,
    "current_price": 60
  },
  "peers": [
    {
      "id": "G1",
      "forward_pe": 18,
      "expected_eps_growth_percent": 15
    },
    {
      "id": "G2",
      "forward_pe": 21,
      "expected_eps_growth_percent": 15
    },
    {
      "id": "G3",
      "forward_pe": 24,
      "expected_eps_growth_percent": 15
    }
  ]
}
```

### Call

```ts
pegRatio(rawInputs)
```

### Returns

object with 15 fields: model, growth_unit, peer_count, peer_ratios, peg_summary, target_forward_pe, target_growth_percent, target_peg_ratio, …

```json
{
  "model": "forward-pe-divided-by-growth-percentage-points",
  "growth_unit": "percentage-points",
  "peer_count": 5,
  "peer_ratios": [
    {
      "id": "G1",
      "forward_pe": 18,
      "expected_eps_growth_percent": 15,
      "peg_ratio": 1.2
    },
    {
      "id": "G2",
      "forward_pe": 21,
      "expected_eps_growth_percent": 15,
      "peg_ratio": 1.4
    },
    {
      "id": "G3",
      "forward_pe": 24,
      "expected_eps_growth_percent": 15,
      "peg_ratio": 1.6
    }
  ],
  "peg_summary": {
    "minimum": 1.2,
    "median": 1.6,
    "maximum": 2,
    "range": 0.8
  },
  "target_forward_pe": 24,
  "target_growth_percent": 12,
  "target_peg_ratio": 2,
  "selected_peer_peg": 1.6,
  "relative_peg": 1.25,
  "implied_forward_pe": 19.200000000000003,
  "forward_earnings_per_share": 2.5,
  "implied_price": 48.00000000000001,
  "premium_discount_to_current": -0.19999999999999984
}
```

Showing 14 of 15 fields.

## Other exports

`calculate`, `pEComparableValuation`, `evEbitdaComparableValuation`, `priceToBookValuation`, `peerMultipleRegression`. Every module additionally exports `run` as an alias of its primary
function, and a `meta` object carrying its catalog id, domain, family, shape and article URL.

## Verification and provenance

Tier: **verified** (via input-expected).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.0.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/fundamental-analysis-and-valuation/relative-valuation/peg-ratio/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/fundamental-analysis-and-valuation/relative-valuation/peg-ratio/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/fundamental-analysis-and-valuation/llms.txt
