@livefolio/sdk / evaluateFeatureSpecs
Function: evaluateFeatureSpecs()
evaluateFeatureSpecs(
specs,runtime,t):Promise<Map<string,number|undefined>>
Defined in: tactical/evaluate-feature-specs.ts:86
Resolves each TacticalFeatureSpec in specs to a scalar value as of date t by calling into runtime and reading the series at the appropriate bar index. All specs are computed in parallel via Promise.all.
The returned map uses each spec's id as the key. The value is undefined when the indicator series has no data on or before t, or when the delay offset steps past the beginning of the series.
Validation performed before dispatching to the runtime:
- Duplicate
idvalues inspecsthrow immediately. - A non-integer or negative
delaythrows immediately.
Parameters
| Parameter | Type | Description |
|---|---|---|
specs | readonly TacticalFeatureSpec[] | Ordered list of feature declarations from TacticalSpec.features. |
runtime | FeatureRuntime | Feature computation backend that owns the data feed and cache. |
t | Date | Evaluation date; the series is read at the latest bar on or before t. |
Returns
Promise<Map<string, number | undefined>>
A map from feature id to resolved numeric value (undefined when unavailable).
Example
ts
import { evaluateFeatureSpecs } from '@livefolio/sdk';
import type { TacticalFeatureSpec } from '@livefolio/sdk';
const specs: TacticalFeatureSpec[] = [
{ id: 'spy_sma200', kind: 'sma', asset: { id: 'SPY', symbol: 'SPY' }, period: 200 },
{ id: 'spy_price', kind: 'price', asset: { id: 'SPY', symbol: 'SPY' } },
];
const values = await evaluateFeatureSpecs(specs, runtime, new Date('2024-06-01'));
// values.get('spy_price') → 528.3