# Market-Wide Stock Screening and Ranking

`D18-F09-A13` · Fundamental Analysis and Valuation → Integrated Equity Scoring · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/fundamental-analysis-and-valuation/integrated-equity-scoring/market-wide-stock-screening-and-ranking/
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 { marketWideStockScreeningAndRanking } from "fintech-algorithms/fundamental-analysis-and-valuation/integrated-equity-scoring/market-wide-stock-screening-and-ranking";
```

## Signature

```ts
marketWideStockScreeningAndRanking(data)
```

Applies eligibility, score, confidence and liquidity floors to a universe of scored names, ranks the survivors, and records why each excluded name failed.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ screen_floor: number; min_confidence: number; min_liquidity: number; universe: Array<{ id: string; eligible: boolean; score: number; confidence: number; liquidity: number; sector?: string }> }` | yes | `screen_floor` is the minimum score and must be between 0 and 100, `min_confidence` a fraction between 0 and 1, and `min_liquidity` a nonnegative floor. Each universe row needs a text `id`, a `score` between 0 and 100, a `confidence` between 0 and 1 and a nonnegative `liquidity`; its `eligible` must be exactly true to pass, and `sector` falls back to `unspecified`. |

## Returns

`{ state: string; method: string; ranked: Array<{ rank: number; id: string; score: number; confidence: number; liquidity: number; sector: string }>; screened_count: number; universe_count: number; coverage: number; score_floor: number; confidence_floor: number; liquidity_floor: number; excluded: Array<{ id: string; score: number; confidence: number; liquidity: number; sector: string; reasons: string[] }>; tie_break: string }`

`ranked` holds the survivors ordered by score descending, then confidence descending, then id ascending, each carrying a 1-based `rank`. `excluded` carries every failed row with its `reasons` list. `screened_count` over `universe_count` gives `coverage`, the three floor keys echo the thresholds, and `state` is `ranked` when anything survives, otherwise `abstain`.

## Errors

- When universe is not a nonempty list, or a row lacks a text id — throws TypeError
- When min_confidence or a row confidence is not a finite number — throws TypeError
- When screen_floor or a row score is below 0 or above 100 — throws RangeError
- When min_confidence or a row confidence is below 0 or above 1 — throws RangeError
- When min_liquidity or a row liquidity is negative — throws RangeError

## Complexity

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

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`data`:

```json
{
  "screen_floor": 70,
  "min_confidence": 0.75,
  "min_liquidity": 50,
  "universe": [
    {
      "id": "AAA",
      "score": 82,
      "confidence": 0.96,
      "liquidity": 100,
      "eligible": true,
      "sector": "industrial"
    },
    {
      "id": "BBB",
      "score": 82,
      "confidence": 0.88,
      "liquidity": 80,
      "eligible": true,
      "sector": "software"
    },
    {
      "id": "CCC",
      "score": 76,
      "confidence": 0.81,
      "liquidity": 60,
      "eligible": true,
      "sector": "software"
    }
  ]
}
```

### Call

```ts
marketWideStockScreeningAndRanking(data)
```

### Returns

object with 11 fields: state, method, ranked, screened_count, universe_count, coverage, score_floor, confidence_floor, …

```json
{
  "state": "ranked",
  "method": "eligibility-confidence-score-floor-ranking",
  "ranked": [
    {
      "rank": 1,
      "id": "AAA",
      "score": 82,
      "confidence": 0.96,
      "liquidity": 100,
      "sector": "industrial"
    },
    {
      "rank": 2,
      "id": "BBB",
      "score": 82,
      "confidence": 0.88,
      "liquidity": 80,
      "sector": "software"
    },
    {
      "rank": 3,
      "id": "CCC",
      "score": 76,
      "confidence": 0.81,
      "liquidity": 60,
      "sector": "software"
    }
  ],
  "screened_count": 3,
  "universe_count": 6,
  "coverage": 0.5,
  "score_floor": 70,
  "confidence_floor": 0.75,
  "liquidity_floor": 50,
  "excluded": [
    {
      "id": "DDD",
      "score": 74,
      "confidence": 0.62,
      "liquidity": 90,
      "sector": "bank",
      "reasons": ["below confidence floor"]
    },
    {
      "id": "EEE",
      "score": 68,
      "confidence": 0.95,
      "liquidity": 110,
      "sector": "industrial",
      "reasons": ["below score floor"]
    },
    {
      "id": "FFF",
      "score": 90,
      "confidence": 0.99,
      "liquidity": 100,
      "sector": "industrial",
      "reasons": ["not eligible"]
    }
  ],
  "tie_break": "score descending, confidence descending, stable id ascending"
}
```

## Other exports

`calculate`, `pointInTimeStockScoringInputAssembly`, `stockScoringPeerCohortResolver`, `fundamentalMetricDirectionAndPeerNormalization`, `modelApplicabilityAndVariantRouter`, `accountingFinancialHealthComposite`, `earningsQualityComposite`, `dividendSafetyScore`, `balanceSheetResilienceScore`, `distressModelEnsemble`, `crossModelConflictAndDoubleCountingResolver`, `overallExplainableStockScore`, `scoreConfidenceMissingDataPenaltyAndAbstention`, `stockScoreHistoryMigrationAndChangeAttribution`. 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 D).

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/integrated-equity-scoring/market-wide-stock-screening-and-ranking/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/fundamental-analysis-and-valuation/integrated-equity-scoring/market-wide-stock-screening-and-ranking/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
