# Almgren-Chriss Optimal Execution

`D13-F02-A01` · 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/almgren-chriss-optimal-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 { almgrenChrissOptimalExecution } from "fintech-algorithms/execution-and-transaction-cost-analysis/cost-risk-optimization/almgren-chriss-optimal-execution";
```

## Signature

```ts
almgrenChrissOptimalExecution(input)
```

The canonical optimal execution trajectory: trades off market impact against the risk of holding the position longer. Risk aversion is the single parameter that shapes the answer — at zero it degenerates to TWAP.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | `AlmgrenChrissInput` | yes | Total quantity, horizon, volatility, temporary and permanent impact coefficients, and the risk-aversion parameter. The impact coefficients are estimates, and the trajectory is only as good as they are. |

## Returns

`{ trajectory, expected_cost, cost_variance, efficient_frontier_point, … }`

The trading trajectory with expected cost **and** its variance — reporting cost alone hides the trade being made.

## Errors

- When risk aversion is negative, or an impact coefficient 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
{
  "total_quantity": 12000,
  "interval_count": 12,
  "lot_size": 100,
  "temporary_impact_weight": 100,
  "inventory_risk_weight": 1
}
```

### Call

```ts
almgrenChrissOptimalExecution(input)
```

### Returns

object with 13 fields: total_quantity, interval_count, lot_size, temporary_impact_weight, inventory_risk_weight, kappa, scheduled_quantity, remaining_quantity, …

```json
{
  "total_quantity": 12000,
  "interval_count": 12,
  "lot_size": 100,
  "temporary_impact_weight": 100,
  "inventory_risk_weight": 1,
  "kappa": 0.099958380139,
  "scheduled_quantity": 12000,
  "remaining_quantity": 0,
  "temporary_impact_score": 1248000000,
  "inventory_risk_score": 410470000,
  "objective_score": 1658470000,
  "schedule": [
    {
      "interval": 1,
      "target_quantity": 1400,
      "target_remaining_quantity": 10600,
      "temporary_impact_score": 196000000,
      "inventory_risk_score": 112360000
    },
    {
      "interval": 2,
      "target_quantity": 1300,
      "target_remaining_quantity": 9300,
      "temporary_impact_score": 169000000,
      "inventory_risk_score": 86490000
    },
    {
      "interval": 3,
      "target_quantity": 1200,
      "target_remaining_quantity": 8100,
      "temporary_impact_score": 144000000,
      "inventory_risk_score": 65610000
    }
  ],
  "state": "risk-adjusted"
}
```

## Other exports

`implementationShortfallExecution`, `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/almgren-chriss-optimal-execution/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/execution-and-transaction-cost-analysis/cost-risk-optimization/almgren-chriss-optimal-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
