backtest-kit 14.1.0 → 15.1.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.
Files changed (6) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +853 -808
  3. package/build/index.cjs +5413 -3483
  4. package/build/index.mjs +5411 -3485
  5. package/package.json +86 -86
  6. package/types.d.ts +451 -170
package/types.d.ts CHANGED
@@ -1537,9 +1537,20 @@ interface RiskContract {
1537
1537
  }
1538
1538
 
1539
1539
  /**
1540
- * Base fields shared by all signal sync events.
1540
+ * Base fields shared by all order sync events.
1541
1541
  */
1542
- interface SignalSyncBase {
1542
+ interface OrderSyncBase {
1543
+ /**
1544
+ * Which order the sync gate is about:
1545
+ * - "active" — the position order: immediate open, activation fill of a resting
1546
+ * order, and every close. Reject (false/throw) skips the open/close; a rejected
1547
+ * fresh open rolls back the interval throttle and retries on the next tick.
1548
+ * - "schedule" — the resting entry order being PLACED when a scheduled signal is
1549
+ * created (action "signal-open" only). Reject means the exchange did not accept
1550
+ * the resting order: the scheduled signal is NOT registered, the risk
1551
+ * reservation is released and the placement retries on the next tick.
1552
+ */
1553
+ type: "schedule" | "active";
1543
1554
  /** Trading pair symbol (e.g., "BTCUSDT") */
1544
1555
  symbol: string;
1545
1556
  /** Strategy name that generated this signal */
@@ -1573,7 +1584,7 @@ interface SignalSyncBase {
1573
1584
  * - External order sync services
1574
1585
  * - Audit/logging pipelines
1575
1586
  */
1576
- interface SignalOpenContract extends SignalSyncBase {
1587
+ interface OrderOpenContract extends OrderSyncBase {
1577
1588
  /** Discriminator for signal-open action */
1578
1589
  action: "signal-open";
1579
1590
  /** Market price at the moment of activation (VWAP or candle average) */
@@ -1628,7 +1639,7 @@ interface SignalOpenContract extends SignalSyncBase {
1628
1639
  * - External order sync services
1629
1640
  * - Audit/logging pipelines
1630
1641
  */
1631
- interface SignalCloseContract extends SignalSyncBase {
1642
+ interface OrderCloseContract extends OrderSyncBase {
1632
1643
  /** Discriminator for signal-close action */
1633
1644
  action: "signal-close";
1634
1645
  /** Market price at the moment of close */
@@ -1671,37 +1682,48 @@ interface SignalCloseContract extends SignalSyncBase {
1671
1682
  totalPartials: number;
1672
1683
  }
1673
1684
  /**
1674
- * Discriminated union for signal sync events.
1685
+ * Discriminated union for order sync events.
1675
1686
  *
1676
1687
  * Emitted to allow external systems to synchronize with the framework's
1677
- * limit order lifecycle: open (limit filled) and close (position exited).
1688
+ * order lifecycle: open (type "active" immediate/activation fill; type
1689
+ * "schedule" — placement of the resting entry order at scheduled-signal
1690
+ * creation) and close (position exited, always type "active").
1678
1691
  *
1679
- * Note: Only covers the scheduled pending closed lifecycle.
1680
- * Signals that were never activated (cancelled scheduled signals) do NOT emit SignalOpenContract.
1692
+ * Note: cancelled scheduled signals do NOT emit OrderOpenContract their
1693
+ * teardown goes through the schedule-event channel (Broker.commitScheduleCancelled).
1681
1694
  */
1682
- type SignalSyncContract = SignalOpenContract | SignalCloseContract;
1695
+ type OrderSyncContract = OrderOpenContract | OrderCloseContract;
1683
1696
 
1684
1697
  /**
1685
- * Signal pending-ping sync event.
1698
+ * Signal order-ping sync event.
1686
1699
  *
1687
- * Emitted on every live tick while a pending signal (open position) is being monitored,
1688
- * BEFORE the framework evaluates TP/SL/time completion. It asks the external order
1689
- * management system whether the corresponding order is STILL pending (open) on the exchange.
1700
+ * Emitted on every live tick while a signal is being monitored, BEFORE the framework
1701
+ * evaluates completion. It asks the external order management system whether the
1702
+ * corresponding order is STILL open on the exchange. Fires for BOTH monitored states,
1703
+ * discriminated by `type`:
1704
+ * - `type: "active"` — a pending signal (open position); the order backing the position.
1705
+ * - `type: "schedule"` — a scheduled signal; the resting entry order awaiting activation.
1690
1706
  *
1691
1707
  * Listener contract (mirrors syncSubject semantics):
1692
1708
  * - Return true (or do nothing) — the order is still open on the exchange, keep monitoring.
1693
1709
  * - Return false OR throw — the order is no longer open on the exchange (filled, cancelled,
1694
- * liquidated externally). The framework closes the pending signal with closeReason "closed".
1710
+ * liquidated externally). For "active" the framework closes the pending signal with
1711
+ * closeReason "closed"; for "schedule" it cancels the scheduled signal (reason "user").
1712
+ * NOTE for "schedule": if the resting order actually FILLED, confirm it via
1713
+ * activateScheduled/commitActivateScheduled instead of failing the ping — a failed ping
1714
+ * is a terminal cancel, not an activation.
1695
1715
  *
1696
1716
  * Backtest never emits this event — there is no live exchange to query.
1697
1717
  *
1698
1718
  * Consumers:
1699
- * - Broker adapter via `onOrderCheck` (syncPendingSubject subscription)
1719
+ * - Broker adapter via `onOrderActiveCheck` / `onOrderScheduleCheck` (syncPendingSubject subscription)
1700
1720
  * - Registered actions via `orderCheck` / `onOrderCheck`
1701
1721
  */
1702
- interface SignalPingContract {
1722
+ interface OrderCheckContract {
1703
1723
  /** Discriminator for pending-ping action */
1704
1724
  action: "signal-ping";
1725
+ /** Monitored state: "active" — open position order, "schedule" — resting entry order */
1726
+ type: "schedule" | "active";
1705
1727
  /** Trading pair symbol (e.g., "BTCUSDT") */
1706
1728
  symbol: string;
1707
1729
  /** Strategy name that generated this signal */
@@ -2147,7 +2169,7 @@ interface IActionCallbacks {
2147
2169
  * Throw to reject the operation — framework will retry on next tick.
2148
2170
  *
2149
2171
  * MANUAL WIRING — EXCEPTION-BASED GATE: the action-side equivalent of the Broker
2150
- * `onSignalOpenCommit` / `onSignalCloseCommit` gate. Throwing (or returning false) on
2172
+ * `onOrderOpenCommit` / `onOrderCloseCommit` gate. Throwing (or returning false) on
2151
2173
  * `event.action === "signal-open"` rolls the open back to idle (a scheduled activation is
2152
2174
  * cancelled); on `"signal-close"` it skips the close and leaves the position open — retried next
2153
2175
  * tick. Rides the same `syncSubject` emission as the Broker commit hooks, so a throw from either is
@@ -2159,20 +2181,24 @@ interface IActionCallbacks {
2159
2181
  * @param frameName - Timeframe identifier
2160
2182
  * @param backtest - True for backtest mode, false for live trading
2161
2183
  */
2162
- onSignalSync(event: SignalSyncContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
2184
+ onOrderSync(event: OrderSyncContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
2163
2185
  /**
2164
2186
  * Called on every live tick while a pending signal is monitored, BEFORE TP/SL/time evaluation,
2165
2187
  * to confirm the order is still pending (open) on the exchange.
2166
2188
  *
2189
+ * Fires for both monitored states, discriminated by `event.type`: "active" — pending signal
2190
+ * (open position); "schedule" — scheduled signal (resting entry order awaiting activation).
2191
+ *
2167
2192
  * Query the exchange by `event.signalId` and THROW ONLY when the order is NOT FOUND by that id
2168
2193
  * (filled, cancelled, or liquidated externally) — the framework then closes the position with
2169
- * closeReason "closed".
2194
+ * closeReason "closed" (type "active") or cancels the scheduled signal with reason "user"
2195
+ * (type "schedule").
2170
2196
  *
2171
2197
  * CRITICAL: swallow transient/network errors (timeout, 5xx, rate limit, disconnect) — return
2172
2198
  * normally instead of throwing, otherwise a connectivity blip would wrongly close an open
2173
2199
  * position. Throw exclusively on a confirmed "order not found by id" result.
2174
2200
  *
2175
- * NOTE: Like onSignalSync, exceptions from this method are NOT swallowed. They propagate up to
2201
+ * NOTE: Like onOrderSync, exceptions from this method are NOT swallowed. They propagate up to
2176
2202
  * CREATE_SYNC_PENDING_FN which catches them and returns false.
2177
2203
  *
2178
2204
  * MANUAL WIRING — EXCEPTION-BASED GATE: the action-side equivalent of the Broker `onOrderCheck`.
@@ -2189,7 +2215,7 @@ interface IActionCallbacks {
2189
2215
  * @param frameName - Timeframe identifier
2190
2216
  * @param backtest - True for backtest mode, false for live trading
2191
2217
  */
2192
- onOrderCheck(event: SignalPingContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
2218
+ onOrderCheck(event: OrderCheckContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
2193
2219
  }
2194
2220
  /**
2195
2221
  * Action schema registered via addActionSchema().
@@ -2486,17 +2512,17 @@ interface IAction {
2486
2512
  * NOTE: Exceptions are NOT swallowed here — they propagate to CREATE_SYNC_FN.
2487
2513
  *
2488
2514
  * MANUAL WIRING — EXCEPTION-BASED GATE: action-side equivalent of the Broker
2489
- * `onSignalOpenCommit` / `onSignalCloseCommit`. Throw on "signal-open" → open rolls back to idle
2515
+ * `onOrderOpenCommit` / `onOrderCloseCommit`. Throw on "signal-open" → open rolls back to idle
2490
2516
  * (scheduled activation cancelled); throw on "signal-close" → close skipped, position stays open;
2491
2517
  * retried next tick. Same `syncSubject` emission as the Broker commit hooks (collapsed to false by
2492
- * CREATE_SYNC_FN). Live-only. Implement via the {@link IActionCallbacks.onSignalSync} callback.
2518
+ * CREATE_SYNC_FN). Live-only. Implement via the {@link IActionCallbacks.onOrderSync} callback.
2493
2519
  *
2494
2520
  * @deprecated This method is not recommended for use. Implement custom logic in signal(), signalLive(), or signalBacktest() instead.
2495
2521
  * If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() instead.
2496
- * If Action::signalSync throws the exchange will not execute the order!
2522
+ * If Action::orderSync throws the exchange will not execute the order!
2497
2523
  * @param event - Sync event with action "signal-open" or "signal-close"
2498
2524
  */
2499
- signalSync(event: SignalSyncContract): void | Promise<void>;
2525
+ orderSync(event: OrderSyncContract): void | Promise<void>;
2500
2526
  /**
2501
2527
  * Called on every live tick while a pending signal is monitored, BEFORE TP/SL/time evaluation,
2502
2528
  * to confirm the order is still pending (open) on the exchange.
@@ -2519,10 +2545,11 @@ interface IAction {
2519
2545
  *
2520
2546
  * @deprecated This method is not recommended for use. Exchange integration should be implemented
2521
2547
  * in Broker.useBrokerAdapter (the infrastructure domain layer) via onOrderCheck instead.
2522
- * If Action::orderCheck throws the framework will close the position with closeReason "closed"!
2523
- * @param event - Pending-ping event with action "signal-ping"
2548
+ * If Action::orderCheck throws the framework will close the position with closeReason "closed"
2549
+ * (event.type "active") or cancel the scheduled signal (event.type "schedule")!
2550
+ * @param event - Order-ping event with action "signal-ping" and type "schedule" | "active"
2524
2551
  */
2525
- orderCheck(event: SignalPingContract): void | Promise<void>;
2552
+ orderCheck(event: OrderCheckContract): void | Promise<void>;
2526
2553
  /**
2527
2554
  * Cleans up resources and subscriptions when action handler is no longer needed.
2528
2555
  *
@@ -6093,6 +6120,9 @@ declare function commitAverageBuy(symbol: string, cost?: number): Promise<boolea
6093
6120
  *
6094
6121
  * Automatically detects backtest/live mode from execution context.
6095
6122
  *
6123
+ * @deprecated The name is misleading — the function returns the HELD share,
6124
+ * not the closed one. Use {@link getTotalPercentHeld} instead.
6125
+ *
6096
6126
  * @param symbol - Trading pair symbol
6097
6127
  * @returns Promise<number> - held percentage (0–100)
6098
6128
  *
@@ -6111,6 +6141,9 @@ declare function getTotalPercentClosed(symbol: string): Promise<number>;
6111
6141
  *
6112
6142
  * Automatically detects backtest/live mode from execution context.
6113
6143
  *
6144
+ * @deprecated The name is misleading — the function returns the REMAINING
6145
+ * cost basis, not the closed one. Use {@link getRemainingCostBasis} instead.
6146
+ *
6114
6147
  * @param symbol - Trading pair symbol
6115
6148
  * @returns Promise<number> - held cost basis in dollars
6116
6149
  *
@@ -6123,6 +6156,44 @@ declare function getTotalPercentClosed(symbol: string): Promise<number>;
6123
6156
  * ```
6124
6157
  */
6125
6158
  declare function getTotalCostClosed(symbol: string): Promise<number>;
6159
+ /**
6160
+ * Returns the percentage of the position currently held (not yet closed by partials).
6161
+ * 100 = nothing has been closed (full position), 0 = fully closed.
6162
+ * Correctly accounts for DCA entries between partial closes.
6163
+ *
6164
+ * Correctly-named alias for {@link getTotalPercentClosed}.
6165
+ *
6166
+ * @param symbol - Trading pair symbol
6167
+ * @returns Promise<number> - held percentage (0–100)
6168
+ *
6169
+ * @example
6170
+ * ```typescript
6171
+ * import { getTotalPercentHeld } from "backtest-kit";
6172
+ *
6173
+ * const heldPct = await getTotalPercentHeld("BTCUSDT");
6174
+ * console.log(`Holding ${heldPct}% of position`);
6175
+ * ```
6176
+ */
6177
+ declare function getTotalPercentHeld(symbol: string): Promise<number>;
6178
+ /**
6179
+ * Returns the remaining cost basis in dollars — how much of the position is
6180
+ * still held (not yet closed by partials). Correctly accounts for DCA entries
6181
+ * between partial closes.
6182
+ *
6183
+ * Correctly-named alias for {@link getTotalCostClosed}.
6184
+ *
6185
+ * @param symbol - Trading pair symbol
6186
+ * @returns Promise<number> - remaining cost basis in dollars
6187
+ *
6188
+ * @example
6189
+ * ```typescript
6190
+ * import { getRemainingCostBasis } from "backtest-kit";
6191
+ *
6192
+ * const remaining = await getRemainingCostBasis("BTCUSDT");
6193
+ * console.log(`Holding $${remaining} of position`);
6194
+ * ```
6195
+ */
6196
+ declare function getRemainingCostBasis(symbol: string): Promise<number>;
6126
6197
  /**
6127
6198
  * Returns the currently active pending signal for the strategy.
6128
6199
  * If no active signal exists, returns null.
@@ -7080,16 +7151,15 @@ declare function getStrategyStatus(symbol: string): Promise<StrategyStatus>;
7080
7151
  *
7081
7152
  * Automatically detects backtest/live mode from execution context.
7082
7153
  *
7083
- * @param symbol - Trading pair symbol
7084
- * @param strategyName - Strategy name to stop
7154
+ * @param symbol - Trading pair symbol; the strategy is resolved from the active method context
7085
7155
  * @returns Promise that resolves when stop flag is set
7086
7156
  *
7087
7157
  * @example
7088
7158
  * ```typescript
7089
- * import { stop } from "backtest-kit";
7159
+ * import { stopStrategy } from "backtest-kit";
7090
7160
  *
7091
- * // Stop strategy after some condition
7092
- * await stop("BTCUSDT", "my-strategy");
7161
+ * // Stop strategy after some condition (inside a strategy/action callback)
7162
+ * await stopStrategy("BTCUSDT");
7093
7163
  * ```
7094
7164
  */
7095
7165
  declare function stopStrategy(symbol: string): Promise<void>;
@@ -9665,9 +9735,9 @@ declare function listenValidation(fn: (error: Error) => void): () => void;
9665
9735
  *
9666
9736
  * @example
9667
9737
  * ```typescript
9668
- * import { listenPartialProfit } from "./function/event";
9738
+ * import { listenPartialProfitAvailable } from "./function/event";
9669
9739
  *
9670
- * const unsubscribe = listenPartialProfit((event) => {
9740
+ * const unsubscribe = listenPartialProfitAvailable((event) => {
9671
9741
  * console.log(`Signal ${event.data.id} reached ${event.level}% profit`);
9672
9742
  * console.log(`Symbol: ${event.symbol}, Price: ${event.currentPrice}`);
9673
9743
  * console.log(`Mode: ${event.backtest ? "Backtest" : "Live"}`);
@@ -9721,9 +9791,9 @@ declare function listenPartialProfitAvailableOnce(filterFn: (event: PartialProfi
9721
9791
  *
9722
9792
  * @example
9723
9793
  * ```typescript
9724
- * import { listenPartialLoss } from "./function/event";
9794
+ * import { listenPartialLossAvailable } from "./function/event";
9725
9795
  *
9726
- * const unsubscribe = listenPartialLoss((event) => {
9796
+ * const unsubscribe = listenPartialLossAvailable((event) => {
9727
9797
  * console.log(`Signal ${event.data.id} reached ${event.level}% loss`);
9728
9798
  * console.log(`Symbol: ${event.symbol}, Price: ${event.currentPrice}`);
9729
9799
  * console.log(`Mode: ${event.backtest ? "Backtest" : "Live"}`);
@@ -9778,9 +9848,9 @@ declare function listenPartialLossAvailableOnce(filterFn: (event: PartialLossCon
9778
9848
  *
9779
9849
  * @example
9780
9850
  * ```typescript
9781
- * import { listenBreakeven } from "./function/event";
9851
+ * import { listenBreakevenAvailable } from "./function/event";
9782
9852
  *
9783
- * const unsubscribe = listenBreakeven((event) => {
9853
+ * const unsubscribe = listenBreakevenAvailable((event) => {
9784
9854
  * console.log(`Signal ${event.data.id} reached breakeven`);
9785
9855
  * console.log(`Symbol: ${event.symbol}, Position: ${event.data.position}`);
9786
9856
  * console.log(`Entry: ${event.data.priceOpen}, Current: ${event.currentPrice}`);
@@ -10197,7 +10267,7 @@ declare function listenStrategyCommitOnce(filterFn: (event: StrategyCommitContra
10197
10267
  * @param fn - Callback function to handle sync events. If the function returns a promise, signal processing will wait until it resolves.
10198
10268
  * @returns Unsubscribe function to stop listening
10199
10269
  */
10200
- declare function listenSync(fn: (event: SignalSyncContract) => void, warned?: boolean): () => void;
10270
+ declare function listenSync(fn: (event: OrderSyncContract) => void, warned?: boolean): () => void;
10201
10271
  /**
10202
10272
  * Subscribes to filtered signal synchronization events with one-time execution.
10203
10273
  * If throws position is not being opened/closed until the async function completes. Useful for synchronizing with external systems.
@@ -10206,7 +10276,30 @@ declare function listenSync(fn: (event: SignalSyncContract) => void, warned?: bo
10206
10276
  * @param fn - Callback function to handle the filtered event (called only once). If the function returns a promise, signal processing will wait until it resolves.
10207
10277
  * @returns Unsubscribe function to cancel the listener before it fires
10208
10278
  */
10209
- declare function listenSyncOnce(filterFn: (event: SignalSyncContract) => boolean, fn: (event: SignalSyncContract) => void, warned?: boolean): () => void;
10279
+ declare function listenSyncOnce(filterFn: (event: OrderSyncContract) => boolean, fn: (event: OrderSyncContract) => void, warned?: boolean): () => void;
10280
+ /**
10281
+ * Subscribes to order-check ping events with queued async processing.
10282
+ * If throws, the order behind the monitored signal is treated as no longer open on the
10283
+ * exchange until the async function completes. Useful for synchronizing with external systems.
10284
+ *
10285
+ * Emits on every live tick while a signal is monitored, BEFORE completion evaluation,
10286
+ * discriminated by `event.type`: "active" — pending signal (open position), "schedule" —
10287
+ * scheduled signal (resting entry order). Backtest never emits this event.
10288
+ *
10289
+ * @param fn - Callback function to handle check events. If the function returns a promise, signal processing will wait until it resolves.
10290
+ * @returns Unsubscribe function to stop listening
10291
+ */
10292
+ declare function listenCheck(fn: (event: OrderCheckContract) => void, warned?: boolean): () => void;
10293
+ /**
10294
+ * Subscribes to filtered order-check ping events with one-time execution.
10295
+ * If throws, the order behind the monitored signal is treated as no longer open on the
10296
+ * exchange until the async function completes. Useful for synchronizing with external systems.
10297
+ *
10298
+ * @param filterFn - Predicate to filter which events trigger the callback
10299
+ * @param fn - Callback function to handle the filtered event (called only once). If the function returns a promise, signal processing will wait until it resolves.
10300
+ * @returns Unsubscribe function to cancel the listener before it fires
10301
+ */
10302
+ declare function listenCheckOnce(filterFn: (event: OrderCheckContract) => boolean, fn: (event: OrderCheckContract) => void, warned?: boolean): () => void;
10210
10303
  /**
10211
10304
  * Subscribes to highest profit events with queued async processing.
10212
10305
  * Emits when a signal reaches a new highest profit level during its lifecycle.
@@ -10688,8 +10781,8 @@ declare function getMinutesSinceLatestSignalCreated(symbol: string): Promise<num
10688
10781
  /**
10689
10782
  * Reads the state value scoped to the current active signal.
10690
10783
  *
10691
- * Resolves the active pending signal automatically from execution context.
10692
- * If no pending signal exists, logs a warning and returns the initialValue.
10784
+ * Resolves the active pending or scheduled signal automatically from execution context.
10785
+ * Throws if neither a pending nor a scheduled signal exists.
10693
10786
  *
10694
10787
  * Automatically detects backtest/live mode from execution context.
10695
10788
  *
@@ -10726,8 +10819,8 @@ declare function getSignalState<Value extends object = object>(symbol: string, d
10726
10819
  /**
10727
10820
  * Updates the state value scoped to the current active signal.
10728
10821
  *
10729
- * Resolves the active pending signal automatically from execution context.
10730
- * If no pending signal exists, logs a warning and returns without writing.
10822
+ * Resolves the active pending or scheduled signal automatically from execution context.
10823
+ * Throws if neither a pending nor a scheduled signal exists.
10731
10824
  *
10732
10825
  * Automatically detects backtest/live mode from execution context.
10733
10826
  *
@@ -12742,7 +12835,7 @@ interface TrailingTakeCommitNotification {
12742
12835
  * Signal sync open notification.
12743
12836
  * Emitted when a scheduled (limit order) signal is activated and the position is opened.
12744
12837
  */
12745
- interface SignalSyncOpenNotification {
12838
+ interface OrderSyncOpenNotification {
12746
12839
  /** Discriminator for type-safe union */
12747
12840
  type: "signal_sync.open";
12748
12841
  /** Unique notification identifier */
@@ -12830,7 +12923,7 @@ interface SignalSyncOpenNotification {
12830
12923
  * Signal sync close notification.
12831
12924
  * Emitted when an active pending signal is closed (TP/SL hit, time expired, or user-initiated).
12832
12925
  */
12833
- interface SignalSyncCloseNotification {
12926
+ interface OrderSyncCloseNotification {
12834
12927
  /** Discriminator for type-safe union */
12835
12928
  type: "signal_sync.close";
12836
12929
  /** Unique notification identifier */
@@ -13400,7 +13493,7 @@ interface SignalInfoNotification {
13400
13493
  * }
13401
13494
  * ```
13402
13495
  */
13403
- type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | AverageBuyCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | CancelScheduledCommitNotification | ClosePendingCommitNotification | SignalSyncOpenNotification | SignalSyncCloseNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification | SignalInfoNotification;
13496
+ type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | AverageBuyCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | CancelScheduledCommitNotification | ClosePendingCommitNotification | OrderSyncOpenNotification | OrderSyncCloseNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification | SignalInfoNotification;
13404
13497
 
13405
13498
  /**
13406
13499
  * Unified tick event data for report generation.
@@ -16640,6 +16733,8 @@ declare class PersistMemoryInstance implements IPersistMemoryInstance {
16640
16733
  writeMemoryData(data: MemoryData, memoryId: string, _when: Date): Promise<void>;
16641
16734
  /**
16642
16735
  * Soft-deletes a memory entry by writing `removed: true` flag.
16736
+ * No-op when the entry does not exist (readValue throws on a missing
16737
+ * entity, so existence must be checked first to keep removal idempotent).
16643
16738
  *
16644
16739
  * @param memoryId - Memory entry identifier
16645
16740
  * @returns Promise that resolves when removal is complete
@@ -17236,16 +17331,27 @@ declare class PersistSessionInstance implements IPersistSessionInstance {
17236
17331
  readonly strategyName: string;
17237
17332
  readonly exchangeName: string;
17238
17333
  readonly frameName: string;
17334
+ readonly symbol: string;
17335
+ readonly backtest: boolean;
17239
17336
  /** Underlying file-based storage scoped to this context */
17240
17337
  private readonly _storage;
17338
+ /**
17339
+ * Entity key inside the per-strategy/exchange/frame storage directory.
17340
+ * Includes the symbol and backtest flag: without them two symbols running
17341
+ * the same strategy would clobber one shared record and restore each
17342
+ * other's session state after a restart.
17343
+ */
17344
+ private readonly _entityId;
17241
17345
  /**
17242
17346
  * Creates new session persistence instance.
17243
17347
  *
17244
17348
  * @param strategyName - Strategy identifier
17245
17349
  * @param exchangeName - Exchange identifier
17246
- * @param frameName - Frame identifier (also used as entity ID)
17350
+ * @param frameName - Frame identifier (storage subdirectory)
17351
+ * @param symbol - Trading pair symbol (part of the entity key)
17352
+ * @param backtest - Whether the session belongs to a backtest run (part of the entity key)
17247
17353
  */
17248
- constructor(strategyName: string, exchangeName: string, frameName: string);
17354
+ constructor(strategyName: string, exchangeName: string, frameName: string, symbol: string, backtest: boolean);
17249
17355
  /**
17250
17356
  * Initializes the underlying PersistBase storage.
17251
17357
  *
@@ -17254,13 +17360,13 @@ declare class PersistSessionInstance implements IPersistSessionInstance {
17254
17360
  */
17255
17361
  waitForInit(initial: boolean): Promise<void>;
17256
17362
  /**
17257
- * Reads the persisted session data using `frameName` as the entity key.
17363
+ * Reads the persisted session data using the per-symbol entity key.
17258
17364
  *
17259
17365
  * @returns Promise resolving to session data or null if not found
17260
17366
  */
17261
17367
  readSessionData(): Promise<SessionData | null>;
17262
17368
  /**
17263
- * Writes the session data using `frameName` as the entity key.
17369
+ * Writes the session data using the per-symbol entity key.
17264
17370
  *
17265
17371
  * @param data - Session data to persist
17266
17372
  * @returns Promise that resolves when write is complete
@@ -17276,7 +17382,7 @@ declare class PersistSessionInstance implements IPersistSessionInstance {
17276
17382
  * Constructor type for IPersistSessionInstance.
17277
17383
  * Used by PersistSessionUtils.usePersistSessionAdapter() to register custom adapters.
17278
17384
  */
17279
- type TPersistSessionInstanceCtor = new (strategyName: string, exchangeName: string, frameName: string) => IPersistSessionInstance;
17385
+ type TPersistSessionInstanceCtor = new (strategyName: string, exchangeName: string, frameName: string, symbol: string, backtest: boolean) => IPersistSessionInstance;
17280
17386
  /**
17281
17387
  * Utility class for managing session persistence.
17282
17388
  *
@@ -17297,9 +17403,14 @@ declare class PersistSessionUtils {
17297
17403
  private PersistSessionInstanceCtor;
17298
17404
  /**
17299
17405
  * Memoized factory creating one IPersistSessionInstance per
17300
- * (strategyName, exchangeName, frameName) triple.
17406
+ * (strategyName, exchangeName, frameName, symbol, backtest) tuple.
17301
17407
  */
17302
17408
  private getSessionStorage;
17409
+ /**
17410
+ * Builds the memoization key for the given context.
17411
+ * Kept in sync with the getSessionStorage key function.
17412
+ */
17413
+ private static GET_KEY_FN;
17303
17414
  /**
17304
17415
  * Registers a custom IPersistSessionInstance constructor.
17305
17416
  * Clears the memoization cache so subsequent calls use the new adapter.
@@ -17317,7 +17428,7 @@ declare class PersistSessionUtils {
17317
17428
  * @param initial - Whether this is the first initialization
17318
17429
  * @returns Promise that resolves when initialization is complete
17319
17430
  */
17320
- waitForInit: (strategyName: string, exchangeName: string, frameName: string, initial: boolean) => Promise<void>;
17431
+ waitForInit: (strategyName: string, exchangeName: string, frameName: string, initial: boolean, symbol: string, backtest: boolean) => Promise<void>;
17321
17432
  /**
17322
17433
  * Reads persisted session data for the given context.
17323
17434
  * Lazily initializes the instance on first access.
@@ -17327,7 +17438,7 @@ declare class PersistSessionUtils {
17327
17438
  * @param frameName - Frame identifier
17328
17439
  * @returns Promise resolving to session data or null if none persisted
17329
17440
  */
17330
- readSessionData: (strategyName: string, exchangeName: string, frameName: string) => Promise<SessionData | null>;
17441
+ readSessionData: (strategyName: string, exchangeName: string, frameName: string, symbol: string, backtest: boolean) => Promise<SessionData | null>;
17331
17442
  /**
17332
17443
  * Writes session data for the given context.
17333
17444
  * Lazily initializes the instance on first access.
@@ -17339,7 +17450,7 @@ declare class PersistSessionUtils {
17339
17450
  * @param when - Logical timestamp this value belongs to (duplicates `data.when` for API consistency)
17340
17451
  * @returns Promise that resolves when write is complete
17341
17452
  */
17342
- writeSessionData: (data: SessionData, strategyName: string, exchangeName: string, frameName: string, when: Date) => Promise<void>;
17453
+ writeSessionData: (data: SessionData, strategyName: string, exchangeName: string, frameName: string, when: Date, symbol: string, backtest: boolean) => Promise<void>;
17343
17454
  /**
17344
17455
  * Switches to PersistSessionDummyInstance (all operations are no-ops).
17345
17456
  */
@@ -17361,7 +17472,7 @@ declare class PersistSessionUtils {
17361
17472
  * @param exchangeName - Exchange identifier
17362
17473
  * @param frameName - Frame identifier
17363
17474
  */
17364
- dispose: (strategyName: string, exchangeName: string, frameName: string) => void;
17475
+ dispose: (strategyName: string, exchangeName: string, frameName: string, symbol: string, backtest: boolean) => void;
17365
17476
  }
17366
17477
  /**
17367
17478
  * Global singleton instance of PersistSessionUtils.
@@ -25022,7 +25133,7 @@ declare class SyncMarkdownService {
25022
25133
  private readonly loggerService;
25023
25134
  private getStorage;
25024
25135
  /**
25025
- * Subscribes to `syncSubject` to start receiving `SignalSyncContract` events.
25136
+ * Subscribes to `syncSubject` to start receiving `OrderSyncContract` events.
25026
25137
  * Protected against multiple subscriptions via `singleshot` — subsequent calls
25027
25138
  * return the same unsubscribe function without re-subscribing.
25028
25139
  *
@@ -25057,7 +25168,7 @@ declare class SyncMarkdownService {
25057
25168
  */
25058
25169
  unsubscribe: () => Promise<void>;
25059
25170
  /**
25060
- * Handles a single `SignalSyncContract` event emitted by `syncSubject`.
25171
+ * Handles a single `OrderSyncContract` event emitted by `syncSubject`.
25061
25172
  *
25062
25173
  * Maps the contract fields to a `SyncEvent`, enriching it with a
25063
25174
  * `createdAt` ISO timestamp from `getContextTimestamp()` (backtest clock
@@ -25068,8 +25179,8 @@ declare class SyncMarkdownService {
25068
25179
  * Routes the constructed event to the appropriate `ReportStorage` bucket
25069
25180
  * via `getStorage(symbol, strategyName, exchangeName, frameName, backtest)`.
25070
25181
  *
25071
- * @param data - Discriminated union `SignalSyncContract`
25072
- * (`SignalOpenContract | SignalCloseContract`)
25182
+ * @param data - Discriminated union `OrderSyncContract`
25183
+ * (`OrderOpenContract | OrderCloseContract`)
25073
25184
  */
25074
25185
  private tick;
25075
25186
  /**
@@ -25350,8 +25461,8 @@ type TStorageUtilsCtor = new () => IStorageUtils;
25350
25461
  *
25351
25462
  * Features:
25352
25463
  * - Adapter pattern for swappable storage implementations
25353
- * - Default adapter: StoragePersistBacktestUtils (persistent storage)
25354
- * - Alternative adapters: StorageMemoryBacktestUtils, StorageDummyBacktestUtils
25464
+ * - Default adapter: StorageMemoryBacktestUtils (in-memory storage)
25465
+ * - Alternative adapters: StoragePersistBacktestUtils, StorageDummyBacktestUtils
25355
25466
  * - Convenience methods: usePersist(), useMemory(), useDummy()
25356
25467
  */
25357
25468
  declare class StorageBacktestAdapter implements IStorageUtils {
@@ -25898,7 +26009,7 @@ interface INotificationTarget {
25898
26009
  * Signal synchronization events for live trading (`signal_sync.open`, `signal_sync.close`).
25899
26010
  * Fired when a limit order is confirmed filled (`signal-open`) or when an open
25900
26011
  * position is confirmed exited (`signal-close`) by the exchange sync layer.
25901
- * Source: `syncSubject` (SignalSyncContract).
26012
+ * Source: `syncSubject` (OrderSyncContract).
25902
26013
  */
25903
26014
  signal_sync: boolean;
25904
26015
  /**
@@ -25969,7 +26080,7 @@ interface INotificationUtils {
25969
26080
  * Handles signal sync event (signal-open, signal-close).
25970
26081
  * @param data - The signal sync contract data
25971
26082
  */
25972
- handleSync(data: SignalSyncContract): Promise<void>;
26083
+ handleSync(data: OrderSyncContract): Promise<void>;
25973
26084
  /**
25974
26085
  * Handles risk rejection event.
25975
26086
  * @param data - The risk contract data
@@ -26061,7 +26172,7 @@ declare class NotificationBacktestAdapter implements INotificationUtils {
26061
26172
  * Proxies call to the underlying notification adapter.
26062
26173
  * @param data - The signal sync contract data
26063
26174
  */
26064
- handleSync: (data: SignalSyncContract) => any;
26175
+ handleSync: (data: OrderSyncContract) => any;
26065
26176
  /**
26066
26177
  * Handles risk rejection event.
26067
26178
  * Proxies call to the underlying notification adapter.
@@ -26182,7 +26293,7 @@ declare class NotificationLiveAdapter implements INotificationUtils {
26182
26293
  * Proxies call to the underlying notification adapter.
26183
26294
  * @param data - The signal sync contract data
26184
26295
  */
26185
- handleSync: (data: SignalSyncContract) => any;
26296
+ handleSync: (data: OrderSyncContract) => any;
26186
26297
  /**
26187
26298
  * Handles risk rejection event.
26188
26299
  * Proxies call to the underlying notification adapter.
@@ -27074,7 +27185,8 @@ declare class ExchangeUtils {
27074
27185
  /**
27075
27186
  * Fetches raw candles with flexible date/limit parameters.
27076
27187
  *
27077
- * Uses Date.now() instead of execution context when for look-ahead bias protection.
27188
+ * Look-ahead bias protection: the reference "now" is execution context `when`
27189
+ * when a context is active (backtest), otherwise the current wall-clock time.
27078
27190
  *
27079
27191
  * @param symbol - Trading pair symbol (e.g., "BTCUSDT")
27080
27192
  * @param interval - Candle interval (e.g., "1m", "1h")
@@ -29308,12 +29420,18 @@ declare class ActionBase implements IPublicAction {
29308
29420
  /**
29309
29421
  * Payload for the signal-open broker event.
29310
29422
  *
29311
- * Emitted automatically via syncSubject when a new pending signal is activated.
29312
- * Forwarded to the registered IBroker adapter via `onSignalOpenCommit`.
29423
+ * Emitted automatically via syncSubject and forwarded to the registered IBroker adapter via
29424
+ * `onOrderOpenCommit`. Discriminated by `type`:
29425
+ * - "active" — a pending signal is being opened (immediate entry or activation fill of the
29426
+ * resting order); throw = the exchange did not fill the entry, the framework rolls back the
29427
+ * open and retries on the next tick;
29428
+ * - "schedule" — the resting entry order is being PLACED (scheduled signal creation); throw =
29429
+ * the exchange did not accept the resting order, the scheduled signal is NOT registered and
29430
+ * the placement retries on the next tick.
29313
29431
  *
29314
29432
  * @example
29315
29433
  * ```typescript
29316
- * const payload: BrokerSignalOpenPayload = {
29434
+ * const payload: BrokerOrderOpenPayload = {
29317
29435
  * symbol: "BTCUSDT",
29318
29436
  * cost: 100,
29319
29437
  * position: "long",
@@ -29325,7 +29443,9 @@ declare class ActionBase implements IPublicAction {
29325
29443
  * };
29326
29444
  * ```
29327
29445
  */
29328
- type BrokerSignalOpenPayload = {
29446
+ type BrokerOrderOpenPayload = {
29447
+ /** Which order is being opened: "active" — position entry, "schedule" — resting entry order placement */
29448
+ type: "schedule" | "active";
29329
29449
  /** Trading pair symbol, e.g. "BTCUSDT" */
29330
29450
  symbol: string;
29331
29451
  /** Unique signal identifier (UUID v4) the order belongs to */
@@ -29359,11 +29479,11 @@ type BrokerSignalOpenPayload = {
29359
29479
  * Payload for the signal-close broker event.
29360
29480
  *
29361
29481
  * Emitted automatically via syncSubject when a pending signal is closed (SL/TP hit or manual close).
29362
- * Forwarded to the registered IBroker adapter via `onSignalCloseCommit`.
29482
+ * Forwarded to the registered IBroker adapter via `onOrderCloseCommit`.
29363
29483
  *
29364
29484
  * @example
29365
29485
  * ```typescript
29366
- * const payload: BrokerSignalClosePayload = {
29486
+ * const payload: BrokerOrderClosePayload = {
29367
29487
  * symbol: "BTCUSDT",
29368
29488
  * cost: 100,
29369
29489
  * position: "long",
@@ -29378,7 +29498,7 @@ type BrokerSignalOpenPayload = {
29378
29498
  * };
29379
29499
  * ```
29380
29500
  */
29381
- type BrokerSignalClosePayload = {
29501
+ type BrokerOrderClosePayload = {
29382
29502
  /** Trading pair symbol, e.g. "BTCUSDT" */
29383
29503
  symbol: string;
29384
29504
  /** Unique signal identifier (UUID v4) the order belongs to */
@@ -29415,16 +29535,25 @@ type BrokerSignalClosePayload = {
29415
29535
  backtest: boolean;
29416
29536
  };
29417
29537
  /**
29418
- * Payload for the pending-order synchronization broker event.
29538
+ * Payload for the order synchronization broker event.
29419
29539
  *
29420
- * Emitted automatically via syncPendingSubject on every live tick while a pending signal is
29421
- * monitored, BEFORE the framework evaluates TP/SL/time. Forwarded to the registered IBroker
29422
- * adapter via `onOrderCheck`.
29540
+ * Emitted automatically via syncPendingSubject on every live tick while a signal is monitored,
29541
+ * BEFORE the framework evaluates completion. Forwarded to the registered IBroker adapter,
29542
+ * routed by `type` to the matching callback:
29543
+ * - `type: "active"` — pending signal (open position), before TP/SL/time evaluation —
29544
+ * delivered to `onOrderActiveCheck`;
29545
+ * - `type: "schedule"` — scheduled signal, before timeout/price-activation evaluation
29546
+ * (the order in question is the resting entry order) — delivered to `onOrderScheduleCheck`.
29423
29547
  *
29424
29548
  * The adapter should query the exchange by `signalId` and THROW ONLY when the order is
29425
29549
  * definitively NOT FOUND by that id (filled, cancelled, or liquidated externally). A throw
29426
29550
  * propagates to CREATE_SYNC_PENDING_FN, which makes the framework close the pending signal with
29427
- * closeReason "closed". Returning normally keeps the position under normal TP/SL monitoring.
29551
+ * closeReason "closed" (type "active") or cancel the scheduled signal with reason "user"
29552
+ * (type "schedule"). Returning normally keeps the signal under normal monitoring.
29553
+ *
29554
+ * NOTE for type "schedule": if the resting entry order actually FILLED, confirm the fill via
29555
+ * `commitActivateScheduled` instead of throwing — a throw here is a terminal cancel, not an
29556
+ * activation.
29428
29557
  *
29429
29558
  * CRITICAL: transient/network errors (timeout, 5xx, rate limit, disconnect) must be SWALLOWED —
29430
29559
  * return normally instead of throwing. A thrown network error would wrongly close an open
@@ -29432,7 +29561,7 @@ type BrokerSignalClosePayload = {
29432
29561
  *
29433
29562
  * @example
29434
29563
  * ```typescript
29435
- * const payload: BrokerSignalPendingPayload = {
29564
+ * const payload: BrokerOrderCheckPayload = {
29436
29565
  * symbol: "BTCUSDT",
29437
29566
  * position: "long",
29438
29567
  * currentPrice: 50500,
@@ -29444,7 +29573,9 @@ type BrokerSignalClosePayload = {
29444
29573
  * };
29445
29574
  * ```
29446
29575
  */
29447
- type BrokerSignalPendingPayload = {
29576
+ type BrokerOrderCheckPayload = {
29577
+ /** Monitored state: "active" — open position order, "schedule" — resting entry order */
29578
+ type: "schedule" | "active";
29448
29579
  /** Trading pair symbol, e.g. "BTCUSDT" */
29449
29580
  symbol: string;
29450
29581
  /** Unique signal identifier (UUID v4) the order belongs to */
@@ -29483,7 +29614,7 @@ type BrokerSignalPendingPayload = {
29483
29614
  *
29484
29615
  * Emitted automatically via activePingSubject on every live tick while a pending (open) signal is
29485
29616
  * monitored. Forwarded to the registered IBroker adapter via `onSignalActivePing`. Purely
29486
- * informational — unlike `onOrderCheck` a throw here does NOT close the position.
29617
+ * informational — unlike `onOrderActiveCheck` a throw here does NOT close the position.
29487
29618
  *
29488
29619
  * @example
29489
29620
  * ```typescript
@@ -29607,7 +29738,7 @@ type BrokerIdlePingPayload = {
29607
29738
  * Emitted automatically via scheduleEventSubject (action "scheduled") when a new scheduled signal is
29608
29739
  * created and starts waiting for priceOpen activation. Forwarded to the registered IBroker adapter
29609
29740
  * via `onSignalScheduleOpen`. The scheduled -> active transition is NOT reported here — activation
29610
- * arrives through `onSignalOpenCommit`.
29741
+ * arrives through `onOrderOpenCommit`.
29611
29742
  *
29612
29743
  * @example
29613
29744
  * ```typescript
@@ -30065,7 +30196,7 @@ type BrokerAverageBuyPayload = {
30065
30196
  * async waitForInit() {
30066
30197
  * await this.exchange.connect();
30067
30198
  * }
30068
- * async onSignalOpenCommit(payload) {
30199
+ * async onOrderOpenCommit(payload) {
30069
30200
  * await this.exchange.placeOrder({ symbol: payload.symbol, side: payload.position });
30070
30201
  * }
30071
30202
  * // ... other methods
@@ -30082,7 +30213,7 @@ interface IBroker {
30082
30213
  * syncSubject BEFORE the framework mutates strategy state, so it is also the close **gate**.
30083
30214
  *
30084
30215
  * MANUAL WIRING — EXCEPTION-BASED: place the real exit order here (tag/look up by `payload.signalId`)
30085
- * and record final PnL. This is the confirmed-close commit; like `onSignalSync` (signal-close) it
30216
+ * and record final PnL. This is the confirmed-close commit; like `onOrderSync` (signal-close) it
30086
30217
  * shares the gate semantics — a THROW means "the exchange did not close the position" and the
30087
30218
  * framework SKIPS the close, leaving the position open and retrying on the next tick. Return
30088
30219
  * normally to let the close proceed. Backtest short-circuits this (no live exchange), so the gate is
@@ -30091,28 +30222,32 @@ interface IBroker {
30091
30222
  * This differs from `onSignalPendingClose`, which is the informational lifecycle hook that fires
30092
30223
  * AFTER the close is committed (and cannot veto it).
30093
30224
  */
30094
- onSignalCloseCommit(payload: BrokerSignalClosePayload): Promise<void>;
30225
+ onOrderCloseCommit(payload: BrokerOrderClosePayload): Promise<void>;
30095
30226
  /**
30096
- * Called when a signal is being opened (position entry). Emitted via syncSubject BEFORE the
30097
- * framework mutates strategy state, so it is also the open **gate**.
30227
+ * Called when an order is being opened. Emitted via syncSubject BEFORE the framework mutates
30228
+ * strategy state, so it is also the open **gate**. Discriminated by `payload.type`:
30229
+ * - "active" — position entry (immediate open or activation fill of the resting order);
30230
+ * - "schedule" — PLACEMENT of the resting entry order at scheduled-signal creation.
30098
30231
  *
30099
- * MANUAL WIRING — EXCEPTION-BASED: place the real entry order here (tag the exchange order with
30100
- * `payload.signalId` so later `onOrderCheck` / `onSignalActivePing` can find it). Like `onSignalSync`
30101
- * (signal-open) it shares the gate semantics — a THROW means "the exchange did not fill the entry"
30102
- * (e.g. limit order rejected) and the framework ROLLS BACK the open: the pending signal returns to
30103
- * idle (a scheduled activation is cancelled) and is retried on the next tick. Return normally to let
30104
- * the open proceed. Also the point where a scheduled signal's activation surfaces. Backtest
30105
- * short-circuits this, so the gate is live-only.
30232
+ * MANUAL WIRING — EXCEPTION-BASED: place the real order here (tag the exchange order with
30233
+ * `payload.signalId` so later `onOrderActiveCheck` / `onOrderScheduleCheck` / `onSignalActivePing` can find it). Like `onOrderSync`
30234
+ * (signal-open) it shares the gate semantics — a THROW means "the exchange did not accept/fill the
30235
+ * order" and the framework ROLLS BACK: for type "active" the pending signal returns to idle (a
30236
+ * scheduled activation is cancelled); for type "schedule" the scheduled signal is NOT registered
30237
+ * and the risk reservation is released. Both retry on the next tick. Return normally to let the
30238
+ * open proceed. Backtest short-circuits this, so the gate is live-only.
30106
30239
  *
30107
30240
  * This differs from `onSignalPendingOpen`, which is the informational lifecycle hook that fires
30108
30241
  * AFTER the open is committed (and cannot veto it).
30109
30242
  */
30110
- onSignalOpenCommit(payload: BrokerSignalOpenPayload): Promise<void>;
30243
+ onOrderOpenCommit(payload: BrokerOrderOpenPayload): Promise<void>;
30111
30244
  /**
30112
- * Called on every live tick while a pending signal is monitored, BEFORE TP/SL/time evaluation.
30245
+ * Called on every live tick while a pending signal (open position) is monitored,
30246
+ * BEFORE TP/SL/time evaluation (`payload.type` is always "active").
30247
+ *
30113
30248
  * Query the exchange by `payload.signalId` and THROW ONLY when the order is NOT FOUND by that id
30114
- * — the framework will then close the position with closeReason "closed". Return normally to keep
30115
- * monitoring.
30249
+ * — the framework will then close the position with closeReason "closed". Return normally to
30250
+ * keep monitoring.
30116
30251
  *
30117
30252
  * CRITICAL: swallow transient/network errors (timeout, 5xx, rate limit, disconnect) — return
30118
30253
  * normally instead of throwing, otherwise a connectivity blip would wrongly close an open
@@ -30133,7 +30268,7 @@ interface IBroker {
30133
30268
  *
30134
30269
  * @example
30135
30270
  * ```typescript
30136
- * async onOrderCheck(payload: BrokerSignalPendingPayload) {
30271
+ * async onOrderActiveCheck(payload: BrokerOrderCheckPayload) {
30137
30272
  * let order: Order | null;
30138
30273
  * try {
30139
30274
  * order = await this.exchange.getOrderById(payload.signalId);
@@ -30146,11 +30281,45 @@ interface IBroker {
30146
30281
  * }
30147
30282
  * ```
30148
30283
  */
30149
- onOrderCheck(payload: BrokerSignalPendingPayload): Promise<void>;
30284
+ onOrderActiveCheck(payload: BrokerOrderCheckPayload): Promise<void>;
30285
+ /**
30286
+ * Called on every live tick while a scheduled signal (resting entry order) is monitored,
30287
+ * BEFORE timeout/price-activation evaluation (`payload.type` is always "schedule").
30288
+ *
30289
+ * Query the exchange by `payload.signalId` and THROW ONLY when the resting order is NOT FOUND
30290
+ * by that id — the framework will then cancel the scheduled signal with reason "user". Return
30291
+ * normally to keep monitoring. A FILLED resting order must be confirmed via
30292
+ * `commitActivateScheduled`, not by throwing here (a throw is a terminal cancel, not an
30293
+ * activation).
30294
+ *
30295
+ * CRITICAL: swallow transient/network errors (timeout, 5xx, rate limit, disconnect) — return
30296
+ * normally instead of throwing, otherwise a connectivity blip would wrongly cancel the resting
30297
+ * order. Throw exclusively on a confirmed "order not found by id" result.
30298
+ *
30299
+ * Manual wiring — EXCEPTION-BASED VARIANT: the throw-driven alternative to the imperative
30300
+ * commit-function wiring in `onSignalSchedulePing` (`commitActivateScheduled` /
30301
+ * `commitCancelScheduled`). Pick ONE per condition.
30302
+ *
30303
+ * @example
30304
+ * ```typescript
30305
+ * async onOrderScheduleCheck(payload: BrokerOrderCheckPayload) {
30306
+ * let order: Order | null;
30307
+ * try {
30308
+ * order = await this.exchange.getOrderById(payload.signalId);
30309
+ * } catch (networkError) {
30310
+ * return; // transient — keep the resting order monitored, retry next tick
30311
+ * }
30312
+ * if (!order) {
30313
+ * throw new Error(`Order ${payload.signalId} not found`); // confirmed gone -> cancel "user"
30314
+ * }
30315
+ * }
30316
+ * ```
30317
+ */
30318
+ onOrderScheduleCheck(payload: BrokerOrderCheckPayload): Promise<void>;
30150
30319
  /**
30151
30320
  * Called on every live tick while a pending (open) signal is monitored.
30152
30321
  * Purely informational mirror of the active-ping lifecycle — a throw here does NOT close the
30153
- * position (unlike `onOrderCheck`).
30322
+ * position (unlike `onOrderActiveCheck`).
30154
30323
  *
30155
30324
  * Manual wiring — EVENT-BASED (driving an open position from real exchange state)
30156
30325
  *
@@ -30194,7 +30363,7 @@ interface IBroker {
30194
30363
  * Poll your real resting/limit order and translate it via the commit-functions from
30195
30364
  * `src/function/strategy.ts` (deferred to the next tick):
30196
30365
  * - `commitActivateScheduled(symbol, { id })` — resting order filled/resolved → activate now,
30197
- * without waiting for VWAP to reach priceOpen (surfaces as `onSignalOpenCommit` next tick).
30366
+ * without waiting for VWAP to reach priceOpen (surfaces as `onOrderOpenCommit` next tick).
30198
30367
  * - `commitCancelScheduled(symbol, { id })` — resting order cancelled/rejected externally → drop it.
30199
30368
  *
30200
30369
  * @example
@@ -30222,7 +30391,7 @@ interface IBroker {
30222
30391
  onSignalIdlePing(payload: BrokerIdlePingPayload): Promise<void>;
30223
30392
  /**
30224
30393
  * Called when a new scheduled signal is created and starts waiting for priceOpen activation.
30225
- * The scheduled -> active transition is reported via `onSignalOpenCommit`, not here.
30394
+ * The scheduled -> active transition is reported via `onOrderOpenCommit`, not here.
30226
30395
  *
30227
30396
  * Manual wiring — EVENT-BASED (placing the resting order)
30228
30397
  *
@@ -30274,7 +30443,7 @@ interface IBroker {
30274
30443
  *
30275
30444
  * Fires ONCE at open — place the real entry confirmation and protective TP/SL orders (tag them with
30276
30445
  * `payload.signalId`). Drive the rest per-tick from `onSignalActivePing`. This hook does not gate
30277
- * the position; for a true entry gate use `onSignalSync` (signal-open).
30446
+ * the position; for a true entry gate use `onOrderSync` (signal-open).
30278
30447
  */
30279
30448
  onSignalPendingOpen(payload: BrokerPendingOpenPayload): Promise<void>;
30280
30449
  /**
@@ -30319,7 +30488,7 @@ interface IBroker {
30319
30488
  * @example
30320
30489
  * ```typescript
30321
30490
  * class MyBroker implements Partial<IBroker> {
30322
- * async onSignalOpenCommit(payload: BrokerSignalOpenPayload) { ... }
30491
+ * async onOrderOpenCommit(payload: BrokerOrderOpenPayload) { ... }
30323
30492
  * }
30324
30493
  *
30325
30494
  * Broker.useBrokerAdapter(MyBroker); // MyBroker satisfies TBrokerCtor
@@ -30379,7 +30548,7 @@ declare class BrokerAdapter {
30379
30548
  *
30380
30549
  * @example
30381
30550
  * ```typescript
30382
- * await Broker.commitSignalOpen({
30551
+ * await Broker.commitOrderOpen({
30383
30552
  * symbol: "BTCUSDT",
30384
30553
  * cost: 100,
30385
30554
  * position: "long",
@@ -30391,7 +30560,7 @@ declare class BrokerAdapter {
30391
30560
  * });
30392
30561
  * ```
30393
30562
  */
30394
- commitSignalOpen: (payload: BrokerSignalOpenPayload) => Promise<void>;
30563
+ commitOrderOpen: (payload: BrokerOrderOpenPayload) => Promise<void>;
30395
30564
  /**
30396
30565
  * Forwards a signal-close event to the registered broker adapter.
30397
30566
  *
@@ -30402,7 +30571,7 @@ declare class BrokerAdapter {
30402
30571
  *
30403
30572
  * @example
30404
30573
  * ```typescript
30405
- * await Broker.commitSignalClose({
30574
+ * await Broker.commitOrderClose({
30406
30575
  * symbol: "BTCUSDT",
30407
30576
  * cost: 100,
30408
30577
  * position: "long",
@@ -30417,18 +30586,21 @@ declare class BrokerAdapter {
30417
30586
  * });
30418
30587
  * ```
30419
30588
  */
30420
- commitSignalClose: (payload: BrokerSignalClosePayload) => Promise<void>;
30589
+ commitOrderClose: (payload: BrokerOrderClosePayload) => Promise<void>;
30421
30590
  /**
30422
- * Forwards a pending-order ping to the registered broker adapter.
30591
+ * Forwards an order ping to the registered broker adapter.
30423
30592
  *
30424
30593
  * Called automatically via syncPendingSubject when `enable()` is active, on every live tick
30425
- * while a pending signal is monitored. Skipped silently in backtest mode or when no adapter is
30426
- * registered. Exceptions are NOT swallowed: a throw from the adapter propagates up to
30427
- * syncPendingSubject.next() CREATE_SYNC_PENDING_FN, which closes the position with "closed".
30594
+ * while a pending signal (payload.type "active") or a scheduled signal (payload.type
30595
+ * "schedule") is monitored routed to `onOrderActiveCheck` / `onOrderScheduleCheck`
30596
+ * respectively. Skipped silently in backtest mode or when no adapter is registered.
30597
+ * Exceptions are NOT swallowed: a throw from the adapter propagates up to
30598
+ * syncPendingSubject.next() → CREATE_SYNC_PENDING_FN, which closes the position with "closed"
30599
+ * (type "active") or cancels the scheduled signal with reason "user" (type "schedule").
30428
30600
  *
30429
- * @param payload - Pending ping details: symbol, position, prices, pnl, context, backtest flag
30601
+ * @param payload - Order ping details: type, symbol, position, prices, pnl, context, backtest flag
30430
30602
  */
30431
- commitSignalPending: (payload: BrokerSignalPendingPayload) => Promise<void>;
30603
+ commitOrderCheck: (payload: BrokerOrderCheckPayload) => Promise<void>;
30432
30604
  /**
30433
30605
  * Forwards an active-ping to the registered broker adapter.
30434
30606
  *
@@ -30474,6 +30646,14 @@ declare class BrokerAdapter {
30474
30646
  * Called automatically via scheduleEventSubject (action "cancelled") when a scheduled signal is
30475
30647
  * removed before activation. Skipped silently in backtest mode or when no adapter is registered.
30476
30648
  *
30649
+ * IMPORTANT (adapter responsibility): the cancel may race the real fill. The framework decides
30650
+ * to drop the scheduled signal from ITS view (risk reject at activation, sync reject, stop,
30651
+ * timeout), but the resting limit order on the exchange may have ALREADY filled by the time this
30652
+ * arrives. The adapter MUST check the actual order status before cancelling: if the order is
30653
+ * filled, cancelling is a no-op on the exchange and the adapter owns the resulting position
30654
+ * (close it or reconcile via onOrderActiveCheck / onSignalActivePing). The framework cannot model
30655
+ * this case — from its side the signal is terminally cancelled.
30656
+ *
30477
30657
  * @param payload - Scheduled cancel details: symbol, signalId, position, prices, reason, context, backtest
30478
30658
  */
30479
30659
  commitScheduleCancelled: (payload: BrokerScheduleCancelledPayload) => Promise<void>;
@@ -30733,8 +30913,8 @@ declare class BrokerAdapter {
30733
30913
  * 4. No explicit dispose — clean up in `waitForInit` teardown or externally
30734
30914
  *
30735
30915
  * Event flow (called only in live mode, skipped in backtest):
30736
- * - `onSignalOpenCommit` — new position opened
30737
- * - `onSignalCloseCommit` — position closed (SL/TP hit or manual close)
30916
+ * - `onOrderOpenCommit` — new position opened
30917
+ * - `onOrderCloseCommit` — position closed (SL/TP hit or manual close)
30738
30918
  * - `onPartialProfitCommit` — partial close at profit executed
30739
30919
  * - `onPartialLossCommit` — partial close at loss executed
30740
30920
  * - `onTrailingStopCommit` — trailing stop-loss updated
@@ -30756,8 +30936,8 @@ declare class BrokerAdapter {
30756
30936
  * await this.client.connect();
30757
30937
  * }
30758
30938
  *
30759
- * async onSignalOpenCommit(payload: BrokerSignalOpenPayload) {
30760
- * super.onSignalOpenCommit(payload); // Call parent for logging
30939
+ * async onOrderOpenCommit(payload: BrokerOrderOpenPayload) {
30940
+ * super.onOrderOpenCommit(payload); // Call parent for logging
30761
30941
  * await this.client!.placeOrder({
30762
30942
  * symbol: payload.symbol,
30763
30943
  * side: payload.position === "long" ? "BUY" : "SELL",
@@ -30765,8 +30945,8 @@ declare class BrokerAdapter {
30765
30945
  * });
30766
30946
  * }
30767
30947
  *
30768
- * async onSignalCloseCommit(payload: BrokerSignalClosePayload) {
30769
- * super.onSignalCloseCommit(payload); // Call parent for logging
30948
+ * async onOrderCloseCommit(payload: BrokerOrderClosePayload) {
30949
+ * super.onOrderCloseCommit(payload); // Call parent for logging
30770
30950
  * await this.client!.closePosition(payload.symbol);
30771
30951
  * }
30772
30952
  * }
@@ -30780,11 +30960,11 @@ declare class BrokerAdapter {
30780
30960
  * ```typescript
30781
30961
  * // Minimal implementation — only handle opens and closes
30782
30962
  * class NotifyBroker extends BrokerBase {
30783
- * async onSignalOpenCommit(payload: BrokerSignalOpenPayload) {
30963
+ * async onOrderOpenCommit(payload: BrokerOrderOpenPayload) {
30784
30964
  * await sendTelegram(`Opened ${payload.position} on ${payload.symbol}`);
30785
30965
  * }
30786
30966
  *
30787
- * async onSignalCloseCommit(payload: BrokerSignalClosePayload) {
30967
+ * async onOrderCloseCommit(payload: BrokerOrderClosePayload) {
30788
30968
  * const pnl = payload.pnl.profit - payload.pnl.loss;
30789
30969
  * await sendTelegram(`Closed ${payload.symbol}: PnL $${pnl.toFixed(2)}`);
30790
30970
  * }
@@ -30821,14 +31001,14 @@ declare class BrokerBase implements IBroker {
30821
31001
  * Manual wiring — EXCEPTION-BASED GATE: emitted BEFORE the framework mutates state, so a THROW here
30822
31002
  * (e.g. limit order rejected) rolls back the open — the pending signal returns to idle and retries
30823
31003
  * next tick; return normally to let it open. Live-only (backtest short-circuits). See
30824
- * {@link IBroker.onSignalOpenCommit} for the full semantics.
31004
+ * {@link IBroker.onOrderOpenCommit} for the full semantics.
30825
31005
  *
30826
31006
  * @param payload - Signal open details: symbol, cost, position, priceOpen, priceTakeProfit, priceStopLoss, context, backtest
30827
31007
  *
30828
31008
  * @example
30829
31009
  * ```typescript
30830
- * async onSignalOpenCommit(payload: BrokerSignalOpenPayload) {
30831
- * super.onSignalOpenCommit(payload); // Keep parent logging
31010
+ * async onOrderOpenCommit(payload: BrokerOrderOpenPayload) {
31011
+ * super.onOrderOpenCommit(payload); // Keep parent logging
30832
31012
  * const order = await this.exchange.placeMarketOrder({
30833
31013
  * symbol: payload.symbol,
30834
31014
  * side: payload.position === "long" ? "BUY" : "SELL",
@@ -30840,9 +31020,10 @@ declare class BrokerBase implements IBroker {
30840
31020
  * }
30841
31021
  * ```
30842
31022
  */
30843
- onSignalOpenCommit(payload: BrokerSignalOpenPayload): Promise<void>;
31023
+ onOrderOpenCommit(payload: BrokerOrderOpenPayload): Promise<void>;
30844
31024
  /**
30845
- * Called on every live tick while a pending signal is monitored, BEFORE TP/SL/time evaluation.
31025
+ * Called on every live tick while a pending signal (open position) is monitored, BEFORE
31026
+ * TP/SL/time evaluation.
30846
31027
  *
30847
31028
  * Override to query the exchange for the order by `payload.signalId` and THROW ONLY when it is
30848
31029
  * definitively NOT FOUND by that id (filled, cancelled, or liquidated externally) — the framework
@@ -30854,16 +31035,36 @@ declare class BrokerBase implements IBroker {
30854
31035
  * a confirmed "order not found by id" response is a valid reason to throw.
30855
31036
  *
30856
31037
  * Manual wiring — EXCEPTION-BASED VARIANT: the throw-driven alternative to the imperative
30857
- * commit-function wiring in `onSignalActivePing`. See {@link IBroker.onOrderCheck} for the full
30858
- * comparison and example.
31038
+ * commit-function wiring in `onSignalActivePing`. See {@link IBroker.onOrderActiveCheck} for the
31039
+ * full comparison and example.
31040
+ *
31041
+ * @param payload - Pending ping details: symbol, signalId, position, prices, pnl, context, backtest
31042
+ */
31043
+ onOrderActiveCheck(payload: BrokerOrderCheckPayload): Promise<void>;
31044
+ /**
31045
+ * Called on every live tick while a scheduled signal (resting entry order) is monitored, BEFORE
31046
+ * timeout/price-activation evaluation.
31047
+ *
31048
+ * Override to query the exchange for the resting order by `payload.signalId` and THROW ONLY when
31049
+ * it is definitively NOT FOUND by that id — the framework then cancels the scheduled signal with
31050
+ * reason "user". The default implementation logs and returns normally. A FILLED resting order
31051
+ * must be confirmed via `commitActivateScheduled`, not by throwing here.
31052
+ *
31053
+ * CRITICAL: swallow transient/network errors (timeout, 5xx, rate limit, disconnect) — return
31054
+ * normally instead of throwing; only a confirmed "order not found by id" response is a valid
31055
+ * reason to throw.
31056
+ *
31057
+ * Manual wiring — EXCEPTION-BASED VARIANT: the throw-driven alternative to the imperative
31058
+ * commit-function wiring in `onSignalSchedulePing`. See {@link IBroker.onOrderScheduleCheck} for
31059
+ * the full comparison and example.
30859
31060
  *
30860
31061
  * @param payload - Pending ping details: symbol, signalId, position, prices, pnl, context, backtest
30861
31062
  */
30862
- onOrderCheck(payload: BrokerSignalPendingPayload): Promise<void>;
31063
+ onOrderScheduleCheck(payload: BrokerOrderCheckPayload): Promise<void>;
30863
31064
  /**
30864
31065
  * Called on every live tick while a pending (open) signal is monitored.
30865
31066
  *
30866
- * Purely informational mirror of the active-ping lifecycle — unlike `onOrderCheck`, a throw here
31067
+ * Purely informational mirror of the active-ping lifecycle — unlike `onOrderActiveCheck`, a throw here
30867
31068
  * does NOT close the position. Override to mirror live monitoring state into your own systems.
30868
31069
  * The default implementation logs.
30869
31070
  *
@@ -30897,7 +31098,7 @@ declare class BrokerBase implements IBroker {
30897
31098
  /**
30898
31099
  * Called when a new scheduled signal is created and starts waiting for priceOpen activation.
30899
31100
  *
30900
- * The scheduled -> active transition is reported via `onSignalOpenCommit`, not here. Override to
31101
+ * The scheduled -> active transition is reported via `onOrderOpenCommit`, not here. Override to
30901
31102
  * place a resting/limit order on the exchange. The default logs.
30902
31103
  *
30903
31104
  * Manual wiring — EVENT-BASED: fires ONCE at creation — place the real resting order (tag it with
@@ -30953,14 +31154,14 @@ declare class BrokerBase implements IBroker {
30953
31154
  * Manual wiring — EXCEPTION-BASED GATE: emitted BEFORE the framework mutates state, so a THROW here
30954
31155
  * (e.g. exit order failed) SKIPS the close — the position stays open and the close retries next
30955
31156
  * tick; return normally to let it close. Live-only (backtest short-circuits). See
30956
- * {@link IBroker.onSignalCloseCommit} for the full semantics.
31157
+ * {@link IBroker.onOrderCloseCommit} for the full semantics.
30957
31158
  *
30958
31159
  * @param payload - Signal close details: symbol, cost, position, currentPrice, pnl, totalEntries, totalPartials, context, backtest
30959
31160
  *
30960
31161
  * @example
30961
31162
  * ```typescript
30962
- * async onSignalCloseCommit(payload: BrokerSignalClosePayload) {
30963
- * super.onSignalCloseCommit(payload); // Keep parent logging
31163
+ * async onOrderCloseCommit(payload: BrokerOrderClosePayload) {
31164
+ * super.onOrderCloseCommit(payload); // Keep parent logging
30964
31165
  * const ok = await this.exchange.closePosition(payload.symbol);
30965
31166
  * if (!ok) {
30966
31167
  * throw new Error(`Exit not filled for ${payload.symbol}`); // -> keep position open, retry next tick
@@ -30969,7 +31170,7 @@ declare class BrokerBase implements IBroker {
30969
31170
  * }
30970
31171
  * ```
30971
31172
  */
30972
- onSignalCloseCommit(payload: BrokerSignalClosePayload): Promise<void>;
31173
+ onOrderCloseCommit(payload: BrokerOrderClosePayload): Promise<void>;
30973
31174
  /**
30974
31175
  * Called when a partial close at profit is executed.
30975
31176
  *
@@ -31162,7 +31363,7 @@ interface WalkerStopContract {
31162
31363
  * This ensures that the framework's internal state remains consistent with the exchange's state.
31163
31364
  * Consumers should implement retry logic in their listeners to handle transient synchronization failures.
31164
31365
  */
31165
- declare const syncSubject: Subject<SignalSyncContract>;
31366
+ declare const syncSubject: Subject<OrderSyncContract>;
31166
31367
  /**
31167
31368
  * Pending-order synchronization emitter.
31168
31369
  * Emitted on every live tick while a pending signal is monitored, BEFORE TP/SL/time evaluation.
@@ -31171,7 +31372,7 @@ declare const syncSubject: Subject<SignalSyncContract>;
31171
31372
  * If a listener returns false OR throws, the order is treated as no longer open on the exchange
31172
31373
  * and the framework closes the pending signal with closeReason "closed". Never emitted in backtest.
31173
31374
  */
31174
- declare const syncPendingSubject: Subject<SignalPingContract>;
31375
+ declare const syncPendingSubject: Subject<OrderCheckContract>;
31175
31376
  /**
31176
31377
  * Global signal emitter for all trading events (live + backtest).
31177
31378
  * Emits all signal events regardless of execution mode.
@@ -31446,10 +31647,13 @@ declare const waitForCandle: (interval: CandleInterval) => Promise<number>;
31446
31647
  * @param {string | number} price - The price to round, can be a string or number
31447
31648
  * @param {number} tickSize - The tick size that determines the precision (e.g., 0.01 for 2 decimal places)
31448
31649
  * @returns {string} The price rounded to the precision specified by the tick size
31650
+ * @throws {Error} If tickSize is not a positive finite number
31449
31651
  *
31450
31652
  * @example
31451
31653
  * roundTicks(123.456789, 0.01) // returns "123.46"
31452
31654
  * roundTicks("100.12345", 0.001) // returns "100.123"
31655
+ * roundTicks(123.456789, 1) // returns "123"
31656
+ * roundTicks(123.456789, 1e-9) // returns "123.456789000"
31453
31657
  */
31454
31658
  declare const roundTicks: (price: string | number, tickSize: number) => string;
31455
31659
 
@@ -31607,69 +31811,113 @@ declare const set: (object: any, path: any, value: any) => boolean;
31607
31811
 
31608
31812
  /**
31609
31813
  * Calculate the percentage difference between two numbers.
31814
+ *
31815
+ * The result is how many percent the larger value exceeds the smaller one:
31816
+ * percentDiff(100, 150) === 50, percentDiff(150, 100) === 50.
31817
+ *
31818
+ * Edge cases are reported honestly instead of a sentinel value:
31819
+ * - Both values equal (including 0, 0) — returns 0.
31820
+ * - One value is 0 and the other is not — returns Infinity
31821
+ * (the difference is unbounded; no finite percent can express it).
31822
+ *
31610
31823
  * @param {number} a - The first number.
31611
31824
  * @param {number} b - The second number.
31612
31825
  * @returns {number} The percentage difference between the two numbers.
31613
31826
  */
31614
- declare const percentDiff: (a?: number, b?: number) => number;
31827
+ declare const percentDiff: (a: number, b: number) => number;
31615
31828
 
31616
31829
  /**
31617
31830
  * Calculate the percentage change from yesterday's value to today's value.
31618
- * @param {number} yesterdayValue - The value from yesterday.
31831
+ *
31832
+ * Formula: ((todayValue - yesterdayValue) / yesterdayValue) * 100
31833
+ *
31834
+ * Positive result — value grew, negative — value dropped.
31835
+ *
31836
+ * @param {number} yesterdayValue - The value from yesterday (base of comparison).
31619
31837
  * @param {number} todayValue - The value from today.
31620
- * @returns {number} The percentage change from yesterday to today.
31838
+ * @returns {number} The percentage change from yesterday to today (e.g. 5 for +5%).
31839
+ *
31840
+ * @example
31841
+ * percentValue(100, 105); // 5
31842
+ * percentValue(100, 95); // -5
31621
31843
  */
31622
31844
  declare const percentValue: (yesterdayValue: number, todayValue: number) => number;
31623
31845
 
31624
31846
  /**
31625
- * Convert an absolute dollar amount to a percentage of the invested position cost.
31847
+ * Convert an absolute dollar amount to a percentage of a cost basis.
31626
31848
  * Use the result as the `percent` argument to `commitPartialProfit` / `commitPartialLoss`.
31627
31849
  *
31850
+ * IMPORTANT: `percentToClose` in partial closes is applied to the REMAINING
31851
+ * cost basis (what is still held after prior partials), not to the total
31852
+ * invested amount. To close an exact dollar amount, pass the remaining cost
31853
+ * basis from `getTotalCostClosed` as `costBasis` — not `getPositionInvestedCost`.
31854
+ *
31628
31855
  * @param dollarAmount - Dollar value to close (e.g. 150)
31629
- * @param investedCost - Total invested cost from `getPositionInvestedCost` (e.g. 300)
31630
- * @returns Percentage of the position to close (0–100)
31856
+ * @param costBasis - Remaining cost basis from `getTotalCostClosed` (e.g. 300)
31857
+ * @returns Percentage of the remaining position to close (0–100)
31631
31858
  *
31632
31859
  * @example
31633
- * const percent = investedCostToPercent(150, 300); // 50
31860
+ * const remaining = await getTotalCostClosed("BTCUSDT"); // e.g. 300
31861
+ * const percent = investedCostToPercent(150, remaining); // 50
31634
31862
  * await commitPartialProfit("BTCUSDT", percent);
31635
31863
  */
31636
- declare const investedCostToPercent: (dollarAmount: number, investedCost: number) => number;
31864
+ declare const investedCostToPercent: (dollarAmount: number, costBasis: number) => number;
31637
31865
 
31638
31866
  /**
31639
31867
  * Convert an absolute stop-loss price to a percentShift for `commitTrailingStop`.
31640
31868
  *
31641
31869
  * percentShift = newSlDistancePercent - originalSlDistancePercent
31642
- * where distance = Math.abs((effectivePriceOpen - slPrice) / effectivePriceOpen * 100)
31870
+ *
31871
+ * The new distance is SIGNED by position direction (mirrors how ClientStrategy
31872
+ * applies the shift): a stop-loss moved past the entry into the profit zone
31873
+ * produces a negative distance, so any target price is expressible —
31874
+ * `slPercentShiftToPrice(slPriceToPercentShift(x, ...), ...) === x` holds for
31875
+ * targets on both sides of the entry.
31876
+ *
31877
+ * LONG: newSlDistancePercent = (effectivePriceOpen - newStopLossPrice) / effectivePriceOpen * 100
31878
+ * SHORT: newSlDistancePercent = (newStopLossPrice - effectivePriceOpen) / effectivePriceOpen * 100
31643
31879
  *
31644
31880
  * @param newStopLossPrice - Desired absolute stop-loss price
31645
31881
  * @param originalStopLossPrice - Original stop-loss price from the pending signal
31646
31882
  * @param effectivePriceOpen - Effective entry price (from `getPositionEffectivePrice`)
31883
+ * @param position - Position direction: "long" or "short"
31647
31884
  * @returns percentShift to pass to `commitTrailingStop`
31648
31885
  *
31649
31886
  * @example
31650
31887
  * // LONG: entry=100, originalSL=90, desired newSL=95
31651
- * const shift = slPriceToPercentShift(95, 90, 100); // -5
31888
+ * const shift = slPriceToPercentShift(95, 90, 100, "long"); // -5
31889
+ * // LONG: entry=100, originalSL=90, desired newSL=105 (profit zone)
31890
+ * const shiftProfit = slPriceToPercentShift(105, 90, 100, "long"); // -15
31652
31891
  * await commitTrailingStop("BTCUSDT", shift, currentPrice);
31653
31892
  */
31654
- declare const slPriceToPercentShift: (newStopLossPrice: number, originalStopLossPrice: number, effectivePriceOpen: number) => number;
31893
+ declare const slPriceToPercentShift: (newStopLossPrice: number, originalStopLossPrice: number, effectivePriceOpen: number, position: "long" | "short") => number;
31655
31894
 
31656
31895
  /**
31657
31896
  * Convert an absolute take-profit price to a percentShift for `commitTrailingTake`.
31658
31897
  *
31659
31898
  * percentShift = newTpDistancePercent - originalTpDistancePercent
31660
- * where distance = Math.abs((tpPrice - effectivePriceOpen) / effectivePriceOpen * 100)
31899
+ *
31900
+ * The new distance is SIGNED by position direction (mirrors how ClientStrategy
31901
+ * applies the shift): a take-profit moved past the entry produces a negative
31902
+ * distance, so any target price is expressible —
31903
+ * `tpPercentShiftToPrice(tpPriceToPercentShift(x, ...), ...) === x` holds for
31904
+ * targets on both sides of the entry.
31905
+ *
31906
+ * LONG: newTpDistancePercent = (newTakeProfitPrice - effectivePriceOpen) / effectivePriceOpen * 100
31907
+ * SHORT: newTpDistancePercent = (effectivePriceOpen - newTakeProfitPrice) / effectivePriceOpen * 100
31661
31908
  *
31662
31909
  * @param newTakeProfitPrice - Desired absolute take-profit price
31663
31910
  * @param originalTakeProfitPrice - Original take-profit price from the pending signal
31664
31911
  * @param effectivePriceOpen - Effective entry price (from `getPositionEffectivePrice`)
31912
+ * @param position - Position direction: "long" or "short"
31665
31913
  * @returns percentShift to pass to `commitTrailingTake`
31666
31914
  *
31667
31915
  * @example
31668
31916
  * // LONG: entry=100, originalTP=110, desired newTP=107
31669
- * const shift = tpPriceToPercentShift(107, 110, 100); // -3
31917
+ * const shift = tpPriceToPercentShift(107, 110, 100, "long"); // -3
31670
31918
  * await commitTrailingTake("BTCUSDT", shift, currentPrice);
31671
31919
  */
31672
- declare const tpPriceToPercentShift: (newTakeProfitPrice: number, originalTakeProfitPrice: number, effectivePriceOpen: number) => number;
31920
+ declare const tpPriceToPercentShift: (newTakeProfitPrice: number, originalTakeProfitPrice: number, effectivePriceOpen: number, position: "long" | "short") => number;
31673
31921
 
31674
31922
  /**
31675
31923
  * Convert a percentShift for `commitTrailingStop` back to an absolute stop-loss price.
@@ -31881,7 +32129,9 @@ declare class ClientExchange implements IExchange {
31881
32129
  * @param symbol - Trading pair symbol
31882
32130
  * @param interval - Candle interval
31883
32131
  * @param limit - Number of candles to fetch
31884
- * @returns Promise resolving to array of candles
32132
+ * @returns Promise resolving to array of candles; an EMPTY array when the
32133
+ * requested range extends beyond Date.now() (those candles have not
32134
+ * closed yet in the real world — the caller decides how to proceed)
31885
32135
  * @throws Error if trying to fetch future candles in live mode
31886
32136
  */
31887
32137
  getNextCandles(symbol: string, interval: CandleInterval, limit: number): Promise<ICandleData[]>;
@@ -32222,10 +32472,20 @@ declare class ClientRisk implements IRisk {
32222
32472
  readonly params: IRiskParams;
32223
32473
  /**
32224
32474
  * Map of active positions tracked across all strategies.
32225
- * Key: `${strategyName}:${exchangeName}:${symbol}`
32475
+ * Key: `${strategyName}_${exchangeName}_${symbol}` (see CREATE_NAME_FN)
32226
32476
  * Starts as POSITION_NEED_FETCH symbol, gets initialized on first use.
32227
32477
  */
32228
32478
  _activePositions: RiskMap | typeof POSITION_NEED_FETCH;
32479
+ /**
32480
+ * Keys of transient reservation placeholders (checkSignalAndReserve) still
32481
+ * awaiting their finalizing addSignal / releasing removeSignal. Excluded from
32482
+ * persisted snapshots in _updatePositions: a reservation is process-transient,
32483
+ * but a CONCURRENT strategy's addSignal persists the whole shared map — flushed
32484
+ * to disk that placeholder would survive a crash as a phantom position and
32485
+ * block the shared concurrency limit for the whole signal lifetime (forever
32486
+ * for minuteEstimatedTime: Infinity, which the expiry pruning never removes).
32487
+ */
32488
+ _reservedKeys: Set<string>;
32229
32489
  constructor(params: IRiskParams);
32230
32490
  /**
32231
32491
  * Initializes active positions by loading from persistence.
@@ -32624,7 +32884,7 @@ declare class ActionCoreService implements TAction$1 {
32624
32884
  * @param event - Sync event with action "signal-open" or "signal-close"
32625
32885
  * @param context - Strategy execution context
32626
32886
  */
32627
- signalSync: (backtest: boolean, event: SignalSyncContract, context: {
32887
+ orderSync: (backtest: boolean, event: OrderSyncContract, context: {
32628
32888
  strategyName: StrategyName;
32629
32889
  exchangeName: ExchangeName;
32630
32890
  frameName: FrameName;
@@ -32637,7 +32897,7 @@ declare class ActionCoreService implements TAction$1 {
32637
32897
  * @param event - Pending-ping event with action "signal-ping"
32638
32898
  * @param context - Strategy execution context
32639
32899
  */
32640
- orderCheck: (backtest: boolean, event: SignalPingContract, context: {
32900
+ orderCheck: (backtest: boolean, event: OrderCheckContract, context: {
32641
32901
  strategyName: StrategyName;
32642
32902
  exchangeName: ExchangeName;
32643
32903
  frameName: FrameName;
@@ -34461,6 +34721,19 @@ declare class FrameConnectionService implements IFrame {
34461
34721
  * @returns Configured ClientFrame instance
34462
34722
  */
34463
34723
  getFrame: ((frameName: FrameName) => ClientFrame) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientFrame>;
34724
+ /**
34725
+ * Disposes cached ClientFrame instance(s) so the next getTimeframe call
34726
+ * regenerates timeframes. Without this, ClientFrame's singleshot would keep
34727
+ * the endDate-to-now clamp frozen at the moment of the first run: a
34728
+ * long-running process re-running the same frame would silently backtest
34729
+ * against stale timeframes and never see newly available candles.
34730
+ *
34731
+ * When called without arguments, clears all memoized frames.
34732
+ * Called by Backtest/Walker at strategy start.
34733
+ *
34734
+ * @param frameName - Frame to clear; omit to clear all frames
34735
+ */
34736
+ clear: (frameName?: FrameName) => void;
34464
34737
  /**
34465
34738
  * Retrieves backtest timeframe boundaries for symbol.
34466
34739
  *
@@ -34760,14 +35033,16 @@ declare class ActionProxy implements IPublicAction {
34760
35033
  *
34761
35034
  * @param event - Sync event with action "signal-open" or "signal-close"
34762
35035
  */
34763
- signalSync(event: SignalSyncContract): Promise<void>;
35036
+ orderSync(event: OrderSyncContract): Promise<void>;
34764
35037
  /**
34765
- * Gate for the pending-order ping (order still open on exchange?).
35038
+ * Gate for the order ping (order still open on exchange?). Fires for both
35039
+ * monitored states: event.type "active" (open position order) and "schedule"
35040
+ * (resting entry order of a scheduled signal).
34766
35041
  * NOT wrapped in trycatch — exceptions propagate to CREATE_SYNC_PENDING_FN.
34767
35042
  *
34768
- * @param event - Pending-ping event with action "signal-ping"
35043
+ * @param event - Order-ping event with action "signal-ping" and type "schedule" | "active"
34769
35044
  */
34770
- orderCheck(event: SignalPingContract): Promise<void>;
35045
+ orderCheck(event: OrderCheckContract): Promise<void>;
34771
35046
  /**
34772
35047
  * Cleans up resources with error capture.
34773
35048
  *
@@ -34826,6 +35101,12 @@ declare class ClientAction implements IAction {
34826
35101
  * Starts as null, gets initialized on first use.
34827
35102
  */
34828
35103
  _handlerInstance: ActionProxy | null;
35104
+ /**
35105
+ * Terminal flag set by dispose(). Once true, all event methods become no-ops:
35106
+ * the handler will not be recreated (waitForInit is singleshot), so late
35107
+ * events must not reach the schema callbacks either.
35108
+ */
35109
+ _isDisposed: boolean;
34829
35110
  /**
34830
35111
  * Creates a new ClientAction instance.
34831
35112
  *
@@ -34934,12 +35215,12 @@ declare class ClientAction implements IAction {
34934
35215
  * Gate for position open/close via limit order.
34935
35216
  * NOT wrapped in trycatch — exceptions propagate to CREATE_SYNC_FN.
34936
35217
  */
34937
- signalSync(event: SignalSyncContract): Promise<void>;
35218
+ orderSync(event: OrderSyncContract): Promise<void>;
34938
35219
  /**
34939
35220
  * Gate for the pending-order ping (order still open on exchange?).
34940
35221
  * NOT wrapped in trycatch — exceptions propagate to CREATE_SYNC_PENDING_FN.
34941
35222
  */
34942
- orderCheck(event: SignalPingContract): Promise<void>;
35223
+ orderCheck(event: OrderCheckContract): Promise<void>;
34943
35224
  /**
34944
35225
  * Cleans up resources and subscriptions when action handler is no longer needed.
34945
35226
  * Uses singleshot pattern to ensure cleanup happens exactly once.
@@ -35171,7 +35452,7 @@ declare class ActionConnectionService implements TAction {
35171
35452
  frameName: FrameName;
35172
35453
  }) => Promise<void>;
35173
35454
  /**
35174
- * Routes signalSync event to appropriate ClientAction instance.
35455
+ * Routes orderSync event to appropriate ClientAction instance.
35175
35456
  * NOT wrapped in trycatch — exceptions propagate to CREATE_SYNC_FN.
35176
35457
  *
35177
35458
  * @param event - Sync event with action "signal-open" or "signal-close"
@@ -35179,7 +35460,7 @@ declare class ActionConnectionService implements TAction {
35179
35460
  * @param context - Execution context
35180
35461
  * @returns true to allow, false to reject
35181
35462
  */
35182
- signalSync: (event: SignalSyncContract, backtest: boolean, context: {
35463
+ orderSync: (event: OrderSyncContract, backtest: boolean, context: {
35183
35464
  actionName: ActionName;
35184
35465
  strategyName: StrategyName;
35185
35466
  exchangeName: ExchangeName;
@@ -35193,7 +35474,7 @@ declare class ActionConnectionService implements TAction {
35193
35474
  * @param backtest - Whether running in backtest mode
35194
35475
  * @param context - Execution context
35195
35476
  */
35196
- orderCheck: (event: SignalPingContract, backtest: boolean, context: {
35477
+ orderCheck: (event: OrderCheckContract, backtest: boolean, context: {
35197
35478
  actionName: ActionName;
35198
35479
  strategyName: StrategyName;
35199
35480
  exchangeName: ExchangeName;
@@ -39576,4 +39857,4 @@ declare const getTotalClosed: (signal: Signal) => {
39576
39857
  */
39577
39858
  declare const getPriceScale: (value: number) => number;
39578
39859
 
39579
- export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AfterEndContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, type BeforeStartContract, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerActivePingPayload, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerIdlePingPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerPendingClosePayload, type BrokerPendingOpenPayload, type BrokerScheduleCancelledPayload, type BrokerScheduleOpenPayload, type BrokerSchedulePingPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerSignalPendingPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, type CommitPayload, Constant, type CriticalErrorNotification, Cron, type CronCallback, type CronEntry, type CronHandle, 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 IPersistBreakevenInstance, type IPersistCandleInstance, type IPersistIntervalInstance, type IPersistLogInstance, type IPersistMeasureInstance, type IPersistMemoryInstance, type IPersistNotificationInstance, type IPersistPartialInstance, type IPersistRecentInstance, type IPersistRiskInstance, type IPersistScheduleInstance, type IPersistSessionInstance, type IPersistSignalInstance, type IPersistStateInstance, type IPersistStorageInstance, type IPersistStrategyInstance, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IRecentUtils, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IRuntimeInfo, type IRuntimeRange, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISessionInstance, type ISignalDto, type ISignalIntervalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStateInstance, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type IdlePingContract, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Lookup, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, MemoryBacktest, MemoryBacktestAdapter, type MemoryData, MemoryLive, MemoryLiveAdapter, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistBreakevenInstance, PersistCandleAdapter, PersistCandleInstance, PersistIntervalAdapter, PersistIntervalInstance, PersistLogAdapter, PersistLogInstance, PersistMeasureAdapter, PersistMeasureInstance, PersistMemoryAdapter, PersistMemoryInstance, PersistNotificationAdapter, PersistNotificationInstance, PersistPartialAdapter, PersistPartialInstance, PersistRecentAdapter, PersistRecentInstance, PersistRiskAdapter, PersistRiskInstance, PersistScheduleAdapter, PersistScheduleInstance, PersistSessionAdapter, PersistSessionInstance, PersistSignalAdapter, PersistSignalInstance, PersistStateAdapter, PersistStateInstance, PersistStorageAdapter, PersistStorageInstance, PersistStrategyAdapter, PersistStrategyInstance, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Recent, RecentBacktest, type RecentData, RecentLive, Reflect, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, type RuntimeData, Schedule, type ScheduleData, type ScheduleEventContract, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, Session, SessionBacktest, type SessionData, SessionLive, type SignalCancelledNotification, type SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalEventContract, type SignalInfoContract, type SignalInfoNotification, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalPingContract, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, State, StateBacktest, StateBacktestAdapter, type StateData, StateLive, StateLiveAdapter, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyData, type StrategyEvent, type StrategyStatisticsModel, type StrategyStatus, Sync, type SyncEvent, type SyncStatisticsModel, System, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TPersistBreakevenInstanceCtor, type TPersistCandleInstanceCtor, type TPersistIntervalInstanceCtor, type TPersistLogInstanceCtor, type TPersistMeasureInstanceCtor, type TPersistMemoryInstanceCtor, type TPersistNotificationInstanceCtor, type TPersistPartialInstanceCtor, type TPersistRecentInstanceCtor, type TPersistRiskInstanceCtor, type TPersistScheduleInstanceCtor, type TPersistSessionInstanceCtor, type TPersistSignalInstanceCtor, type TPersistStateInstanceCtor, type TPersistStorageInstanceCtor, type TPersistStrategyInstanceCtor, type TRecentUtilsCtor, type TReportBase, type TSessionInstanceCtor, type TStateInstanceCtor, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, beginContext, beginTime, cacheCandles, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitCreateSignal, commitCreateStopLoss, commitCreateTakeProfit, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitSignalNotify, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, createSignalState, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getClosePrice, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, getMinutesSinceLatestSignalCreated, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionActiveMinutes, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getPositionWaitingMinutes, getPriceScale, getRawCandles, getRiskSchema, getRuntimeInfo, getScheduledSignal, getSessionData, getSignalState, getSizingSchema, getStrategySchema, getStrategyStatus, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, intervalStepMs, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenAfterEnd, listenAfterEndOnce, listenBacktestProgress, listenBeforeStart, listenBeforeStartOnce, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenIdlePing, listenIdlePingOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenScheduleEvent, listenScheduleEventOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalEvent, listenSignalEventOnce, listenSignalLive, listenSignalLiveOnce, listenSignalNotify, listenSignalNotifyOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, setSessionData, setSignalState, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toPlainString, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCandles, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, waitForReady, warmCandles, writeMemory };
39860
+ export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AfterEndContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, type BeforeStartContract, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerActivePingPayload, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerIdlePingPayload, type BrokerOrderCheckPayload, type BrokerOrderClosePayload, type BrokerOrderOpenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerPendingClosePayload, type BrokerPendingOpenPayload, type BrokerScheduleCancelledPayload, type BrokerScheduleOpenPayload, type BrokerSchedulePingPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, type CommitPayload, Constant, type CriticalErrorNotification, Cron, type CronCallback, type CronEntry, type CronHandle, 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 IPersistBreakevenInstance, type IPersistCandleInstance, type IPersistIntervalInstance, type IPersistLogInstance, type IPersistMeasureInstance, type IPersistMemoryInstance, type IPersistNotificationInstance, type IPersistPartialInstance, type IPersistRecentInstance, type IPersistRiskInstance, type IPersistScheduleInstance, type IPersistSessionInstance, type IPersistSignalInstance, type IPersistStateInstance, type IPersistStorageInstance, type IPersistStrategyInstance, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, type IPublicSignalRow, type IRecentUtils, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IRuntimeInfo, type IRuntimeRange, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISessionInstance, type ISignalDto, type ISignalIntervalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStateInstance, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type IdlePingContract, type InfoErrorNotification, Interval, type IntervalData, Live, type LiveStatisticsModel, Log, type LogData, Lookup, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MarkdownWriter, MaxDrawdown, type MaxDrawdownContract, type MaxDrawdownEvent, type MaxDrawdownStatisticsModel, type MeasureData, Memory, MemoryBacktest, MemoryBacktestAdapter, type MemoryData, MemoryLive, MemoryLiveAdapter, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, type OrderCheckContract, type OrderCloseContract, type OrderOpenContract, type OrderSyncCloseNotification, type OrderSyncContract, type OrderSyncOpenNotification, 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, PersistBreakevenInstance, PersistCandleAdapter, PersistCandleInstance, PersistIntervalAdapter, PersistIntervalInstance, PersistLogAdapter, PersistLogInstance, PersistMeasureAdapter, PersistMeasureInstance, PersistMemoryAdapter, PersistMemoryInstance, PersistNotificationAdapter, PersistNotificationInstance, PersistPartialAdapter, PersistPartialInstance, PersistRecentAdapter, PersistRecentInstance, PersistRiskAdapter, PersistRiskInstance, PersistScheduleAdapter, PersistScheduleInstance, PersistSessionAdapter, PersistSessionInstance, PersistSignalAdapter, PersistSignalInstance, PersistStateAdapter, PersistStateInstance, PersistStorageAdapter, PersistStorageInstance, PersistStrategyAdapter, PersistStrategyInstance, Position, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Recent, RecentBacktest, type RecentData, RecentLive, Reflect, Report, ReportBase, type ReportName, ReportWriter, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, type RuntimeData, Schedule, type ScheduleData, type ScheduleEventContract, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, Session, SessionBacktest, type SessionData, SessionLive, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalEventContract, type SignalInfoContract, type SignalInfoNotification, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, State, StateBacktest, StateBacktestAdapter, type StateData, StateLive, StateLiveAdapter, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyData, type StrategyEvent, type StrategyStatisticsModel, type StrategyStatus, Sync, type SyncEvent, type SyncStatisticsModel, System, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TPersistBreakevenInstanceCtor, type TPersistCandleInstanceCtor, type TPersistIntervalInstanceCtor, type TPersistLogInstanceCtor, type TPersistMeasureInstanceCtor, type TPersistMemoryInstanceCtor, type TPersistNotificationInstanceCtor, type TPersistPartialInstanceCtor, type TPersistRecentInstanceCtor, type TPersistRiskInstanceCtor, type TPersistScheduleInstanceCtor, type TPersistSessionInstanceCtor, type TPersistSignalInstanceCtor, type TPersistStateInstanceCtor, type TPersistStorageInstanceCtor, type TPersistStrategyInstanceCtor, type TRecentUtilsCtor, type TReportBase, type TSessionInstanceCtor, type TStateInstanceCtor, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, beginContext, beginTime, cacheCandles, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitCreateSignal, commitCreateStopLoss, commitCreateTakeProfit, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitSignalNotify, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, createSignalState, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getClosePrice, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, getMinutesSinceLatestSignalCreated, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionActiveMinutes, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getPositionWaitingMinutes, getPriceScale, getRawCandles, getRemainingCostBasis, getRiskSchema, getRuntimeInfo, getScheduledSignal, getSessionData, getSignalState, getSizingSchema, getStrategySchema, getStrategyStatus, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getTotalPercentHeld, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, intervalStepMs, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenAfterEnd, listenAfterEndOnce, listenBacktestProgress, listenBeforeStart, listenBeforeStartOnce, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenCheck, listenCheckOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenIdlePing, listenIdlePingOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenScheduleEvent, listenScheduleEventOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalEvent, listenSignalEventOnce, listenSignalLive, listenSignalLiveOnce, listenSignalNotify, listenSignalNotifyOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, setSessionData, setSignalState, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toPlainString, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCandles, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, waitForReady, warmCandles, writeMemory };