# Circuit-Breaker Trigger

`D12-F03-A06` · Matching Engines and Venue Logic → Order Controls · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/matching-engines-and-venue-logic/order-controls/circuit-breaker-trigger/
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 { circuitBreakerTrigger } from "fintech-algorithms/matching-engines-and-venue-logic/order-controls/circuit-breaker-trigger";
```

## Signature

```ts
circuitBreakerTrigger(reference_close_atoms, current_index_atoms, level_thresholds_bps, previously_triggered_level)
```

Evaluates market-wide circuit breaker levels against the index move. Levels are sequential — once a level has fired it cannot fire again the same session, which is why the previously-triggered level is an input.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `reference_close_atoms` | `number` | yes | Prior close the move is measured from, in atoms. · min: 0, integer: true |
| `current_index_atoms` | `number` | yes | Current index level in atoms. · min: 0, integer: true |
| `level_thresholds_bps` | `number[]` | yes | Thresholds in basis points, ascending. |
| `previously_triggered_level` | `number` | yes | Highest level already triggered this session; 0 if none. |

## Returns

`{ triggered, level, decline_bps, halt_required, … }`

Whether a breaker fires, at which level, and the measured decline.

## Errors

- When thresholds are not ascending — throws

## Complexity

Time `O(levels)`, space `O(1)`.

## 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

`reference_close_atoms`:

```json
4000000
```

`current_index_atoms`:

```json
3480000
```

`level_thresholds_bps`:

```json
[700, 1300, 2000]
```

`previously_triggered_level`:

```json
1
```

### Call

```ts
circuitBreakerTrigger(reference_close_atoms, current_index_atoms, level_thresholds_bps, previously_triggered_level)
```

### Returns

object with 12 fields: reference_close_atoms, current_index_atoms, decline_bps, level_thresholds_bps, previously_triggered_level, reached_level, newly_triggered_level, newly_triggered, …

```json
{
  "reference_close_atoms": 4000000,
  "current_index_atoms": 3480000,
  "decline_bps": 1300,
  "level_thresholds_bps": [700, 1300, 2000],
  "previously_triggered_level": 1,
  "reached_level": 2,
  "newly_triggered_level": 2,
  "newly_triggered": true,
  "action": "level-2-halt",
  "next_threshold_bps": 2000,
  "distance_to_next_threshold_bps": 700,
  "state": "triggered"
}
```

## Other exports

`tickSizeValidation`, `priceBandValidation`, `selfTradePrevention`, `cancelOnDisconnect`, `fatFingerLimit`, `calculate`. 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.1.
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/matching-engines-and-venue-logic/order-controls/circuit-breaker-trigger/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/matching-engines-and-venue-logic/order-controls/circuit-breaker-trigger/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/matching-engines-and-venue-logic/llms.txt
