backtest-kit 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -74,7 +74,6 @@
74
74
  "typescript": "^5.0.0"
75
75
  },
76
76
  "dependencies": {
77
- "ccxt": "^4.5.35",
78
77
  "di-kit": "^1.0.18",
79
78
  "di-scoped": "^1.0.20",
80
79
  "functools-kit": "^1.0.95",
package/types.d.ts CHANGED
@@ -1007,10 +1007,15 @@ interface IBreakeven {
1007
1007
  * Base fields for all signal commit events.
1008
1008
  */
1009
1009
  interface SignalCommitBase {
1010
+ /** Trading pair symbol (e.g., "BTCUSDT") */
1010
1011
  symbol: string;
1012
+ /** Strategy name that generated this signal */
1011
1013
  strategyName: StrategyName;
1014
+ /** Exchange name where signal was executed */
1012
1015
  exchangeName: ExchangeName;
1016
+ /** Timeframe name (used in backtest mode, empty string in live mode) */
1013
1017
  frameName: FrameName;
1018
+ /** Whether this event is from backtest mode (true) or live mode (false) */
1014
1019
  backtest: boolean;
1015
1020
  /** Unique signal identifier (UUID v4) */
1016
1021
  signalId: string;
@@ -1021,93 +1026,178 @@ interface SignalCommitBase {
1021
1026
  * Cancel scheduled signal event.
1022
1027
  */
1023
1028
  interface CancelScheduledCommit extends SignalCommitBase {
1029
+ /** Discriminator for cancel-scheduled action */
1024
1030
  action: "cancel-scheduled";
1031
+ /** Optional identifier for the cancellation reason (user-provided) */
1025
1032
  cancelId?: string;
1026
1033
  }
1027
1034
  /**
1028
1035
  * Close pending signal event.
1029
1036
  */
1030
1037
  interface ClosePendingCommit extends SignalCommitBase {
1038
+ /** Discriminator for close-pending action */
1031
1039
  action: "close-pending";
1040
+ /** Optional identifier for the close reason (user-provided) */
1032
1041
  closeId?: string;
1033
1042
  }
1034
1043
  /**
1035
1044
  * Partial profit event.
1036
1045
  */
1037
1046
  interface PartialProfitCommit extends SignalCommitBase {
1047
+ /** Discriminator for partial-profit action */
1038
1048
  action: "partial-profit";
1049
+ /** Percentage of position to close (0-100) */
1039
1050
  percentToClose: number;
1051
+ /** Current market price at time of action */
1040
1052
  currentPrice: number;
1053
+ /** Trade direction: "long" (buy) or "short" (sell) */
1041
1054
  position: "long" | "short";
1055
+ /** Entry price for the position */
1042
1056
  priceOpen: number;
1057
+ /** Effective take profit price (may differ from original after trailing) */
1043
1058
  priceTakeProfit: number;
1059
+ /** Effective stop loss price (may differ from original after trailing) */
1044
1060
  priceStopLoss: number;
1061
+ /** Original take profit price before any trailing adjustments */
1045
1062
  originalPriceTakeProfit: number;
1063
+ /** Original stop loss price before any trailing adjustments */
1046
1064
  originalPriceStopLoss: number;
1065
+ /** Signal creation timestamp in milliseconds */
1047
1066
  scheduledAt: number;
1067
+ /** Position activation timestamp in milliseconds (when price reached priceOpen) */
1048
1068
  pendingAt: number;
1049
1069
  }
1050
1070
  /**
1051
1071
  * Partial loss event.
1052
1072
  */
1053
1073
  interface PartialLossCommit extends SignalCommitBase {
1074
+ /** Discriminator for partial-loss action */
1054
1075
  action: "partial-loss";
1076
+ /** Percentage of position to close (0-100) */
1055
1077
  percentToClose: number;
1078
+ /** Current market price at time of action */
1056
1079
  currentPrice: number;
1080
+ /** Trade direction: "long" (buy) or "short" (sell) */
1057
1081
  position: "long" | "short";
1082
+ /** Entry price for the position */
1058
1083
  priceOpen: number;
1084
+ /** Effective take profit price (may differ from original after trailing) */
1059
1085
  priceTakeProfit: number;
1086
+ /** Effective stop loss price (may differ from original after trailing) */
1060
1087
  priceStopLoss: number;
1088
+ /** Original take profit price before any trailing adjustments */
1061
1089
  originalPriceTakeProfit: number;
1090
+ /** Original stop loss price before any trailing adjustments */
1062
1091
  originalPriceStopLoss: number;
1092
+ /** Signal creation timestamp in milliseconds */
1063
1093
  scheduledAt: number;
1094
+ /** Position activation timestamp in milliseconds (when price reached priceOpen) */
1064
1095
  pendingAt: number;
1065
1096
  }
1066
1097
  /**
1067
1098
  * Trailing stop event.
1068
1099
  */
1069
1100
  interface TrailingStopCommit extends SignalCommitBase {
1101
+ /** Discriminator for trailing-stop action */
1070
1102
  action: "trailing-stop";
1103
+ /** Percentage shift for stop loss adjustment */
1071
1104
  percentShift: number;
1105
+ /** Current market price at time of trailing adjustment */
1072
1106
  currentPrice: number;
1107
+ /** Trade direction: "long" (buy) or "short" (sell) */
1073
1108
  position: "long" | "short";
1109
+ /** Entry price for the position */
1074
1110
  priceOpen: number;
1111
+ /** Effective take profit price (may differ from original after trailing) */
1075
1112
  priceTakeProfit: number;
1113
+ /** Effective stop loss price (updated by this trailing action) */
1076
1114
  priceStopLoss: number;
1115
+ /** Original take profit price before any trailing adjustments */
1077
1116
  originalPriceTakeProfit: number;
1117
+ /** Original stop loss price before any trailing adjustments */
1078
1118
  originalPriceStopLoss: number;
1119
+ /** Signal creation timestamp in milliseconds */
1079
1120
  scheduledAt: number;
1121
+ /** Position activation timestamp in milliseconds (when price reached priceOpen) */
1080
1122
  pendingAt: number;
1081
1123
  }
1082
1124
  /**
1083
1125
  * Trailing take event.
1084
1126
  */
1085
1127
  interface TrailingTakeCommit extends SignalCommitBase {
1128
+ /** Discriminator for trailing-take action */
1086
1129
  action: "trailing-take";
1130
+ /** Percentage shift for take profit adjustment */
1087
1131
  percentShift: number;
1132
+ /** Current market price at time of trailing adjustment */
1088
1133
  currentPrice: number;
1134
+ /** Trade direction: "long" (buy) or "short" (sell) */
1089
1135
  position: "long" | "short";
1136
+ /** Entry price for the position */
1090
1137
  priceOpen: number;
1138
+ /** Effective take profit price (updated by this trailing action) */
1091
1139
  priceTakeProfit: number;
1140
+ /** Effective stop loss price (may differ from original after trailing) */
1092
1141
  priceStopLoss: number;
1142
+ /** Original take profit price before any trailing adjustments */
1093
1143
  originalPriceTakeProfit: number;
1144
+ /** Original stop loss price before any trailing adjustments */
1094
1145
  originalPriceStopLoss: number;
1146
+ /** Signal creation timestamp in milliseconds */
1095
1147
  scheduledAt: number;
1148
+ /** Position activation timestamp in milliseconds (when price reached priceOpen) */
1096
1149
  pendingAt: number;
1097
1150
  }
1098
1151
  /**
1099
1152
  * Breakeven event.
1100
1153
  */
1101
1154
  interface BreakevenCommit extends SignalCommitBase {
1155
+ /** Discriminator for breakeven action */
1102
1156
  action: "breakeven";
1157
+ /** Current market price at time of breakeven adjustment */
1158
+ currentPrice: number;
1159
+ /** Trade direction: "long" (buy) or "short" (sell) */
1160
+ position: "long" | "short";
1161
+ /** Entry price for the position */
1162
+ priceOpen: number;
1163
+ /** Effective take profit price (may differ from original after trailing) */
1164
+ priceTakeProfit: number;
1165
+ /** Effective stop loss price (set to priceOpen by breakeven action) */
1166
+ priceStopLoss: number;
1167
+ /** Original take profit price before any trailing adjustments */
1168
+ originalPriceTakeProfit: number;
1169
+ /** Original stop loss price before any trailing adjustments */
1170
+ originalPriceStopLoss: number;
1171
+ /** Signal creation timestamp in milliseconds */
1172
+ scheduledAt: number;
1173
+ /** Position activation timestamp in milliseconds (when price reached priceOpen) */
1174
+ pendingAt: number;
1175
+ }
1176
+ /**
1177
+ * Activate scheduled signal event.
1178
+ */
1179
+ interface ActivateScheduledCommit extends SignalCommitBase {
1180
+ /** Discriminator for activate-scheduled action */
1181
+ action: "activate-scheduled";
1182
+ /** Optional identifier for the activation reason (user-provided) */
1183
+ activateId?: string;
1184
+ /** Current market price at time of activation */
1103
1185
  currentPrice: number;
1186
+ /** Trade direction: "long" (buy) or "short" (sell) */
1104
1187
  position: "long" | "short";
1188
+ /** Entry price for the position */
1105
1189
  priceOpen: number;
1190
+ /** Effective take profit price */
1106
1191
  priceTakeProfit: number;
1192
+ /** Effective stop loss price */
1107
1193
  priceStopLoss: number;
1194
+ /** Original take profit price before any trailing adjustments */
1108
1195
  originalPriceTakeProfit: number;
1196
+ /** Original stop loss price before any trailing adjustments */
1109
1197
  originalPriceStopLoss: number;
1198
+ /** Signal creation timestamp in milliseconds */
1110
1199
  scheduledAt: number;
1200
+ /** Position activation timestamp in milliseconds (set during this activation) */
1111
1201
  pendingAt: number;
1112
1202
  }
1113
1203
  /**
@@ -1123,7 +1213,7 @@ interface BreakevenCommit extends SignalCommitBase {
1123
1213
  * Consumers must retrieve signal data from StrategyCoreService using
1124
1214
  * getPendingSignal() or getScheduledSignal() methods.
1125
1215
  */
1126
- type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit;
1216
+ type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit | ActivateScheduledCommit;
1127
1217
 
1128
1218
  /**
1129
1219
  * Signal generation interval for throttling.
@@ -1390,11 +1480,22 @@ interface ITrailingTakeCommitRow extends ICommitRowBase {
1390
1480
  /** Price at which trailing was set */
1391
1481
  currentPrice: number;
1392
1482
  }
1483
+ /**
1484
+ * Queued activate scheduled commit.
1485
+ */
1486
+ interface IActivateScheduledCommitRow extends ICommitRowBase {
1487
+ /** Discriminator */
1488
+ action: "activate-scheduled";
1489
+ /** Signal ID being activated */
1490
+ signalId: string;
1491
+ /** Activation ID (optional, for user-initiated activations) */
1492
+ activateId?: string;
1493
+ }
1393
1494
  /**
1394
1495
  * Discriminated union of all queued commit events.
1395
1496
  * These are stored in _commitQueue and processed in tick()/backtest().
1396
1497
  */
1397
- type ICommitRow = IPartialProfitCommitRow | IPartialLossCommitRow | IBreakevenCommitRow | ITrailingStopCommitRow | ITrailingTakeCommitRow;
1498
+ type ICommitRow = IPartialProfitCommitRow | IPartialLossCommitRow | IBreakevenCommitRow | ITrailingStopCommitRow | ITrailingTakeCommitRow | IActivateScheduledCommitRow;
1398
1499
  /**
1399
1500
  * Optional lifecycle callbacks for signal events.
1400
1501
  * Called when signals are opened, active, idle, closed, scheduled, or cancelled.
@@ -1811,6 +1912,28 @@ interface IStrategy {
1811
1912
  * ```
1812
1913
  */
1813
1914
  cancelScheduled: (symbol: string, backtest: boolean, cancelId?: string) => Promise<void>;
1915
+ /**
1916
+ * Activates the scheduled signal without waiting for price to reach priceOpen.
1917
+ *
1918
+ * Forces immediate activation of the scheduled signal at the current price.
1919
+ * Does NOT affect active pending signals or strategy operation.
1920
+ * Does NOT set stop flag - strategy can continue generating new signals.
1921
+ *
1922
+ * Use case: User-initiated early activation of a scheduled entry.
1923
+ *
1924
+ * @param symbol - Trading pair symbol (e.g., "BTCUSDT")
1925
+ * @param backtest - Whether running in backtest mode
1926
+ * @param activateId - Optional identifier for this activation operation
1927
+ * @returns Promise that resolves when scheduled signal is activated
1928
+ *
1929
+ * @example
1930
+ * ```typescript
1931
+ * // Activate scheduled signal without waiting for priceOpen
1932
+ * await strategy.activateScheduled("BTCUSDT", false, "user-activate-123");
1933
+ * // Scheduled signal becomes pending signal immediately
1934
+ * ```
1935
+ */
1936
+ activateScheduled: (symbol: string, backtest: boolean, activateId?: string) => Promise<void>;
1814
1937
  /**
1815
1938
  * Closes the pending signal without stopping the strategy.
1816
1939
  *
@@ -3838,6 +3961,27 @@ declare function commitTrailingTake(symbol: string, percentShift: number, curren
3838
3961
  * ```
3839
3962
  */
3840
3963
  declare function commitBreakeven(symbol: string): Promise<boolean>;
3964
+ /**
3965
+ * Activates a scheduled signal early without waiting for price to reach priceOpen.
3966
+ *
3967
+ * Sets the activation flag on the scheduled signal. The actual activation
3968
+ * happens on the next tick() when strategy detects the flag.
3969
+ *
3970
+ * Automatically detects backtest/live mode from execution context.
3971
+ *
3972
+ * @param symbol - Trading pair symbol
3973
+ * @param activateId - Optional activation ID for tracking user-initiated activations
3974
+ * @returns Promise that resolves when activation flag is set
3975
+ *
3976
+ * @example
3977
+ * ```typescript
3978
+ * import { commitActivateScheduled } from "backtest-kit";
3979
+ *
3980
+ * // Activate scheduled signal early with custom ID
3981
+ * await commitActivateScheduled("BTCUSDT", "manual-activate-001");
3982
+ * ```
3983
+ */
3984
+ declare function commitActivateScheduled(symbol: string, activateId?: string): Promise<void>;
3841
3985
 
3842
3986
  /**
3843
3987
  * Stops the strategy from generating new signals.
@@ -6972,6 +7116,50 @@ interface BreakevenCommitNotification {
6972
7116
  /** Unix timestamp in milliseconds when the notification was created */
6973
7117
  createdAt: number;
6974
7118
  }
7119
+ /**
7120
+ * Activate scheduled commit notification.
7121
+ * Emitted when a scheduled signal is activated by user (without waiting for priceOpen).
7122
+ */
7123
+ interface ActivateScheduledCommitNotification {
7124
+ /** Discriminator for type-safe union */
7125
+ type: "activate_scheduled.commit";
7126
+ /** Unique notification identifier */
7127
+ id: string;
7128
+ /** Unix timestamp in milliseconds when activation was committed */
7129
+ timestamp: number;
7130
+ /** Whether this notification is from backtest mode (true) or live mode (false) */
7131
+ backtest: boolean;
7132
+ /** Trading pair symbol (e.g., "BTCUSDT") */
7133
+ symbol: string;
7134
+ /** Strategy name that generated this signal */
7135
+ strategyName: StrategyName;
7136
+ /** Exchange name where signal was executed */
7137
+ exchangeName: ExchangeName;
7138
+ /** Unique signal identifier (UUID v4) */
7139
+ signalId: string;
7140
+ /** Optional activation identifier (provided when user calls activateScheduled()) */
7141
+ activateId?: string;
7142
+ /** Trade direction: "long" (buy) or "short" (sell) */
7143
+ position: "long" | "short";
7144
+ /** Entry price for the position */
7145
+ priceOpen: number;
7146
+ /** Effective take profit price */
7147
+ priceTakeProfit: number;
7148
+ /** Effective stop loss price */
7149
+ priceStopLoss: number;
7150
+ /** Original take profit price before any trailing adjustments */
7151
+ originalPriceTakeProfit: number;
7152
+ /** Original stop loss price before any trailing adjustments */
7153
+ originalPriceStopLoss: number;
7154
+ /** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
7155
+ scheduledAt: number;
7156
+ /** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
7157
+ pendingAt: number;
7158
+ /** Current market price when activation was executed */
7159
+ currentPrice: number;
7160
+ /** Unix timestamp in milliseconds when the notification was created */
7161
+ createdAt: number;
7162
+ }
6975
7163
  /**
6976
7164
  * Trailing stop commit notification.
6977
7165
  * Emitted when trailing stop action is executed.
@@ -7264,7 +7452,7 @@ interface ValidationErrorNotification {
7264
7452
  * }
7265
7453
  * ```
7266
7454
  */
7267
- type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification;
7455
+ type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification;
7268
7456
 
7269
7457
  /**
7270
7458
  * Unified tick event data for report generation.
@@ -7686,7 +7874,7 @@ interface RiskStatisticsModel {
7686
7874
  * Action types for strategy events.
7687
7875
  * Represents all possible strategy management actions.
7688
7876
  */
7689
- type StrategyActionType = "cancel-scheduled" | "close-pending" | "partial-profit" | "partial-loss" | "trailing-stop" | "trailing-take" | "breakeven";
7877
+ type StrategyActionType = "cancel-scheduled" | "close-pending" | "partial-profit" | "partial-loss" | "trailing-stop" | "trailing-take" | "breakeven" | "activate-scheduled";
7690
7878
  /**
7691
7879
  * Unified strategy event data for markdown report generation.
7692
7880
  * Contains all information about strategy management actions.
@@ -7716,6 +7904,8 @@ interface StrategyEvent {
7716
7904
  cancelId?: string;
7717
7905
  /** Close ID for close-pending action */
7718
7906
  closeId?: string;
7907
+ /** Activate ID for activate-scheduled action */
7908
+ activateId?: string;
7719
7909
  /** ISO timestamp string when action was created */
7720
7910
  createdAt: string;
7721
7911
  /** True if backtest mode, false if live mode */
@@ -7769,6 +7959,8 @@ interface StrategyStatisticsModel {
7769
7959
  trailingTakeCount: number;
7770
7960
  /** Count of breakeven events */
7771
7961
  breakevenCount: number;
7962
+ /** Count of activate-scheduled events */
7963
+ activateScheduledCount: number;
7772
7964
  }
7773
7965
 
7774
7966
  declare const BASE_WAIT_FOR_INIT_SYMBOL: unique symbol;
@@ -9742,6 +9934,32 @@ declare class BacktestUtils {
9742
9934
  exchangeName: ExchangeName;
9743
9935
  frameName: FrameName;
9744
9936
  }) => Promise<boolean>;
9937
+ /**
9938
+ * Activates a scheduled signal early without waiting for price to reach priceOpen.
9939
+ *
9940
+ * Sets the activation flag on the scheduled signal. The actual activation
9941
+ * happens on the next tick() when strategy detects the flag.
9942
+ *
9943
+ * @param symbol - Trading pair symbol
9944
+ * @param context - Execution context with strategyName, exchangeName, and frameName
9945
+ * @param activateId - Optional activation ID for tracking user-initiated activations
9946
+ * @returns Promise that resolves when activation flag is set
9947
+ *
9948
+ * @example
9949
+ * ```typescript
9950
+ * // Activate scheduled signal early with custom ID
9951
+ * await Backtest.commitActivateScheduled("BTCUSDT", {
9952
+ * strategyName: "my-strategy",
9953
+ * exchangeName: "binance",
9954
+ * frameName: "1h"
9955
+ * }, "manual-activate-001");
9956
+ * ```
9957
+ */
9958
+ commitActivateScheduled: (symbol: string, context: {
9959
+ strategyName: StrategyName;
9960
+ exchangeName: ExchangeName;
9961
+ frameName: FrameName;
9962
+ }, activateId?: string) => Promise<void>;
9745
9963
  /**
9746
9964
  * Gets statistical data from all closed signals for a symbol-strategy pair.
9747
9965
  *
@@ -10470,6 +10688,30 @@ declare class LiveUtils {
10470
10688
  strategyName: StrategyName;
10471
10689
  exchangeName: ExchangeName;
10472
10690
  }) => Promise<boolean>;
10691
+ /**
10692
+ * Activates a scheduled signal early without waiting for price to reach priceOpen.
10693
+ *
10694
+ * Sets the activation flag on the scheduled signal. The actual activation
10695
+ * happens on the next tick() when strategy detects the flag.
10696
+ *
10697
+ * @param symbol - Trading pair symbol
10698
+ * @param context - Execution context with strategyName and exchangeName
10699
+ * @param activateId - Optional activation ID for tracking user-initiated activations
10700
+ * @returns Promise that resolves when activation flag is set
10701
+ *
10702
+ * @example
10703
+ * ```typescript
10704
+ * // Activate scheduled signal early with custom ID
10705
+ * await Live.commitActivateScheduled("BTCUSDT", {
10706
+ * strategyName: "my-strategy",
10707
+ * exchangeName: "binance"
10708
+ * }, "manual-activate-001");
10709
+ * ```
10710
+ */
10711
+ commitActivateScheduled: (symbol: string, context: {
10712
+ strategyName: StrategyName;
10713
+ exchangeName: ExchangeName;
10714
+ }, activateId?: string) => Promise<void>;
10473
10715
  /**
10474
10716
  * Gets statistical data from all live trading events for a symbol-strategy pair.
10475
10717
  *
@@ -14273,6 +14515,34 @@ declare class StrategyCoreService implements TStrategy$1 {
14273
14515
  exchangeName: ExchangeName;
14274
14516
  frameName: FrameName;
14275
14517
  }) => Promise<boolean>;
14518
+ /**
14519
+ * Activates a scheduled signal early without waiting for price to reach priceOpen.
14520
+ *
14521
+ * Validates strategy existence and delegates to connection service
14522
+ * to set the activation flag. The actual activation happens on next tick().
14523
+ *
14524
+ * @param backtest - Whether running in backtest mode
14525
+ * @param symbol - Trading pair symbol
14526
+ * @param context - Execution context with strategyName, exchangeName, frameName
14527
+ * @param activateId - Optional identifier for the activation reason
14528
+ * @returns Promise that resolves when activation flag is set
14529
+ *
14530
+ * @example
14531
+ * ```typescript
14532
+ * // Activate scheduled signal early
14533
+ * await strategyCoreService.activateScheduled(
14534
+ * false,
14535
+ * "BTCUSDT",
14536
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "" },
14537
+ * "manual-activation"
14538
+ * );
14539
+ * ```
14540
+ */
14541
+ activateScheduled: (backtest: boolean, symbol: string, context: {
14542
+ strategyName: StrategyName;
14543
+ exchangeName: ExchangeName;
14544
+ frameName: FrameName;
14545
+ }, activateId?: string) => Promise<void>;
14276
14546
  }
14277
14547
 
14278
14548
  /**
@@ -14482,6 +14752,29 @@ declare class StrategyMarkdownService {
14482
14752
  exchangeName: ExchangeName;
14483
14753
  frameName: FrameName;
14484
14754
  }, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
14755
+ /**
14756
+ * Records an activate-scheduled event when a scheduled signal is activated early.
14757
+ *
14758
+ * @param symbol - Trading pair symbol (e.g., "BTCUSDT")
14759
+ * @param currentPrice - Current market price at time of activation
14760
+ * @param isBacktest - Whether this is a backtest or live trading event
14761
+ * @param context - Strategy context with strategyName, exchangeName, frameName
14762
+ * @param timestamp - Timestamp from StrategyCommitContract (execution context time)
14763
+ * @param position - Trade direction: "long" or "short"
14764
+ * @param priceOpen - Entry price for the position
14765
+ * @param priceTakeProfit - Effective take profit price
14766
+ * @param priceStopLoss - Effective stop loss price
14767
+ * @param originalPriceTakeProfit - Original take profit before trailing
14768
+ * @param originalPriceStopLoss - Original stop loss before trailing
14769
+ * @param scheduledAt - Signal creation timestamp in milliseconds
14770
+ * @param pendingAt - Pending timestamp in milliseconds
14771
+ * @param activateId - Optional identifier for the activation reason
14772
+ */
14773
+ activateScheduled: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
14774
+ strategyName: StrategyName;
14775
+ exchangeName: ExchangeName;
14776
+ frameName: FrameName;
14777
+ }, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, activateId?: string) => Promise<void>;
14485
14778
  /**
14486
14779
  * Retrieves aggregated statistics from accumulated strategy events.
14487
14780
  *
@@ -16976,6 +17269,34 @@ declare class StrategyConnectionService implements TStrategy {
16976
17269
  exchangeName: ExchangeName;
16977
17270
  frameName: FrameName;
16978
17271
  }) => Promise<boolean>;
17272
+ /**
17273
+ * Activates a scheduled signal early without waiting for price to reach priceOpen.
17274
+ *
17275
+ * Delegates to ClientStrategy.activateScheduled() which sets _activatedSignal flag.
17276
+ * The actual activation happens on next tick() when strategy detects the flag.
17277
+ *
17278
+ * @param backtest - Whether running in backtest mode
17279
+ * @param symbol - Trading pair symbol
17280
+ * @param context - Execution context with strategyName, exchangeName, frameName
17281
+ * @param activateId - Optional identifier for the activation reason
17282
+ * @returns Promise that resolves when activation flag is set
17283
+ *
17284
+ * @example
17285
+ * ```typescript
17286
+ * // Activate scheduled signal early
17287
+ * await strategyConnectionService.activateScheduled(
17288
+ * false,
17289
+ * "BTCUSDT",
17290
+ * { strategyName: "my-strategy", exchangeName: "binance", frameName: "" },
17291
+ * "manual-activation"
17292
+ * );
17293
+ * ```
17294
+ */
17295
+ activateScheduled: (backtest: boolean, symbol: string, context: {
17296
+ strategyName: StrategyName;
17297
+ exchangeName: ExchangeName;
17298
+ frameName: FrameName;
17299
+ }, activateId?: string) => Promise<void>;
16979
17300
  }
16980
17301
 
16981
17302
  /**
@@ -20024,6 +20345,29 @@ declare class StrategyReportService {
20024
20345
  exchangeName: ExchangeName;
20025
20346
  frameName: FrameName;
20026
20347
  }, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
20348
+ /**
20349
+ * Logs an activate-scheduled event when a scheduled signal is activated early.
20350
+ *
20351
+ * @param symbol - Trading pair symbol (e.g., "BTCUSDT")
20352
+ * @param currentPrice - Current market price at time of activation
20353
+ * @param isBacktest - Whether this is a backtest or live trading event
20354
+ * @param context - Strategy context with strategyName, exchangeName, frameName
20355
+ * @param timestamp - Timestamp from StrategyCommitContract (execution context time)
20356
+ * @param position - Trade direction: "long" or "short"
20357
+ * @param priceOpen - Entry price for the position
20358
+ * @param priceTakeProfit - Effective take profit price
20359
+ * @param priceStopLoss - Effective stop loss price
20360
+ * @param originalPriceTakeProfit - Original take profit before trailing
20361
+ * @param originalPriceStopLoss - Original stop loss before trailing
20362
+ * @param scheduledAt - Signal creation timestamp in milliseconds
20363
+ * @param pendingAt - Pending timestamp in milliseconds
20364
+ * @param activateId - Optional identifier for the activation reason
20365
+ */
20366
+ activateScheduled: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
20367
+ strategyName: StrategyName;
20368
+ exchangeName: ExchangeName;
20369
+ frameName: FrameName;
20370
+ }, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, activateId?: string) => Promise<void>;
20027
20371
  /**
20028
20372
  * Initializes the service for event logging.
20029
20373
  *
@@ -20112,4 +20456,4 @@ declare const backtest: {
20112
20456
  loggerService: LoggerService;
20113
20457
  };
20114
20458
 
20115
- export { ActionBase, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
20459
+ export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };