@captorab/openseries-ts - v1.0.0
    Preparing search index...

    Class OpenFrame

    Collection of aligned timeseries with portfolio and correlation methods.

    Index

    Constructors

    • Parameters

      • constituents: OpenTimeSeries[]
      • weights: number[] | null = null
      • Optionaloptions: { countries?: string | string[] }

      Returns OpenFrame

    Properties

    columnLabels: string[]
    constituents: OpenTimeSeries[]
    countries: string[]

    Country code(s) for business calendar (holidays, resampling). Used when adapting data to business days.

    tsdf: { columns: number[][]; dates: string[] }
    weights: number[] | null

    Accessors

    Methods

    • Parameters

      • assetColumn: number
      • marketColumn: number

      Returns number

    • CAGR-based capture ratio vs benchmark column. Matches Python openseries capture_ratio_func behavior: uses frame data as-is (no resample) with dynamic time_factor = observations / (span_days/365.25).

      Parameters

      • ratio: "both" | "up" | "down"

        "up" | "down" | "both" (up/down or both = up/down)

      • baseColumn: number = -1

        Benchmark column index (-1 = last)

      • Optionalopts: { freq?: ResampleFreq }
        • Optionalfreq?: ResampleFreq

          If set, resample to period-end before computing (e.g. "ME" for monthly). When omitted, uses frame data as-is to match Python default.

      Returns number[]

    • Filters tsdf to retain only business days. Mutates in place.

      Returns this

    • Parameters

      • baseColumn: number = -1

      Returns number[]

    • Parameters

      • assetColumn: number
      • marketColumn: number
      • riskfreeRate: number = 0

      Returns number

    • Max drawdown per column (price series). Returns array of max drawdowns.

      Returns number[]

    • Date when max drawdown bottom occurs per column. Returns array of date strings (or undefined when no drawdown).

      Returns (string | undefined)[]

    • Parameters

      • how: "inner" | "outer" = "outer"

      Returns this

    • Ordinary Least Squares fit of y on x. Regresses tsdf column yColumn (dependent) on xColumn (explanatory). Matches Python openseries ord_least_squares_fit.

      Parameters

      • yColumn: number

        Column index of dependent variable y

      • xColumn: number

        Column index of exogenous variable x

      • Optionalopts: { fittedSeries?: boolean }
        • OptionalfittedSeries?: boolean

          If true, add fitted values as new column (default true)

      Returns OrdLeastSquaresResult

      Object with coefficient (slope), intercept, and rsquared

    • Resamples all constituents to business period-end frequency, then re-merges. Throws if any constituent is a return series.

      Parameters

      Returns this

    • Returns return columns (first element 0). Throws if mixed PRICE/RTRN.

      Returns number[][]

    • Converts each column to drawdown series (value / running peak - 1). Operates on the frame's aligned tsdf. Call after mergeSeries and truncate so drawdown is computed on the truncated date range.

      Returns this

    • Parameters

      • baseColumn: number = -1
      • Optional_opts: { fromDate?: string; toDate?: string }

      Returns number[]

    • Truncates frame and constituents to a common date range.

      Parameters

      • opts: { endCut?: string; startCut?: string; where?: "before" | "after" | "both" } = {}

        Truncation options

        • OptionalendCut?: string

          New last date (default: earliest last date if where includes 'after')

        • OptionalstartCut?: string

          New first date (default: latest first date of all constituents if where includes 'before')

        • Optionalwhere?: "before" | "after" | "both"

          Which end(s) to truncate when cuts not provided

      Returns this