@livefolio/sdk 0.3.3 → 0.3.5
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 +35 -3
- package/dist/index.js +402 -53
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
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[]
|
|
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,13 +507,13 @@ 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
|
}>;
|
|
492
514
|
private _doResolveCreate;
|
|
493
515
|
private _doResolveReference;
|
|
494
516
|
private _getLatestClosedTradingDay;
|
|
495
|
-
private _getLatestStrategySeriesDate;
|
|
496
517
|
private _ensureFresh;
|
|
497
518
|
private _sync;
|
|
498
519
|
/**
|
|
@@ -505,8 +526,15 @@ declare class StrategyHandle {
|
|
|
505
526
|
* map) we take the read-only preview path: historical signal bars come
|
|
506
527
|
* straight from storage, today's bar is computed in-memory via
|
|
507
528
|
* `signal.computeAt(date, overrides, prevBool)`, and nothing is written.
|
|
529
|
+
*
|
|
530
|
+
* Incremental path: when a strategy checkpoint exists (`getLatestSeriesDate`
|
|
531
|
+
* returns non-null), only the window (lastDate, limitDate] is processed.
|
|
532
|
+
* The current allocation is carried forward from `getLatestAllocationId`.
|
|
533
|
+
* Bootstrap: when no checkpoint exists, falls back to `_evaluateCold` which
|
|
534
|
+
* runs the full-history evaluation.
|
|
508
535
|
*/
|
|
509
536
|
private _evaluate;
|
|
537
|
+
private _evaluateCold;
|
|
510
538
|
private _querySeriesFromDb;
|
|
511
539
|
series(range?: DateRange): Promise<StrategyBar[]>;
|
|
512
540
|
value(date?: string): Promise<AllocationHandle | null>;
|
|
@@ -596,4 +624,8 @@ interface PriceStream {
|
|
|
596
624
|
close(): void;
|
|
597
625
|
}
|
|
598
626
|
|
|
599
|
-
|
|
627
|
+
declare function allocationsEqual(a: AllocationHandle | null, b: AllocationHandle | null): boolean;
|
|
628
|
+
|
|
629
|
+
declare function computeRebalanceDates(tradingDays: string[], freq: TradingFreq, offset: number): Set<string>;
|
|
630
|
+
|
|
631
|
+
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 };
|