Skip to content
TotalFinance

Core · @insiderfinance/totalfinance

@insiderfinance/totalfinance/core

import { … } from '@insiderfinance/totalfinance/core'
stable-by-law (pre-1.0; not a 1.0 stability guarantee)class 8type 26iface 37const 11fn 70JSON ↗
iface

DaySession

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { DaySession } from '@insiderfinance/totalfinance/core';

export interface DaySession {
    date: string;
    isBusinessDay: boolean;
    isHalfDay: boolean;
    /** Local `HH:MM` open (present only on business days). */
    open?: string;
    /** Local `HH:MM` close (early close on half days). */
    close?: string;
}
Fields, parameters and returned members (5)
Name · typeMeaning · unitRequired · default
closestring

Local HH:MM close (early close on half days).

unitless by name
OptionalNo @default declared
datestring—unitless by nameRequiredNo @default declared
isBusinessDayboolean—unitless by nameRequiredNo @default declared
isHalfDayboolean—unitless by nameRequiredNo @default declared
openstring

Local HH:MM open (present only on business days).

unitless by name
OptionalNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

Deliverable

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { Deliverable } from '@insiderfinance/totalfinance/core';

export interface Deliverable {
    cash?: number;
    shares?: Array<{
        symbol: string;
        quantity: number;
    }>;
    notes?: string;
}
Fields, parameters and returned members (3)
Name · typeMeaning · unitRequired · default
cashnumber—unitless by nameOptionalNo @default declared
notesstring—unitless by nameOptionalNo @default declared
shares{ symbol: string; quantity: number; }[]—unitless by nameOptionalNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

Diagnostics

#

Non-value metadata about how a result was computed.

Signature
import type { Diagnostics } from '@insiderfinance/totalfinance/core';

/** Non-value metadata about how a result was computed. */
export interface Diagnostics {
    /** Pricing/solver engine name, e.g. `black-scholes-merton`. */
    engine?: string;
    /** Numerical method, e.g. `closed-form`, `brent`, `finite-difference`. */
    method?: string;
    /** Whether an iterative procedure converged. `false` means the value is not trustworthy. */
    converged?: boolean;
    /** Iteration count for iterative methods. */
    iterations?: number;
    /**
     * When a meta-engine (e.g. `engines.auto()`) selected a delegate, this is a one-sentence,
     * human-readable explanation of WHY that delegate was chosen (`engine` then names the delegate).
     * Absent when no auto-selection took place.
     */
    autoReason?: string;
    /**
     * The structured engine-selection report (Gate C, `@insiderfinance/totalfinance/core/pricing`): who was selected,
     * why, and — for automatic selection — every candidate considered with its verdict. This is the
     * machine-readable superset of `engine` + `autoReason` (which remain for compatibility);
     * `selected.name` always agrees with `engine` when both are present.
     */
    selection?: SelectionReport;
    /**
     * Named intermediate quantities the value decomposes into — a par spread's protection leg and
     * risky annuity, a forward variance's near/far legs. The H-series explain paths disclose their
     * arithmetic here so a caller can audit the ratio, not just receive it (3B.3).
     */
    decomposition?: Record<string, number>;
    /** Structured warnings; always present (possibly empty). */
    warnings: QuantWarning[];
    /** Wall-clock timing in milliseconds, when measured. */
    timingMs?: number;
    /**
     * Series facades: number of leading output slots that are warmup sentinels (null/NaN) while the
     * computation seeds. Equals the input length when the indicator never emitted.
     */
    warmup?: number;
    /**
     * Finite-difference engines: the ACTUAL bump sizes used for FD Greeks (spec P2.3) — adaptive
     * near the vol/time boundaries, so the caller can see exactly what was differenced.
     * Keys: `spotStep`, `volatilityStep`, `timeStepYears`, `rateStep`, and — extended Greeks only —
     * `dividendYieldStep`. Each is the actual step differenced, in the unit of the coordinate it
     * bumps. (This doc named the retired `hS`/`hSig`/`hT`/`hR`/`hQ` keys for one release after the
     * emit sites had moved to the semantic names, so a caller following it read `undefined`.)
     */
    finiteDifferenceBumps?: Record<string, number>;
}
Fields, parameters and returned members (17)

Loading 17 members…

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

Dividend

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { Dividend } from '@insiderfinance/totalfinance/core';

export interface Dividend {
    symbol: SymbolId;
    exDate: string;
    payDate?: string;
    amount: number;
    currency?: string;
    type?: 'regular' | 'special' | 'returnOfCapital' | 'unknown';
}
Fields, parameters and returned members (6)
Name · typeMeaning · unitRequired · default
amountnumber—unitless by nameRequiredNo @default declared
currencystring—unitless by nameOptionalNo @default declared
exDatestring—calendar date (YYYY-MM-DD)RequiredNo @default declared
payDatestring—calendar date (YYYY-MM-DD)OptionalNo @default declared
symbolstring—unitless by nameRequiredNo @default declared
type'unknown' | 'regular' | 'special' | 'returnOfCapital'—unitless by nameOptionalNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

DividendModel

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { DividendModel } from '@insiderfinance/totalfinance/core';

export type DividendModel = 'none' | 'continuousYield' | 'discreteSchedule';

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

EpochMs

#

Unix epoch milliseconds.

Signature
import type { EpochMs } from '@insiderfinance/totalfinance/core';

/** Unix epoch milliseconds. */
export type EpochMs = number;

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

ErrorCode

#

A literal table allows bundlers to discard the registry or unused properties without executing a catalog constructor. The declared key/value/order contract is checked independently below.

Signature
import type { ErrorCode } from '@insiderfinance/totalfinance/core';

export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
Fields, parameters and returned members (151)

Loading 151 members…

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

ExerciseTime

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { ExerciseTime } from '@insiderfinance/totalfinance/core';

export type ExerciseTime = 'AM' | 'PM';

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

Facade

#

ExplainValue defaults to Output and diverges only for solver facades (Law 7 / E3): the plain call THROWS on failure so its output stays number, while the .explain envelope reports the same failure softly as value: null + converged: false.

Signature
import type { Facade } from '@insiderfinance/totalfinance/core';

/**
 * A callable `(input) => Output` with an `.explain(input) => Computed<Output, Extra>` companion. The
 * `Extra` type parameter carries the domain-specific assumptions the envelope discloses (it defaults
 * to none), so `f.explain(input).assumptions.<extraField>` type-checks.
 */
/**
 * `ExplainValue` defaults to `Output` and diverges only for solver facades (Law 7 / E3): the plain
 * call THROWS on failure so its output stays `number`, while the `.explain` envelope reports the
 * same failure softly as `value: null` + `converged: false`.
 */
export type Facade<Input, Output, Extra extends Record<string, unknown> = Record<never, never>, ExplainValue = Output> = ((input: Input) => Output) & {
    explain: (input: Input) => Computed<ExplainValue, Extra>;
};
Fields, parameters and returned members (7)
Name · typeMeaning · unitRequired · default
(input)Input—unitless by nameRequiredNo @default declared
explain(input: Input) => Computed<ExplainValue, Extra>—unitless by nameRequiredNo @default declared
explain().return.assumptionsimport('@insiderfinance/totalfinance/core').Assumptions<Extra>

Every applied convention, echoed back.

unitless by name
RequiredNo @default declared
explain().return.diagnosticsimport('@insiderfinance/totalfinance/core').Diagnostics

How the value was computed, plus any warnings.

unitless by name
RequiredNo @default declared
explain().return.provenanceimport('@insiderfinance/totalfinance/core').Provenance

Optional data lineage when the inputs came from a provider.

unitless by name
OptionalNo @default declared
explain().return.valueExplainValue

The computed value. Never NaN or ±Infinity: a value the model cannot produce is null beside a diagnostic that says why (Law 7 — a warning never licenses a non-finite number).

unitless by name
RequiredNo @default declared
explain(input)Input—unitless by nameRequiredNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

FormatMoneyOptions

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { FormatMoneyOptions } from '@insiderfinance/totalfinance/core';

export interface FormatMoneyOptions {
    currency?: string;
    locale?: string;
    decimals?: number;
}
Fields, parameters and returned members (3)
Name · typeMeaning · unitRequired · default
currencystring—unitless by nameOptionalNo @default declared
decimalsnumber—unitless by nameOptionalNo @default declared
localestring—unitless by nameOptionalNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

FormatPercentOptions

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { FormatPercentOptions } from '@insiderfinance/totalfinance/core';

export interface FormatPercentOptions {
    /** Fraction digits (default `2`). */
    decimals?: number;
    /** If `true`, the input is already a percentage (e.g. `22`) rather than a fraction (`0.22`). */
    asPercentagePoints?: boolean;
    locale?: string;
}
Fields, parameters and returned members (3)
Name · typeMeaning · unitRequired · default
asPercentagePointsboolean

If true, the input is already a percentage (e.g. 22) rather than a fraction (0.22).

unitless by name
OptionalNo @default declared
decimalsnumber

Fraction digits (default 2).

unitless by name
OptionalNo @default declared
localestring—unitless by nameOptionalNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

GreekUnits

#

Units in which Greeks are reported.

Signature
import type { GreekUnits } from '@insiderfinance/totalfinance/core';

/** Units in which Greeks are reported. */
export interface GreekUnits {
    theta: ThetaUnit;
    vega: VegaUnit;
    rho: RhoUnit;
}
Fields, parameters and returned members (3)
Name · typeMeaning · unitRequired · default
rhoRhoUnit—unitless by nameRequiredNo @default declared
thetaThetaUnit—unitless by nameRequiredNo @default declared
vegaVegaUnit—unitless by nameRequiredNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

GuaranteedSelection

#

The names a selection of type S is CERTAIN to contain — the names a result may promise as required. Every other name in S[number] was only possibly selected, so a result types it as optional.

A name is guaranteed when every possible value of S holds it as a whole element: - readonly ['price', 'gamma'] guarantees 'price' | 'gamma'; - a union of selections guarantees only what all of them share: readonly ['gamma'] | readonly ['delta'] (a conditional) guarantees nothing, and readonly ['price', 'gamma'] | readonly ['price'] guarantees 'price'; - an element that is itself a union guarantees none of its members: readonly ['gamma' | 'delta'] holds one of the two, and the type cannot say which; - a list without a fixed length (BlackScholesOutput[]) guarantees nothing.

S extends unknown distributes over the members of S, giving one verdict per possible selection; a name is kept only when no member says false.

Signature
import type { GuaranteedSelection } from '@insiderfinance/totalfinance/core';

/**
 * The names a selection of type `S` is CERTAIN to contain — the names a result may promise as
 * required. Every other name in `S[number]` was only possibly selected, so a result types it as
 * optional.
 *
 * A name is guaranteed when every possible value of `S` holds it as a whole element:
 * - `readonly ['price', 'gamma']` guarantees `'price' | 'gamma'`;
 * - a union of selections guarantees only what all of them share:
 *   `readonly ['gamma'] | readonly ['delta']` (a conditional) guarantees nothing, and
 *   `readonly ['price', 'gamma'] | readonly ['price']` guarantees `'price'`;
 * - an element that is itself a union guarantees none of its members: `readonly ['gamma' | 'delta']`
 *   holds one of the two, and the type cannot say which;
 * - a list without a fixed length (`BlackScholesOutput[]`) guarantees nothing.
 *
 * `S extends unknown` distributes over the members of `S`, giving one verdict per possible
 * selection; a name is kept only when no member says `false`.
 */
export type GuaranteedSelection<S extends readonly string[]> = {
    [K in S[number]]: false extends (S extends unknown ? number extends S['length'] ? false : K extends {
        [I in keyof S]: [
            S[I]
        ] extends [
            K
        ] ? K : never;
    }[number] ? true : false : never) ? never : K;
}[S[number]];

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

HolidayRule

#

A holiday/half-day rule: given a year, return the ISO date it falls on, or null if not observed.

Signature
import type { HolidayRule } from '@insiderfinance/totalfinance/core';

// ---- rules engine ----
/** A holiday/half-day rule: given a year, return the ISO date it falls on, or `null` if not observed. */
export type HolidayRule = (year: number) => string | null;
Fields, parameters and returned members (1)
Name · typeMeaning · unitRequired · default
(year)number—unitless by nameRequiredNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

class

InputError

#

Invalid or nonsensical input (programmer error or malformed payload).

Signature
import { InputError } from '@insiderfinance/totalfinance/core';

export declare class InputError extends QuantError {
  constructor(message: string, options: QuantErrorOptions);
  static captureStackTrace(targetObject: object, constructorOpt?: Function): void;
  static prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
  static stackTraceLimit: number;
  cause?: unknown;
  readonly code: string;
  readonly context?: Record<string, unknown>;
  message: string;
  name: string;
  stack?: string;
  toJSON(): { serialization: 1; name: string; code: string; message: string; context?: Record<string, unknown>; };
}
Fields, parameters and returned members (16)

Loading 16 members…

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

InterestCompounding

#

The ONE public interest-compounding grammar (FC0). Every rate-bearing contract in the library quotes its compounding in this vocabulary — the former core 'continuous' | 'simple' pair and fixed-income's separate curve grammar (with its bare-number periodic form) are unified here, with no compatibility aliases (pre-1.0). The object form names its meaning: a bare 12 said nothing about being periods-per-year.

Signature
import type { InterestCompounding } from '@insiderfinance/totalfinance/core';

/** Interest compounding conventions. */
/**
 * The ONE public interest-compounding grammar (FC0). Every rate-bearing contract in the library
 * quotes its compounding in this vocabulary — the former core `'continuous' | 'simple'` pair and
 * fixed-income's separate curve grammar (with its bare-number periodic form) are unified here,
 * with no compatibility aliases (pre-1.0). The object form names its meaning: a bare `12` said
 * nothing about being periods-per-year.
 */
export type InterestCompounding = 'simple' | 'continuous' | 'annual' | 'semiannual' | 'quarterly' | 'monthly' | {
    type: 'periodic';
    periodsPerYear: number;
};
Fields, parameters and returned members (2)
Name · typeMeaning · unitRequired · default
periodsPerYearnumber—per year (count)RequiredNo @default declared
type'periodic'—unitless by nameRequiredNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

JSONSchema

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { JSONSchema } from '@insiderfinance/totalfinance/core';

export interface JSONSchema {
    $schema?: string;
    $id?: string;
    title?: string;
    description?: string;
    type?: JSONSchemaTypeName | JSONSchemaTypeName[];
    enum?: unknown[];
    const?: unknown;
    default?: unknown;
    // object
    properties?: Record<string, JSONSchema>;
    required?: string[];
    additionalProperties?: boolean | JSONSchema;
    // array
    items?: JSONSchema;
    minItems?: number;
    maxItems?: number;
    // number
    minimum?: number;
    maximum?: number;
    exclusiveMinimum?: number;
    exclusiveMaximum?: number;
    multipleOf?: number;
    // string
    minLength?: number;
    maxLength?: number;
    pattern?: string;
    format?: string;
    // composition
    anyOf?: JSONSchema[];
    oneOf?: JSONSchema[];
    allOf?: JSONSchema[];
    /** Allow vendor/extension keywords without losing type-checking on the known ones. */
    [key: string]: unknown;
}
Fields, parameters and returned members (52)

Loading 52 members…

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

MarketInputs

#

The canonical market snapshot every pricing/analytics entrypoint takes (spec §5.3 / WS3.2). One shape, one vocabulary: spot, rate, optional dividendYield (default 0), and the asOf the snapshot is valid for. Package-specific markets EXTEND this and add their own fields (options adds forward/volatility/quotes; structure/vol pair it with a separate config), so the same word always means the same thing across the workspace.

Signature
import type { MarketInputs } from '@insiderfinance/totalfinance/core';

/**
 * The canonical market snapshot every pricing/analytics entrypoint takes (spec §5.3 / WS3.2). One
 * shape, one vocabulary: `spot`, `rate`, optional `dividendYield` (default 0), and the `asOf` the
 * snapshot is valid for. Package-specific markets EXTEND this and add their own fields (options adds
 * `forward`/`volatility`/quotes; structure/vol pair it with a separate `config`), so the same word
 * always means the same thing across the workspace.
 */
export interface MarketInputs {
    spot: number;
    riskFreeRate: number;
    /** Continuous dividend yield; defaults to 0 when omitted. */
    dividendYield?: number;
    /**
     * Snapshot time: epoch ms, `'YYYY-MM-DD'`, or a ZONED ISO datetime — one grammar for "when"
     * across every package. Each boundary resolves it once via core `resolveAsOf` (zone-less
     * datetimes are rejected with a teaching error; TotalFinance never reads the machine clock or zone).
     */
    asOf: EpochMs | string;
}
Fields, parameters and returned members (4)
Name · typeMeaning · unitRequired · default
asOfstring | number

Snapshot time: epoch ms, 'YYYY-MM-DD', or a ZONED ISO datetime — one grammar for "when" across every package. Each boundary resolves it once via core resolveAsOf (zone-less datetimes are rejected with a teaching error; TotalFinance never reads the machine clock or zone).

an instant: epoch milliseconds or a YYYY-MM-DD / zoned ISO string (the resolveAsOf convention)
RequiredNo @default declared
dividendYieldnumber

Continuous dividend yield; defaults to 0 when omitted.

decimal rate (0.05 = 5%)
OptionalNo @default declared
riskFreeRatenumber—decimal rate (0.05 = 5%)RequiredNo @default declared
spotnumber—unitless by nameRequiredNo @default declared

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

ORDER_SIDES

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import { ORDER_SIDES } from '@insiderfinance/totalfinance/core';

export declare const ORDER_SIDES: readonly OrderSide[];

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

ORDER_TYPES

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import { ORDER_TYPES } from '@insiderfinance/totalfinance/core';

export declare const ORDER_TYPES: readonly OrderType[];

Stability: stable-by-law (pre-1.0; not a 1.0 stability guarantee). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.