backtest-kit 5.6.7 → 5.9.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
@@ -2119,8 +2119,12 @@ interface ISignalDto {
2119
2119
  priceTakeProfit: number;
2120
2120
  /** Stop loss exit price (must be < priceOpen for long, > priceOpen for short) */
2121
2121
  priceStopLoss: number;
2122
- /** Expected duration in minutes before time_expired */
2123
- minuteEstimatedTime: number;
2122
+ /**
2123
+ * Expected duration in minutes before time_expired.
2124
+ * Use `Infinity` for no timeout — position stays open until TP/SL or explicit closePending().
2125
+ * Default: GLOBAL_CONFIG.CC_MAX_SIGNAL_LIFETIME_MINUTES
2126
+ */
2127
+ minuteEstimatedTime?: number;
2124
2128
  /** Cost of this entry in USD. Default: GLOBAL_CONFIG.CC_POSITION_ENTRY_COST */
2125
2129
  cost?: number;
2126
2130
  }
@@ -2135,6 +2139,8 @@ interface ISignalRow extends ISignalDto {
2135
2139
  cost: number;
2136
2140
  /** Entry price for the position */
2137
2141
  priceOpen: number;
2142
+ /** Expected duration in minutes before time_expired (required in row, defaults applied in ClientStrategy) */
2143
+ minuteEstimatedTime: number;
2138
2144
  /** Unique exchange identifier for execution */
2139
2145
  exchangeName: ExchangeName;
2140
2146
  /** Unique strategy identifier for execution */
@@ -2679,6 +2685,8 @@ interface IStrategyTickResultActive {
2679
2685
  backtest: boolean;
2680
2686
  /** Unix timestamp in milliseconds when this tick result was created (from candle timestamp in backtest or execution context when in live) */
2681
2687
  createdAt: number;
2688
+ /** Unix timestamp in milliseconds of the last processed candle. Used by BacktestLogicPrivateService to advance chunkStart for the next chunk request. */
2689
+ _backtestLastTimestamp: number;
2682
2690
  }
2683
2691
  /**
2684
2692
  * Tick result: signal closed with PNL.
@@ -2748,9 +2756,10 @@ interface IStrategyTickResultCancelled {
2748
2756
  */
2749
2757
  type IStrategyTickResult = IStrategyTickResultIdle | IStrategyTickResultScheduled | IStrategyTickResultWaiting | IStrategyTickResultOpened | IStrategyTickResultActive | IStrategyTickResultClosed | IStrategyTickResultCancelled;
2750
2758
  /**
2751
- * Backtest returns closed result (TP/SL or time_expired) or cancelled result (scheduled signal never activated).
2759
+ * Backtest returns closed result (TP/SL or time_expired), cancelled result (scheduled signal never activated),
2760
+ * or active result (candles exhausted but signal still open — only for minuteEstimatedTime = Infinity).
2752
2761
  */
2753
- type IStrategyBacktestResult = IStrategyTickResultOpened | IStrategyTickResultScheduled | IStrategyTickResultClosed | IStrategyTickResultCancelled;
2762
+ type IStrategyBacktestResult = IStrategyTickResultOpened | IStrategyTickResultScheduled | IStrategyTickResultActive | IStrategyTickResultClosed | IStrategyTickResultCancelled;
2754
2763
  /**
2755
2764
  * Strategy interface implemented by ClientStrategy.
2756
2765
  * Defines core strategy execution methods.
@@ -4874,7 +4883,7 @@ declare function getTotalCostClosed(symbol: string): Promise<number>;
4874
4883
  * }
4875
4884
  * ```
4876
4885
  */
4877
- declare function getPendingSignal(symbol: string): Promise<IPublicSignalRow>;
4886
+ declare function getPendingSignal(symbol: string): Promise<IPublicSignalRow | null>;
4878
4887
  /**
4879
4888
  * Returns the currently active scheduled signal for the strategy.
4880
4889
  * If no scheduled signal exists, returns null.
@@ -5513,8 +5522,10 @@ declare const GLOBAL_CONFIG: {
5513
5522
  */
5514
5523
  CC_MAX_STOPLOSS_DISTANCE_PERCENT: number;
5515
5524
  /**
5516
- * Maximum signal lifetime in minutes
5517
- * Prevents eternal signals that block risk limits for weeks/months
5525
+ * Maximum signal lifetime in minutes.
5526
+ * Also used as the default when minuteEstimatedTime is not provided in ISignalDto.
5527
+ * Prevents eternal signals that block risk limits for weeks/months.
5528
+ * Use Infinity to allow signals to live indefinitely (until TP/SL or explicit close).
5518
5529
  * Default: 1440 minutes (1 day)
5519
5530
  */
5520
5531
  CC_MAX_SIGNAL_LIFETIME_MINUTES: number;
@@ -8380,54 +8391,344 @@ declare function getNextCandles(symbol: string, interval: CandleInterval, limit:
8380
8391
  */
8381
8392
  declare function getAggregatedTrades(symbol: string, limit?: number): Promise<IAggregatedTradeData[]>;
8382
8393
 
8383
- /** Unique identifier for a dump result. Can be a string or numeric ID. */
8384
- type ResultId = string | number;
8385
- /** Role of the message sender in LLM chat history. */
8386
- type BaseRole = "assistant" | "system" | "user";
8387
8394
  /**
8388
- * A single message in the chat history.
8389
- * Used to represent system instructions, user input, or LLM responses.
8395
+ * Writes a value to memory scoped to the current signal.
8396
+ *
8397
+ * Reads symbol from execution context and signalId from the active pending signal.
8398
+ * If no pending signal exists, logs a warning and returns without writing.
8399
+ *
8400
+ * Automatically detects backtest/live mode from execution context.
8401
+ *
8402
+ * @param dto.bucketName - Memory bucket name
8403
+ * @param dto.memoryId - Unique memory entry identifier
8404
+ * @param dto.value - Value to store
8405
+ * @returns Promise that resolves when write is complete
8406
+ *
8407
+ * @deprecated Better use Memory.writeMemory with manual signalId argument
8408
+ *
8409
+ * @example
8410
+ * ```typescript
8411
+ * import { writeMemory } from "backtest-kit";
8412
+ *
8413
+ * await writeMemory({ bucketName: "my-strategy", memoryId: "context", value: { trend: "up", confidence: 0.9 } });
8414
+ * ```
8390
8415
  */
8391
- interface Message<Role extends BaseRole = BaseRole> {
8392
- /**
8393
- * The sender of the message.
8394
- * - "system": System instructions and context
8395
- * - "user": User input and questions
8396
- * - "assistant": LLM responses
8397
- */
8416
+ declare function writeMemory<T extends object = object>(dto: {
8417
+ bucketName: string;
8418
+ memoryId: string;
8419
+ value: T;
8420
+ }): Promise<void>;
8421
+ /**
8422
+ * Reads a value from memory scoped to the current signal.
8423
+ *
8424
+ * Reads symbol from execution context and signalId from the active pending signal.
8425
+ * If no pending signal exists, logs a warning and returns null.
8426
+ *
8427
+ * Automatically detects backtest/live mode from execution context.
8428
+ *
8429
+ * @param dto.bucketName - Memory bucket name
8430
+ * @param dto.memoryId - Unique memory entry identifier
8431
+ * @returns Promise resolving to stored value or null if no signal
8432
+ * @throws Error if entry not found within an active signal
8433
+ *
8434
+ * @deprecated Better use Memory.readMemory with manual signalId argument
8435
+ *
8436
+ * @example
8437
+ * ```typescript
8438
+ * import { readMemory } from "backtest-kit";
8439
+ *
8440
+ * const ctx = await readMemory<{ trend: string }>({ bucketName: "my-strategy", memoryId: "context" });
8441
+ * ```
8442
+ */
8443
+ declare function readMemory<T extends object = object>(dto: {
8444
+ bucketName: string;
8445
+ memoryId: string;
8446
+ }): Promise<T | null>;
8447
+ /**
8448
+ * Searches memory entries for the current signal using BM25 full-text scoring.
8449
+ *
8450
+ * Reads symbol from execution context and signalId from the active pending signal.
8451
+ * If no pending signal exists, logs a warning and returns an empty array.
8452
+ *
8453
+ * Automatically detects backtest/live mode from execution context.
8454
+ *
8455
+ * @param dto.bucketName - Memory bucket name
8456
+ * @param dto.query - Search query string
8457
+ * @returns Promise resolving to matching entries sorted by relevance, or empty array if no signal
8458
+ *
8459
+ * @deprecated Better use Memory.searchMemory with manual signalId argument
8460
+ *
8461
+ * @example
8462
+ * ```typescript
8463
+ * import { searchMemory } from "backtest-kit";
8464
+ *
8465
+ * const results = await searchMemory({ bucketName: "my-strategy", query: "bullish trend" });
8466
+ * ```
8467
+ */
8468
+ declare function searchMemory<T extends object = object>(dto: {
8469
+ bucketName: string;
8470
+ query: string;
8471
+ }): Promise<Array<{
8472
+ memoryId: string;
8473
+ score: number;
8474
+ content: T;
8475
+ }>>;
8476
+ /**
8477
+ * Lists all memory entries for the current signal.
8478
+ *
8479
+ * Reads symbol from execution context and signalId from the active pending signal.
8480
+ * If no pending signal exists, logs a warning and returns an empty array.
8481
+ *
8482
+ * Automatically detects backtest/live mode from execution context.
8483
+ *
8484
+ * @param dto.bucketName - Memory bucket name
8485
+ * @returns Promise resolving to all stored entries, or empty array if no signal
8486
+ *
8487
+ * @deprecated Better use Memory.listMemory with manual signalId argument
8488
+ *
8489
+ * @example
8490
+ * ```typescript
8491
+ * import { listMemory } from "backtest-kit";
8492
+ *
8493
+ * const entries = await listMemory({ bucketName: "my-strategy" });
8494
+ * ```
8495
+ */
8496
+ declare function listMemory<T extends object = object>(dto: {
8497
+ bucketName: string;
8498
+ }): Promise<Array<{
8499
+ memoryId: string;
8500
+ content: T;
8501
+ }>>;
8502
+ /**
8503
+ * Removes a memory entry for the current signal.
8504
+ *
8505
+ * Reads symbol from execution context and signalId from the active pending signal.
8506
+ * If no pending signal exists, logs a warning and returns without removing.
8507
+ *
8508
+ * Automatically detects backtest/live mode from execution context.
8509
+ *
8510
+ * @param dto.bucketName - Memory bucket name
8511
+ * @param dto.memoryId - Unique memory entry identifier
8512
+ * @returns Promise that resolves when removal is complete
8513
+ *
8514
+ * @deprecated Better use Memory.removeMemory with manual signalId argument
8515
+ *
8516
+ * @example
8517
+ * ```typescript
8518
+ * import { removeMemory } from "backtest-kit";
8519
+ *
8520
+ * await removeMemory({ bucketName: "my-strategy", memoryId: "context" });
8521
+ * ```
8522
+ */
8523
+ declare function removeMemory(dto: {
8524
+ bucketName: string;
8525
+ memoryId: string;
8526
+ }): Promise<void>;
8527
+
8528
+ /** Role of the message sender in an LLM chat history. */
8529
+ type MessageRole = "assistant" | "system" | "tool" | "user";
8530
+ /**
8531
+ * A tool call requested by the assistant.
8532
+ * Represents a single function invocation emitted in an assistant message.
8533
+ */
8534
+ type MessageToolCall = {
8535
+ /** Unique identifier for this tool call, referenced by the tool result message via tool_call_id. */
8536
+ id: string;
8537
+ /** Always "function" — the only supported tool call type. */
8538
+ type: "function";
8539
+ /** The function to invoke. */
8540
+ function: {
8541
+ /** Name of the function to call. */
8542
+ name: string;
8543
+ /** Arguments passed to the function, keyed by parameter name. */
8544
+ arguments: {
8545
+ [key: string]: any;
8546
+ };
8547
+ };
8548
+ };
8549
+ /**
8550
+ * A single message in an LLM chat history.
8551
+ * Covers all roles: system instructions, user input, assistant responses, and tool results.
8552
+ */
8553
+ interface MessageModel<Role extends MessageRole = MessageRole> {
8554
+ /** Sender role — determines how the message is interpreted by the model. */
8398
8555
  role: Role;
8399
- /**
8400
- * The text content of the message.
8401
- * Contains the actual message text sent or received.
8402
- */
8556
+ /** Text content of the message. Empty string for assistant messages that only contain tool_calls. */
8403
8557
  content: string;
8558
+ /** Chain-of-thought / reasoning exposed by some providers (e.g. DeepSeek). */
8559
+ reasoning_content?: string | null;
8560
+ /** Tool calls emitted by the assistant. Present only on assistant messages. */
8561
+ tool_calls?: MessageToolCall[];
8562
+ /** Images attached to the message. Supported as Blob, raw bytes, or base64 strings. */
8563
+ images?: Blob[] | Uint8Array[] | string[];
8564
+ /** ID of the tool call this message is responding to. Present only on tool messages. */
8565
+ tool_call_id?: string;
8404
8566
  }
8567
+
8568
+ /**
8569
+ * Dumps the full agent message history scoped to the current signal.
8570
+ *
8571
+ * Reads signalId from the active pending signal via execution and method context.
8572
+ * If no pending signal exists, logs a warning and returns without writing.
8573
+ *
8574
+ * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
8575
+ * @param dto.dumpId - Unique identifier for this agent invocation
8576
+ * @param dto.messages - Full chat history (system, user, assistant, tool)
8577
+ * @param dto.description - Human-readable label describing the agent invocation context; included in the BM25 index for Memory search
8578
+ * @returns Promise that resolves when the dump is complete
8579
+ *
8580
+ * @deprecated Better use Dump.dumpAgentAnswer with manual signalId argument
8581
+ *
8582
+ * @example
8583
+ * ```typescript
8584
+ * import { dumpAgentAnswer } from "backtest-kit";
8585
+ *
8586
+ * await dumpAgentAnswer({ bucketName: "my-strategy", dumpId: "reasoning-1", messages, description: "BTC long signal reasoning" });
8587
+ * ```
8588
+ */
8589
+ declare function dumpAgentAnswer(dto: {
8590
+ bucketName: string;
8591
+ dumpId: string;
8592
+ messages: MessageModel[];
8593
+ description: string;
8594
+ }): Promise<void>;
8595
+ /**
8596
+ * Dumps a flat key-value record scoped to the current signal.
8597
+ *
8598
+ * Reads signalId from the active pending signal via execution and method context.
8599
+ * If no pending signal exists, logs a warning and returns without writing.
8600
+ *
8601
+ * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
8602
+ * @param dto.dumpId - Unique identifier for this dump entry
8603
+ * @param dto.record - Arbitrary flat object to persist
8604
+ * @param dto.description - Human-readable label describing the record contents; included in the BM25 index for Memory search
8605
+ * @returns Promise that resolves when the dump is complete
8606
+ *
8607
+ * @deprecated Better use Dump.dumpRecord with manual signalId argument
8608
+ *
8609
+ * @example
8610
+ * ```typescript
8611
+ * import { dumpRecord } from "backtest-kit";
8612
+ *
8613
+ * await dumpRecord({ bucketName: "my-strategy", dumpId: "context", record: { price: 42000, signal: "long" }, description: "Signal context at entry" });
8614
+ * ```
8615
+ */
8616
+ declare function dumpRecord(dto: {
8617
+ bucketName: string;
8618
+ dumpId: string;
8619
+ record: Record<string, unknown>;
8620
+ description: string;
8621
+ }): Promise<void>;
8622
+ /**
8623
+ * Dumps an array of objects as a table scoped to the current signal.
8624
+ *
8625
+ * Reads signalId from the active pending signal via execution and method context.
8626
+ * If no pending signal exists, logs a warning and returns without writing.
8627
+ *
8628
+ * Column headers are derived from the union of all keys across all rows.
8629
+ *
8630
+ * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
8631
+ * @param dto.dumpId - Unique identifier for this dump entry
8632
+ * @param dto.rows - Array of arbitrary objects to render as a table
8633
+ * @param dto.description - Human-readable label describing the table contents; included in the BM25 index for Memory search
8634
+ * @returns Promise that resolves when the dump is complete
8635
+ *
8636
+ * @deprecated Better use Dump.dumpTable with manual signalId argument
8637
+ *
8638
+ * @example
8639
+ * ```typescript
8640
+ * import { dumpTable } from "backtest-kit";
8641
+ *
8642
+ * await dumpTable({ bucketName: "my-strategy", dumpId: "candles", rows: [{ time: 1234, close: 42000 }], description: "Recent candle history" });
8643
+ * ```
8644
+ */
8645
+ declare function dumpTable(dto: {
8646
+ bucketName: string;
8647
+ dumpId: string;
8648
+ rows: Record<string, unknown>[];
8649
+ description: string;
8650
+ }): Promise<void>;
8651
+ /**
8652
+ * Dumps raw text content scoped to the current signal.
8653
+ *
8654
+ * Reads signalId from the active pending signal via execution and method context.
8655
+ * If no pending signal exists, logs a warning and returns without writing.
8656
+ *
8657
+ * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
8658
+ * @param dto.dumpId - Unique identifier for this dump entry
8659
+ * @param dto.content - Arbitrary text content to persist
8660
+ * @param dto.description - Human-readable label describing the content; included in the BM25 index for Memory search
8661
+ * @returns Promise that resolves when the dump is complete
8662
+ *
8663
+ * @deprecated Better use Dump.dumpText with manual signalId argument
8664
+ *
8665
+ * @example
8666
+ * ```typescript
8667
+ * import { dumpText } from "backtest-kit";
8668
+ *
8669
+ * await dumpText({ bucketName: "my-strategy", dumpId: "summary", content: "Agent concluded: bullish", description: "Agent final summary" });
8670
+ * ```
8671
+ */
8672
+ declare function dumpText(dto: {
8673
+ bucketName: string;
8674
+ dumpId: string;
8675
+ content: string;
8676
+ description: string;
8677
+ }): Promise<void>;
8678
+ /**
8679
+ * Dumps an error description scoped to the current signal.
8680
+ *
8681
+ * Reads signalId from the active pending signal via execution and method context.
8682
+ * If no pending signal exists, logs a warning and returns without writing.
8683
+ *
8684
+ * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
8685
+ * @param dto.dumpId - Unique identifier for this dump entry
8686
+ * @param dto.content - Error message or description to persist
8687
+ * @param dto.description - Human-readable label describing the error context; included in the BM25 index for Memory search
8688
+ * @returns Promise that resolves when the dump is complete
8689
+ *
8690
+ * @deprecated Better use Dump.dumpError with manual signalId argument
8691
+ *
8692
+ * @example
8693
+ * ```typescript
8694
+ * import { dumpError } from "backtest-kit";
8695
+ *
8696
+ * await dumpError({ bucketName: "my-strategy", dumpId: "error-1", content: "Tool call failed: timeout", description: "Tool execution error" });
8697
+ * ```
8698
+ */
8699
+ declare function dumpError(dto: {
8700
+ bucketName: string;
8701
+ dumpId: string;
8702
+ content: string;
8703
+ description: string;
8704
+ }): Promise<void>;
8405
8705
  /**
8406
- * Dumps chat history and result data to markdown files in a structured directory.
8706
+ * Dumps an arbitrary nested object as a fenced JSON block scoped to the current signal.
8407
8707
  *
8408
- * Creates a subfolder named after `resultId` inside `outputDir`.
8409
- * If the subfolder already exists, the function returns early without overwriting.
8410
- * Writes:
8411
- * - `00_system_prompt.md` — system messages and output data summary
8412
- * - `NN_user_message.md` — each user message as a separate file
8413
- * - `NN_llm_output.md` — final LLM output data
8708
+ * Reads signalId from the active pending signal via execution and method context.
8709
+ * If no pending signal exists, logs a warning and returns without writing.
8414
8710
  *
8415
- * Warns via logger if any user message exceeds 30 KB.
8711
+ * @param dto.bucketName - Bucket name grouping dumps by strategy or agent name
8712
+ * @param dto.dumpId - Unique identifier for this dump entry
8713
+ * @param dto.json - Arbitrary nested object to serialize with JSON.stringify
8714
+ * @param dto.description - Human-readable label describing the object contents; included in the BM25 index for Memory search
8715
+ * @returns Promise that resolves when the dump is complete
8416
8716
  *
8417
- * @param resultId - Unique identifier for the result (used as subfolder name)
8418
- * @param history - Full chat history containing system, user, and assistant messages
8419
- * @param result - Structured output data to include in the dump
8420
- * @param outputDir - Base directory for output files (default: `./dump/strategy`)
8421
- * @returns Promise that resolves when all files are written
8717
+ * @deprecated Prefer dumpRecord — flat key-value structure maps naturally to markdown tables and SQL storage
8422
8718
  *
8423
8719
  * @example
8424
8720
  * ```typescript
8425
- * import { dumpMessages } from "backtest-kit";
8721
+ * import { dumpJson } from "backtest-kit";
8426
8722
  *
8427
- * await dumpMessages("result-123", history, { profit: 42 });
8723
+ * await dumpJson({ bucketName: "my-strategy", dumpId: "signal-state", json: { entries: [], partials: [] }, description: "Signal state snapshot" });
8428
8724
  * ```
8429
8725
  */
8430
- declare function dumpMessages<Data extends object = any>(resultId: ResultId, history: Message[], result: Data, outputDir?: string): Promise<void>;
8726
+ declare function dumpJson(dto: {
8727
+ bucketName: string;
8728
+ dumpId: string;
8729
+ json: object;
8730
+ description: string;
8731
+ }): Promise<void>;
8431
8732
 
8432
8733
  /**
8433
8734
  * Portfolio heatmap statistics for a single symbol.
@@ -10346,6 +10647,7 @@ interface StrategyStatisticsModel {
10346
10647
  averageBuyCount: number;
10347
10648
  }
10348
10649
 
10650
+ /** Symbol key for the singleshot waitForInit function on PersistBase instances. */
10349
10651
  declare const BASE_WAIT_FOR_INIT_SYMBOL: unique symbol;
10350
10652
  /**
10351
10653
  * Signal data stored in persistence layer.
@@ -10355,7 +10657,10 @@ type SignalData = ISignalRow | null;
10355
10657
  /**
10356
10658
  * Cache.file data type stored in persistence layer.
10357
10659
  */
10358
- type MeasureData = unknown;
10660
+ type MeasureData = {
10661
+ id: string;
10662
+ data: unknown;
10663
+ };
10359
10664
  /**
10360
10665
  * Type helper for PersistBase instance.
10361
10666
  */
@@ -11051,7 +11356,7 @@ type StorageData = IStorageSignalRow[];
11051
11356
  */
11052
11357
  declare class PersistStorageUtils {
11053
11358
  private PersistStorageFactory;
11054
- private getStorageStorage;
11359
+ private getStorage;
11055
11360
  /**
11056
11361
  * Registers a custom persistence adapter.
11057
11362
  *
@@ -11246,7 +11551,7 @@ declare class PersistMeasureUtils {
11246
11551
  *
11247
11552
  * @param Ctor - Custom PersistBase constructor
11248
11553
  */
11249
- usePersistMeasureAdapter(Ctor: TPersistBaseCtor<string, unknown>): void;
11554
+ usePersistMeasureAdapter(Ctor: TPersistBaseCtor<string, MeasureData>): void;
11250
11555
  /**
11251
11556
  * Reads cached measure data for a given bucket and key.
11252
11557
  *
@@ -11278,8 +11583,144 @@ declare class PersistMeasureUtils {
11278
11583
  * Used by Cache.file for persistent caching of external API responses.
11279
11584
  */
11280
11585
  declare const PersistMeasureAdapter: PersistMeasureUtils;
11586
+ /**
11587
+ * Type for persisted memory entry data.
11588
+ * Each memory entry is an arbitrary JSON-serializable object.
11589
+ */
11590
+ type MemoryData = {
11591
+ priority: number;
11592
+ data: object;
11593
+ removed: boolean;
11594
+ index: string;
11595
+ };
11596
+ /**
11597
+ * Utility class for managing memory entry persistence.
11598
+ *
11599
+ * Features:
11600
+ * - Memoized storage instances per (signalId, bucketName) pair
11601
+ * - Custom adapter support
11602
+ * - Atomic read/write/remove operations
11603
+ * - Async iteration over stored keys for index rebuilding
11604
+ *
11605
+ * Storage layout: ./dump/memory/<signalId>/<bucketName>/<memoryId>.json
11606
+ *
11607
+ * Used by MemoryPersistInstance for crash-safe memory persistence.
11608
+ */
11609
+ declare class PersistMemoryUtils {
11610
+ private PersistMemoryFactory;
11611
+ private getMemoryStorage;
11612
+ /**
11613
+ * Registers a custom persistence adapter.
11614
+ *
11615
+ * @param Ctor - Custom PersistBase constructor
11616
+ *
11617
+ * @example
11618
+ * ```typescript
11619
+ * class RedisPersist extends PersistBase {
11620
+ * async readValue(id) { return JSON.parse(await redis.get(id)); }
11621
+ * async writeValue(id, entity) { await redis.set(id, JSON.stringify(entity)); }
11622
+ * }
11623
+ * PersistMemoryAdapter.usePersistMemoryAdapter(RedisPersist);
11624
+ * ```
11625
+ */
11626
+ usePersistMemoryAdapter(Ctor: TPersistBaseCtor<string, MemoryData>): void;
11627
+ /**
11628
+ * Initializes the storage for a given (signalId, bucketName) pair.
11629
+ *
11630
+ * @param signalId - Signal identifier (entity folder name)
11631
+ * @param bucketName - Bucket name (subfolder under memory/)
11632
+ * @param initial - Whether this is the first initialization
11633
+ * @returns Promise that resolves when initialization is complete
11634
+ */
11635
+ waitForInit: (signalId: string, bucketName: string, initial: boolean) => Promise<void>;
11636
+ /**
11637
+ * Reads a memory entry from persistence storage.
11638
+ *
11639
+ * @param signalId - Signal identifier
11640
+ * @param bucketName - Bucket name
11641
+ * @param memoryId - Memory entry identifier
11642
+ * @returns Promise resolving to entry data or null if not found
11643
+ */
11644
+ readMemoryData: (signalId: string, bucketName: string, memoryId: string) => Promise<MemoryData | null>;
11645
+ /**
11646
+ * Checks if a memory entry exists in persistence storage.
11647
+ *
11648
+ * @param signalId - Signal identifier
11649
+ * @param bucketName - Bucket name
11650
+ * @param memoryId - Memory entry identifier
11651
+ * @returns Promise resolving to true if entry exists
11652
+ */
11653
+ hasMemoryData: (signalId: string, bucketName: string, memoryId: string) => Promise<boolean>;
11654
+ /**
11655
+ * Writes a memory entry to disk with atomic file writes.
11656
+ *
11657
+ * @param data - Entry data to persist
11658
+ * @param signalId - Signal identifier
11659
+ * @param bucketName - Bucket name
11660
+ * @param memoryId - Memory entry identifier
11661
+ * @returns Promise that resolves when write is complete
11662
+ */
11663
+ writeMemoryData: (data: MemoryData, signalId: string, bucketName: string, memoryId: string) => Promise<void>;
11664
+ /**
11665
+ * Marks a memory entry as removed (soft delete — file is kept on disk).
11666
+ *
11667
+ * @param signalId - Signal identifier
11668
+ * @param bucketName - Bucket name
11669
+ * @param memoryId - Memory entry identifier
11670
+ * @returns Promise that resolves when removal is complete
11671
+ */
11672
+ removeMemoryData: (signalId: string, bucketName: string, memoryId: string) => Promise<void>;
11673
+ /**
11674
+ * Lists all memory entry IDs for a given (signalId, bucketName) pair.
11675
+ * Used by MemoryPersistInstance to rebuild the BM25 index on init.
11676
+ *
11677
+ * @param signalId - Signal identifier
11678
+ * @param bucketName - Bucket name
11679
+ * @returns AsyncGenerator yielding memory entry IDs
11680
+ */
11681
+ listMemoryData(signalId: string, bucketName: string): AsyncGenerator<{
11682
+ memoryId: string;
11683
+ data: MemoryData;
11684
+ }>;
11685
+ /**
11686
+ * Dispose persist adapter to prevent memory leak
11687
+ *
11688
+ * @param signalId - Signal identifier
11689
+ * @param bucketName - Bucket name
11690
+ */
11691
+ clear: (signalId: string, bucketName: string) => void;
11692
+ /**
11693
+ * Switches to the default JSON persist adapter.
11694
+ * All future persistence writes will use JSON storage.
11695
+ */
11696
+ useJson(): void;
11697
+ /**
11698
+ * Switches to a dummy persist adapter that discards all writes.
11699
+ * All future persistence writes will be no-ops.
11700
+ */
11701
+ useDummy(): void;
11702
+ }
11703
+ /**
11704
+ * Global singleton instance of PersistMemoryUtils.
11705
+ * Used by MemoryPersistInstance for crash-safe memory entry persistence.
11706
+ *
11707
+ * @example
11708
+ * ```typescript
11709
+ * // Custom adapter
11710
+ * PersistMemoryAdapter.usePersistMemoryAdapter(RedisPersist);
11711
+ *
11712
+ * // Write entry
11713
+ * await PersistMemoryAdapter.writeMemoryData({ foo: "bar" }, "sig-1", "strategy", "context");
11714
+ *
11715
+ * // Read entry
11716
+ * const data = await PersistMemoryAdapter.readMemoryData("sig-1", "strategy", "context");
11717
+ * ```
11718
+ */
11719
+ declare const PersistMemoryAdapter: PersistMemoryUtils;
11281
11720
 
11721
+ /** Symbol key for the singleshot waitForInit function on ReportBase instances. */
11282
11722
  declare const WAIT_FOR_INIT_SYMBOL$1: unique symbol;
11723
+ /** Symbol key for the timeout-protected write function on ReportBase instances. */
11283
11724
  declare const WRITE_SAFE_SYMBOL$1: unique symbol;
11284
11725
  /**
11285
11726
  * Configuration interface for selective report service enablement.
@@ -11593,7 +12034,9 @@ interface IMarkdownTarget {
11593
12034
  /** Enable highest profit milestone tracking reports */
11594
12035
  highest_profit: boolean;
11595
12036
  }
12037
+ /** Symbol key for the singleshot waitForInit function on MarkdownFileBase instances. */
11596
12038
  declare const WAIT_FOR_INIT_SYMBOL: unique symbol;
12039
+ /** Symbol key for the timeout-protected write function on MarkdownFileBase instances. */
11597
12040
  declare const WRITE_SAFE_SYMBOL: unique symbol;
11598
12041
  /**
11599
12042
  * Union type of all valid markdown report names.
@@ -12236,7 +12679,7 @@ declare class BacktestUtils {
12236
12679
  strategyName: StrategyName;
12237
12680
  exchangeName: ExchangeName;
12238
12681
  frameName: FrameName;
12239
- }) => AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
12682
+ }) => AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, any>;
12240
12683
  /**
12241
12684
  * Runs backtest in background without yielding results.
12242
12685
  *
@@ -12283,7 +12726,7 @@ declare class BacktestUtils {
12283
12726
  strategyName: StrategyName;
12284
12727
  exchangeName: ExchangeName;
12285
12728
  frameName: FrameName;
12286
- }) => Promise<IPublicSignalRow>;
12729
+ }) => Promise<IPublicSignalRow | null>;
12287
12730
  /**
12288
12731
  * Returns the percentage of the position currently held (not closed).
12289
12732
  * 100 = nothing has been closed (full position), 0 = fully closed.
@@ -13579,7 +14022,7 @@ declare class LiveUtils {
13579
14022
  getPendingSignal: (symbol: string, currentPrice: number, context: {
13580
14023
  strategyName: StrategyName;
13581
14024
  exchangeName: ExchangeName;
13582
- }) => Promise<IPublicSignalRow>;
14025
+ }) => Promise<IPublicSignalRow | null>;
13583
14026
  /**
13584
14027
  * Returns the percentage of the position currently held (not closed).
13585
14028
  * 100 = nothing has been closed (full position), 0 = fully closed.
@@ -15592,21 +16035,31 @@ declare class HeatMarkdownService {
15592
16035
  */
15593
16036
  unsubscribe: () => Promise<void>;
15594
16037
  /**
15595
- * Processes tick events and accumulates closed signals.
15596
- * Should be called from signal emitter subscription.
16038
+ * Handles a single tick event emitted by `signalEmitter`.
15597
16039
  *
15598
- * Only processes closed signals - opened signals are ignored.
16040
+ * Filters out every action except `"closed"` idle, scheduled, waiting,
16041
+ * opened, active, and cancelled ticks are silently ignored.
16042
+ * For closed signals, routes the payload to the appropriate `HeatmapStorage`
16043
+ * via `getStorage(exchangeName, frameName, backtest)` and calls `addSignal`.
15599
16044
  *
15600
- * @param data - Tick result from strategy execution (closed signals only)
16045
+ * @param data - Union tick result from `signalEmitter`; only
16046
+ * `IStrategyTickResultClosed` payloads are processed
15601
16047
  */
15602
16048
  private tick;
15603
16049
  /**
15604
- * Gets aggregated portfolio heatmap statistics.
16050
+ * Returns aggregated portfolio heatmap statistics for the given context.
15605
16051
  *
15606
- * @param exchangeName - Exchange name
15607
- * @param frameName - Frame name
15608
- * @param backtest - True if backtest mode, false if live mode
15609
- * @returns Promise resolving to heatmap statistics with per-symbol and portfolio-wide metrics
16052
+ * Delegates to the `HeatmapStorage` instance identified by
16053
+ * `(exchangeName, frameName, backtest)`. If no signals have been accumulated
16054
+ * yet for that combination, the returned `symbols` array will be empty and
16055
+ * portfolio-level fields will be `null` / `0`.
16056
+ *
16057
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
16058
+ * @param frameName - Backtest frame identifier (e.g. `"1m-btc"`)
16059
+ * @param backtest - `true` for backtest mode, `false` for live mode
16060
+ * @returns Promise resolving to `HeatmapStatisticsModel` with per-symbol rows
16061
+ * sorted by `sharpeRatio` descending and portfolio-wide aggregates
16062
+ * @throws {Error} If `subscribe()` has not been called before this method
15610
16063
  *
15611
16064
  * @example
15612
16065
  * ```typescript
@@ -15623,73 +16076,86 @@ declare class HeatMarkdownService {
15623
16076
  */
15624
16077
  getData: (exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<HeatmapStatisticsModel>;
15625
16078
  /**
15626
- * Generates markdown report with portfolio heatmap table.
16079
+ * Generates a markdown heatmap report for the given context.
15627
16080
  *
15628
- * @param strategyName - Strategy name for report title
15629
- * @param exchangeName - Exchange name
15630
- * @param frameName - Frame name
15631
- * @param backtest - True if backtest mode, false if live mode
15632
- * @param columns - Column configuration for formatting the table
15633
- * @returns Promise resolving to markdown formatted report string
16081
+ * Delegates to `HeatmapStorage.getReport`. The resulting string includes a
16082
+ * portfolio summary line followed by a markdown table with one row per
16083
+ * symbol, ordered by `sharpeRatio` descending.
16084
+ *
16085
+ * @param strategyName - Strategy name rendered in the report heading
16086
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
16087
+ * @param frameName - Backtest frame identifier (e.g. `"1m-btc"`)
16088
+ * @param backtest - `true` for backtest mode, `false` for live mode
16089
+ * @param columns - Column definitions controlling the table layout;
16090
+ * defaults to `COLUMN_CONFIG.heat_columns`
16091
+ * @returns Promise resolving to the full markdown string
16092
+ * @throws {Error} If `subscribe()` has not been called before this method
15634
16093
  *
15635
16094
  * @example
15636
16095
  * ```typescript
15637
16096
  * const service = new HeatMarkdownService();
15638
16097
  * const markdown = await service.getReport("my-strategy", "binance", "frame1", true);
15639
16098
  * console.log(markdown);
15640
- * // Output:
15641
16099
  * // # Portfolio Heatmap: my-strategy
15642
16100
  * //
15643
16101
  * // **Total Symbols:** 5 | **Portfolio PNL:** +45.3% | **Portfolio Sharpe:** 1.85 | **Total Trades:** 120
15644
16102
  * //
15645
16103
  * // | Symbol | Total PNL | Sharpe | Max DD | Trades |
15646
- * // |--------|-----------|--------|--------|--------|
15647
- * // | BTCUSDT | +15.5% | 2.10 | -2.5% | 45 |
15648
- * // | ETHUSDT | +12.3% | 1.85 | -3.1% | 38 |
15649
- * // ...
16104
+ * // | --- | --- | --- | --- | --- |
16105
+ * // | BTCUSDT | +15.5% | 2.10 | -2.5% | 45 |
16106
+ * // | ETHUSDT | +12.3% | 1.85 | -3.1% | 38 |
15650
16107
  * ```
15651
16108
  */
15652
16109
  getReport: (strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean, columns?: Columns$6[]) => Promise<string>;
15653
16110
  /**
15654
- * Saves heatmap report to disk.
16111
+ * Generates the heatmap report and writes it to disk.
15655
16112
  *
15656
- * Creates directory if it doesn't exist.
15657
- * Default filename: {strategyName}.md
16113
+ * Delegates to `HeatmapStorage.dump`. The filename follows the pattern:
16114
+ * - Backtest: `{strategyName}_{exchangeName}_{frameName}_backtest-{timestamp}.md`
16115
+ * - Live: `{strategyName}_{exchangeName}_live-{timestamp}.md`
15658
16116
  *
15659
- * @param strategyName - Strategy name for report filename
15660
- * @param exchangeName - Exchange name
15661
- * @param frameName - Frame name
15662
- * @param backtest - True if backtest mode, false if live mode
15663
- * @param path - Optional directory path to save report (default: "./dump/heatmap")
15664
- * @param columns - Column configuration for formatting the table
16117
+ * @param strategyName - Strategy name used in the report heading and filename
16118
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
16119
+ * @param frameName - Backtest frame identifier (e.g. `"1m-btc"`)
16120
+ * @param backtest - `true` for backtest mode, `false` for live mode
16121
+ * @param path - Directory to write the file into; defaults to `"./dump/heatmap"`
16122
+ * @param columns - Column definitions for table formatting;
16123
+ * defaults to `COLUMN_CONFIG.heat_columns`
16124
+ * @throws {Error} If `subscribe()` has not been called before this method
15665
16125
  *
15666
16126
  * @example
15667
16127
  * ```typescript
15668
16128
  * const service = new HeatMarkdownService();
15669
16129
  *
15670
- * // Save to default path: ./dump/heatmap/my-strategy.md
16130
+ * // Save to default path
15671
16131
  * await service.dump("my-strategy", "binance", "frame1", true);
15672
16132
  *
15673
- * // Save to custom path: ./reports/my-strategy.md
16133
+ * // Save to custom path
15674
16134
  * await service.dump("my-strategy", "binance", "frame1", true, "./reports");
15675
16135
  * ```
15676
16136
  */
15677
16137
  dump: (strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean, path?: string, columns?: Columns$6[]) => Promise<void>;
15678
16138
  /**
15679
- * Clears accumulated heatmap data from storage.
15680
- * If payload is provided, clears only that exchangeName+frameName+backtest combination's data.
15681
- * If payload is omitted, clears all data.
16139
+ * Evicts memoized `HeatmapStorage` instances, releasing all accumulated signal data.
16140
+ *
16141
+ * - With `payload` clears only the storage bucket identified by
16142
+ * `(payload.exchangeName, payload.frameName, payload.backtest)`;
16143
+ * subsequent calls to `getData` / `getReport` / `dump` for that combination
16144
+ * will start from an empty state.
16145
+ * - Without `payload` — clears **all** storage buckets across every
16146
+ * exchange / frame / mode combination.
15682
16147
  *
15683
- * @param payload - Optional payload with exchangeName, frameName, backtest to clear specific data
16148
+ * Also called internally by the unsubscribe closure returned from `subscribe()`.
16149
+ *
16150
+ * @param payload - Optional scope to restrict which bucket is cleared;
16151
+ * omit to clear everything
15684
16152
  *
15685
16153
  * @example
15686
16154
  * ```typescript
15687
- * const service = new HeatMarkdownService();
15688
- *
15689
- * // Clear specific exchange+frame+backtest data
16155
+ * // Clear one specific context
15690
16156
  * await service.clear({ exchangeName: "binance", frameName: "frame1", backtest: true });
15691
16157
  *
15692
- * // Clear all data
16158
+ * // Clear all contexts
15693
16159
  * await service.clear();
15694
16160
  * ```
15695
16161
  */
@@ -16343,12 +16809,129 @@ type Columns$4 = ColumnModel<HighestProfitEvent>;
16343
16809
  declare class HighestProfitMarkdownService {
16344
16810
  private readonly loggerService;
16345
16811
  private getStorage;
16812
+ /**
16813
+ * Subscribes to `highestProfitSubject` to start receiving `HighestProfitContract`
16814
+ * events. Protected against multiple subscriptions via `singleshot` — subsequent
16815
+ * calls return the same unsubscribe function without re-subscribing.
16816
+ *
16817
+ * The returned unsubscribe function clears the `singleshot` state, evicts all
16818
+ * memoized `ReportStorage` instances, and detaches from `highestProfitSubject`.
16819
+ *
16820
+ * @returns Unsubscribe function; calling it tears down the subscription and
16821
+ * clears all accumulated data
16822
+ *
16823
+ * @example
16824
+ * ```typescript
16825
+ * const service = new HighestProfitMarkdownService();
16826
+ * const unsubscribe = service.subscribe();
16827
+ * // ... later
16828
+ * unsubscribe();
16829
+ * ```
16830
+ */
16346
16831
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
16347
- unsubscribe: () => Promise<void>;
16348
- private tick;
16349
- getData: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<HighestProfitStatisticsModel>;
16832
+ /**
16833
+ * Detaches from `highestProfitSubject` and clears all accumulated data.
16834
+ *
16835
+ * Calls the unsubscribe closure returned by `subscribe()`.
16836
+ * If `subscribe()` was never called, does nothing.
16837
+ *
16838
+ * @example
16839
+ * ```typescript
16840
+ * const service = new HighestProfitMarkdownService();
16841
+ * service.subscribe();
16842
+ * // ... later
16843
+ * await service.unsubscribe();
16844
+ * ```
16845
+ */
16846
+ unsubscribe: () => Promise<void>;
16847
+ /**
16848
+ * Handles a single `HighestProfitContract` event emitted by `highestProfitSubject`.
16849
+ *
16850
+ * Routes the payload to the appropriate `ReportStorage` bucket via
16851
+ * `getStorage(symbol, strategyName, exchangeName, frameName, backtest)` —
16852
+ * where `strategyName` is taken from `data.signal.strategyName` — and
16853
+ * delegates event construction to `ReportStorage.addEvent`.
16854
+ *
16855
+ * @param data - `HighestProfitContract` payload containing `symbol`,
16856
+ * `signal`, `currentPrice`, `backtest`, `timestamp`, `exchangeName`,
16857
+ * `frameName`
16858
+ */
16859
+ private tick;
16860
+ /**
16861
+ * Returns accumulated highest profit statistics for the given context.
16862
+ *
16863
+ * Delegates to the `ReportStorage` bucket identified by
16864
+ * `(symbol, strategyName, exchangeName, frameName, backtest)`.
16865
+ * If no events have been recorded yet for that combination, the returned
16866
+ * model has an empty `eventList` and `totalEvents` of `0`.
16867
+ *
16868
+ * @param symbol - Trading pair symbol (e.g. `"BTCUSDT"`)
16869
+ * @param strategyName - Strategy identifier
16870
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
16871
+ * @param frameName - Backtest frame identifier; empty string for live mode
16872
+ * @param backtest - `true` for backtest mode, `false` for live mode
16873
+ * @returns Promise resolving to `HighestProfitStatisticsModel` with
16874
+ * `eventList` (newest first) and `totalEvents`
16875
+ * @throws {Error} If `subscribe()` has not been called before this method
16876
+ */
16877
+ getData: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<HighestProfitStatisticsModel>;
16878
+ /**
16879
+ * Generates a markdown highest profit report for the given context.
16880
+ *
16881
+ * Delegates to `ReportStorage.getReport`. The resulting string includes a
16882
+ * markdown table (newest events first) followed by the total event count.
16883
+ *
16884
+ * @param symbol - Trading pair symbol (e.g. `"BTCUSDT"`)
16885
+ * @param strategyName - Strategy identifier
16886
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
16887
+ * @param frameName - Backtest frame identifier; empty string for live mode
16888
+ * @param backtest - `true` for backtest mode, `false` for live mode
16889
+ * @param columns - Column definitions controlling the table layout;
16890
+ * defaults to `COLUMN_CONFIG.highest_profit_columns`
16891
+ * @returns Promise resolving to the full markdown string
16892
+ * @throws {Error} If `subscribe()` has not been called before this method
16893
+ */
16350
16894
  getReport: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean, columns?: Columns$4[]) => Promise<string>;
16895
+ /**
16896
+ * Generates the highest profit report and writes it to disk.
16897
+ *
16898
+ * Delegates to `ReportStorage.dump`. The filename follows the pattern:
16899
+ * - Backtest: `{symbol}_{strategyName}_{exchangeName}_{frameName}_backtest-{timestamp}.md`
16900
+ * - Live: `{symbol}_{strategyName}_{exchangeName}_live-{timestamp}.md`
16901
+ *
16902
+ * @param symbol - Trading pair symbol (e.g. `"BTCUSDT"`)
16903
+ * @param strategyName - Strategy identifier
16904
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
16905
+ * @param frameName - Backtest frame identifier; empty string for live mode
16906
+ * @param backtest - `true` for backtest mode, `false` for live mode
16907
+ * @param path - Directory to write the file into; defaults to `"./dump/highest_profit"`
16908
+ * @param columns - Column definitions for table formatting;
16909
+ * defaults to `COLUMN_CONFIG.highest_profit_columns`
16910
+ * @throws {Error} If `subscribe()` has not been called before this method
16911
+ */
16351
16912
  dump: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean, path?: string, columns?: Columns$4[]) => Promise<void>;
16913
+ /**
16914
+ * Evicts memoized `ReportStorage` instances, releasing all accumulated event data.
16915
+ *
16916
+ * - With `payload` — clears only the storage bucket identified by
16917
+ * `(symbol, strategyName, exchangeName, frameName, backtest)`;
16918
+ * subsequent calls for that combination start from an empty state.
16919
+ * - Without `payload` — clears **all** storage buckets.
16920
+ *
16921
+ * Also called internally by the unsubscribe closure returned from `subscribe()`.
16922
+ *
16923
+ * @param payload - Optional scope to restrict which bucket is cleared;
16924
+ * omit to clear everything
16925
+ *
16926
+ * @example
16927
+ * ```typescript
16928
+ * // Clear one specific context
16929
+ * await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy", exchangeName: "binance", frameName: "1m-btc", backtest: true });
16930
+ *
16931
+ * // Clear all contexts
16932
+ * await service.clear();
16933
+ * ```
16934
+ */
16352
16935
  clear: (payload?: {
16353
16936
  symbol: string;
16354
16937
  strategyName: StrategyName;
@@ -16968,12 +17551,133 @@ type Columns$2 = ColumnModel<SyncEvent>;
16968
17551
  declare class SyncMarkdownService {
16969
17552
  private readonly loggerService;
16970
17553
  private getStorage;
17554
+ /**
17555
+ * Subscribes to `syncSubject` to start receiving `SignalSyncContract` events.
17556
+ * Protected against multiple subscriptions via `singleshot` — subsequent calls
17557
+ * return the same unsubscribe function without re-subscribing.
17558
+ *
17559
+ * The returned unsubscribe function clears the `singleshot` state, evicts all
17560
+ * memoized `ReportStorage` instances, and detaches from `syncSubject`.
17561
+ *
17562
+ * @returns Unsubscribe function; calling it tears down the subscription and
17563
+ * clears all accumulated data
17564
+ *
17565
+ * @example
17566
+ * ```typescript
17567
+ * const service = new SyncMarkdownService();
17568
+ * const unsubscribe = service.subscribe();
17569
+ * // ... later
17570
+ * unsubscribe();
17571
+ * ```
17572
+ */
16971
17573
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
17574
+ /**
17575
+ * Detaches from `syncSubject` and clears all accumulated data.
17576
+ *
17577
+ * Calls the unsubscribe closure returned by `subscribe()`.
17578
+ * If `subscribe()` was never called, does nothing.
17579
+ *
17580
+ * @example
17581
+ * ```typescript
17582
+ * const service = new SyncMarkdownService();
17583
+ * service.subscribe();
17584
+ * // ... later
17585
+ * await service.unsubscribe();
17586
+ * ```
17587
+ */
16972
17588
  unsubscribe: () => Promise<void>;
17589
+ /**
17590
+ * Handles a single `SignalSyncContract` event emitted by `syncSubject`.
17591
+ *
17592
+ * Maps the contract fields to a `SyncEvent`, enriching it with a
17593
+ * `createdAt` ISO timestamp from `getContextTimestamp()` (backtest clock
17594
+ * or real clock aligned to the nearest minute).
17595
+ * For `"signal-close"` events, `closeReason` is preserved; for
17596
+ * `"signal-open"` events it is set to `undefined`.
17597
+ *
17598
+ * Routes the constructed event to the appropriate `ReportStorage` bucket
17599
+ * via `getStorage(symbol, strategyName, exchangeName, frameName, backtest)`.
17600
+ *
17601
+ * @param data - Discriminated union `SignalSyncContract`
17602
+ * (`SignalOpenContract | SignalCloseContract`)
17603
+ */
16973
17604
  private tick;
17605
+ /**
17606
+ * Returns accumulated sync statistics for the given context.
17607
+ *
17608
+ * Delegates to the `ReportStorage` bucket identified by
17609
+ * `(symbol, strategyName, exchangeName, frameName, backtest)`.
17610
+ * If no events have been recorded yet for that combination, the returned
17611
+ * model has an empty `eventList` and all counters set to `0`.
17612
+ *
17613
+ * @param symbol - Trading pair symbol (e.g. `"BTCUSDT"`)
17614
+ * @param strategyName - Strategy identifier
17615
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
17616
+ * @param frameName - Backtest frame identifier; empty string for live mode
17617
+ * @param backtest - `true` for backtest mode, `false` for live mode
17618
+ * @returns Promise resolving to `SyncStatisticsModel` with `eventList`,
17619
+ * `totalEvents`, `openCount`, `closeCount`
17620
+ * @throws {Error} If `subscribe()` has not been called before this method
17621
+ */
16974
17622
  getData: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<SyncStatisticsModel>;
17623
+ /**
17624
+ * Generates a markdown sync report for the given context.
17625
+ *
17626
+ * Delegates to `ReportStorage.getReport`. The resulting string includes a
17627
+ * markdown table (newest events first) followed by total / open / close
17628
+ * counters.
17629
+ *
17630
+ * @param symbol - Trading pair symbol (e.g. `"BTCUSDT"`)
17631
+ * @param strategyName - Strategy identifier
17632
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
17633
+ * @param frameName - Backtest frame identifier; empty string for live mode
17634
+ * @param backtest - `true` for backtest mode, `false` for live mode
17635
+ * @param columns - Column definitions controlling the table layout;
17636
+ * defaults to `COLUMN_CONFIG.sync_columns`
17637
+ * @returns Promise resolving to the full markdown string
17638
+ * @throws {Error} If `subscribe()` has not been called before this method
17639
+ */
16975
17640
  getReport: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean, columns?: Columns$2[]) => Promise<string>;
17641
+ /**
17642
+ * Generates the sync report and writes it to disk.
17643
+ *
17644
+ * Delegates to `ReportStorage.dump`. The filename follows the pattern:
17645
+ * - Backtest: `{symbol}_{strategyName}_{exchangeName}_{frameName}_backtest-{timestamp}.md`
17646
+ * - Live: `{symbol}_{strategyName}_{exchangeName}_live-{timestamp}.md`
17647
+ *
17648
+ * @param symbol - Trading pair symbol (e.g. `"BTCUSDT"`)
17649
+ * @param strategyName - Strategy identifier
17650
+ * @param exchangeName - Exchange identifier (e.g. `"binance"`)
17651
+ * @param frameName - Backtest frame identifier; empty string for live mode
17652
+ * @param backtest - `true` for backtest mode, `false` for live mode
17653
+ * @param path - Directory to write the file into; defaults to `"./dump/sync"`
17654
+ * @param columns - Column definitions for table formatting;
17655
+ * defaults to `COLUMN_CONFIG.sync_columns`
17656
+ * @throws {Error} If `subscribe()` has not been called before this method
17657
+ */
16976
17658
  dump: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean, path?: string, columns?: Columns$2[]) => Promise<void>;
17659
+ /**
17660
+ * Evicts memoized `ReportStorage` instances, releasing all accumulated event data.
17661
+ *
17662
+ * - With `payload` — clears only the storage bucket identified by
17663
+ * `(symbol, strategyName, exchangeName, frameName, backtest)`;
17664
+ * subsequent calls for that combination start from an empty state.
17665
+ * - Without `payload` — clears **all** storage buckets.
17666
+ *
17667
+ * Also called internally by the unsubscribe closure returned from `subscribe()`.
17668
+ *
17669
+ * @param payload - Optional scope to restrict which bucket is cleared;
17670
+ * omit to clear everything
17671
+ *
17672
+ * @example
17673
+ * ```typescript
17674
+ * // Clear one specific context
17675
+ * await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy", exchangeName: "binance", frameName: "1m-btc", backtest: true });
17676
+ *
17677
+ * // Clear all contexts
17678
+ * await service.clear();
17679
+ * ```
17680
+ */
16977
17681
  clear: (payload?: {
16978
17682
  symbol: string;
16979
17683
  strategyName: StrategyName;
@@ -17153,6 +17857,18 @@ interface IStorageUtils {
17153
17857
  * @returns Array of all signal rows
17154
17858
  */
17155
17859
  list(): Promise<IStorageSignalRow[]>;
17860
+ /**
17861
+ * Handles active ping event for opened signals.
17862
+ * Updates updatedAt for the signal if it is currently opened.
17863
+ * @param event - The active ping event data
17864
+ */
17865
+ handleActivePing(event: ActivePingContract): Promise<void>;
17866
+ /**
17867
+ * Handles schedule ping event for scheduled signals.
17868
+ * Updates updatedAt for the signal if it is currently scheduled.
17869
+ * @param event - The schedule ping event data
17870
+ */
17871
+ handleSchedulePing(event: SchedulePingContract): Promise<void>;
17156
17872
  }
17157
17873
  /**
17158
17874
  * Constructor type for storage adapters.
@@ -17208,6 +17924,8 @@ declare class StorageBacktestAdapter implements IStorageUtils {
17208
17924
  * @returns Array of all signal rows
17209
17925
  */
17210
17926
  list: () => Promise<IStorageSignalRow[]>;
17927
+ handleActivePing: (event: ActivePingContract) => Promise<void>;
17928
+ handleSchedulePing: (event: SchedulePingContract) => Promise<void>;
17211
17929
  /**
17212
17930
  * Sets the storage adapter constructor.
17213
17931
  * All future storage operations will use this adapter.
@@ -17280,6 +17998,8 @@ declare class StorageLiveAdapter implements IStorageUtils {
17280
17998
  * @returns Array of all signal rows
17281
17999
  */
17282
18000
  list: () => Promise<IStorageSignalRow[]>;
18001
+ handleActivePing: (event: ActivePingContract) => Promise<void>;
18002
+ handleSchedulePing: (event: SchedulePingContract) => Promise<void>;
17283
18003
  /**
17284
18004
  * Sets the storage adapter constructor.
17285
18005
  * All future storage operations will use this adapter.
@@ -17699,6 +18419,370 @@ declare const NotificationLive: NotificationLiveAdapter;
17699
18419
  */
17700
18420
  declare const NotificationBacktest: NotificationBacktestAdapter;
17701
18421
 
18422
+ /**
18423
+ * Tuning parameters for BM25 full-text search scoring.
18424
+ * Controls term frequency saturation, document length normalization, and minimum score threshold.
18425
+ */
18426
+ type SearchSettings = {
18427
+ /**
18428
+ * Term frequency saturation parameter.
18429
+ * Higher values give more weight to repeated terms; lower values saturate faster.
18430
+ * Typical range: 1.2–2.0. Default: 1.5.
18431
+ */
18432
+ BM25_K1: number;
18433
+ /**
18434
+ * Document length normalization factor.
18435
+ * 0 = no normalization, 1 = full normalization by average document length.
18436
+ * Default: 0.75.
18437
+ */
18438
+ BM25_B: number;
18439
+ /**
18440
+ * Minimum BM25 score threshold for a result to be included in the output.
18441
+ * Results with score below this value are filtered out.
18442
+ * Default: 0.5.
18443
+ */
18444
+ BM25_SCORE: number;
18445
+ };
18446
+
18447
+ /**
18448
+ * Interface for memory instance implementations.
18449
+ * Defines the contract for local, persist, and dummy backends.
18450
+ */
18451
+ interface IMemoryInstance {
18452
+ /**
18453
+ * Initialize the memory instance.
18454
+ * @param initial - Whether this is the first initialization
18455
+ */
18456
+ waitForInit(initial: boolean): Promise<void>;
18457
+ /**
18458
+ * Write a value to memory.
18459
+ * @param memoryId - Unique entry identifier
18460
+ * @param value - Value to store
18461
+ * @param index - Optional BM25 index string; defaults to JSON.stringify(value)
18462
+ */
18463
+ writeMemory<T extends object = object>(memoryId: string, value: T, index?: string): Promise<void>;
18464
+ /**
18465
+ * Search memory using BM25 full-text scoring.
18466
+ * @param query - Search query string
18467
+ * @returns Array of matching entries with scores
18468
+ */
18469
+ searchMemory<T extends object = object>(query: string, settings?: SearchSettings): Promise<Array<{
18470
+ memoryId: string;
18471
+ score: number;
18472
+ content: T;
18473
+ }>>;
18474
+ /**
18475
+ * List all entries in memory.
18476
+ * @returns Array of all stored entries
18477
+ */
18478
+ listMemory<T extends object = object>(): Promise<Array<{
18479
+ memoryId: string;
18480
+ content: T;
18481
+ }>>;
18482
+ /**
18483
+ * Remove an entry from memory.
18484
+ * @param memoryId - Unique entry identifier
18485
+ */
18486
+ removeMemory(memoryId: string): Promise<void>;
18487
+ /**
18488
+ * Read a single entry from memory.
18489
+ * @param memoryId - Unique entry identifier
18490
+ * @returns Entry value
18491
+ * @throws Error if entry not found
18492
+ */
18493
+ readMemory<T extends object = object>(memoryId: string): Promise<T>;
18494
+ /**
18495
+ * Releases any resources held by this instance.
18496
+ */
18497
+ dispose(): void;
18498
+ }
18499
+ /**
18500
+ * Constructor type for memory instance implementations.
18501
+ * Used for swapping backends via MemoryAdapter.
18502
+ */
18503
+ type TMemoryInstanceCtor = new (signalId: string, bucketName: string) => IMemoryInstance;
18504
+ /**
18505
+ * Public surface of MemoryAdapter - IMemoryInstance minus waitForInit.
18506
+ * waitForInit is managed internally by the adapter.
18507
+ */
18508
+ type TMemoryInstance = Omit<{
18509
+ [key in keyof IMemoryInstance]: any;
18510
+ }, keyof {
18511
+ waitForInit: never;
18512
+ }>;
18513
+ /**
18514
+ * Facade for memory instances scoped per (signalId, bucketName).
18515
+ * Manages lazy initialization and instance lifecycle.
18516
+ *
18517
+ * Features:
18518
+ * - Memoized instances per (signalId, bucketName) pair
18519
+ * - Swappable backend via useLocal(), usePersist(), useDummy()
18520
+ * - Default backend: MemoryPersistInstance (in-memory BM25 + persist storage)
18521
+ */
18522
+ declare class MemoryAdapter implements TMemoryInstance {
18523
+ private MemoryFactory;
18524
+ private getInstance;
18525
+ /**
18526
+ * Activates the adapter by subscribing to signal lifecycle events.
18527
+ * Clears memoized instances for a signalId when it is cancelled or closed,
18528
+ * preventing stale instances from accumulating in memory.
18529
+ * Idempotent — subsequent calls return the same subscription handle.
18530
+ * Must be called before any memory method is used.
18531
+ */
18532
+ enable: (() => (...args: any[]) => any) & functools_kit.ISingleshotClearable;
18533
+ /**
18534
+ * Deactivates the adapter by unsubscribing from signal lifecycle events.
18535
+ * No-op if enable() was never called.
18536
+ */
18537
+ disable: () => void;
18538
+ /**
18539
+ * Write a value to memory.
18540
+ * @param dto.memoryId - Unique entry identifier
18541
+ * @param dto.value - Value to store
18542
+ * @param dto.signalId - Signal identifier
18543
+ * @param dto.bucketName - Bucket name
18544
+ * @param dto.index - Optional BM25 index string; defaults to JSON.stringify(value)
18545
+ */
18546
+ writeMemory: <T extends object = object>(dto: {
18547
+ memoryId: string;
18548
+ value: T;
18549
+ signalId: string;
18550
+ bucketName: string;
18551
+ index?: string;
18552
+ }) => Promise<void>;
18553
+ /**
18554
+ * Search memory using BM25 full-text scoring.
18555
+ * @param dto.query - Search query string
18556
+ * @param dto.signalId - Signal identifier
18557
+ * @param dto.bucketName - Bucket name
18558
+ * @returns Matching entries sorted by relevance score
18559
+ */
18560
+ searchMemory: <T extends object = object>(dto: {
18561
+ query: string;
18562
+ signalId: string;
18563
+ bucketName: string;
18564
+ settings?: SearchSettings;
18565
+ }) => Promise<{
18566
+ memoryId: string;
18567
+ score: number;
18568
+ content: T;
18569
+ }[]>;
18570
+ /**
18571
+ * List all entries in memory.
18572
+ * @param dto.signalId - Signal identifier
18573
+ * @param dto.bucketName - Bucket name
18574
+ * @returns Array of all stored entries
18575
+ */
18576
+ listMemory: <T extends object = object>(dto: {
18577
+ signalId: string;
18578
+ bucketName: string;
18579
+ }) => Promise<{
18580
+ memoryId: string;
18581
+ content: T;
18582
+ }[]>;
18583
+ /**
18584
+ * Remove an entry from memory.
18585
+ * @param dto.memoryId - Unique entry identifier
18586
+ * @param dto.signalId - Signal identifier
18587
+ * @param dto.bucketName - Bucket name
18588
+ */
18589
+ removeMemory: (dto: {
18590
+ memoryId: string;
18591
+ signalId: string;
18592
+ bucketName: string;
18593
+ }) => Promise<void>;
18594
+ /**
18595
+ * Read a single entry from memory.
18596
+ * @param dto.memoryId - Unique entry identifier
18597
+ * @param dto.signalId - Signal identifier
18598
+ * @param dto.bucketName - Bucket name
18599
+ * @returns Entry value
18600
+ * @throws Error if entry not found
18601
+ */
18602
+ readMemory: <T extends object = object>(dto: {
18603
+ memoryId: string;
18604
+ signalId: string;
18605
+ bucketName: string;
18606
+ }) => Promise<T>;
18607
+ /**
18608
+ * Switches to in-memory BM25 adapter (default).
18609
+ * All data lives in process memory only.
18610
+ */
18611
+ useLocal: () => void;
18612
+ /**
18613
+ * Switches to file-system backed adapter.
18614
+ * Data is persisted to ./dump/memory/<signalId>/<bucketName>/.
18615
+ */
18616
+ usePersist: () => void;
18617
+ /**
18618
+ * Switches to dummy adapter that discards all writes.
18619
+ */
18620
+ useDummy: () => void;
18621
+ /**
18622
+ * Releases resources held by this adapter.
18623
+ * Delegates to disable() to unsubscribe from signal lifecycle events.
18624
+ */
18625
+ dispose: () => void;
18626
+ }
18627
+ declare const Memory: MemoryAdapter;
18628
+
18629
+ /**
18630
+ * Context required to identify a dump entry.
18631
+ * Passed only through DumpAdapter - instances receive signalId and bucketName via constructor.
18632
+ */
18633
+ interface IDumpContext {
18634
+ /** Signal identifier - scopes the dump to a specific trade */
18635
+ signalId: string;
18636
+ /** Bucket name - groups dumps by strategy or agent name */
18637
+ bucketName: string;
18638
+ /** Unique identifier for this dump entry */
18639
+ dumpId: string;
18640
+ /** Human-readable label describing the dump contents; included in the BM25 index for Memory search and rendered in Markdown output */
18641
+ description: string;
18642
+ }
18643
+ /**
18644
+ * Interface for dump instance implementations.
18645
+ * Instances are scoped to (signalId, bucketName) via constructor.
18646
+ * Methods receive only the payload and dumpId.
18647
+ */
18648
+ interface IDumpInstance {
18649
+ /**
18650
+ * Persist the full message history of one agent invocation.
18651
+ * @param messages - Full chat history (system, user, assistant, tool)
18652
+ * @param dumpId - Unique identifier for this dump entry
18653
+ * @param description - Human-readable label describing the agent invocation context; included in the BM25 index for Memory search
18654
+ */
18655
+ dumpAgentAnswer(messages: MessageModel[], dumpId: string, description: string): Promise<void>;
18656
+ /**
18657
+ * Persist a flat key-value record.
18658
+ * @param record - Arbitrary flat object to dump
18659
+ * @param dumpId - Unique identifier for this dump entry
18660
+ * @param description - Human-readable label describing the record contents; included in the BM25 index for Memory search
18661
+ */
18662
+ dumpRecord(record: Record<string, unknown>, dumpId: string, description: string): Promise<void>;
18663
+ /**
18664
+ * Persist an array of objects as a table.
18665
+ * Column headers are derived from the union of all keys across all rows.
18666
+ * @param rows - Array of arbitrary objects to dump
18667
+ * @param dumpId - Unique identifier for this dump entry
18668
+ * @param description - Human-readable label describing the table contents; included in the BM25 index for Memory search
18669
+ */
18670
+ dumpTable(rows: Record<string, unknown>[], dumpId: string, description: string): Promise<void>;
18671
+ /**
18672
+ * Persist a raw text or markdown string.
18673
+ * @param content - Arbitrary text content to dump
18674
+ * @param dumpId - Unique identifier for this dump entry
18675
+ * @param description - Human-readable label describing the content; included in the BM25 index for Memory search
18676
+ */
18677
+ dumpText(content: string, dumpId: string, description: string): Promise<void>;
18678
+ /**
18679
+ * Persist an error description.
18680
+ * @param content - Error message or description to dump
18681
+ * @param dumpId - Unique identifier for this dump entry
18682
+ * @param description - Human-readable label describing the error context; included in the BM25 index for Memory search
18683
+ */
18684
+ dumpError(content: string, dumpId: string, description: string): Promise<void>;
18685
+ /**
18686
+ * Persist an arbitrary nested object as a fenced JSON block.
18687
+ * @param json - Arbitrary object to serialize with JSON.stringify
18688
+ * @param dumpId - Unique identifier for this dump entry
18689
+ * @param description - Human-readable label describing the object contents; included in the BM25 index for Memory search
18690
+ * @deprecated Prefer dumpRecord - flat key-value structure maps naturally to markdown tables and SQL storage
18691
+ */
18692
+ dumpJson(json: object, dumpId: string, description: string): Promise<void>;
18693
+ /**
18694
+ * Releases any resources held by this instance.
18695
+ */
18696
+ dispose(): void;
18697
+ }
18698
+ /**
18699
+ * Constructor type for dump instance implementations.
18700
+ * Used for swapping backends via DumpAdapter.useDumpAdapter().
18701
+ */
18702
+ type TDumpInstanceCtor = new (signalId: string, bucketName: string) => IDumpInstance;
18703
+ /**
18704
+ * Facade for dump instances with swappable backend.
18705
+ * Default backend: DumpMarkdownInstance.
18706
+ *
18707
+ * Accepts IDumpContext on every call, constructs a scoped instance per (signalId, bucketName),
18708
+ * and delegates with only the dumpId.
18709
+ *
18710
+ * Switch backends via:
18711
+ * - useMarkdown() - write one .md file per call (default)
18712
+ * - useMemory() - store data in Memory
18713
+ * - useDummy() - no-op, discard all writes
18714
+ * - useDumpAdapter(Ctor) - inject a custom implementation
18715
+ */
18716
+ declare class DumpAdapter {
18717
+ private DumpFactory;
18718
+ private getInstance;
18719
+ /**
18720
+ * Activates the adapter by subscribing to signal lifecycle events.
18721
+ * Clears memoized instances for a signalId when it is cancelled or closed,
18722
+ * preventing stale instances from accumulating in memory.
18723
+ * Idempotent — subsequent calls return the same subscription handle.
18724
+ * Must be called before any dump method is used.
18725
+ */
18726
+ enable: (() => (...args: any[]) => any) & functools_kit.ISingleshotClearable;
18727
+ /**
18728
+ * Deactivates the adapter by unsubscribing from signal lifecycle events.
18729
+ * No-op if enable() was never called.
18730
+ */
18731
+ disable: () => void;
18732
+ /**
18733
+ * Persist the full message history of one agent invocation.
18734
+ */
18735
+ dumpAgentAnswer: (messages: MessageModel[], context: IDumpContext) => Promise<void>;
18736
+ /**
18737
+ * Persist a flat key-value record.
18738
+ */
18739
+ dumpRecord: (record: Record<string, unknown>, context: IDumpContext) => Promise<void>;
18740
+ /**
18741
+ * Persist an array of objects as a table.
18742
+ */
18743
+ dumpTable: (rows: Record<string, unknown>[], context: IDumpContext) => Promise<void>;
18744
+ /**
18745
+ * Persist raw text content.
18746
+ */
18747
+ dumpText: (content: string, context: IDumpContext) => Promise<void>;
18748
+ /**
18749
+ * Persist an error description.
18750
+ */
18751
+ dumpError: (content: string, context: IDumpContext) => Promise<void>;
18752
+ /**
18753
+ * Persist an arbitrary nested object as a fenced JSON block.
18754
+ * @deprecated Prefer dumpRecord - flat key-value structure maps naturally to markdown tables and SQL storage
18755
+ */
18756
+ dumpJson: (json: object, context: IDumpContext) => Promise<void>;
18757
+ /**
18758
+ * Switches to markdown backend (default).
18759
+ * Writes one .md file per call to ./dump/agent/{signalId}/{bucketName}/{dumpId}.md
18760
+ */
18761
+ useMarkdown: () => void;
18762
+ /**
18763
+ * Switches to memory backend.
18764
+ * Stores data via Memory.writeMemory.
18765
+ */
18766
+ useMemory: () => void;
18767
+ /**
18768
+ * Switches to dummy backend.
18769
+ * All writes are discarded.
18770
+ */
18771
+ useDummy: () => void;
18772
+ /**
18773
+ * Switches to dual-write backend.
18774
+ * Writes to both Memory and Markdown simultaneously.
18775
+ */
18776
+ useMarkdownMemoryBoth: () => void;
18777
+ /**
18778
+ * Injects a custom dump adapter implementation.
18779
+ * Uses Reflect.construct for ES3/ES6 interop compatibility.
18780
+ * @param Ctor - Constructor for the custom dump implementation
18781
+ */
18782
+ useDumpAdapter: (Ctor: TDumpInstanceCtor) => void;
18783
+ }
18784
+ declare const Dump: DumpAdapter;
18785
+
17702
18786
  /**
17703
18787
  * Utility class for exchange operations.
17704
18788
  *
@@ -19940,15 +21024,49 @@ type BrokerAverageBuyPayload = {
19940
21024
  /** true when called during a backtest run — adapter should skip exchange calls */
19941
21025
  backtest: boolean;
19942
21026
  };
21027
+ /**
21028
+ * Broker adapter interface for live order execution.
21029
+ *
21030
+ * Implement this interface to connect the framework to a real exchange or broker.
21031
+ * All methods are called BEFORE the corresponding DI-core state mutation, so if any
21032
+ * method throws, the internal state remains unchanged (transaction semantics).
21033
+ *
21034
+ * In backtest mode all calls are silently skipped by BrokerAdapter — the adapter
21035
+ * never receives backtest traffic.
21036
+ *
21037
+ * @example
21038
+ * ```typescript
21039
+ * class MyBroker implements IBroker {
21040
+ * async waitForInit() {
21041
+ * await this.exchange.connect();
21042
+ * }
21043
+ * async onSignalOpenCommit(payload) {
21044
+ * await this.exchange.placeOrder({ symbol: payload.symbol, side: payload.position });
21045
+ * }
21046
+ * // ... other methods
21047
+ * }
21048
+ *
21049
+ * Broker.useBrokerAdapter(MyBroker);
21050
+ * ```
21051
+ */
19943
21052
  interface IBroker {
21053
+ /** Called once before first use. Connect to exchange, load credentials, etc. */
19944
21054
  waitForInit(): Promise<void>;
21055
+ /** Called when a new signal is closed (take-profit, stop-loss, or manual close). */
19945
21056
  onSignalCloseCommit(payload: BrokerSignalClosePayload): Promise<void>;
21057
+ /** Called when a new signal is opened (position entry confirmed). */
19946
21058
  onSignalOpenCommit(payload: BrokerSignalOpenPayload): Promise<void>;
21059
+ /** Called when a partial profit close is committed. */
19947
21060
  onPartialProfitCommit(payload: BrokerPartialProfitPayload): Promise<void>;
21061
+ /** Called when a partial loss close is committed. */
19948
21062
  onPartialLossCommit(payload: BrokerPartialLossPayload): Promise<void>;
21063
+ /** Called when a trailing stop update is committed. */
19949
21064
  onTrailingStopCommit(payload: BrokerTrailingStopPayload): Promise<void>;
21065
+ /** Called when a trailing take-profit update is committed. */
19950
21066
  onTrailingTakeCommit(payload: BrokerTrailingTakePayload): Promise<void>;
21067
+ /** Called when a breakeven stop is committed (stop loss moved to entry price). */
19951
21068
  onBreakevenCommit(payload: BrokerBreakevenPayload): Promise<void>;
21069
+ /** Called when a DCA (average-buy) entry is committed. */
19952
21070
  onAverageBuyCommit(payload: BrokerAverageBuyPayload): Promise<void>;
19953
21071
  }
19954
21072
  type TBrokerCtor = new () => Partial<IBroker>;
@@ -22532,7 +23650,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
22532
23650
  strategyName: StrategyName;
22533
23651
  exchangeName: ExchangeName;
22534
23652
  frameName: FrameName;
22535
- }, candles: ICandleData[]) => Promise<IStrategyTickResultClosed | IStrategyTickResultCancelled>;
23653
+ }, candles: ICandleData[]) => Promise<IStrategyTickResultClosed | IStrategyTickResultCancelled | IStrategyTickResultActive>;
22536
23654
  /**
22537
23655
  * Stops the specified strategy from generating new signals.
22538
23656
  *
@@ -23932,7 +25050,7 @@ declare class StrategyCoreService implements TStrategy {
23932
25050
  strategyName: StrategyName;
23933
25051
  exchangeName: ExchangeName;
23934
25052
  frameName: FrameName;
23935
- }) => Promise<IStrategyTickResultClosed | IStrategyTickResultCancelled>;
25053
+ }) => Promise<IStrategyTickResultClosed | IStrategyTickResultCancelled | IStrategyTickResultActive>;
23936
25054
  /**
23937
25055
  * Stops the strategy from generating new signals.
23938
25056
  *
@@ -25091,12 +26209,14 @@ declare class WalkerSchemaService {
25091
26209
  * Supports early termination via break in consumer.
25092
26210
  */
25093
26211
  declare class BacktestLogicPrivateService {
25094
- private readonly loggerService;
25095
- private readonly strategyCoreService;
25096
- private readonly exchangeCoreService;
25097
- private readonly frameCoreService;
25098
- private readonly methodContextService;
25099
- private readonly actionCoreService;
26212
+ readonly loggerService: LoggerService;
26213
+ readonly strategyCoreService: StrategyCoreService;
26214
+ readonly exchangeCoreService: ExchangeCoreService;
26215
+ readonly frameCoreService: FrameCoreService;
26216
+ readonly methodContextService: {
26217
+ readonly context: IMethodContext;
26218
+ };
26219
+ readonly actionCoreService: ActionCoreService;
25100
26220
  /**
25101
26221
  * Runs backtest for a symbol, streaming closed signals as async generator.
25102
26222
  *
@@ -25111,7 +26231,7 @@ declare class BacktestLogicPrivateService {
25111
26231
  * }
25112
26232
  * ```
25113
26233
  */
25114
- run(symbol: string): AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
26234
+ run(symbol: string): AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, any>;
25115
26235
  }
25116
26236
 
25117
26237
  /**
@@ -25168,6 +26288,7 @@ type IBacktestLogicPrivateService = Omit<BacktestLogicPrivateService, keyof {
25168
26288
  strategyCoreService: never;
25169
26289
  exchangeCoreService: never;
25170
26290
  frameCoreService: never;
26291
+ actionCoreService: never;
25171
26292
  methodContextService: never;
25172
26293
  }>;
25173
26294
  /**
@@ -25218,7 +26339,7 @@ declare class BacktestLogicPublicService implements TBacktestLogicPrivateService
25218
26339
  strategyName: StrategyName;
25219
26340
  exchangeName: ExchangeName;
25220
26341
  frameName: FrameName;
25221
- }) => AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
26342
+ }) => AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, any>;
25222
26343
  }
25223
26344
 
25224
26345
  /**
@@ -25357,7 +26478,7 @@ declare class BacktestCommandService implements TBacktestLogicPublicService {
25357
26478
  strategyName: StrategyName;
25358
26479
  exchangeName: ExchangeName;
25359
26480
  frameName: FrameName;
25360
- }) => AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
26481
+ }) => AsyncGenerator<IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, any>;
25361
26482
  }
25362
26483
 
25363
26484
  /**
@@ -26940,8 +28061,57 @@ declare class SyncReportService {
26940
28061
  */
26941
28062
  declare class HighestProfitReportService {
26942
28063
  private readonly loggerService;
28064
+ /**
28065
+ * Handles a single `HighestProfitContract` event emitted by `highestProfitSubject`.
28066
+ *
28067
+ * Writes a JSONL record to the `"highest_profit"` report database via
28068
+ * `Report.writeData`, capturing the full signal snapshot at the moment
28069
+ * the new profit record was set:
28070
+ * - `timestamp`, `symbol`, `strategyName`, `exchangeName`, `frameName`, `backtest`
28071
+ * - `signalId`, `position`, `currentPrice`
28072
+ * - `priceOpen`, `priceTakeProfit`, `priceStopLoss` (effective values from the signal)
28073
+ *
28074
+ * `strategyName` and signal-level fields are sourced from `data.signal`
28075
+ * rather than the contract root.
28076
+ *
28077
+ * @param data - `HighestProfitContract` payload containing `symbol`,
28078
+ * `signal`, `currentPrice`, `backtest`, `timestamp`, `exchangeName`,
28079
+ * `frameName`
28080
+ */
26943
28081
  private tick;
28082
+ /**
28083
+ * Subscribes to `highestProfitSubject` to start persisting profit records.
28084
+ * Protected against multiple subscriptions via `singleshot` — subsequent
28085
+ * calls return the same unsubscribe function without re-subscribing.
28086
+ *
28087
+ * The returned unsubscribe function clears the `singleshot` state and
28088
+ * detaches from `highestProfitSubject`.
28089
+ *
28090
+ * @returns Unsubscribe function; calling it tears down the subscription
28091
+ *
28092
+ * @example
28093
+ * ```typescript
28094
+ * const service = new HighestProfitReportService();
28095
+ * const unsubscribe = service.subscribe();
28096
+ * // ... later
28097
+ * unsubscribe();
28098
+ * ```
28099
+ */
26944
28100
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
28101
+ /**
28102
+ * Detaches from `highestProfitSubject`, stopping further JSONL writes.
28103
+ *
28104
+ * Calls the unsubscribe closure returned by `subscribe()`.
28105
+ * If `subscribe()` was never called, does nothing.
28106
+ *
28107
+ * @example
28108
+ * ```typescript
28109
+ * const service = new HighestProfitReportService();
28110
+ * service.subscribe();
28111
+ * // ... later
28112
+ * await service.unsubscribe();
28113
+ * ```
28114
+ */
26945
28115
  unsubscribe: () => Promise<void>;
26946
28116
  }
26947
28117
 
@@ -27098,4 +28268,4 @@ declare const getTotalClosed: (signal: Signal) => {
27098
28268
  remainingCostBasis: number;
27099
28269
  };
27100
28270
 
27101
- 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, Constant, type CriticalErrorNotification, type DoneContract, 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 IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, 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 InfoErrorNotification, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MeasureData, 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, PersistLogAdapter, PersistMeasureAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, 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 TLogCtor, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, 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, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };
28271
+ 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, 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 IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, 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 InfoErrorNotification, Live, type LiveStatisticsModel, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, 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, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, 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 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, 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, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, 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, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles, writeMemory };