backtest-kit 1.5.47 → 1.6.2
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/build/index.cjs +660 -13
- package/build/index.mjs +659 -14
- package/package.json +1 -1
- package/types.d.ts +322 -2
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1138,6 +1138,14 @@ interface IScheduledSignalRow extends ISignalRow {
|
|
|
1138
1138
|
/** Entry price for the position */
|
|
1139
1139
|
priceOpen: number;
|
|
1140
1140
|
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Scheduled signal row with cancellation ID.
|
|
1143
|
+
* Extends IScheduledSignalRow to include optional cancelId for user-initiated cancellations.
|
|
1144
|
+
*/
|
|
1145
|
+
interface IScheduledSignalCancelRow extends IScheduledSignalRow {
|
|
1146
|
+
/** Cancellation ID (only for user-initiated cancellations) */
|
|
1147
|
+
cancelId?: string;
|
|
1148
|
+
}
|
|
1141
1149
|
/**
|
|
1142
1150
|
* Optional lifecycle callbacks for signal events.
|
|
1143
1151
|
* Called when signals are opened, active, idle, closed, scheduled, or cancelled.
|
|
@@ -1163,6 +1171,8 @@ interface IStrategyCallbacks {
|
|
|
1163
1171
|
onPartialProfit: (symbol: string, data: ISignalRow, currentPrice: number, revenuePercent: number, backtest: boolean) => void;
|
|
1164
1172
|
/** Called when signal is in partial loss state (price moved against position but not hit SL yet) */
|
|
1165
1173
|
onPartialLoss: (symbol: string, data: ISignalRow, currentPrice: number, lossPercent: number, backtest: boolean) => void;
|
|
1174
|
+
/** Called every minute regardless of strategy interval (for custom monitoring like checking if signal should be cancelled) */
|
|
1175
|
+
onPing: (symbol: string, data: IScheduledSignalRow, when: Date, backtest: boolean) => void | Promise<void>;
|
|
1166
1176
|
}
|
|
1167
1177
|
/**
|
|
1168
1178
|
* Strategy schema registered via addStrategy().
|
|
@@ -1193,6 +1203,11 @@ interface IStrategySchema {
|
|
|
1193
1203
|
* Used in discriminated union for type-safe handling.
|
|
1194
1204
|
*/
|
|
1195
1205
|
type StrategyCloseReason = "time_expired" | "take_profit" | "stop_loss";
|
|
1206
|
+
/**
|
|
1207
|
+
* Reason why scheduled signal was cancelled.
|
|
1208
|
+
* Used in discriminated union for type-safe handling.
|
|
1209
|
+
*/
|
|
1210
|
+
type StrategyCancelReason = "timeout" | "price_reject" | "user";
|
|
1196
1211
|
/**
|
|
1197
1212
|
* Profit and loss calculation result.
|
|
1198
1213
|
* Includes adjusted prices with fees (0.1%) and slippage (0.1%).
|
|
@@ -1335,6 +1350,10 @@ interface IStrategyTickResultCancelled {
|
|
|
1335
1350
|
symbol: string;
|
|
1336
1351
|
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
1337
1352
|
backtest: boolean;
|
|
1353
|
+
/** Reason for cancellation */
|
|
1354
|
+
reason: StrategyCancelReason;
|
|
1355
|
+
/** Optional cancellation ID (provided when user calls Backtest.cancel() or Live.cancel()) */
|
|
1356
|
+
cancelId?: string;
|
|
1338
1357
|
}
|
|
1339
1358
|
/**
|
|
1340
1359
|
* Discriminated union of all tick results.
|
|
@@ -3174,6 +3193,80 @@ interface RiskContract {
|
|
|
3174
3193
|
backtest: boolean;
|
|
3175
3194
|
}
|
|
3176
3195
|
|
|
3196
|
+
/**
|
|
3197
|
+
* Contract for ping events during scheduled signal monitoring.
|
|
3198
|
+
*
|
|
3199
|
+
* Emitted by pingSubject every minute when a scheduled signal is being monitored.
|
|
3200
|
+
* Used for tracking scheduled signal lifecycle and custom monitoring logic.
|
|
3201
|
+
*
|
|
3202
|
+
* Events are emitted only when scheduled signal is active (not cancelled, not activated).
|
|
3203
|
+
* Allows users to implement custom cancellation logic via onPing callback.
|
|
3204
|
+
*
|
|
3205
|
+
* Consumers:
|
|
3206
|
+
* - User callbacks via listenPing() / listenPingOnce()
|
|
3207
|
+
*
|
|
3208
|
+
* @example
|
|
3209
|
+
* ```typescript
|
|
3210
|
+
* import { listenPing } from "backtest-kit";
|
|
3211
|
+
*
|
|
3212
|
+
* // Listen to all ping events
|
|
3213
|
+
* listenPing((event) => {
|
|
3214
|
+
* console.log(`[${event.backtest ? "Backtest" : "Live"}] Ping for ${event.symbol}`);
|
|
3215
|
+
* console.log(`Strategy: ${event.strategyName}, Exchange: ${event.exchangeName}`);
|
|
3216
|
+
* console.log(`Signal ID: ${event.data.id}, priceOpen: ${event.data.priceOpen}`);
|
|
3217
|
+
* console.log(`Timestamp: ${new Date(event.timestamp).toISOString()}`);
|
|
3218
|
+
* });
|
|
3219
|
+
*
|
|
3220
|
+
* // Wait for specific ping
|
|
3221
|
+
* listenPingOnce(
|
|
3222
|
+
* (event) => event.symbol === "BTCUSDT",
|
|
3223
|
+
* (event) => console.log("BTCUSDT ping received:", event.timestamp)
|
|
3224
|
+
* );
|
|
3225
|
+
* ```
|
|
3226
|
+
*/
|
|
3227
|
+
interface PingContract {
|
|
3228
|
+
/**
|
|
3229
|
+
* Trading pair symbol (e.g., "BTCUSDT").
|
|
3230
|
+
* Identifies which market this ping event belongs to.
|
|
3231
|
+
*/
|
|
3232
|
+
symbol: string;
|
|
3233
|
+
/**
|
|
3234
|
+
* Strategy name that is monitoring this scheduled signal.
|
|
3235
|
+
* Identifies which strategy execution this ping event belongs to.
|
|
3236
|
+
*/
|
|
3237
|
+
strategyName: string;
|
|
3238
|
+
/**
|
|
3239
|
+
* Exchange name where this scheduled signal is being monitored.
|
|
3240
|
+
* Identifies which exchange this ping event belongs to.
|
|
3241
|
+
*/
|
|
3242
|
+
exchangeName: string;
|
|
3243
|
+
/**
|
|
3244
|
+
* Complete scheduled signal row data.
|
|
3245
|
+
* Contains all signal information: id, position, priceOpen, priceTakeProfit, priceStopLoss, etc.
|
|
3246
|
+
*/
|
|
3247
|
+
data: IScheduledSignalRow;
|
|
3248
|
+
/**
|
|
3249
|
+
* Execution mode flag.
|
|
3250
|
+
* - true: Event from backtest execution (historical candle data)
|
|
3251
|
+
* - false: Event from live trading (real-time tick)
|
|
3252
|
+
*/
|
|
3253
|
+
backtest: boolean;
|
|
3254
|
+
/**
|
|
3255
|
+
* Event timestamp in milliseconds since Unix epoch.
|
|
3256
|
+
*
|
|
3257
|
+
* Timing semantics:
|
|
3258
|
+
* - Live mode: when.getTime() at the moment of ping
|
|
3259
|
+
* - Backtest mode: candle.timestamp of the candle being processed
|
|
3260
|
+
*
|
|
3261
|
+
* @example
|
|
3262
|
+
* ```typescript
|
|
3263
|
+
* const eventDate = new Date(event.timestamp);
|
|
3264
|
+
* console.log(`Ping at: ${eventDate.toISOString()}`);
|
|
3265
|
+
* ```
|
|
3266
|
+
*/
|
|
3267
|
+
timestamp: number;
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3177
3270
|
/**
|
|
3178
3271
|
* Subscribes to all signal events with queued async processing.
|
|
3179
3272
|
*
|
|
@@ -3957,6 +4050,61 @@ declare function listenRisk(fn: (event: RiskContract) => void): () => void;
|
|
|
3957
4050
|
* ```
|
|
3958
4051
|
*/
|
|
3959
4052
|
declare function listenRiskOnce(filterFn: (event: RiskContract) => boolean, fn: (event: RiskContract) => void): () => void;
|
|
4053
|
+
/**
|
|
4054
|
+
* Subscribes to ping events during scheduled signal monitoring with queued async processing.
|
|
4055
|
+
*
|
|
4056
|
+
* Events are emitted every minute when a scheduled signal is being monitored (waiting for activation).
|
|
4057
|
+
* Allows tracking of scheduled signal lifecycle and custom monitoring logic.
|
|
4058
|
+
*
|
|
4059
|
+
* @param fn - Callback function to handle ping events
|
|
4060
|
+
* @returns Unsubscribe function to stop listening
|
|
4061
|
+
*
|
|
4062
|
+
* @example
|
|
4063
|
+
* ```typescript
|
|
4064
|
+
* import { listenPing } from "./function/event";
|
|
4065
|
+
*
|
|
4066
|
+
* const unsubscribe = listenPing((event) => {
|
|
4067
|
+
* console.log(`Ping for ${event.symbol} at ${new Date(event.timestamp).toISOString()}`);
|
|
4068
|
+
* console.log(`Strategy: ${event.strategyName}, Exchange: ${event.exchangeName}`);
|
|
4069
|
+
* console.log(`Mode: ${event.backtest ? "Backtest" : "Live"}`);
|
|
4070
|
+
* });
|
|
4071
|
+
*
|
|
4072
|
+
* // Later: stop listening
|
|
4073
|
+
* unsubscribe();
|
|
4074
|
+
* ```
|
|
4075
|
+
*/
|
|
4076
|
+
declare function listenPing(fn: (event: PingContract) => void): () => void;
|
|
4077
|
+
/**
|
|
4078
|
+
* Subscribes to filtered ping events with one-time execution.
|
|
4079
|
+
*
|
|
4080
|
+
* Listens for events matching the filter predicate, then executes callback once
|
|
4081
|
+
* and automatically unsubscribes. Useful for waiting for specific ping conditions.
|
|
4082
|
+
*
|
|
4083
|
+
* @param filterFn - Predicate to filter which events trigger the callback
|
|
4084
|
+
* @param fn - Callback function to handle the filtered event (called only once)
|
|
4085
|
+
* @returns Unsubscribe function to cancel the listener before it fires
|
|
4086
|
+
*
|
|
4087
|
+
* @example
|
|
4088
|
+
* ```typescript
|
|
4089
|
+
* import { listenPingOnce } from "./function/event";
|
|
4090
|
+
*
|
|
4091
|
+
* // Wait for first ping on BTCUSDT
|
|
4092
|
+
* listenPingOnce(
|
|
4093
|
+
* (event) => event.symbol === "BTCUSDT",
|
|
4094
|
+
* (event) => console.log("First BTCUSDT ping received")
|
|
4095
|
+
* );
|
|
4096
|
+
*
|
|
4097
|
+
* // Wait for ping in backtest mode
|
|
4098
|
+
* const cancel = listenPingOnce(
|
|
4099
|
+
* (event) => event.backtest === true,
|
|
4100
|
+
* (event) => console.log("Backtest ping received at", new Date(event.timestamp))
|
|
4101
|
+
* );
|
|
4102
|
+
*
|
|
4103
|
+
* // Cancel if needed before event fires
|
|
4104
|
+
* cancel();
|
|
4105
|
+
* ```
|
|
4106
|
+
*/
|
|
4107
|
+
declare function listenPingOnce(filterFn: (event: PingContract) => boolean, fn: (event: PingContract) => void): () => void;
|
|
3960
4108
|
|
|
3961
4109
|
/**
|
|
3962
4110
|
* Checks if trade context is active (execution and method contexts).
|
|
@@ -4357,6 +4505,10 @@ interface ScheduledEvent {
|
|
|
4357
4505
|
closeTimestamp?: number;
|
|
4358
4506
|
/** Duration in minutes (only for cancelled/opened) */
|
|
4359
4507
|
duration?: number;
|
|
4508
|
+
/** Cancellation reason (only for cancelled events) */
|
|
4509
|
+
cancelReason?: "timeout" | "price_reject" | "user";
|
|
4510
|
+
/** Cancellation ID (only for user-initiated cancellations) */
|
|
4511
|
+
cancelId?: string;
|
|
4360
4512
|
}
|
|
4361
4513
|
/**
|
|
4362
4514
|
* Statistical data calculated from scheduled signals.
|
|
@@ -5290,6 +5442,40 @@ declare class BacktestUtils {
|
|
|
5290
5442
|
exchangeName: string;
|
|
5291
5443
|
frameName: string;
|
|
5292
5444
|
}) => () => void;
|
|
5445
|
+
/**
|
|
5446
|
+
* Retrieves the currently active pending signal for the strategy.
|
|
5447
|
+
* If no active signal exists, returns null.
|
|
5448
|
+
*
|
|
5449
|
+
* @param symbol - Trading pair symbol
|
|
5450
|
+
* @param strategyName - Name of strategy to get pending signal for
|
|
5451
|
+
* @returns Promise resolving to pending signal or null
|
|
5452
|
+
*
|
|
5453
|
+
* @example
|
|
5454
|
+
* ```typescript
|
|
5455
|
+
* const pending = await Backtest.getPendingSignal("BTCUSDT", "my-strategy");
|
|
5456
|
+
* if (pending) {
|
|
5457
|
+
* console.log("Active signal:", pending.id);
|
|
5458
|
+
* }
|
|
5459
|
+
* ```
|
|
5460
|
+
*/
|
|
5461
|
+
getPendingSignal: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow>;
|
|
5462
|
+
/**
|
|
5463
|
+
* Retrieves the currently active scheduled signal for the strategy.
|
|
5464
|
+
* If no scheduled signal exists, returns null.
|
|
5465
|
+
*
|
|
5466
|
+
* @param symbol - Trading pair symbol
|
|
5467
|
+
* @param strategyName - Name of strategy to get scheduled signal for
|
|
5468
|
+
* @returns Promise resolving to scheduled signal or null
|
|
5469
|
+
*
|
|
5470
|
+
* @example
|
|
5471
|
+
* ```typescript
|
|
5472
|
+
* const scheduled = await Backtest.getScheduledSignal("BTCUSDT", "my-strategy");
|
|
5473
|
+
* if (scheduled) {
|
|
5474
|
+
* console.log("Scheduled signal:", scheduled.id);
|
|
5475
|
+
* }
|
|
5476
|
+
* ```
|
|
5477
|
+
*/
|
|
5478
|
+
getScheduledSignal: (symbol: string, strategyName: StrategyName) => Promise<IScheduledSignalRow>;
|
|
5293
5479
|
/**
|
|
5294
5480
|
* Stops the strategy from generating new signals.
|
|
5295
5481
|
*
|
|
@@ -5308,6 +5494,25 @@ declare class BacktestUtils {
|
|
|
5308
5494
|
* ```
|
|
5309
5495
|
*/
|
|
5310
5496
|
stop: (symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
5497
|
+
/**
|
|
5498
|
+
* Cancels the scheduled signal without stopping the strategy.
|
|
5499
|
+
*
|
|
5500
|
+
* Clears the scheduled signal (waiting for priceOpen activation).
|
|
5501
|
+
* Does NOT affect active pending signals or strategy operation.
|
|
5502
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
5503
|
+
*
|
|
5504
|
+
* @param symbol - Trading pair symbol
|
|
5505
|
+
* @param strategyName - Strategy name
|
|
5506
|
+
* @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
|
|
5507
|
+
* @returns Promise that resolves when scheduled signal is cancelled
|
|
5508
|
+
*
|
|
5509
|
+
* @example
|
|
5510
|
+
* ```typescript
|
|
5511
|
+
* // Cancel scheduled signal with custom ID
|
|
5512
|
+
* await Backtest.cancel("BTCUSDT", "my-strategy", "manual-cancel-001");
|
|
5513
|
+
* ```
|
|
5514
|
+
*/
|
|
5515
|
+
cancel: (symbol: string, strategyName: StrategyName, cancelId?: string) => Promise<void>;
|
|
5311
5516
|
/**
|
|
5312
5517
|
* Gets statistical data from all closed signals for a symbol-strategy pair.
|
|
5313
5518
|
*
|
|
@@ -5656,6 +5861,40 @@ declare class LiveUtils {
|
|
|
5656
5861
|
strategyName: string;
|
|
5657
5862
|
exchangeName: string;
|
|
5658
5863
|
}) => () => void;
|
|
5864
|
+
/**
|
|
5865
|
+
* Retrieves the currently active pending signal for the strategy.
|
|
5866
|
+
* If no active signal exists, returns null.
|
|
5867
|
+
*
|
|
5868
|
+
* @param symbol - Trading pair symbol
|
|
5869
|
+
* @param strategyName - Name of strategy to get pending signal for
|
|
5870
|
+
* @returns Promise resolving to pending signal or null
|
|
5871
|
+
*
|
|
5872
|
+
* @example
|
|
5873
|
+
* ```typescript
|
|
5874
|
+
* const pending = await Live.getPendingSignal("BTCUSDT", "my-strategy");
|
|
5875
|
+
* if (pending) {
|
|
5876
|
+
* console.log("Active signal:", pending.id);
|
|
5877
|
+
* }
|
|
5878
|
+
* ```
|
|
5879
|
+
*/
|
|
5880
|
+
getPendingSignal: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow>;
|
|
5881
|
+
/**
|
|
5882
|
+
* Retrieves the currently active scheduled signal for the strategy.
|
|
5883
|
+
* If no scheduled signal exists, returns null.
|
|
5884
|
+
*
|
|
5885
|
+
* @param symbol - Trading pair symbol
|
|
5886
|
+
* @param strategyName - Name of strategy to get scheduled signal for
|
|
5887
|
+
* @returns Promise resolving to scheduled signal or null
|
|
5888
|
+
*
|
|
5889
|
+
* @example
|
|
5890
|
+
* ```typescript
|
|
5891
|
+
* const scheduled = await Live.getScheduledSignal("BTCUSDT", "my-strategy");
|
|
5892
|
+
* if (scheduled) {
|
|
5893
|
+
* console.log("Scheduled signal:", scheduled.id);
|
|
5894
|
+
* }
|
|
5895
|
+
* ```
|
|
5896
|
+
*/
|
|
5897
|
+
getScheduledSignal: (symbol: string, strategyName: StrategyName) => Promise<IScheduledSignalRow>;
|
|
5659
5898
|
/**
|
|
5660
5899
|
* Stops the strategy from generating new signals.
|
|
5661
5900
|
*
|
|
@@ -5674,6 +5913,25 @@ declare class LiveUtils {
|
|
|
5674
5913
|
* ```
|
|
5675
5914
|
*/
|
|
5676
5915
|
stop: (symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
5916
|
+
/**
|
|
5917
|
+
* Cancels the scheduled signal without stopping the strategy.
|
|
5918
|
+
*
|
|
5919
|
+
* Clears the scheduled signal (waiting for priceOpen activation).
|
|
5920
|
+
* Does NOT affect active pending signals or strategy operation.
|
|
5921
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
5922
|
+
*
|
|
5923
|
+
* @param symbol - Trading pair symbol
|
|
5924
|
+
* @param strategyName - Strategy name
|
|
5925
|
+
* @param cancelId - Optional cancellation ID for tracking user-initiated cancellations
|
|
5926
|
+
* @returns Promise that resolves when scheduled signal is cancelled
|
|
5927
|
+
*
|
|
5928
|
+
* @example
|
|
5929
|
+
* ```typescript
|
|
5930
|
+
* // Cancel scheduled signal in live trading with custom ID
|
|
5931
|
+
* await Live.cancel("BTCUSDT", "my-strategy", "manual-cancel-001");
|
|
5932
|
+
* ```
|
|
5933
|
+
*/
|
|
5934
|
+
cancel: (symbol: string, strategyName: StrategyName, cancelId?: string) => Promise<void>;
|
|
5677
5935
|
/**
|
|
5678
5936
|
* Gets statistical data from all live trading events for a symbol-strategy pair.
|
|
5679
5937
|
*
|
|
@@ -8204,6 +8462,12 @@ declare const partialLossSubject: Subject<PartialLossContract>;
|
|
|
8204
8462
|
* Does not emit for allowed signals (prevents spam).
|
|
8205
8463
|
*/
|
|
8206
8464
|
declare const riskSubject: Subject<RiskContract>;
|
|
8465
|
+
/**
|
|
8466
|
+
* Ping emitter for scheduled signal monitoring events.
|
|
8467
|
+
* Emits every minute when a scheduled signal is being monitored (waiting for activation).
|
|
8468
|
+
* Allows users to track scheduled signal lifecycle and implement custom cancellation logic.
|
|
8469
|
+
*/
|
|
8470
|
+
declare const pingSubject: Subject<PingContract>;
|
|
8207
8471
|
|
|
8208
8472
|
declare const emitters_doneBacktestSubject: typeof doneBacktestSubject;
|
|
8209
8473
|
declare const emitters_doneLiveSubject: typeof doneLiveSubject;
|
|
@@ -8213,6 +8477,7 @@ declare const emitters_exitEmitter: typeof exitEmitter;
|
|
|
8213
8477
|
declare const emitters_partialLossSubject: typeof partialLossSubject;
|
|
8214
8478
|
declare const emitters_partialProfitSubject: typeof partialProfitSubject;
|
|
8215
8479
|
declare const emitters_performanceEmitter: typeof performanceEmitter;
|
|
8480
|
+
declare const emitters_pingSubject: typeof pingSubject;
|
|
8216
8481
|
declare const emitters_progressBacktestEmitter: typeof progressBacktestEmitter;
|
|
8217
8482
|
declare const emitters_progressOptimizerEmitter: typeof progressOptimizerEmitter;
|
|
8218
8483
|
declare const emitters_progressWalkerEmitter: typeof progressWalkerEmitter;
|
|
@@ -8225,7 +8490,7 @@ declare const emitters_walkerCompleteSubject: typeof walkerCompleteSubject;
|
|
|
8225
8490
|
declare const emitters_walkerEmitter: typeof walkerEmitter;
|
|
8226
8491
|
declare const emitters_walkerStopSubject: typeof walkerStopSubject;
|
|
8227
8492
|
declare namespace emitters {
|
|
8228
|
-
export { emitters_doneBacktestSubject as doneBacktestSubject, emitters_doneLiveSubject as doneLiveSubject, emitters_doneWalkerSubject as doneWalkerSubject, emitters_errorEmitter as errorEmitter, emitters_exitEmitter as exitEmitter, emitters_partialLossSubject as partialLossSubject, emitters_partialProfitSubject as partialProfitSubject, emitters_performanceEmitter as performanceEmitter, emitters_progressBacktestEmitter as progressBacktestEmitter, emitters_progressOptimizerEmitter as progressOptimizerEmitter, emitters_progressWalkerEmitter as progressWalkerEmitter, emitters_riskSubject as riskSubject, emitters_signalBacktestEmitter as signalBacktestEmitter, emitters_signalEmitter as signalEmitter, emitters_signalLiveEmitter as signalLiveEmitter, emitters_validationSubject as validationSubject, emitters_walkerCompleteSubject as walkerCompleteSubject, emitters_walkerEmitter as walkerEmitter, emitters_walkerStopSubject as walkerStopSubject };
|
|
8493
|
+
export { emitters_doneBacktestSubject as doneBacktestSubject, emitters_doneLiveSubject as doneLiveSubject, emitters_doneWalkerSubject as doneWalkerSubject, emitters_errorEmitter as errorEmitter, emitters_exitEmitter as exitEmitter, emitters_partialLossSubject as partialLossSubject, emitters_partialProfitSubject as partialProfitSubject, emitters_performanceEmitter as performanceEmitter, emitters_pingSubject as pingSubject, emitters_progressBacktestEmitter as progressBacktestEmitter, emitters_progressOptimizerEmitter as progressOptimizerEmitter, emitters_progressWalkerEmitter as progressWalkerEmitter, emitters_riskSubject as riskSubject, emitters_signalBacktestEmitter as signalBacktestEmitter, emitters_signalEmitter as signalEmitter, emitters_signalLiveEmitter as signalLiveEmitter, emitters_validationSubject as validationSubject, emitters_walkerCompleteSubject as walkerCompleteSubject, emitters_walkerEmitter as walkerEmitter, emitters_walkerStopSubject as walkerStopSubject };
|
|
8229
8494
|
}
|
|
8230
8495
|
|
|
8231
8496
|
/**
|
|
@@ -8825,6 +9090,17 @@ declare class StrategyConnectionService {
|
|
|
8825
9090
|
* @returns Promise resolving to pending signal or null
|
|
8826
9091
|
*/
|
|
8827
9092
|
getPendingSignal: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
9093
|
+
/**
|
|
9094
|
+
* Retrieves the currently active scheduled signal for the strategy.
|
|
9095
|
+
* If no scheduled signal exists, returns null.
|
|
9096
|
+
* Used internally for monitoring scheduled signal activation.
|
|
9097
|
+
*
|
|
9098
|
+
* @param symbol - Trading pair symbol
|
|
9099
|
+
* @param strategyName - Name of strategy to get scheduled signal for
|
|
9100
|
+
*
|
|
9101
|
+
* @returns Promise resolving to scheduled signal or null
|
|
9102
|
+
*/
|
|
9103
|
+
getScheduledSignal: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<IScheduledSignalRow | null>;
|
|
8828
9104
|
/**
|
|
8829
9105
|
* Retrieves the stopped state of the strategy.
|
|
8830
9106
|
*
|
|
@@ -8885,6 +9161,24 @@ declare class StrategyConnectionService {
|
|
|
8885
9161
|
symbol: string;
|
|
8886
9162
|
strategyName: StrategyName;
|
|
8887
9163
|
}) => Promise<void>;
|
|
9164
|
+
/**
|
|
9165
|
+
* Cancels the scheduled signal for the specified strategy.
|
|
9166
|
+
*
|
|
9167
|
+
* Delegates to ClientStrategy.cancel() which clears the scheduled signal
|
|
9168
|
+
* without stopping the strategy or affecting pending signals.
|
|
9169
|
+
*
|
|
9170
|
+
* Note: Cancelled event will be emitted on next tick() call when strategy
|
|
9171
|
+
* detects the scheduled signal was cancelled.
|
|
9172
|
+
*
|
|
9173
|
+
* @param backtest - Whether running in backtest mode
|
|
9174
|
+
* @param ctx - Context with symbol and strategyName
|
|
9175
|
+
* @param cancelId - Optional cancellation ID for user-initiated cancellations
|
|
9176
|
+
* @returns Promise that resolves when scheduled signal is cancelled
|
|
9177
|
+
*/
|
|
9178
|
+
cancel: (backtest: boolean, ctx: {
|
|
9179
|
+
symbol: string;
|
|
9180
|
+
strategyName: StrategyName;
|
|
9181
|
+
}, cancelId?: string) => Promise<void>;
|
|
8888
9182
|
}
|
|
8889
9183
|
|
|
8890
9184
|
/**
|
|
@@ -9150,6 +9444,16 @@ declare class StrategyCoreService {
|
|
|
9150
9444
|
* @returns Promise resolving to pending signal or null
|
|
9151
9445
|
*/
|
|
9152
9446
|
getPendingSignal: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
9447
|
+
/**
|
|
9448
|
+
* Retrieves the currently active scheduled signal for the symbol.
|
|
9449
|
+
* If no scheduled signal exists, returns null.
|
|
9450
|
+
* Used internally for monitoring scheduled signal activation.
|
|
9451
|
+
*
|
|
9452
|
+
* @param symbol - Trading pair symbol
|
|
9453
|
+
* @param strategyName - Name of the strategy
|
|
9454
|
+
* @returns Promise resolving to scheduled signal or null
|
|
9455
|
+
*/
|
|
9456
|
+
getScheduledSignal: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<IScheduledSignalRow | null>;
|
|
9153
9457
|
/**
|
|
9154
9458
|
* Checks if the strategy has been stopped.
|
|
9155
9459
|
*
|
|
@@ -9200,6 +9504,22 @@ declare class StrategyCoreService {
|
|
|
9200
9504
|
symbol: string;
|
|
9201
9505
|
strategyName: StrategyName;
|
|
9202
9506
|
}) => Promise<void>;
|
|
9507
|
+
/**
|
|
9508
|
+
* Cancels the scheduled signal without stopping the strategy.
|
|
9509
|
+
*
|
|
9510
|
+
* Delegates to StrategyConnectionService.cancel() to clear scheduled signal
|
|
9511
|
+
* and emit cancelled event through emitters.
|
|
9512
|
+
* Does not require execution context.
|
|
9513
|
+
*
|
|
9514
|
+
* @param backtest - Whether running in backtest mode
|
|
9515
|
+
* @param ctx - Context with symbol and strategyName
|
|
9516
|
+
* @param cancelId - Optional cancellation ID for user-initiated cancellations
|
|
9517
|
+
* @returns Promise that resolves when scheduled signal is cancelled
|
|
9518
|
+
*/
|
|
9519
|
+
cancel: (backtest: boolean, ctx: {
|
|
9520
|
+
symbol: string;
|
|
9521
|
+
strategyName: StrategyName;
|
|
9522
|
+
}, cancelId?: string) => Promise<void>;
|
|
9203
9523
|
/**
|
|
9204
9524
|
* Clears the memoized ClientStrategy instance from cache.
|
|
9205
9525
|
*
|
|
@@ -10910,4 +11230,4 @@ declare const backtest: {
|
|
|
10910
11230
|
loggerService: LoggerService;
|
|
10911
11231
|
};
|
|
10912
11232
|
|
|
10913
|
-
export { Backtest, type BacktestStatisticsModel, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, Live, type LiveStatisticsModel, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, type ProgressBacktestContract, type ProgressOptimizerContract, type ProgressWalkerContract, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskStatisticsModel, Schedule, type ScheduleData, type ScheduleStatisticsModel, type ScheduledEvent, type SignalData, type SignalInterval, type TPersistBase, type TPersistBaseCtor, type TickEvent, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addExchange, addFrame, addOptimizer, addRisk, addSizing, addStrategy, addWalker, dumpSignal, emitters, formatPrice, formatQuantity, getAveragePrice, getCandles, getColumns, getConfig, getDate, getDefaultColumns, getDefaultConfig, getMode, hasTradeContext, backtest as lib, listExchanges, listFrames, listOptimizers, listRisks, listSizings, listStrategies, listWalkers, listenBacktestProgress, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLoss, listenPartialLossOnce, listenPartialProfit, listenPartialProfitOnce, listenPerformance, listenRisk, listenRiskOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, setColumns, setConfig, setLogger, validate };
|
|
11233
|
+
export { Backtest, type BacktestStatisticsModel, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, Live, type LiveStatisticsModel, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, type PingContract, PositionSize, type ProgressBacktestContract, type ProgressOptimizerContract, type ProgressWalkerContract, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskStatisticsModel, Schedule, type ScheduleData, type ScheduleStatisticsModel, type ScheduledEvent, type SignalData, type SignalInterval, type TPersistBase, type TPersistBaseCtor, type TickEvent, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addExchange, addFrame, addOptimizer, addRisk, addSizing, addStrategy, addWalker, dumpSignal, emitters, formatPrice, formatQuantity, getAveragePrice, getCandles, getColumns, getConfig, getDate, getDefaultColumns, getDefaultConfig, getMode, hasTradeContext, backtest as lib, listExchanges, listFrames, listOptimizers, listRisks, listSizings, listStrategies, listWalkers, listenBacktestProgress, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLoss, listenPartialLossOnce, listenPartialProfit, listenPartialProfitOnce, listenPerformance, listenPing, listenPingOnce, listenRisk, listenRiskOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, setColumns, setConfig, setLogger, validate };
|