Skip to content

@livefolio/sdk / FeatureRuntimeOptions

Type Alias: FeatureRuntimeOptions

FeatureRuntimeOptions = { dataFeed: DataFeed; featureCache: FeatureCache; field?: BarField; freq: Frequency; mode?: "historical"; range: DateRange; } | { dataFeed?: DataFeed; featureCache: FeatureCache; field?: BarField; freq: Frequency; initialBars?: ReadonlyMap<AssetId, ReadonlyArray<Bar>>; mode: "streaming"; }

Defined in: features/runtime.ts:35

Configuration for a FeatureRuntime instance.

Accepts two shapes — select via the mode discriminant:

  • 'historical' (default, mode may be omitted): range-bounded backtest mode. Bars are fetched from DataFeed once per asset and cached in memory.
  • 'streaming': open-ended live mode. No fixed range; bars are pushed in via appendBar. Indicator computation reads from the growing in-process buffer instead of calling DataFeed.bars.

The historical variant is backward-compatible — existing callers that omit mode compile and behave identically to before.

Union Members

Type Literal

{ dataFeed: DataFeed; featureCache: FeatureCache; field?: BarField; freq: Frequency; mode?: "historical"; range: DateRange; }

NameTypeDescriptionDefined in
dataFeedDataFeedThe market-data source used to fetch OHLCV bars.features/runtime.ts:41
featureCacheFeatureCachePersistent indicator cache. Use MemoryFeatureCache for a single backtest run, or supply a cross-process cache implementation to share results across multiple runs or processes.features/runtime.ts:47
field?BarFieldWhich OHLCV field to use as the scalar price series. Defaults to 'close'. All indicators within a single FeatureRuntime instance share the same field.features/runtime.ts:65
freqFrequencyBar frequency forwarded to DataFeed.bars and embedded in cache keys. Must match the granularity expected by the indicators (e.g. '1d' for daily SMA/EMA).features/runtime.ts:60
mode?"historical"Selects historical (range-bounded) mode. May be omitted; defaults to 'historical'.features/runtime.ts:39
rangeDateRangeThe date range over which bars are fetched. This should span at least the backtest range plus any indicator warmup period (e.g. period - 1 extra bars for SMA/EMA). FeatureRuntime does not automatically extend the range for warmup — the caller is responsible for providing enough history.features/runtime.ts:54

Type Literal

{ dataFeed?: DataFeed; featureCache: FeatureCache; field?: BarField; freq: Frequency; initialBars?: ReadonlyMap<AssetId, ReadonlyArray<Bar>>; mode: "streaming"; }

NameTypeDescriptionDefined in
dataFeed?DataFeedOptional — not called in streaming mode. Omit in streaming-only usages. If provided it is stored but never invoked; supply only when sharing an options object that also carries a DataFeed for other purposes.features/runtime.ts:73
featureCacheFeatureCachePersistent indicator cache. In streaming mode the cache is bypassed entirely — every compute call recomputes from the in-memory bar buffer. The instance is still required so that a shared cache object can be passed without special-casing at the call site.features/runtime.ts:80
field?BarFieldWhich OHLCV field to use as the scalar price series. Defaults to 'close'.features/runtime.ts:89
freqFrequencyBar frequency embedded in cache keys. Must match the granularity of the bars pushed via appendBar.features/runtime.ts:85
initialBars?ReadonlyMap<AssetId, ReadonlyArray<Bar>>Optional seed bars per asset (keyed by AssetId), used to bootstrap the streaming buffer from a prior historical run's BacktestResult. Bars must already be in ascending t order per asset.features/runtime.ts:95
mode"streaming"Selects streaming (open-ended live) mode. Required.features/runtime.ts:69

Released under the MIT License.