# Liquidity-Seeking Execution

`D13-F02-A04` · Execution and Transaction Cost Analysis → Cost/Risk Optimization · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/execution-and-transaction-cost-analysis/cost-risk-optimization/liquidity-seeking-execution/
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 { liquiditySeekingExecution } from "fintech-algorithms/execution-and-transaction-cost-analysis/cost-risk-optimization/liquidity-seeking-execution";
```

## Signature

```ts
liquiditySeekingExecution(input)
```

Trades opportunistically when liquidity appears rather than on a schedule. Completion time is uncertain by construction — the strategy trades schedule certainty for better prices.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | `LiquiditySeekingInput` | yes | Quantity, the liquidity signals to react to, minimum acceptable size, and the price limit beyond which liquidity is declined. |

## Returns

`{ opportunities, executed, remaining, completion_estimate, … }`

Opportunities taken and passed, with the completion estimate that remains genuinely an estimate.

## Errors

- When the minimum size exceeds the total quantity — throws

## Complexity

Time `O(signals)`, space `O(opportunities)`.

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

`input`:

```json
{
  "total_quantity": 4000,
  "side": "buy",
  "limit_price_atoms": 1000200,
  "minimum_confidence_bps": 7500,
  "maximum_age_ms": 50,
  "max_take_per_event": 700,
  "lot_size": 100,
  "liquidity_events": [
    {
      "event_id": "LQ-01",
      "price_atoms": 1000000,
      "available_quantity": 500,
      "age_ms": 12,
      "confidence_bps": 8500
    },
    {
      "event_id": "LQ-02",
      "price_atoms": 1000100,
      "available_quantity": 900,
      "age_ms": 18,
      "confidence_bps": 7800
    },
    {
      "event_id": "LQ-03",
      "price_atoms": 1000300,
      "available_quantity": 700,
      "age_ms": 8,
      "confidence_bps": 9200
    }
  ]
}
```

### Call

```ts
liquiditySeekingExecution(input)
```

### Returns

object with 9 fields: side, limit_price_atoms, total_quantity, accepted_quantity, remaining_quantity, accepted_event_count, rejected_event_count, events, …

```json
{
  "side": "buy",
  "limit_price_atoms": 1000200,
  "total_quantity": 4000,
  "accepted_quantity": 4000,
  "remaining_quantity": 0,
  "accepted_event_count": 7,
  "rejected_event_count": 5,
  "events": [
    {
      "event_id": "LQ-01",
      "price_atoms": 1000000,
      "available_quantity": 500,
      "age_ms": 12,
      "confidence_bps": 8500,
      "planned_take_quantity": 500,
      "reason": "accepted",
      "remaining_quantity": 3500
    },
    {
      "event_id": "LQ-02",
      "price_atoms": 1000100,
      "available_quantity": 900,
      "age_ms": 18,
      "confidence_bps": 7800,
      "planned_take_quantity": 700,
      "reason": "accepted",
      "remaining_quantity": 2800
    },
    {
      "event_id": "LQ-03",
      "price_atoms": 1000300,
      "available_quantity": 700,
      "age_ms": 8,
      "confidence_bps": 9200,
      "planned_take_quantity": 0,
      "reason": "outside-limit",
      "remaining_quantity": 2800
    }
  ],
  "state": "parent-complete"
}
```

## Other exports

`almgrenChrissOptimalExecution`, `implementationShortfallExecution`, `arrivalPriceExecution`, `opportunisticDarkPoolExecution`, `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/execution-and-transaction-cost-analysis/cost-risk-optimization/liquidity-seeking-execution/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/execution-and-transaction-cost-analysis/cost-risk-optimization/liquidity-seeking-execution/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/execution-and-transaction-cost-analysis/llms.txt
