# Filing-Revision Versioning

`D02-F04-A04` · Corporate Actions and Security Master Data → Point-in-Time Universe · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/corporate-actions-and-security-master-data/point-in-time-universe/filing-revision-versioning/
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 { calculate } from "fintech-algorithms/corporate-actions-and-security-master-data/point-in-time-universe/filing-revision-versioning";
```

## Signature

```ts
calculate(data)
```

Selects the version of a financial filing that was current at a knowledge time. Companies restate; using the final restated figure in a backtest means trading on numbers nobody had.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ entityId: string; reportPeriod: string; formFamily: string; asOf: string; records: FilingRecord[] }` | yes | `records` is the full filing and amendment history for the period. `asOf` is the knowledge time — the amendment that superseded a figure last week was not available a month ago. |

## Returns

`{ entityId, reportPeriod, asOf, selectionBasis, accessionNo, form, amendmentNumber, acceptedAt, … }`

The selected filing with its accession number and acceptance time, and the basis on which it was chosen.

## Errors

- When no filing exists for the period at asOf — reported on the result rather than thrown

## Complexity

Time `O(records)`, space `O(1)`.

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`data`:

```json
{
  "entityId": "CIK0000033619",
  "reportPeriod": "2017-09-29",
  "formFamily": "10-K",
  "asOf": "2018-02-01T00:00:00Z",
  "records": [
    {
      "entityId": "CIK0000033619",
      "reportPeriod": "2017-09-29",
      "form": "10-K",
      "accessionNo": "0001564590-17-024189",
      "amendmentNumber": 0,
      "acceptedAt": "2017-11-21T16:32:41Z",
      "ingestedAt": "2017-11-21T16:40:00Z",
      "amendmentScope": ["Original annual filing"],
      "facts": {
        "basicEpsUsdPerShare": 3.94,
        "netEarningsUsdMillions": 117.387
      }
    },
    {
      "entityId": "CIK0000033619",
      "reportPeriod": "2017-09-29",
      "form": "10-K/A",
      "accessionNo": "0001564590-18-007244",
      "amendmentNumber": 1,
      "acceptedAt": "2018-03-30T14:43:54Z",
      "ingestedAt": "2018-03-30T15:00:00Z",
      "amendmentScope": ["Item 6", "Item 7", "Item 8", "Item 9A", "Item 15"],
      "facts": {
        "basicEpsUsdPerShare": 3.75,
        "netEarningsUsdMillions": 111.554
      }
    }
  ]
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 13 fields: entityId, reportPeriod, asOf, selectionBasis, accessionNo, form, amendmentNumber, acceptedAt, …

```json
{
  "entityId": "CIK0000033619",
  "reportPeriod": "2017-09-29",
  "asOf": "2018-02-01T00:00:00Z",
  "selectionBasis": "latest accepted filing among locally ingested versions",
  "accessionNo": "0001564590-17-024189",
  "form": "10-K",
  "amendmentNumber": 0,
  "acceptedAt": "2017-11-21T16:32:41Z",
  "ingestedAt": "2017-11-21T16:40:00Z",
  "amendmentScope": ["Original annual filing"],
  "facts": {
    "basicEpsUsdPerShare": 3.94,
    "netEarningsUsdMillions": 117.387
  },
  "eligibleAccessions": ["0001564590-17-024189"],
  "excludedNotYetIngested": ["0001564590-18-007244"]
}
```

## Verification and provenance

Tier: **verified** (via input-expected).

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/corporate-actions-and-security-master-data/point-in-time-universe/filing-revision-versioning/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/corporate-actions-and-security-master-data/point-in-time-universe/filing-revision-versioning/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/corporate-actions-and-security-master-data/llms.txt
