@livefolio/sdk / LiveEvent
Type Alias: LiveEvent<F, _S>
LiveEvent<
F,_S> = {features:F;portfolio:Portfolio;previewOrders:ReadonlyArray<Order>;previewPortfolio:Portfolio;prices:ReadonlyMap<AssetId,number>;t:Date;type:"mark"; } |BacktestSnapshot&object
Defined in: strategy/run-live.ts:28
Unified event stream from runLive. Discriminated union of two variants:
mark— emitted per tick. The strategy is run in PREVIEW mode (state is snapshot/restored, no executor call, no portfolio commit). Use this to render the wiggling rightmost chart point and the "if the session ended now, the strategy would do X" preview UX.snapshot— emitted when a tick crosses a session boundary. The just-closed bar is finalized,strategy.buildruns for real, orders are submitted to the executor, fills are applied, and state advances. Same shape as BacktestSnapshot from runBacktest (plus thetype: 'snapshot'discriminant), so consumers can append snapshot events to the same chart array used by historical results.
Type Parameters
| Type Parameter | Default type |
|---|---|
F extends Features | Features |
_S | unknown |
Union Members
Type Literal
{ features: F; portfolio: Portfolio; previewOrders: ReadonlyArray<Order>; previewPortfolio: Portfolio; prices: ReadonlyMap<AssetId, number>; t: Date; type: "mark"; }
| Name | Type | Description | Defined in |
|---|---|---|---|
features | F | Features recomputed for the in-progress session. | strategy/run-live.ts:41 |
portfolio | Portfolio | Portfolio at the start of the current session — unchanged by the preview. | strategy/run-live.ts:34 |
previewOrders | ReadonlyArray<Order> | Orders the strategy would emit if the session closed at the current tick price. Computed from a state SNAPSHOT — the returned state value is discarded, so no committed state is mutated. | strategy/run-live.ts:47 |
previewPortfolio | Portfolio | Best-effort placeholder — returns the unchanged portfolio. A future simulateFills(orders, prices) helper will compute the hypothetical post-rebalance NAV that would result from applying previewOrders at prices. Until then, consumers compute NAV themselves from portfolio + prices. | strategy/run-live.ts:55 |
prices | ReadonlyMap<AssetId, number> | Per-asset accumulating close so far in the current session. Only assets that have received at least one tick this session appear in the map. | strategy/run-live.ts:39 |
t | Date | Wall-clock arrival time of this tick. | strategy/run-live.ts:32 |
type | "mark" | - | strategy/run-live.ts:30 |
BacktestSnapshot & object