@livefolio/sdk 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -112,6 +112,7 @@ declare class IndicatorHandle {
112
112
  private _getLatestSeriesDate;
113
113
  private _ensureFresh;
114
114
  private _sync;
115
+ private _fetchRawBarsForIncremental;
115
116
  private _upsertSeries;
116
117
  private _querySeriesFromDb;
117
118
  /**
@@ -162,6 +163,12 @@ declare class IndicatorHandle {
162
163
  * point at `date` to land on.
163
164
  */
164
165
  private _resolveRawBars;
166
+ /**
167
+ * Resolve the single raw (unleveraged) value for `symbol` at `date`.
168
+ * Returns the override directly when present; otherwise delegates to
169
+ * `_resolveRawBars` with a one-day window and picks the matching bar.
170
+ */
171
+ private _resolveRawBarAt;
165
172
  /**
166
173
  * Resolve raw (unleveraged) bars for a market symbol from storage. Maps:
167
174
  * - `^VIX` → the VIX indicator's stored series
@@ -222,9 +229,16 @@ interface StorageProvider {
222
229
  id: number;
223
230
  }>;
224
231
  getSeries(indicatorId: number, range?: DateRange): Promise<DailyBar[]>;
225
- writeSeries(indicatorId: number, bars: DailyBar[]): Promise<void>;
232
+ writeSeries(indicatorId: number, bars: DailyBar[], opts?: {
233
+ metadata?: unknown;
234
+ }): Promise<void>;
226
235
  getLatestSeriesDate(indicatorId: number): Promise<string | null>;
227
236
  getValue(indicatorId: number, date?: string): Promise<number | null>;
237
+ getLatestBar(indicatorId: number): Promise<{
238
+ date: string;
239
+ value: number;
240
+ metadata: unknown;
241
+ } | null>;
228
242
  };
229
243
  signals: {
230
244
  upsert(identity: {
@@ -297,7 +311,9 @@ declare class SignalHandle {
297
311
  private _getLatestSignalSeriesDate;
298
312
  private _getLastSignalValue;
299
313
  private _ensureFresh;
314
+ private _isSingleBarFastPath;
300
315
  private _sync;
316
+ private _evaluateOneBar;
301
317
  private _upsertSeries;
302
318
  private _querySeriesFromDb;
303
319
  /**
@@ -338,6 +354,11 @@ declare class AllocationHandle {
338
354
  id: number;
339
355
  }>;
340
356
  static fromResolved(storage: StorageProvider, id: number, holdings: [TickerHandle, number][]): AllocationHandle;
357
+ toJSON(): Array<{
358
+ symbol: string;
359
+ leverage: number;
360
+ weight: number;
361
+ }>;
341
362
  private _doResolve;
342
363
  }
343
364
 
@@ -486,6 +507,7 @@ declare class StrategyHandle {
486
507
  get freq(): TradingFreq;
487
508
  get offset(): number;
488
509
  get rules(): StrategyRule[];
510
+ marketSymbols(): string[];
489
511
  resolve(): Promise<{
490
512
  id: number;
491
513
  }>;
@@ -505,8 +527,15 @@ declare class StrategyHandle {
505
527
  * map) we take the read-only preview path: historical signal bars come
506
528
  * straight from storage, today's bar is computed in-memory via
507
529
  * `signal.computeAt(date, overrides, prevBool)`, and nothing is written.
530
+ *
531
+ * Incremental path: when a strategy checkpoint exists (`getLatestSeriesDate`
532
+ * returns non-null), only the window (lastDate, limitDate] is processed.
533
+ * The current allocation is carried forward from `getLatestAllocationId`.
534
+ * Bootstrap: when no checkpoint exists, falls back to `_evaluateCold` which
535
+ * runs the full-history evaluation.
508
536
  */
509
537
  private _evaluate;
538
+ private _evaluateCold;
510
539
  private _querySeriesFromDb;
511
540
  series(range?: DateRange): Promise<StrategyBar[]>;
512
541
  value(date?: string): Promise<AllocationHandle | null>;
@@ -596,4 +625,8 @@ interface PriceStream {
596
625
  close(): void;
597
626
  }
598
627
 
599
- export { AllocationHandle, type Comparison, type DailyBar, type DateRange, IndicatorHandle, type IndicatorIdentity, type IndicatorType, type LiveEvaluator, type LivePreviewState, type LiveRuleState, type LiveSignalState, type LivefolioClient, type LivefolioClientOptions, type MarketProvider, PortfolioHandle, type PortfolioSnapshot, type PriceStream, SignalHandle, type SignalIdentity, type SimulateOptions, SimulationHandle, type StorageProvider, type StrategyBar, type StrategyDefinition, StrategyHandle, type StrategyLiveState, type StrategyOptions, type StrategyReferenceData, type StrategyRule, type StrategyRuleDefinition, type StrategySeriesEntry, type StreamStatus, TickerHandle, type Trade, type TradingFreq, type Unit, createClient };
628
+ declare function allocationsEqual(a: AllocationHandle | null, b: AllocationHandle | null): boolean;
629
+
630
+ declare function computeRebalanceDates(tradingDays: string[], freq: TradingFreq, offset: number): Set<string>;
631
+
632
+ export { AllocationHandle, type Comparison, type DailyBar, type DateRange, IndicatorHandle, type IndicatorIdentity, type IndicatorType, type LiveEvaluator, type LivePreviewState, type LiveRuleState, type LiveSignalState, type LivefolioClient, type LivefolioClientOptions, type MarketProvider, PortfolioHandle, type PortfolioSnapshot, type PriceStream, SignalHandle, type SignalIdentity, type SimulateOptions, SimulationHandle, type StorageProvider, type StrategyBar, type StrategyDefinition, StrategyHandle, type StrategyLiveState, type StrategyOptions, type StrategyReferenceData, type StrategyRule, type StrategyRuleDefinition, type StrategySeriesEntry, type StreamStatus, TickerHandle, type Trade, type TradingFreq, type Unit, allocationsEqual, computeRebalanceDates, createClient };