Glossary
Terms are listed alphabetically. API reference links point to the generated TypeDoc pages.
Asset An instrument in the strategy's universe. Represented as { id: string; symbol: string }, where id is the canonical key used throughout the SDK (e.g. 'us:SPY') and symbol is the human-readable ticker. See Asset.
Bar A single OHLCV data point: { t, open, high, low, close, volume }. The timestamp t is a Date in UTC. Bars are the atomic unit of market data returned by a DataFeed. See Bar.
Calendar The interface for exchange trading-day arithmetic. Provides isOpen, sessions, next, and previous. Reference implementations: NYSEExchangeCalendar and LSEExchangeCalendar. See Calendar.
Comparison A rule-tree node that compares two feature references. Has op ('gt', 'lt', 'gte', 'lte', 'eq', 'ne'), left, and right. Used as the cond of an IfNode. See Comparison and ComparisonOp.
DataFeed The market-data interface. Exposes bars(asset, range, freq) as an async iterable of Bar objects. The SDK ships no built-in implementation; @livefolio/yfinance is a companion adapter. See DataFeed.
Dialect The tactical dialect is the specific rule-tree language understood by fromSpec and evaluateRuleTree. It defines the if/else and allocate node types, feature spec kinds (price, sma, ema, rsi, etc.), and rebalance frequencies. All dialect symbols are exported under the tactical namespace.
Executor The order-routing interface. Receives a batch of Order objects and returns Fill objects. BacktestExecutor is the reference implementation; a live broker adapter would implement the same interface. See Executor.
FeatureCache The indicator memoization interface. Stores computed feature values keyed by (feature spec, asset, date). MemoryFeatureCache is the in-process reference impl. See FeatureCache and MemoryFeatureCache.
FeatureSpec A declaration of what indicator to compute and how. In the tactical dialect, feature specs are TacticalFeatureSpec objects: { id, kind, asset, ...params }. The id is the handle used in rule-tree comparisons. See TacticalFeatureSpec.
Fill The record of an executed order: { orderId, asset, quantity, price, t }. Returned by Executor.submit. Applied to the portfolio via applyFills. See Fill.
fromSpec A function that converts a TacticalSpec (plain data) into a Strategy<F> (a typed object the runtime can drive). Does not fetch data or compute anything; hydration is lazy. See fromSpec.
Order An instruction to open, close, or adjust a position. The union type Order = OpenOrder | CloseOrder | AdjustOrder | RebalanceOrder. Generated by the runtime when target weights differ from current holdings. See Order.
Portfolio The current state of all holdings: { cash, positions, t }. Passed to runBacktest as initialPortfolio and updated after each session's fills. See Portfolio.
Position A single held asset: { positionId, asset, quantity, basis }, where basis is the cost basis in the portfolio's currency. See Position.
RebalanceConfig Configuration for when the strategy rebalances: { frequency }. Supported frequencies include 'Daily', 'Weekly', 'Monthly', and 'Quarterly'. Evaluated per session by isRebalanceDay. See RebalanceConfig.
RuleNode The discriminated union of nodes in the strategy rule tree. A RuleNode is either an IfNode (branches on a Comparison) or an AllocateNode (leaf with target weights). The root of TacticalSpec.rules is always a RuleNode. See RuleNode.
runBacktest The main runtime loop. Accepts a Strategy, DataFeed, Executor, Calendar, and an initial Portfolio. Walks calendar sessions over a DateRange, computes features, evaluates rules, submits orders, applies fills, and records snapshots. Returns BacktestResult. See runBacktest.
Session A single trading day's open/close interval on an exchange. Calendar.sessions(range) returns an array of session open timestamps. See Session.
Snapshot (see BacktestSnapshot) A record of state at the end of a single trading session: portfolio, orders submitted, and fills received. runBacktest returns one snapshot per session. See BacktestSnapshot.
Strategy The hydrated form of a TacticalSpec. A Strategy<F> exposes evaluate(features): TargetWeights and carries the feature spec list. Created by fromSpec; consumed by runBacktest. See Strategy.
Synthetics Derived assets constructed from other assets (e.g. a 60/40 blend). Declared in TacticalSpec.synthetics and materialized by withSynthetics. Synthetics can appear as allocation targets in the rule tree.
TacticalSpec The top-level strategy declaration. A plain, JSON-shaped object with universe, features, rebalance, and rules fields. Serializable, versionable, and portable across runtimes. See TacticalSpec.
Target weights A mapping from asset ID to allocation fraction, summing to 1.0. The output of evaluating the rule tree on a rebalance day. Represented as Record<AssetId, number>. The runtime converts target weights into Order objects by comparing them to current holdings. See TargetWeights.
Universe The set of Asset objects a strategy may allocate to. Declared in TacticalSpec.universe. The runtime restricts target-weight keys to assets in the universe.