# Historical VWAP Execution

`D13-F01-A02` · Execution and Transaction Cost Analysis → Schedule-Based Execution · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/execution-and-transaction-cost-analysis/schedule-based-execution/historical-vwap-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 { historicalVwapExecution } from "fintech-algorithms/execution-and-transaction-cost-analysis/schedule-based-execution/historical-vwap-execution";
```

## Signature

```ts
historicalVwapExecution(total_quantity, historical_bucket_volumes, lot_size, profile_id)
```

Distributes an order according to a historical intraday volume profile — heavier at the open and close. Assumes today resembles the profile, which is exactly the assumption that fails on event days.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `total_quantity` | `number` | yes | Total quantity. · min: 1, integer: true |
| `historical_bucket_volumes` | `number[]` | yes | Historical volume per bucket, forming the profile. |
| `lot_size` | `number` | yes | Lot size. · min: 1, integer: true |
| `profile_id` | `string` | yes | Identifier of the profile used, recorded so an execution can be explained after the fact. |

## Returns

`{ schedule, profile_weights, profile_id, … }`

The schedule with the profile weights that produced it.

## Errors

- When the historical volumes sum to zero — throws

## Complexity

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

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

`total_quantity`:

```json
24000
```

`historical_bucket_volumes`:

```json
[2400, 2000, 1700, 1500, 1300, 1200]
```

Showing 6 of 24 elements.

`lot_size`:

```json
100
```

`profile_id`:

```json
"SYN-24B-U-2026-07"
```

### Call

```ts
historicalVwapExecution(total_quantity, historical_bucket_volumes, lot_size, profile_id)
```

### Returns

object with 9 fields: profile_id, total_quantity, lot_size, bucket_count, historical_volume_total, scheduled_quantity, remaining_quantity, schedule, …

```json
{
  "profile_id": "SYN-24B-U-2026-07",
  "total_quantity": 24000,
  "lot_size": 100,
  "bucket_count": 24,
  "historical_volume_total": 38250,
  "scheduled_quantity": 24000,
  "remaining_quantity": 0,
  "schedule": [
    {
      "bucket": 1,
      "historical_volume": 2400,
      "historical_weight": 0.062745098039,
      "target_quantity": 1500,
      "target_cumulative_quantity": 1500
    },
    {
      "bucket": 2,
      "historical_volume": 2000,
      "historical_weight": 0.052287581699,
      "target_quantity": 1300,
      "target_cumulative_quantity": 2800
    },
    {
      "bucket": 3,
      "historical_volume": 1700,
      "historical_weight": 0.044444444444,
      "target_quantity": 1100,
      "target_cumulative_quantity": 3900
    }
  ],
  "state": "complete-schedule"
}
```

## Other exports

`twapExecution`, `adaptiveVwapExecution`, `percentageOfVolumeExecution`, `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/schedule-based-execution/historical-vwap-execution/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/execution-and-transaction-cost-analysis/schedule-based-execution/historical-vwap-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
