# Asynchronous Return Alignment

`D01-F03-A05` · Market Data Engineering → Time Synchronization · archetype `row-classify` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/market-data-engineering/time-synchronization/asynchronous-return-alignment/
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 { classifyIntervalPair } from "fintech-algorithms/market-data-engineering/time-synchronization/asynchronous-return-alignment";
```

## Signature

```ts
classifyIntervalPair(left, right, evaluatedAt)
```

Compares two return intervals and reports exactly how they overlap. Correlating returns measured over intervals that only partly coincide is a quiet and common source of wrong numbers.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `left` | `ReturnInterval` | yes | First return, carrying `event_start`, `event_end`, `available_at` and `return_value`. |
| `right` | `ReturnInterval` | yes | Second return, in the same shape. |
| `evaluatedAt` | `string` | no | Decision time, ISO 8601. Omitted, no evaluation cutoff is applied and availability is reported without being judged against a moment. |

## Returns

`{ geometry, event_overlap_start, event_overlap_end, event_overlap_ms, left_overlap_fraction, right_overlap_fraction, … }`

The overlap geometry — disjoint, partial, nested or identical — with the overlapping window and what fraction of each interval it represents.

## Errors

- When an interval ends before it starts — throws

## Complexity

Time `O(1)`, 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

`left`:

```json
{
  "return_id": "L1",
  "instrument": "L",
  "partition": "S",
  "event_start": "2026-01-01T00:00:00.000Z",
  "event_end": "2026-01-01T00:00:04.000Z",
  "available_at": "2026-01-01T00:00:04.000Z",
  "return_value": 0.01
}
```

`right`:

```json
{
  "return_id": "R1",
  "instrument": "R",
  "partition": "S",
  "event_start": "2026-01-01T00:00:00.000Z",
  "event_end": "2026-01-01T00:00:04.000Z",
  "available_at": "2026-01-01T00:00:04.000Z",
  "return_value": 0.01
}
```

### Call

```ts
classifyIntervalPair(left, right, evaluatedAt)
```

### Returns

object with 11 fields: left_return_id, right_return_id, partition, geometry, event_overlap_start, event_overlap_end, event_overlap_ms, left_overlap_fraction, …

```json
{
  "left_return_id": "L1",
  "right_return_id": "R1",
  "partition": "S",
  "geometry": "exact",
  "event_overlap_start": "2026-01-01T00:00:00.000Z",
  "event_overlap_end": "2026-01-01T00:00:04.000Z",
  "event_overlap_ms": 4000,
  "left_overlap_fraction": 1,
  "right_overlap_fraction": 1,
  "pair_available_at": "2026-01-01T00:00:04.000Z",
  "jointly_available_at_evaluation": null
}
```

## Other exports

`diagnoseAsynchronousReturnAlignment`. 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: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

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/market-data-engineering/time-synchronization/asynchronous-return-alignment/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-data-engineering/time-synchronization/asynchronous-return-alignment/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Asynchronous-Return-Alignment-Time-Synchronization-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-data-engineering/llms.txt
