# Implementation-Shortfall Execution

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

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

## Signature

```ts
implementationShortfallExecution(input)
```

Minimises total shortfall against the arrival price, including the opportunity cost of quantity that never executes. Unexecuted quantity is a real cost, and a strategy measured only on filled shares hides it.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | `ShortfallInput` | yes | Arrival price, quantity, impact and volatility parameters, and the urgency that trades impact against timing risk. |

## Returns

`{ schedule, expected_shortfall_bps, market_impact, timing_risk, opportunity_cost, … }`

Shortfall decomposed into impact, timing risk and opportunity cost — the decomposition is what makes it actionable.

## Errors

- When the arrival price is not positive — throws

## Complexity

Time `O(steps)`, space `O(steps)`.

## 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
{
  "remaining_quantity": 10000,
  "side": "buy",
  "decision_price_atoms": 1000000,
  "current_price_atoms": 1001000,
  "spread_bps": 4,
  "impact_coefficient_bps": 35,
  "average_daily_volume": 1000000,
  "volatility_bps": 18,
  "risk_aversion": 0.8,
  "urgency_bps": 12,
  "intervals_remaining": 8,
  "max_child_quantity": 3000,
  "candidate_step_quantity": 500,
  "lot_size": 100
}
```

### Call

```ts
implementationShortfallExecution(input)
```

### Returns

object with 14 fields: side, decision_price_atoms, current_price_atoms, signed_move_bps, adverse_move_bps, remaining_quantity, selected_child_quantity, post_child_quantity, …

```json
{
  "side": "buy",
  "decision_price_atoms": 1000000,
  "current_price_atoms": 1001000,
  "signed_move_bps": 10,
  "adverse_move_bps": 10,
  "remaining_quantity": 10000,
  "selected_child_quantity": 3000,
  "post_child_quantity": 7000,
  "selected_total_score": 122453.181772,
  "selected_immediate_cost_score": 6315,
  "selected_opportunity_cost_score": 80500,
  "selected_inventory_risk_score": 35638.181772,
  "candidates": [
    {
      "child_quantity": 0,
      "residual_quantity": 10000,
      "immediate_cost_score": 0,
      "opportunity_cost_score": 115000,
      "inventory_risk_score": 50911.688245,
      "total_score": 165911.688245
    },
    {
      "child_quantity": 500,
      "residual_quantity": 9500,
      "immediate_cost_score": 1008.75,
      "opportunity_cost_score": 109250,
      "inventory_risk_score": 48366.103833,
      "total_score": 158624.853833
    },
    {
      "child_quantity": 1000,
      "residual_quantity": 9000,
      "immediate_cost_score": 2035,
      "opportunity_cost_score": 103500,
      "inventory_risk_score": 45820.519421,
      "total_score": 151355.519421
    }
  ],
  "state": "execute-now"
}
```

## Other exports

`almgrenChrissOptimalExecution`, `arrivalPriceExecution`, `liquiditySeekingExecution`, `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/implementation-shortfall-execution/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/execution-and-transaction-cost-analysis/cost-risk-optimization/implementation-shortfall-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
