backtest-kit 7.4.0 → 7.5.0

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/types.d.ts CHANGED
@@ -9290,6 +9290,7 @@ declare function getNextCandles(symbol: string, interval: CandleInterval, limit:
9290
9290
  */
9291
9291
  declare function getAggregatedTrades(symbol: string, limit?: number): Promise<IAggregatedTradeData[]>;
9292
9292
 
9293
+ type Dispatch$1<Value extends object = object> = (value: Value) => Value | Promise<Value>;
9293
9294
  /**
9294
9295
  * Returns the latest signal (pending or closed) for the current strategy context.
9295
9296
  *
@@ -9343,27 +9344,458 @@ declare function getLatestSignal(symbol: string): Promise<IPublicSignalRow | nul
9343
9344
  * ```
9344
9345
  */
9345
9346
  declare function getMinutesSinceLatestSignalCreated(symbol: string): Promise<number | null>;
9346
-
9347
9347
  /**
9348
- * Writes a value to memory scoped to the current signal.
9348
+ * Reads the state value scoped to the current active signal.
9349
+ *
9350
+ * Resolves the active pending signal automatically from execution context.
9351
+ * If no pending signal exists, logs a warning and returns the initialValue.
9352
+ *
9353
+ * Automatically detects backtest/live mode from execution context.
9354
+ *
9355
+ * Intended for LLM-driven capitulation strategies that accumulate per-trade
9356
+ * metrics (e.g. peakPercent, minutesOpen) across onActivePing ticks.
9357
+ * Profitable trades endure -0.5–2.5% drawdown and reach peak 2–3%+.
9358
+ * SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
9359
+ * Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
9360
+ *
9361
+ * @param dto.bucketName - State bucket name
9362
+ * @param dto.initialValue - Default value when no persisted state exists
9363
+ * @returns Promise resolving to current state value, or initialValue if no signal
9364
+ *
9365
+ * @deprecated Better use `createSignalState().getState` with codestyle native syntax
9349
9366
  *
9350
- * Reads symbol from execution context and signalId from the active pending signal.
9367
+ * @example
9368
+ * ```typescript
9369
+ * import { getSignalState } from "backtest-kit";
9370
+ *
9371
+ * const { peakPercent, minutesOpen } = await getSignalState({
9372
+ * bucketName: "trade",
9373
+ * initialValue: { peakPercent: 0, minutesOpen: 0 },
9374
+ * });
9375
+ * if (minutesOpen >= 15 && peakPercent < 0.3) {
9376
+ * await commitMarketClose(symbol); // capitulate — LLM thesis not confirmed
9377
+ * }
9378
+ * ```
9379
+ */
9380
+ declare function getSignalState<Value extends object = object>(dto: {
9381
+ bucketName: string;
9382
+ initialValue: Value;
9383
+ }): Promise<Value>;
9384
+ /**
9385
+ * Updates the state value scoped to the current active signal.
9386
+ *
9387
+ * Resolves the active pending signal automatically from execution context.
9351
9388
  * If no pending signal exists, logs a warning and returns without writing.
9352
9389
  *
9353
9390
  * Automatically detects backtest/live mode from execution context.
9354
9391
  *
9392
+ * Intended for LLM-driven capitulation strategies that accumulate per-trade
9393
+ * metrics (e.g. peakPercent, minutesOpen) across onActivePing ticks.
9394
+ * Profitable trades endure -0.5–2.5% drawdown and reach peak 2–3%+.
9395
+ * SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
9396
+ * Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
9397
+ *
9398
+ * @param dto.bucketName - State bucket name
9399
+ * @param dto.initialValue - Default value when no persisted state exists
9400
+ * @param dto.dispatch - New value or updater function receiving current value
9401
+ * @returns Promise resolving to updated state value, or initialValue if no signal
9402
+ *
9403
+ * @deprecated Better use `createSignalState().setState` with codestyle native syntax
9404
+ *
9405
+ * @example
9406
+ * ```typescript
9407
+ * import { setSignalState } from "backtest-kit";
9408
+ *
9409
+ * await setSignalState(
9410
+ * dispatch: (s) => ({
9411
+ * peakPercent: Math.max(s.peakPercent, currentUnrealisedPercent),
9412
+ * minutesOpen: s.minutesOpen + 1,
9413
+ * }),
9414
+ * {
9415
+ * bucketName: "trade",
9416
+ * initialValue: { peakPercent: 0, minutesOpen: 0 },
9417
+ * }
9418
+ * );
9419
+ * ```
9420
+ */
9421
+ declare function setSignalState<Value extends object = object>(dispatch: Value | Dispatch$1<Value>, dto: {
9422
+ bucketName: string;
9423
+ initialValue: Value;
9424
+ }): Promise<Value>;
9425
+
9426
+ /**
9427
+ * Updater function for setState — receives current value and returns the next value.
9428
+ * Used for functional updates to state, e.g. `setState(prev => ({ ...prev, peakPercent: newPeak }))`
9429
+ */
9430
+ type Dispatch<Value extends object = object> = (value: Value) => Value | Promise<Value>;
9431
+ /**
9432
+ * Logical namespace for grouping state buckets within a signal, e.g. "trade" or "metrics".
9433
+ * Used to scope state values for different purposes within the same signal — e.g. "trade" bucket for tracking peakPercent and minutesOpen, "metrics" bucket for tracking other LLM confirmation metrics.
9434
+ */
9435
+ type BucketName = string;
9436
+ /**
9437
+ * Interface for state instance implementations.
9438
+ * Defines the contract for local, persist, and dummy backends.
9439
+ *
9440
+ * Intended use: per-signal mutable state for LLM-driven strategies that track
9441
+ * trade confirmation metrics across the position lifetime — e.g. peak unrealised PnL,
9442
+ * minutes since entry, and capitulation thresholds.
9443
+ *
9444
+ * Example shape:
9445
+ * ```ts
9446
+ * { peakPercent: number; minutesOpen: number }
9447
+ * ```
9448
+ * Profitable trades endure -0.5–2.5% drawdown yet still reach peak 2–3%+.
9449
+ * SL trades either never go positive (Feb25) or show peak < 0.15% (Feb08, Feb13).
9450
+ * Capitulation rule: if position open N minutes and peak < threshold (e.g. 0.3%) —
9451
+ * LLM thesis was not confirmed by market, exit immediately.
9452
+ */
9453
+ interface IStateInstance {
9454
+ /**
9455
+ * Initialize the state instance.
9456
+ * @param initial - Whether this is the first initialization
9457
+ */
9458
+ waitForInit(initial: boolean): Promise<void>;
9459
+ /**
9460
+ * Read the current state value.
9461
+ * @returns Current state value
9462
+ */
9463
+ getState<Value extends object = object>(): Promise<Value>;
9464
+ /**
9465
+ * Update the state value.
9466
+ * @param dispatch - New value or updater function receiving current value
9467
+ * @returns Updated state value
9468
+ */
9469
+ setState<Value extends object = object>(dispatch: Value | Dispatch<Value>): Promise<Value>;
9470
+ /**
9471
+ * Releases any resources held by this instance.
9472
+ */
9473
+ dispose(): Promise<void>;
9474
+ }
9475
+ /**
9476
+ * Constructor type for state instance implementations.
9477
+ * Used for swapping backends via StateBacktestAdapter / StateLiveAdapter.
9478
+ */
9479
+ type TStateInstanceCtor = new (initialValue: object, signalId: string, bucketName: string) => IStateInstance;
9480
+ /**
9481
+ * Public surface of StateBacktestAdapter / StateLiveAdapter — IStateInstance minus waitForInit and dispose.
9482
+ * waitForInit and dispose are managed internally by the adapter.
9483
+ */
9484
+ type TStateAdapter = {
9485
+ [key in Exclude<keyof IStateInstance, "waitForInit" | "dispose">]: any;
9486
+ };
9487
+ /**
9488
+ * Backtest state adapter with pluggable storage backend.
9489
+ *
9490
+ * Features:
9491
+ * - Adapter pattern for swappable state instance implementations
9492
+ * - Default backend: StateLocalInstance (in-memory, no disk persistence)
9493
+ * - Alternative backends: StatePersistInstance, StateDummyInstance
9494
+ * - Convenience methods: useLocal(), usePersist(), useDummy(), useStateAdapter()
9495
+ * - Memoized instances per (signalId, bucketName) pair; cleared via disposeSignal() from StateAdapter
9496
+ *
9497
+ * Primary use case — LLM-driven capitulation rule:
9498
+ * Profitable trades endure -0.5–2.5% drawdown and still reach peak 2–3%+.
9499
+ * SL trades never go positive (Feb25) or show peak < 0.15% (Feb08, Feb13).
9500
+ * Rule: if position open >= N minutes and peakPercent < threshold (e.g. 0.3%),
9501
+ * the LLM thesis was not confirmed by market — exit immediately.
9502
+ * State tracks `{ peakPercent, minutesOpen }` per signal across onActivePing ticks.
9503
+ */
9504
+ declare class StateBacktestAdapter implements TStateAdapter {
9505
+ private StateFactory;
9506
+ private getInstance;
9507
+ /**
9508
+ * Disposes all memoized instances for the given signalId.
9509
+ * Called by StateAdapter when a signal is cancelled or closed.
9510
+ * @param signalId - Signal identifier to dispose
9511
+ */
9512
+ disposeSignal: (signalId: string) => void;
9513
+ /**
9514
+ * Read the current state value for a signal.
9515
+ * @param dto.signalId - Signal identifier
9516
+ * @param dto.bucketName - Bucket name
9517
+ * @param dto.initialValue - Default value when no persisted state exists
9518
+ * @returns Current state value
9519
+ */
9520
+ getState: <Value extends object = object>(dto: {
9521
+ signalId: string;
9522
+ bucketName: BucketName;
9523
+ initialValue: object;
9524
+ }) => Promise<Value>;
9525
+ /**
9526
+ * Update the state value for a signal.
9527
+ * @param dispatch - New value or updater function receiving current value
9528
+ * @param dto.signalId - Signal identifier
9529
+ * @param dto.bucketName - Bucket name
9530
+ * @param dto.initialValue - Default value when no persisted state exists
9531
+ * @returns Updated state value
9532
+ */
9533
+ setState: <Value extends object = object>(dispatch: Value | Dispatch<Value>, dto: {
9534
+ signalId: string;
9535
+ bucketName: BucketName;
9536
+ initialValue: object;
9537
+ }) => Promise<Value>;
9538
+ /**
9539
+ * Switches to in-memory adapter (default).
9540
+ * All data lives in process memory only.
9541
+ */
9542
+ useLocal: () => void;
9543
+ /**
9544
+ * Switches to file-system backed adapter.
9545
+ * Data is persisted to disk via PersistStateAdapter.
9546
+ */
9547
+ usePersist: () => void;
9548
+ /**
9549
+ * Switches to dummy adapter that discards all writes.
9550
+ */
9551
+ useDummy: () => void;
9552
+ /**
9553
+ * Switches to a custom state adapter implementation.
9554
+ * @param Ctor - Constructor for the custom state instance
9555
+ */
9556
+ useStateAdapter: (Ctor: TStateInstanceCtor) => void;
9557
+ /**
9558
+ * Clears the memoized instance cache.
9559
+ * Call this when process.cwd() changes between strategy iterations
9560
+ * so new instances are created with the updated base path.
9561
+ */
9562
+ clear: () => void;
9563
+ }
9564
+ /**
9565
+ * Live trading state adapter with pluggable storage backend.
9566
+ *
9567
+ * Features:
9568
+ * - Adapter pattern for swappable state instance implementations
9569
+ * - Default backend: StatePersistInstance (file-system backed, survives restarts)
9570
+ * - Alternative backends: StateLocalInstance, StateDummyInstance
9571
+ * - Convenience methods: useLocal(), usePersist(), useDummy(), useStateAdapter()
9572
+ * - Memoized instances per (signalId, bucketName) pair; cleared via disposeSignal() from StateAdapter
9573
+ *
9574
+ * Primary use case — LLM-driven capitulation rule:
9575
+ * Profitable trades endure -0.5–2.5% drawdown and still reach peak 2–3%+.
9576
+ * SL trades never go positive (Feb25) or show peak < 0.15% (Feb08, Feb13).
9577
+ * Rule: if position open >= N minutes and peakPercent < threshold (e.g. 0.3%),
9578
+ * the LLM thesis was not confirmed by market — exit immediately.
9579
+ * State persists `{ peakPercent, minutesOpen }` per signal across process restarts.
9580
+ */
9581
+ declare class StateLiveAdapter implements TStateAdapter {
9582
+ private StateFactory;
9583
+ private getInstance;
9584
+ /**
9585
+ * Disposes all memoized instances for the given signalId.
9586
+ * Called by StateAdapter when a signal is cancelled or closed.
9587
+ * @param signalId - Signal identifier to dispose
9588
+ */
9589
+ disposeSignal: (signalId: string) => void;
9590
+ /**
9591
+ * Read the current state value for a signal.
9592
+ * @param dto.signalId - Signal identifier
9593
+ * @param dto.bucketName - Bucket name
9594
+ * @param dto.initialValue - Default value when no persisted state exists
9595
+ * @returns Current state value
9596
+ */
9597
+ getState: <Value extends object = object>(dto: {
9598
+ signalId: string;
9599
+ bucketName: BucketName;
9600
+ initialValue: object;
9601
+ }) => Promise<Value>;
9602
+ /**
9603
+ * Update the state value for a signal.
9604
+ * @param dispatch - New value or updater function receiving current value
9605
+ * @param dto.signalId - Signal identifier
9606
+ * @param dto.bucketName - Bucket name
9607
+ * @param dto.initialValue - Default value when no persisted state exists
9608
+ * @returns Updated state value
9609
+ */
9610
+ setState: <Value extends object = object>(dispatch: Value | Dispatch<Value>, dto: {
9611
+ signalId: string;
9612
+ bucketName: BucketName;
9613
+ initialValue: object;
9614
+ }) => Promise<Value>;
9615
+ /**
9616
+ * Switches to in-memory adapter.
9617
+ * All data lives in process memory only.
9618
+ */
9619
+ useLocal: () => void;
9620
+ /**
9621
+ * Switches to file-system backed adapter (default).
9622
+ * Data is persisted to disk via PersistStateAdapter.
9623
+ */
9624
+ usePersist: () => void;
9625
+ /**
9626
+ * Switches to dummy adapter that discards all writes.
9627
+ */
9628
+ useDummy: () => void;
9629
+ /**
9630
+ * Switches to a custom state adapter implementation.
9631
+ * @param Ctor - Constructor for the custom state instance
9632
+ */
9633
+ useStateAdapter: (Ctor: TStateInstanceCtor) => void;
9634
+ /**
9635
+ * Clears the memoized instance cache.
9636
+ * Call this when process.cwd() changes between strategy iterations
9637
+ * so new instances are created with the updated base path.
9638
+ */
9639
+ clear: () => void;
9640
+ }
9641
+ /**
9642
+ * Main state adapter that manages both backtest and live state storage.
9643
+ *
9644
+ * Features:
9645
+ * - Subscribes to signal lifecycle events (cancelled/closed) to dispose stale instances
9646
+ * - Routes all operations to StateBacktest or StateLive based on dto.backtest
9647
+ * - Singleshot enable pattern prevents duplicate subscriptions
9648
+ * - Cleanup function for proper unsubscription
9649
+ */
9650
+ declare class StateAdapter {
9651
+ /**
9652
+ * Enables state storage by subscribing to signal lifecycle events.
9653
+ * Clears memoized instances in StateBacktest and StateLive when a signal
9654
+ * is cancelled or closed, preventing stale instances from accumulating.
9655
+ * Uses singleshot to ensure one-time subscription.
9656
+ *
9657
+ * @returns Cleanup function that unsubscribes from all emitters
9658
+ */
9659
+ enable: (() => (...args: any[]) => any) & functools_kit.ISingleshotClearable<() => (...args: any[]) => any>;
9660
+ /**
9661
+ * Disables state storage by unsubscribing from signal lifecycle events.
9662
+ * Safe to call multiple times.
9663
+ */
9664
+ disable: () => void;
9665
+ /**
9666
+ * Read the current state value for a signal.
9667
+ * Routes to StateBacktest or StateLive based on dto.backtest.
9668
+ * @param dto.signalId - Signal identifier
9669
+ * @param dto.bucketName - Bucket name
9670
+ * @param dto.initialValue - Default value when no persisted state exists
9671
+ * @param dto.backtest - Flag indicating if the context is backtest or live
9672
+ * @returns Current state value
9673
+ * @throws Error if adapter is not enabled
9674
+ */
9675
+ getState: <Value extends object = object>(dto: {
9676
+ signalId: string;
9677
+ bucketName: BucketName;
9678
+ initialValue: object;
9679
+ backtest: boolean;
9680
+ }) => Promise<Value>;
9681
+ /**
9682
+ * Update the state value for a signal.
9683
+ * Routes to StateBacktest or StateLive based on dto.backtest.
9684
+ * @param dispatch - New value or updater function receiving current value
9685
+ * @param dto.signalId - Signal identifier
9686
+ * @param dto.bucketName - Bucket name
9687
+ * @param dto.initialValue - Default value when no persisted state exists
9688
+ * @param dto.backtest - Flag indicating if the context is backtest or live
9689
+ * @returns Updated state value
9690
+ * @throws Error if adapter is not enabled
9691
+ */
9692
+ setState: <Value extends object = object>(dispatch: Value | Dispatch<Value>, dto: {
9693
+ signalId: string;
9694
+ bucketName: BucketName;
9695
+ initialValue: object;
9696
+ backtest: boolean;
9697
+ }) => Promise<Value>;
9698
+ }
9699
+ /**
9700
+ * Global singleton instance of StateAdapter.
9701
+ * Provides unified state management for backtest and live trading.
9702
+ */
9703
+ declare const State: StateAdapter;
9704
+ /**
9705
+ * Global singleton instance of StateLiveAdapter.
9706
+ * Provides live trading state storage with pluggable backends.
9707
+ */
9708
+ declare const StateLive: StateLiveAdapter;
9709
+ /**
9710
+ * Global singleton instance of StateBacktestAdapter.
9711
+ * Provides backtest state storage with pluggable backends.
9712
+ */
9713
+ declare const StateBacktest: StateBacktestAdapter;
9714
+
9715
+ /**
9716
+ * Parameters for createSignalState — bucket name and default value shape.
9717
+ */
9718
+ interface IStateParams<Value extends object = object> {
9719
+ /** Logical namespace for grouping state buckets within a signal, e.g. "trade" or "metrics". */
9720
+ bucketName: BucketName;
9721
+ /** Default value used when no persisted state exists for the signal. */
9722
+ initialValue: Value;
9723
+ }
9724
+ /**
9725
+ * Reads the current state value for the active pending or scheduled signal.
9726
+ * Resolved from execution context — no signalId argument required.
9727
+ * @returns Current state value
9728
+ * @throws Error if no pending or scheduled signal exists
9729
+ */
9730
+ type GetStateFn<Value extends object = object> = () => Promise<Value>;
9731
+ /**
9732
+ * Updates the state value for the active pending or scheduled signal.
9733
+ * Resolved from execution context — no signalId argument required.
9734
+ * @param dispatch - New value or updater function receiving current value
9735
+ * @returns Updated state value
9736
+ * @throws Error if no pending or scheduled signal exists
9737
+ */
9738
+ type SetStateFn<Value extends object = object> = (dispatch: Value | Dispatch<Value>) => Promise<Value>;
9739
+ /**
9740
+ * Tuple returned by createSignalState — [getState, setState] bound to the bucket.
9741
+ * Both functions resolve the active signal and backtest flag from execution context automatically.
9742
+ */
9743
+ type SignalStateTuple<Value extends object = object> = [GetStateFn<Value>, SetStateFn<Value>];
9744
+ /**
9745
+ * Creates a bound [getState, setState] tuple scoped to a bucket and initial value.
9746
+ *
9747
+ * Both returned functions resolve the active pending or scheduled signal and the
9748
+ * backtest/live flag automatically from execution context — no signalId argument required.
9749
+ *
9750
+ * Automatically detects backtest/live mode from execution context.
9751
+ *
9752
+ * Intended for LLM-driven capitulation strategies that accumulate per-trade
9753
+ * metrics (e.g. peakPercent, minutesOpen) across onActivePing ticks.
9754
+ * Profitable trades endure -0.5–2.5% drawdown and reach peak 2–3%+.
9755
+ * SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
9756
+ * Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
9757
+ *
9758
+ * @param params.bucketName - Logical namespace for grouping state buckets within a signal
9759
+ * @param params.initialValue - Default value when no persisted state exists
9760
+ * @returns Tuple [getState, setState] bound to the bucket and initial value
9761
+ *
9762
+ * @example
9763
+ * ```typescript
9764
+ * import { createSignalState } from "backtest-kit";
9765
+ *
9766
+ * const [getTradeState, setTradeState] = createSignalState({
9767
+ * bucketName: "trade",
9768
+ * initialValue: { peakPercent: 0, minutesOpen: 0 },
9769
+ * });
9770
+ *
9771
+ * // in onActivePing:
9772
+ * await setTradeState((s) => ({
9773
+ * peakPercent: Math.max(s.peakPercent, currentUnrealisedPercent),
9774
+ * minutesOpen: s.minutesOpen + 1,
9775
+ * }));
9776
+ * const { peakPercent, minutesOpen } = await getTradeState();
9777
+ * if (minutesOpen >= 15 && peakPercent < 0.3) await commitMarketClose(symbol);
9778
+ * ```
9779
+ */
9780
+ declare function createSignalState<Value extends object = object>(params: IStateParams<Value>): SignalStateTuple<Value>;
9781
+
9782
+ /**
9783
+ * Writes a value to memory scoped to the current signal.
9784
+ *
9785
+ * Resolves the active pending or scheduled signal automatically from execution context.
9786
+ * Automatically detects backtest/live mode from execution context.
9787
+ *
9355
9788
  * @param dto.bucketName - Memory bucket name
9356
9789
  * @param dto.memoryId - Unique memory entry identifier
9357
9790
  * @param dto.value - Value to store
9791
+ * @param dto.description - BM25 index string for contextual search
9358
9792
  * @returns Promise that resolves when write is complete
9359
9793
  *
9360
- * @deprecated Better use Memory.writeMemory with manual signalId argument
9361
- *
9362
9794
  * @example
9363
9795
  * ```typescript
9364
9796
  * import { writeMemory } from "backtest-kit";
9365
9797
  *
9366
- * await writeMemory({ bucketName: "my-strategy", memoryId: "context", value: { trend: "up", confidence: 0.9 } });
9798
+ * await writeMemory({ bucketName: "my-strategy", memoryId: "context", value: { trend: "up", confidence: 0.9 }, description: "Signal context at entry" });
9367
9799
  * ```
9368
9800
  */
9369
9801
  declare function writeMemory<T extends object = object>(dto: {
@@ -9375,17 +9807,13 @@ declare function writeMemory<T extends object = object>(dto: {
9375
9807
  /**
9376
9808
  * Reads a value from memory scoped to the current signal.
9377
9809
  *
9378
- * Reads symbol from execution context and signalId from the active pending signal.
9379
- * If no pending signal exists, logs a warning and returns null.
9380
- *
9810
+ * Resolves the active pending or scheduled signal automatically from execution context.
9381
9811
  * Automatically detects backtest/live mode from execution context.
9382
9812
  *
9383
9813
  * @param dto.bucketName - Memory bucket name
9384
9814
  * @param dto.memoryId - Unique memory entry identifier
9385
- * @returns Promise resolving to stored value or null if no signal
9386
- * @throws Error if entry not found within an active signal
9387
- *
9388
- * @deprecated Better use Memory.readMemory with manual signalId argument
9815
+ * @returns Promise resolving to stored value
9816
+ * @throws Error if no pending or scheduled signal exists, or if entry not found
9389
9817
  *
9390
9818
  * @example
9391
9819
  * ```typescript
@@ -9397,20 +9825,17 @@ declare function writeMemory<T extends object = object>(dto: {
9397
9825
  declare function readMemory<T extends object = object>(dto: {
9398
9826
  bucketName: string;
9399
9827
  memoryId: string;
9400
- }): Promise<T | null>;
9828
+ }): Promise<T>;
9401
9829
  /**
9402
9830
  * Searches memory entries for the current signal using BM25 full-text scoring.
9403
9831
  *
9404
- * Reads symbol from execution context and signalId from the active pending signal.
9405
- * If no pending signal exists, logs a warning and returns an empty array.
9406
- *
9832
+ * Resolves the active pending or scheduled signal automatically from execution context.
9407
9833
  * Automatically detects backtest/live mode from execution context.
9408
9834
  *
9409
9835
  * @param dto.bucketName - Memory bucket name
9410
9836
  * @param dto.query - Search query string
9411
- * @returns Promise resolving to matching entries sorted by relevance, or empty array if no signal
9412
- *
9413
- * @deprecated Better use Memory.searchMemory with manual signalId argument
9837
+ * @returns Promise resolving to matching entries sorted by relevance
9838
+ * @throws Error if no pending or scheduled signal exists
9414
9839
  *
9415
9840
  * @example
9416
9841
  * ```typescript
@@ -9430,15 +9855,12 @@ declare function searchMemory<T extends object = object>(dto: {
9430
9855
  /**
9431
9856
  * Lists all memory entries for the current signal.
9432
9857
  *
9433
- * Reads symbol from execution context and signalId from the active pending signal.
9434
- * If no pending signal exists, logs a warning and returns an empty array.
9435
- *
9858
+ * Resolves the active pending or scheduled signal automatically from execution context.
9436
9859
  * Automatically detects backtest/live mode from execution context.
9437
9860
  *
9438
9861
  * @param dto.bucketName - Memory bucket name
9439
- * @returns Promise resolving to all stored entries, or empty array if no signal
9440
- *
9441
- * @deprecated Better use Memory.listMemory with manual signalId argument
9862
+ * @returns Promise resolving to all stored entries
9863
+ * @throws Error if no pending or scheduled signal exists
9442
9864
  *
9443
9865
  * @example
9444
9866
  * ```typescript
@@ -9456,16 +9878,13 @@ declare function listMemory<T extends object = object>(dto: {
9456
9878
  /**
9457
9879
  * Removes a memory entry for the current signal.
9458
9880
  *
9459
- * Reads symbol from execution context and signalId from the active pending signal.
9460
- * If no pending signal exists, logs a warning and returns without removing.
9461
- *
9881
+ * Resolves the active pending or scheduled signal automatically from execution context.
9462
9882
  * Automatically detects backtest/live mode from execution context.
9463
9883
  *
9464
9884
  * @param dto.bucketName - Memory bucket name
9465
9885
  * @param dto.memoryId - Unique memory entry identifier
9466
9886
  * @returns Promise that resolves when removal is complete
9467
- *
9468
- * @deprecated Better use Memory.removeMemory with manual signalId argument
9887
+ * @throws Error if no pending or scheduled signal exists
9469
9888
  *
9470
9889
  * @example
9471
9890
  * ```typescript
@@ -9522,16 +9941,15 @@ interface MessageModel<Role extends MessageRole = MessageRole> {
9522
9941
  /**
9523
9942
  * Dumps the full agent message history scoped to the current signal.
9524
9943
  *
9525
- * Reads signalId from the active pending signal via execution and method context.
9526
- * If no pending signal exists, logs a warning and returns without writing.
9944
+ * Resolves the active pending or scheduled signal automatically from execution context.
9945
+ * Automatically detects backtest/live mode from execution context.
9527
9946
  *
9528
9947
  * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
9529
9948
  * @param dto.dumpId - Unique identifier for this agent invocation
9530
9949
  * @param dto.messages - Full chat history (system, user, assistant, tool)
9531
9950
  * @param dto.description - Human-readable label describing the agent invocation context; included in the BM25 index for Memory search
9532
9951
  * @returns Promise that resolves when the dump is complete
9533
- *
9534
- * @deprecated Better use Dump.dumpAgentAnswer with manual signalId argument
9952
+ * @throws Error if no pending or scheduled signal exists
9535
9953
  *
9536
9954
  * @example
9537
9955
  * ```typescript
@@ -9549,16 +9967,15 @@ declare function dumpAgentAnswer(dto: {
9549
9967
  /**
9550
9968
  * Dumps a flat key-value record scoped to the current signal.
9551
9969
  *
9552
- * Reads signalId from the active pending signal via execution and method context.
9553
- * If no pending signal exists, logs a warning and returns without writing.
9970
+ * Resolves the active pending or scheduled signal automatically from execution context.
9971
+ * Automatically detects backtest/live mode from execution context.
9554
9972
  *
9555
9973
  * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
9556
9974
  * @param dto.dumpId - Unique identifier for this dump entry
9557
9975
  * @param dto.record - Arbitrary flat object to persist
9558
9976
  * @param dto.description - Human-readable label describing the record contents; included in the BM25 index for Memory search
9559
9977
  * @returns Promise that resolves when the dump is complete
9560
- *
9561
- * @deprecated Better use Dump.dumpRecord with manual signalId argument
9978
+ * @throws Error if no pending or scheduled signal exists
9562
9979
  *
9563
9980
  * @example
9564
9981
  * ```typescript
@@ -9576,8 +9993,8 @@ declare function dumpRecord(dto: {
9576
9993
  /**
9577
9994
  * Dumps an array of objects as a table scoped to the current signal.
9578
9995
  *
9579
- * Reads signalId from the active pending signal via execution and method context.
9580
- * If no pending signal exists, logs a warning and returns without writing.
9996
+ * Resolves the active pending or scheduled signal automatically from execution context.
9997
+ * Automatically detects backtest/live mode from execution context.
9581
9998
  *
9582
9999
  * Column headers are derived from the union of all keys across all rows.
9583
10000
  *
@@ -9586,8 +10003,7 @@ declare function dumpRecord(dto: {
9586
10003
  * @param dto.rows - Array of arbitrary objects to render as a table
9587
10004
  * @param dto.description - Human-readable label describing the table contents; included in the BM25 index for Memory search
9588
10005
  * @returns Promise that resolves when the dump is complete
9589
- *
9590
- * @deprecated Better use Dump.dumpTable with manual signalId argument
10006
+ * @throws Error if no pending or scheduled signal exists
9591
10007
  *
9592
10008
  * @example
9593
10009
  * ```typescript
@@ -9605,16 +10021,15 @@ declare function dumpTable(dto: {
9605
10021
  /**
9606
10022
  * Dumps raw text content scoped to the current signal.
9607
10023
  *
9608
- * Reads signalId from the active pending signal via execution and method context.
9609
- * If no pending signal exists, logs a warning and returns without writing.
10024
+ * Resolves the active pending or scheduled signal automatically from execution context.
10025
+ * Automatically detects backtest/live mode from execution context.
9610
10026
  *
9611
10027
  * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
9612
10028
  * @param dto.dumpId - Unique identifier for this dump entry
9613
10029
  * @param dto.content - Arbitrary text content to persist
9614
10030
  * @param dto.description - Human-readable label describing the content; included in the BM25 index for Memory search
9615
10031
  * @returns Promise that resolves when the dump is complete
9616
- *
9617
- * @deprecated Better use Dump.dumpText with manual signalId argument
10032
+ * @throws Error if no pending or scheduled signal exists
9618
10033
  *
9619
10034
  * @example
9620
10035
  * ```typescript
@@ -9632,16 +10047,15 @@ declare function dumpText(dto: {
9632
10047
  /**
9633
10048
  * Dumps an error description scoped to the current signal.
9634
10049
  *
9635
- * Reads signalId from the active pending signal via execution and method context.
9636
- * If no pending signal exists, logs a warning and returns without writing.
10050
+ * Resolves the active pending or scheduled signal automatically from execution context.
10051
+ * Automatically detects backtest/live mode from execution context.
9637
10052
  *
9638
10053
  * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
9639
10054
  * @param dto.dumpId - Unique identifier for this dump entry
9640
10055
  * @param dto.content - Error message or description to persist
9641
10056
  * @param dto.description - Human-readable label describing the error context; included in the BM25 index for Memory search
9642
10057
  * @returns Promise that resolves when the dump is complete
9643
- *
9644
- * @deprecated Better use Dump.dumpError with manual signalId argument
10058
+ * @throws Error if no pending or scheduled signal exists
9645
10059
  *
9646
10060
  * @example
9647
10061
  * ```typescript
@@ -9659,14 +10073,15 @@ declare function dumpError(dto: {
9659
10073
  /**
9660
10074
  * Dumps an arbitrary nested object as a fenced JSON block scoped to the current signal.
9661
10075
  *
9662
- * Reads signalId from the active pending signal via execution and method context.
9663
- * If no pending signal exists, logs a warning and returns without writing.
10076
+ * Resolves the active pending or scheduled signal automatically from execution context.
10077
+ * Automatically detects backtest/live mode from execution context.
9664
10078
  *
9665
10079
  * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
9666
10080
  * @param dto.dumpId - Unique identifier for this dump entry
9667
10081
  * @param dto.json - Arbitrary nested object to serialize with JSON.stringify
9668
10082
  * @param dto.description - Human-readable label describing the object contents; included in the BM25 index for Memory search
9669
10083
  * @returns Promise that resolves when the dump is complete
10084
+ * @throws Error if no pending or scheduled signal exists
9670
10085
  *
9671
10086
  * @deprecated Prefer dumpRecord — flat key-value structure maps naturally to markdown tables and SQL storage
9672
10087
  *
@@ -13550,6 +13965,84 @@ declare class PersistRecentUtils {
13550
13965
  * Used by RecentPersistBacktestUtils/RecentPersistLiveUtils for recent signal persistence.
13551
13966
  */
13552
13967
  declare const PersistRecentAdapter: PersistRecentUtils;
13968
+ /**
13969
+ * Type for persisted state entry data.
13970
+ * Wraps an arbitrary JSON-serializable object with a unique id.
13971
+ */
13972
+ type StateData = {
13973
+ id: string;
13974
+ data: object;
13975
+ };
13976
+ /**
13977
+ * Utility class for managing state persistence.
13978
+ *
13979
+ * Features:
13980
+ * - Memoized storage instances per (signalId, bucketName) pair
13981
+ * - Custom adapter support
13982
+ * - Atomic read/write operations
13983
+ *
13984
+ * Storage layout: ./dump/state/<signalId>/<bucketName>.json
13985
+ *
13986
+ * Used by StatePersistInstance for crash-safe state persistence.
13987
+ */
13988
+ declare class PersistStateUtils {
13989
+ private PersistStateFactory;
13990
+ private getStateStorage;
13991
+ /**
13992
+ * Registers a custom persistence adapter.
13993
+ *
13994
+ * @param Ctor - Custom PersistBase constructor
13995
+ */
13996
+ usePersistStateAdapter(Ctor: TPersistBaseCtor<string, StateData>): void;
13997
+ /**
13998
+ * Initializes the storage for a given (signalId, bucketName) pair.
13999
+ *
14000
+ * @param signalId - Signal identifier
14001
+ * @param bucketName - Bucket name
14002
+ * @param initial - Whether this is the first initialization
14003
+ */
14004
+ waitForInit: (signalId: string, bucketName: string, initial: boolean) => Promise<void>;
14005
+ /**
14006
+ * Reads a state entry from persistence storage.
14007
+ *
14008
+ * @param signalId - Signal identifier
14009
+ * @param bucketName - Bucket name
14010
+ * @returns Promise resolving to entry data or null if not found
14011
+ */
14012
+ readStateData: (signalId: string, bucketName: string) => Promise<StateData | null>;
14013
+ /**
14014
+ * Writes a state entry to disk with atomic file writes.
14015
+ *
14016
+ * @param data - Entry data to persist
14017
+ * @param signalId - Signal identifier
14018
+ * @param bucketName - Bucket name
14019
+ */
14020
+ writeStateData: (data: StateData, signalId: string, bucketName: string) => Promise<void>;
14021
+ /**
14022
+ * Switches to a dummy persist adapter that discards all writes.
14023
+ * All future persistence writes will be no-ops.
14024
+ */
14025
+ useDummy: () => void;
14026
+ /**
14027
+ * Clears the memoized storage cache.
14028
+ * Call this when process.cwd() changes between strategy iterations
14029
+ * so new storage instances are created with the updated base path.
14030
+ */
14031
+ clear: () => void;
14032
+ /**
14033
+ * Disposes of the state adapter and releases any resources.
14034
+ * Call this when a signal is removed to clean up its associated storage.
14035
+ *
14036
+ * @param signalId - Signal identifier
14037
+ * @param bucketName - Bucket name
14038
+ */
14039
+ dispose: (signalId: string, bucketName: string) => void;
14040
+ }
14041
+ /**
14042
+ * Global singleton instance of PersistStateUtils.
14043
+ * Used by StatePersistInstance for crash-safe state persistence.
14044
+ */
14045
+ declare const PersistStateAdapter: PersistStateUtils;
13553
14046
 
13554
14047
  /**
13555
14048
  * Configuration interface for selective markdown service enablement.
@@ -22010,50 +22503,47 @@ interface IMemoryInstance {
22010
22503
  }
22011
22504
  /**
22012
22505
  * Constructor type for memory instance implementations.
22013
- * Used for swapping backends via MemoryAdapter.
22506
+ * Used for swapping backends via MemoryBacktestAdapter / MemoryLiveAdapter.
22014
22507
  */
22015
22508
  type TMemoryInstanceCtor = new (signalId: string, bucketName: string) => IMemoryInstance;
22016
22509
  /**
22017
- * Public surface of MemoryAdapter - IMemoryInstance minus waitForInit.
22510
+ * Public surface of MemoryBacktestAdapter / MemoryLiveAdapter — IMemoryInstance minus waitForInit.
22018
22511
  * waitForInit is managed internally by the adapter.
22019
22512
  */
22020
22513
  type TMemoryInstance = Omit<{
22021
22514
  [key in keyof IMemoryInstance]: any;
22022
22515
  }, keyof {
22023
22516
  waitForInit: never;
22517
+ dispose: never;
22024
22518
  }>;
22025
22519
  /**
22026
- * Facade for memory instances scoped per (signalId, bucketName).
22027
- * Manages lazy initialization and instance lifecycle.
22520
+ * Backtest memory adapter with pluggable storage backend.
22028
22521
  *
22029
22522
  * Features:
22030
- * - Memoized instances per (signalId, bucketName) pair
22031
- * - Swappable backend via useLocal(), usePersist(), useDummy()
22032
- * - Default backend: MemoryPersistInstance (in-memory BM25 + persist storage)
22523
+ * - Adapter pattern for swappable memory instance implementations
22524
+ * - Default backend: MemoryLocalInstance (in-memory BM25, no disk persistence)
22525
+ * - Alternative backends: MemoryPersistInstance, MemoryDummyInstance
22526
+ * - Convenience methods: useLocal(), usePersist(), useDummy(), useMemoryAdapter()
22527
+ * - Memoized instances per (signalId, bucketName) pair; cleared via disposeSignal() from MemoryAdapter
22528
+ *
22529
+ * Use this adapter for backtest memory storage.
22033
22530
  */
22034
- declare class MemoryAdapter implements TMemoryInstance {
22531
+ declare class MemoryBacktestAdapter implements TMemoryInstance {
22035
22532
  private MemoryFactory;
22036
22533
  private getInstance;
22037
22534
  /**
22038
- * Activates the adapter by subscribing to signal lifecycle events.
22039
- * Clears memoized instances for a signalId when it is cancelled or closed,
22040
- * preventing stale instances from accumulating in memory.
22041
- * Idempotent — subsequent calls return the same subscription handle.
22042
- * Must be called before any memory method is used.
22535
+ * Disposes all memoized instances for the given signalId.
22536
+ * Called by MemoryAdapter when a signal is cancelled or closed.
22537
+ * @param signalId - Signal identifier to dispose
22043
22538
  */
22044
- enable: (() => (...args: any[]) => any) & functools_kit.ISingleshotClearable<() => (...args: any[]) => any>;
22045
- /**
22046
- * Deactivates the adapter by unsubscribing from signal lifecycle events.
22047
- * No-op if enable() was never called.
22048
- */
22049
- disable: () => void;
22539
+ disposeSignal: (signalId: string) => void;
22050
22540
  /**
22051
22541
  * Write a value to memory.
22052
22542
  * @param dto.memoryId - Unique entry identifier
22053
22543
  * @param dto.value - Value to store
22054
22544
  * @param dto.signalId - Signal identifier
22055
22545
  * @param dto.bucketName - Bucket name
22056
- * @param dto.description - Optional BM25 index string; defaults to JSON.stringify(value)
22546
+ * @param dto.description - BM25 index string; defaults to JSON.stringify(value)
22057
22547
  */
22058
22548
  writeMemory: <T extends object = object>(dto: {
22059
22549
  memoryId: string;
@@ -22130,23 +22620,262 @@ declare class MemoryAdapter implements TMemoryInstance {
22130
22620
  * Switches to dummy adapter that discards all writes.
22131
22621
  */
22132
22622
  useDummy: () => void;
22623
+ /**
22624
+ * Switches to a custom memory adapter implementation.
22625
+ * @param Ctor - Constructor for the custom memory instance
22626
+ */
22627
+ useMemoryAdapter: (Ctor: TMemoryInstanceCtor) => void;
22133
22628
  /**
22134
22629
  * Clears the memoized instance cache.
22135
22630
  * Call this when process.cwd() changes between strategy iterations
22136
22631
  * so new instances are created with the updated base path.
22137
22632
  */
22138
22633
  clear: () => void;
22634
+ }
22635
+ /**
22636
+ * Live trading memory adapter with pluggable storage backend.
22637
+ *
22638
+ * Features:
22639
+ * - Adapter pattern for swappable memory instance implementations
22640
+ * - Default backend: MemoryPersistInstance (file-system backed, survives restarts)
22641
+ * - Alternative backends: MemoryLocalInstance, MemoryDummyInstance
22642
+ * - Convenience methods: useLocal(), usePersist(), useDummy(), useMemoryAdapter()
22643
+ * - Memoized instances per (signalId, bucketName) pair; cleared via disposeSignal() from MemoryAdapter
22644
+ *
22645
+ * Use this adapter for live trading memory storage.
22646
+ */
22647
+ declare class MemoryLiveAdapter implements TMemoryInstance {
22648
+ private MemoryFactory;
22649
+ private getInstance;
22650
+ /**
22651
+ * Disposes all memoized instances for the given signalId.
22652
+ * Called by MemoryAdapter when a signal is cancelled or closed.
22653
+ * @param signalId - Signal identifier to dispose
22654
+ */
22655
+ disposeSignal: (signalId: string) => void;
22139
22656
  /**
22140
- * Releases resources held by this adapter.
22141
- * Delegates to disable() to unsubscribe from signal lifecycle events.
22657
+ * Write a value to memory.
22658
+ * @param dto.memoryId - Unique entry identifier
22659
+ * @param dto.value - Value to store
22660
+ * @param dto.signalId - Signal identifier
22661
+ * @param dto.bucketName - Bucket name
22662
+ * @param dto.description - BM25 index string; defaults to JSON.stringify(value)
22663
+ */
22664
+ writeMemory: <T extends object = object>(dto: {
22665
+ memoryId: string;
22666
+ value: T;
22667
+ signalId: string;
22668
+ bucketName: string;
22669
+ description: string;
22670
+ }) => Promise<void>;
22671
+ /**
22672
+ * Search memory using BM25 full-text scoring.
22673
+ * @param dto.query - Search query string
22674
+ * @param dto.signalId - Signal identifier
22675
+ * @param dto.bucketName - Bucket name
22676
+ * @returns Matching entries sorted by relevance score
22677
+ */
22678
+ searchMemory: <T extends object = object>(dto: {
22679
+ query: string;
22680
+ signalId: string;
22681
+ bucketName: string;
22682
+ settings?: SearchSettings;
22683
+ }) => Promise<{
22684
+ memoryId: string;
22685
+ score: number;
22686
+ content: T;
22687
+ }[]>;
22688
+ /**
22689
+ * List all entries in memory.
22690
+ * @param dto.signalId - Signal identifier
22691
+ * @param dto.bucketName - Bucket name
22692
+ * @returns Array of all stored entries
22693
+ */
22694
+ listMemory: <T extends object = object>(dto: {
22695
+ signalId: string;
22696
+ bucketName: string;
22697
+ }) => Promise<{
22698
+ memoryId: string;
22699
+ content: T;
22700
+ }[]>;
22701
+ /**
22702
+ * Remove an entry from memory.
22703
+ * @param dto.memoryId - Unique entry identifier
22704
+ * @param dto.signalId - Signal identifier
22705
+ * @param dto.bucketName - Bucket name
22706
+ */
22707
+ removeMemory: (dto: {
22708
+ memoryId: string;
22709
+ signalId: string;
22710
+ bucketName: string;
22711
+ }) => Promise<void>;
22712
+ /**
22713
+ * Read a single entry from memory.
22714
+ * @param dto.memoryId - Unique entry identifier
22715
+ * @param dto.signalId - Signal identifier
22716
+ * @param dto.bucketName - Bucket name
22717
+ * @returns Entry value
22718
+ * @throws Error if entry not found
22142
22719
  */
22143
- dispose: () => void;
22720
+ readMemory: <T extends object = object>(dto: {
22721
+ memoryId: string;
22722
+ signalId: string;
22723
+ bucketName: string;
22724
+ }) => Promise<T>;
22725
+ /**
22726
+ * Switches to in-memory BM25 adapter.
22727
+ * All data lives in process memory only.
22728
+ */
22729
+ useLocal: () => void;
22730
+ /**
22731
+ * Switches to file-system backed adapter (default).
22732
+ * Data is persisted to ./dump/memory/<signalId>/<bucketName>/.
22733
+ */
22734
+ usePersist: () => void;
22735
+ /**
22736
+ * Switches to dummy adapter that discards all writes.
22737
+ */
22738
+ useDummy: () => void;
22739
+ /**
22740
+ * Switches to a custom memory adapter implementation.
22741
+ * @param Ctor - Constructor for the custom memory instance
22742
+ */
22743
+ useMemoryAdapter: (Ctor: TMemoryInstanceCtor) => void;
22744
+ /**
22745
+ * Clears the memoized instance cache.
22746
+ * Call this when process.cwd() changes between strategy iterations
22747
+ * so new instances are created with the updated base path.
22748
+ */
22749
+ clear: () => void;
22750
+ }
22751
+ /**
22752
+ * Main memory adapter that manages both backtest and live memory storage.
22753
+ *
22754
+ * Features:
22755
+ * - Subscribes to signal lifecycle events (cancelled/closed) to dispose stale instances
22756
+ * - Routes all operations to MemoryBacktest or MemoryLive based on dto.backtest
22757
+ * - Singleshot enable pattern prevents duplicate subscriptions
22758
+ * - Cleanup function for proper unsubscription
22759
+ */
22760
+ declare class MemoryAdapter {
22761
+ /**
22762
+ * Enables memory storage by subscribing to signal lifecycle events.
22763
+ * Clears memoized instances in MemoryBacktest and MemoryLive when a signal
22764
+ * is cancelled or closed, preventing stale instances from accumulating.
22765
+ * Uses singleshot to ensure one-time subscription.
22766
+ *
22767
+ * @returns Cleanup function that unsubscribes from all emitters
22768
+ */
22769
+ enable: (() => (...args: any[]) => any) & functools_kit.ISingleshotClearable<() => (...args: any[]) => any>;
22770
+ /**
22771
+ * Disables memory storage by unsubscribing from signal lifecycle events.
22772
+ * Safe to call multiple times.
22773
+ */
22774
+ disable: () => void;
22775
+ /**
22776
+ * Write a value to memory.
22777
+ * Routes to MemoryBacktest or MemoryLive based on dto.backtest.
22778
+ * @param dto.memoryId - Unique entry identifier
22779
+ * @param dto.value - Value to store
22780
+ * @param dto.signalId - Signal identifier
22781
+ * @param dto.bucketName - Bucket name
22782
+ * @param dto.description - BM25 index string; defaults to JSON.stringify(value)
22783
+ * @param dto.backtest - Flag indicating if the context is backtest or live
22784
+ */
22785
+ writeMemory: <T extends object = object>(dto: {
22786
+ memoryId: string;
22787
+ value: T;
22788
+ signalId: string;
22789
+ bucketName: string;
22790
+ description: string;
22791
+ backtest: boolean;
22792
+ }) => Promise<void>;
22793
+ /**
22794
+ * Search memory using BM25 full-text scoring.
22795
+ * Routes to MemoryBacktest or MemoryLive based on dto.backtest.
22796
+ * @param dto.query - Search query string
22797
+ * @param dto.signalId - Signal identifier
22798
+ * @param dto.bucketName - Bucket name
22799
+ * @param dto.backtest - Flag indicating if the context is backtest or live
22800
+ * @returns Matching entries sorted by relevance score
22801
+ */
22802
+ searchMemory: <T extends object = object>(dto: {
22803
+ query: string;
22804
+ signalId: string;
22805
+ bucketName: string;
22806
+ settings?: SearchSettings;
22807
+ backtest: boolean;
22808
+ }) => Promise<{
22809
+ memoryId: string;
22810
+ score: number;
22811
+ content: T;
22812
+ }[]>;
22813
+ /**
22814
+ * List all entries in memory.
22815
+ * Routes to MemoryBacktest or MemoryLive based on dto.backtest.
22816
+ * @param dto.signalId - Signal identifier
22817
+ * @param dto.bucketName - Bucket name
22818
+ * @param dto.backtest - Flag indicating if the context is backtest or live
22819
+ * @returns Array of all stored entries
22820
+ */
22821
+ listMemory: <T extends object = object>(dto: {
22822
+ signalId: string;
22823
+ bucketName: string;
22824
+ backtest: boolean;
22825
+ }) => Promise<{
22826
+ memoryId: string;
22827
+ content: T;
22828
+ }[]>;
22829
+ /**
22830
+ * Remove an entry from memory.
22831
+ * Routes to MemoryBacktest or MemoryLive based on dto.backtest.
22832
+ * @param dto.memoryId - Unique entry identifier
22833
+ * @param dto.signalId - Signal identifier
22834
+ * @param dto.bucketName - Bucket name
22835
+ * @param dto.backtest - Flag indicating if the context is backtest or live
22836
+ */
22837
+ removeMemory: (dto: {
22838
+ memoryId: string;
22839
+ signalId: string;
22840
+ bucketName: string;
22841
+ backtest: boolean;
22842
+ }) => Promise<void>;
22843
+ /**
22844
+ * Read a single entry from memory.
22845
+ * Routes to MemoryBacktest or MemoryLive based on dto.backtest.
22846
+ * @param dto.memoryId - Unique entry identifier
22847
+ * @param dto.signalId - Signal identifier
22848
+ * @param dto.bucketName - Bucket name
22849
+ * @param dto.backtest - Flag indicating if the context is backtest or live
22850
+ * @returns Entry value
22851
+ * @throws Error if entry not found
22852
+ */
22853
+ readMemory: <T extends object = object>(dto: {
22854
+ memoryId: string;
22855
+ signalId: string;
22856
+ bucketName: string;
22857
+ backtest: boolean;
22858
+ }) => Promise<T>;
22144
22859
  }
22860
+ /**
22861
+ * Global singleton instance of MemoryAdapter.
22862
+ * Provides unified memory management for backtest and live trading.
22863
+ */
22145
22864
  declare const Memory: MemoryAdapter;
22865
+ /**
22866
+ * Global singleton instance of MemoryLiveAdapter.
22867
+ * Provides live trading memory storage with pluggable backends.
22868
+ */
22869
+ declare const MemoryLive: MemoryLiveAdapter;
22870
+ /**
22871
+ * Global singleton instance of MemoryBacktestAdapter.
22872
+ * Provides backtest memory storage with pluggable backends.
22873
+ */
22874
+ declare const MemoryBacktest: MemoryBacktestAdapter;
22146
22875
 
22147
22876
  /**
22148
22877
  * Context required to identify a dump entry.
22149
- * Passed only through DumpAdapter - instances receive signalId and bucketName via constructor.
22878
+ * Passed only through DumpAdapter - instances receive signalId, bucketName, and backtest via constructor.
22150
22879
  */
22151
22880
  interface IDumpContext {
22152
22881
  /** Signal identifier - scopes the dump to a specific trade */
@@ -22157,6 +22886,8 @@ interface IDumpContext {
22157
22886
  dumpId: string;
22158
22887
  /** Human-readable label describing the dump contents; included in the BM25 index for Memory search and rendered in Markdown output */
22159
22888
  description: string;
22889
+ /** Flag indicating if the context is backtest or live; routed to Memory.writeMemory */
22890
+ backtest: boolean;
22160
22891
  }
22161
22892
  /**
22162
22893
  * Interface for dump instance implementations.
@@ -22217,7 +22948,7 @@ interface IDumpInstance {
22217
22948
  * Constructor type for dump instance implementations.
22218
22949
  * Used for swapping backends via DumpAdapter.useDumpAdapter().
22219
22950
  */
22220
- type TDumpInstanceCtor = new (signalId: string, bucketName: string) => IDumpInstance;
22951
+ type TDumpInstanceCtor = new (signalId: string, bucketName: string, backtest: boolean) => IDumpInstance;
22221
22952
  /**
22222
22953
  * Facade for dump instances with swappable backend.
22223
22954
  * Default backend: DumpMarkdownInstance.
@@ -32944,4 +33675,4 @@ declare const getTotalClosed: (signal: Signal) => {
32944
33675
  remainingCostBasis: number;
32945
33676
  };
32946
33677
 
32947
- export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, type CommitPayload, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IRecentUtils, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalIntervalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type IdlePingContract, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, type MemoryData, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRecentAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Recent, RecentBacktest, type RecentData, RecentLive, Reflect, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, Session, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInfoContract, type SignalInfoNotification, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TRecentUtilsCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitSignalNotify, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, getMinutesSinceLatestSignalCreated, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionActiveMinutes, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getPositionWaitingMinutes, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenIdlePing, listenIdlePingOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalNotify, listenSignalNotifyOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
33678
+ export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, type CommitPayload, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IRecentUtils, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalIntervalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStateInstance, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type IdlePingContract, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, MemoryBacktest, MemoryBacktestAdapter, type MemoryData, MemoryLive, MemoryLiveAdapter, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRecentAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStateAdapter, PersistStorageAdapter, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Recent, RecentBacktest, type RecentData, RecentLive, Reflect, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, Session, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInfoContract, type SignalInfoNotification, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, State, StateBacktest, StateBacktestAdapter, type StateData, StateLive, StateLiveAdapter, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TRecentUtilsCtor, type TReportBase, type TStateInstanceCtor, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitSignalNotify, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, createSignalState, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, getMinutesSinceLatestSignalCreated, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionActiveMinutes, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getPositionWaitingMinutes, getRawCandles, getRiskSchema, getScheduledSignal, getSignalState, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenIdlePing, listenIdlePingOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalNotify, listenSignalNotifyOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, setSignalState, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };