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