# Rights-Issue TERP Adjustment

`D02-F02-A01` · Corporate Actions and Security Master Data → Complex Distributions · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/corporate-actions-and-security-master-data/complex-distributions/rights-issue-terp-adjustment/
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/complex-distributions/rights-issue-terp-adjustment";
```

## Signature

```ts
calculate(input)
```

Computes the theoretical ex-rights price. A rights issue is not a dividend and not a split: shareholders receive the right to buy new shares below market, so value transfers rather than disappears, and TERP is the price that makes the series continuous.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | `{ asOf: string; revisions: EventRevision[] }` | yes | Each revision carries the cum price, the subscription price, and the ratio of new to existing shares. Point-in-time by construction: `asOf` is the knowledge time, and only revisions available at or before it are eligible. Passing the event date instead of the knowledge date is what lets a backtest use information it could not have had. |

## Returns

`{ terp, referencePrice, subscriptionCashQuote, valuePerOldShare, adjustmentFactor, … }`

TERP with every input that produced it, plus the value per old share — the quantity that shows the transfer is a transfer and not a loss.

## Errors

- When no revision is available at asOf — returned as a state on the result rather than thrown
- When the subscription ratio is not positive — throws

## Complexity

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

`input`:

```json
{
  "asOf": "2024-05-24T00:00:00Z",
  "revisions": [
    {
      "eventId": "NG-2024-RIGHTS",
      "revisionId": "NG-PROSPECTUS-2024-05-23",
      "revisionSequence": 1,
      "availableAt": "2024-05-23T23:59:59Z",
      "status": "confirmed",
      "recordAt": "2024-05-20T18:00:00+01:00",
      "exAt": "2024-05-24T08:00:00+01:00",
      "rightsTradingStartAt": "2024-05-24T08:00:00+01:00",
      "paymentDeadlineAt": "2024-06-10T11:00:00+01:00",
      "newSharesTradeAt": "2024-06-12T08:00:00+01:00",
      "terms": {
        "oldShares": 24,
        "newShares": 7,
        "rawCumRightsPrice": 1127.5,
        "cashDisadvantage": 39.12,
        "quoteCurrency": "GBp",
        "subscriptionPrice": 645,
        "subscriptionCurrency": "GBp",
        "fxQuotePerSubscription": 1,
        "feesPerNewShareQuote": 0,
        "taxesPerNewShareQuote": 0,
        "holdingOldShares": 100,
        "outOfMoneyPolicy": "reject",
        "priceSourceId": "NG-PROSPECTUS-P52-LSE-DOL-QUOTE",
        "priceDate": "2024-05-22"
      }
    }
  ]
}
```

### Call

```ts
calculate(input)
```

### Returns

object with 15 fields: eventId, revisionId, availableAt, quoteCurrency, referencePrice, subscriptionCashQuote, terp, valuePerOldShare, …

```json
{
  "eventId": "NG-2024-RIGHTS",
  "revisionId": "NG-PROSPECTUS-2024-05-23",
  "availableAt": "2024-05-23T23:59:59Z",
  "quoteCurrency": "GBp",
  "referencePrice": 1088.38,
  "subscriptionCashQuote": 645,
  "terp": 988.261935,
  "valuePerOldShare": 100.118065,
  "valuePerNewShareRight": 343.261935,
  "adjustmentFactor": 0.908012,
  "issueDiscountToTerp": 0.347339,
  "inTheMoney": true,
  "applied": true,
  "entitlement": {
    "exactNewShares": 29.166667,
    "wholeNewShares": 29,
    "fractionalNewShare": 0.166667
  }
}
```

Showing 14 of 15 fields.

## 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/complex-distributions/rights-issue-terp-adjustment/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/corporate-actions-and-security-master-data/complex-distributions/rights-issue-terp-adjustment/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Rights-Issue-TERP-Adjustment-Corporate-Actions-algorithm
- 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
