backtest-kit 1.13.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/build/index.cjs +880 -398
- package/build/index.mjs +831 -353
- package/package.json +1 -1
- package/types.d.ts +484 -196
package/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { WriteStream } from 'fs';
|
|
|
9
9
|
* @returns Promise resolving to array of Date objects representing tick timestamps
|
|
10
10
|
* @throws Error if called outside of backtest execution context
|
|
11
11
|
*/
|
|
12
|
-
declare function
|
|
12
|
+
declare function getBacktestTimeframe(symbol: string): Promise<Date[]>;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Type alias for enum objects with string key-value pairs
|
|
@@ -1169,8 +1169,10 @@ interface IStrategyCallbacks {
|
|
|
1169
1169
|
onPartialLoss: (symbol: string, data: IPublicSignalRow, currentPrice: number, lossPercent: number, backtest: boolean) => void | Promise<void>;
|
|
1170
1170
|
/** Called when signal reaches breakeven (stop-loss moved to entry price to protect capital) */
|
|
1171
1171
|
onBreakeven: (symbol: string, data: IPublicSignalRow, currentPrice: number, backtest: boolean) => void | Promise<void>;
|
|
1172
|
-
/** Called every minute regardless of strategy interval (for custom monitoring like checking if signal should be cancelled) */
|
|
1173
|
-
|
|
1172
|
+
/** Called every minute for scheduled signals regardless of strategy interval (for custom monitoring like checking if signal should be cancelled) */
|
|
1173
|
+
onSchedulePing: (symbol: string, data: IPublicSignalRow, when: Date, backtest: boolean) => void | Promise<void>;
|
|
1174
|
+
/** Called every minute for active pending signals regardless of strategy interval (for custom monitoring and dynamic management) */
|
|
1175
|
+
onActivePing: (symbol: string, data: IPublicSignalRow, when: Date, backtest: boolean) => void | Promise<void>;
|
|
1174
1176
|
}
|
|
1175
1177
|
/**
|
|
1176
1178
|
* Strategy schema registered via addStrategy().
|
|
@@ -1263,6 +1265,35 @@ interface IStrategyTickResultScheduled {
|
|
|
1263
1265
|
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
1264
1266
|
backtest: boolean;
|
|
1265
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Tick result: scheduled signal is waiting for price to reach entry point.
|
|
1270
|
+
* This is returned on subsequent ticks while monitoring a scheduled signal.
|
|
1271
|
+
* Different from "scheduled" which is only returned once when signal is first created.
|
|
1272
|
+
*/
|
|
1273
|
+
interface IStrategyTickResultWaiting {
|
|
1274
|
+
/** Discriminator for type-safe union */
|
|
1275
|
+
action: "waiting";
|
|
1276
|
+
/** Scheduled signal waiting for activation */
|
|
1277
|
+
signal: IPublicSignalRow;
|
|
1278
|
+
/** Current VWAP price for monitoring */
|
|
1279
|
+
currentPrice: number;
|
|
1280
|
+
/** Strategy name for tracking */
|
|
1281
|
+
strategyName: StrategyName;
|
|
1282
|
+
/** Exchange name for tracking */
|
|
1283
|
+
exchangeName: ExchangeName;
|
|
1284
|
+
/** Time frame name for tracking (e.g., "1m", "5m") */
|
|
1285
|
+
frameName: FrameName;
|
|
1286
|
+
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
1287
|
+
symbol: string;
|
|
1288
|
+
/** Percentage progress towards take profit (always 0 for waiting scheduled signals) */
|
|
1289
|
+
percentTp: number;
|
|
1290
|
+
/** Percentage progress towards stop loss (always 0 for waiting scheduled signals) */
|
|
1291
|
+
percentSl: number;
|
|
1292
|
+
/** Unrealized PNL for scheduled position (theoretical, not yet activated) */
|
|
1293
|
+
pnl: IStrategyPnL;
|
|
1294
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
1295
|
+
backtest: boolean;
|
|
1296
|
+
}
|
|
1266
1297
|
/**
|
|
1267
1298
|
* Tick result: new signal just created.
|
|
1268
1299
|
* Triggered after getSignal validation and persistence.
|
|
@@ -1373,7 +1404,7 @@ interface IStrategyTickResultCancelled {
|
|
|
1373
1404
|
* Discriminated union of all tick results.
|
|
1374
1405
|
* Use type guards: `result.action === "closed"` for type safety.
|
|
1375
1406
|
*/
|
|
1376
|
-
type IStrategyTickResult = IStrategyTickResultIdle | IStrategyTickResultScheduled | IStrategyTickResultOpened | IStrategyTickResultActive | IStrategyTickResultClosed | IStrategyTickResultCancelled;
|
|
1407
|
+
type IStrategyTickResult = IStrategyTickResultIdle | IStrategyTickResultScheduled | IStrategyTickResultWaiting | IStrategyTickResultOpened | IStrategyTickResultActive | IStrategyTickResultClosed | IStrategyTickResultCancelled;
|
|
1377
1408
|
/**
|
|
1378
1409
|
* Backtest returns closed result (TP/SL or time_expired) or cancelled result (scheduled signal never activated).
|
|
1379
1410
|
*/
|
|
@@ -2052,37 +2083,37 @@ interface PartialLossContract {
|
|
|
2052
2083
|
}
|
|
2053
2084
|
|
|
2054
2085
|
/**
|
|
2055
|
-
* Contract for ping events during scheduled signal monitoring.
|
|
2086
|
+
* Contract for schedule ping events during scheduled signal monitoring.
|
|
2056
2087
|
*
|
|
2057
|
-
* Emitted by
|
|
2088
|
+
* Emitted by schedulePingSubject every minute when a scheduled signal is being monitored.
|
|
2058
2089
|
* Used for tracking scheduled signal lifecycle and custom monitoring logic.
|
|
2059
2090
|
*
|
|
2060
2091
|
* Events are emitted only when scheduled signal is active (not cancelled, not activated).
|
|
2061
|
-
* Allows users to implement custom cancellation logic via
|
|
2092
|
+
* Allows users to implement custom cancellation logic via onSchedulePing callback.
|
|
2062
2093
|
*
|
|
2063
2094
|
* Consumers:
|
|
2064
|
-
* - User callbacks via
|
|
2095
|
+
* - User callbacks via listenSchedulePing() / listenSchedulePingOnce()
|
|
2065
2096
|
*
|
|
2066
2097
|
* @example
|
|
2067
2098
|
* ```typescript
|
|
2068
|
-
* import {
|
|
2099
|
+
* import { listenSchedulePing } from "backtest-kit";
|
|
2069
2100
|
*
|
|
2070
|
-
* // Listen to all ping events
|
|
2071
|
-
*
|
|
2072
|
-
* console.log(`[${event.backtest ? "Backtest" : "Live"}] Ping for ${event.symbol}`);
|
|
2101
|
+
* // Listen to all schedule ping events
|
|
2102
|
+
* listenSchedulePing((event) => {
|
|
2103
|
+
* console.log(`[${event.backtest ? "Backtest" : "Live"}] Schedule Ping for ${event.symbol}`);
|
|
2073
2104
|
* console.log(`Strategy: ${event.strategyName}, Exchange: ${event.exchangeName}`);
|
|
2074
2105
|
* console.log(`Signal ID: ${event.data.id}, priceOpen: ${event.data.priceOpen}`);
|
|
2075
2106
|
* console.log(`Timestamp: ${new Date(event.timestamp).toISOString()}`);
|
|
2076
2107
|
* });
|
|
2077
2108
|
*
|
|
2078
|
-
* // Wait for specific ping
|
|
2079
|
-
*
|
|
2109
|
+
* // Wait for specific schedule ping
|
|
2110
|
+
* listenSchedulePingOnce(
|
|
2080
2111
|
* (event) => event.symbol === "BTCUSDT",
|
|
2081
|
-
* (event) => console.log("BTCUSDT ping received:", event.timestamp)
|
|
2112
|
+
* (event) => console.log("BTCUSDT schedule ping received:", event.timestamp)
|
|
2082
2113
|
* );
|
|
2083
2114
|
* ```
|
|
2084
2115
|
*/
|
|
2085
|
-
interface
|
|
2116
|
+
interface SchedulePingContract {
|
|
2086
2117
|
/**
|
|
2087
2118
|
* Trading pair symbol (e.g., "BTCUSDT").
|
|
2088
2119
|
* Identifies which market this ping event belongs to.
|
|
@@ -2125,6 +2156,80 @@ interface PingContract {
|
|
|
2125
2156
|
timestamp: number;
|
|
2126
2157
|
}
|
|
2127
2158
|
|
|
2159
|
+
/**
|
|
2160
|
+
* Contract for active ping events during active pending signal monitoring.
|
|
2161
|
+
*
|
|
2162
|
+
* Emitted by activePingSubject every minute when an active pending signal is being monitored.
|
|
2163
|
+
* Used for tracking active signal lifecycle and custom dynamic management logic.
|
|
2164
|
+
*
|
|
2165
|
+
* Events are emitted only when pending signal is active (not closed yet).
|
|
2166
|
+
* Allows users to implement custom management logic via onActivePing callback.
|
|
2167
|
+
*
|
|
2168
|
+
* Consumers:
|
|
2169
|
+
* - User callbacks via listenActivePing() / listenActivePingOnce()
|
|
2170
|
+
*
|
|
2171
|
+
* @example
|
|
2172
|
+
* ```typescript
|
|
2173
|
+
* import { listenActivePing } from "backtest-kit";
|
|
2174
|
+
*
|
|
2175
|
+
* // Listen to all active ping events
|
|
2176
|
+
* listenActivePing((event) => {
|
|
2177
|
+
* console.log(`[${event.backtest ? "Backtest" : "Live"}] Active Ping for ${event.symbol}`);
|
|
2178
|
+
* console.log(`Strategy: ${event.strategyName}, Exchange: ${event.exchangeName}`);
|
|
2179
|
+
* console.log(`Signal ID: ${event.data.id}, Position: ${event.data.position}`);
|
|
2180
|
+
* console.log(`Timestamp: ${new Date(event.timestamp).toISOString()}`);
|
|
2181
|
+
* });
|
|
2182
|
+
*
|
|
2183
|
+
* // Wait for specific active ping
|
|
2184
|
+
* listenActivePingOnce(
|
|
2185
|
+
* (event) => event.symbol === "BTCUSDT",
|
|
2186
|
+
* (event) => console.log("BTCUSDT active ping received:", event.timestamp)
|
|
2187
|
+
* );
|
|
2188
|
+
* ```
|
|
2189
|
+
*/
|
|
2190
|
+
interface ActivePingContract {
|
|
2191
|
+
/**
|
|
2192
|
+
* Trading pair symbol (e.g., "BTCUSDT").
|
|
2193
|
+
* Identifies which market this ping event belongs to.
|
|
2194
|
+
*/
|
|
2195
|
+
symbol: string;
|
|
2196
|
+
/**
|
|
2197
|
+
* Strategy name that is monitoring this active pending signal.
|
|
2198
|
+
* Identifies which strategy execution this ping event belongs to.
|
|
2199
|
+
*/
|
|
2200
|
+
strategyName: StrategyName;
|
|
2201
|
+
/**
|
|
2202
|
+
* Exchange name where this active pending signal is being monitored.
|
|
2203
|
+
* Identifies which exchange this ping event belongs to.
|
|
2204
|
+
*/
|
|
2205
|
+
exchangeName: ExchangeName;
|
|
2206
|
+
/**
|
|
2207
|
+
* Complete pending signal row data.
|
|
2208
|
+
* Contains all signal information: id, position, priceOpen, priceTakeProfit, priceStopLoss, etc.
|
|
2209
|
+
*/
|
|
2210
|
+
data: ISignalRow;
|
|
2211
|
+
/**
|
|
2212
|
+
* Execution mode flag.
|
|
2213
|
+
* - true: Event from backtest execution (historical candle data)
|
|
2214
|
+
* - false: Event from live trading (real-time tick)
|
|
2215
|
+
*/
|
|
2216
|
+
backtest: boolean;
|
|
2217
|
+
/**
|
|
2218
|
+
* Event timestamp in milliseconds since Unix epoch.
|
|
2219
|
+
*
|
|
2220
|
+
* Timing semantics:
|
|
2221
|
+
* - Live mode: when.getTime() at the moment of ping
|
|
2222
|
+
* - Backtest mode: candle.timestamp of the candle being processed
|
|
2223
|
+
*
|
|
2224
|
+
* @example
|
|
2225
|
+
* ```typescript
|
|
2226
|
+
* const eventDate = new Date(event.timestamp);
|
|
2227
|
+
* console.log(`Active Ping at: ${eventDate.toISOString()}`);
|
|
2228
|
+
* ```
|
|
2229
|
+
*/
|
|
2230
|
+
timestamp: number;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2128
2233
|
/**
|
|
2129
2234
|
* Contract for risk rejection events.
|
|
2130
2235
|
*
|
|
@@ -2257,7 +2362,7 @@ interface RiskContract {
|
|
|
2257
2362
|
* const actionCtors: TActionCtor[] = [TelegramNotifier, ReduxLogger];
|
|
2258
2363
|
* ```
|
|
2259
2364
|
*/
|
|
2260
|
-
type TActionCtor = new (strategyName: StrategyName, frameName: FrameName, actionName: ActionName) => Partial<IPublicAction>;
|
|
2365
|
+
type TActionCtor = new (strategyName: StrategyName, frameName: FrameName, actionName: ActionName, backtest: boolean) => Partial<IPublicAction>;
|
|
2261
2366
|
/**
|
|
2262
2367
|
* Action parameters passed to ClientAction constructor.
|
|
2263
2368
|
* Combines schema with runtime dependencies and execution context.
|
|
@@ -2406,7 +2511,7 @@ interface IActionCallbacks {
|
|
|
2406
2511
|
* @param frameName - Timeframe identifier
|
|
2407
2512
|
* @param backtest - True for backtest mode, false for live trading
|
|
2408
2513
|
*/
|
|
2409
|
-
|
|
2514
|
+
onBreakevenAvailable(event: BreakevenContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
|
|
2410
2515
|
/**
|
|
2411
2516
|
* Called when partial profit level is reached (10%, 20%, 30%, etc).
|
|
2412
2517
|
*
|
|
@@ -2419,7 +2524,7 @@ interface IActionCallbacks {
|
|
|
2419
2524
|
* @param frameName - Timeframe identifier
|
|
2420
2525
|
* @param backtest - True for backtest mode, false for live trading
|
|
2421
2526
|
*/
|
|
2422
|
-
|
|
2527
|
+
onPartialProfitAvailable(event: PartialProfitContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
|
|
2423
2528
|
/**
|
|
2424
2529
|
* Called when partial loss level is reached (-10%, -20%, -30%, etc).
|
|
2425
2530
|
*
|
|
@@ -2432,11 +2537,11 @@ interface IActionCallbacks {
|
|
|
2432
2537
|
* @param frameName - Timeframe identifier
|
|
2433
2538
|
* @param backtest - True for backtest mode, false for live trading
|
|
2434
2539
|
*/
|
|
2435
|
-
|
|
2540
|
+
onPartialLossAvailable(event: PartialLossContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
|
|
2436
2541
|
/**
|
|
2437
2542
|
* Called during scheduled signal monitoring (every minute while waiting for activation).
|
|
2438
2543
|
*
|
|
2439
|
-
* Triggered by: StrategyConnectionService via
|
|
2544
|
+
* Triggered by: StrategyConnectionService via schedulePingSubject
|
|
2440
2545
|
* Frequency: Every minute while scheduled signal is waiting
|
|
2441
2546
|
*
|
|
2442
2547
|
* @param event - Scheduled signal monitoring data
|
|
@@ -2445,7 +2550,20 @@ interface IActionCallbacks {
|
|
|
2445
2550
|
* @param frameName - Timeframe identifier
|
|
2446
2551
|
* @param backtest - True for backtest mode, false for live trading
|
|
2447
2552
|
*/
|
|
2448
|
-
|
|
2553
|
+
onPingScheduled(event: SchedulePingContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
|
|
2554
|
+
/**
|
|
2555
|
+
* Called during active pending signal monitoring (every minute while position is active).
|
|
2556
|
+
*
|
|
2557
|
+
* Triggered by: StrategyConnectionService via activePingSubject
|
|
2558
|
+
* Frequency: Every minute while pending signal is active
|
|
2559
|
+
*
|
|
2560
|
+
* @param event - Active pending signal monitoring data
|
|
2561
|
+
* @param actionName - Action identifier
|
|
2562
|
+
* @param strategyName - Strategy identifier
|
|
2563
|
+
* @param frameName - Timeframe identifier
|
|
2564
|
+
* @param backtest - True for backtest mode, false for live trading
|
|
2565
|
+
*/
|
|
2566
|
+
onPingActive(event: ActivePingContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
|
|
2449
2567
|
/**
|
|
2450
2568
|
* Called when signal is rejected by risk management.
|
|
2451
2569
|
*
|
|
@@ -2461,7 +2579,7 @@ interface IActionCallbacks {
|
|
|
2461
2579
|
onRiskRejection(event: RiskContract, actionName: ActionName, strategyName: StrategyName, frameName: FrameName, backtest: boolean): void | Promise<void>;
|
|
2462
2580
|
}
|
|
2463
2581
|
/**
|
|
2464
|
-
* Action schema registered via
|
|
2582
|
+
* Action schema registered via addActionSchema().
|
|
2465
2583
|
* Defines event handler implementation and lifecycle callbacks for state management integration.
|
|
2466
2584
|
*
|
|
2467
2585
|
* Actions provide a way to attach custom event handlers to strategies for:
|
|
@@ -2476,7 +2594,7 @@ interface IActionCallbacks {
|
|
|
2476
2594
|
*
|
|
2477
2595
|
* @example
|
|
2478
2596
|
* ```typescript
|
|
2479
|
-
* import {
|
|
2597
|
+
* import { addActionSchema } from "backtest-kit";
|
|
2480
2598
|
*
|
|
2481
2599
|
* // Define action handler class
|
|
2482
2600
|
* class TelegramNotifier implements Partial<IAction> {
|
|
@@ -2498,7 +2616,7 @@ interface IActionCallbacks {
|
|
|
2498
2616
|
* }
|
|
2499
2617
|
*
|
|
2500
2618
|
* // Register action schema
|
|
2501
|
-
*
|
|
2619
|
+
* addActionSchema({
|
|
2502
2620
|
* actionName: "telegram-notifier",
|
|
2503
2621
|
* handler: TelegramNotifier,
|
|
2504
2622
|
* callbacks: {
|
|
@@ -2515,6 +2633,8 @@ interface IActionCallbacks {
|
|
|
2515
2633
|
interface IActionSchema {
|
|
2516
2634
|
/** Unique action identifier for registration */
|
|
2517
2635
|
actionName: ActionName;
|
|
2636
|
+
/** Optional developer note for documentation */
|
|
2637
|
+
note?: string;
|
|
2518
2638
|
/** Action handler constructor (instantiated per strategy-frame pair) */
|
|
2519
2639
|
handler: TActionCtor | Partial<IPublicAction>;
|
|
2520
2640
|
/** Optional lifecycle and event callbacks */
|
|
@@ -2682,7 +2802,7 @@ interface IAction {
|
|
|
2682
2802
|
*
|
|
2683
2803
|
* @param event - Breakeven milestone data
|
|
2684
2804
|
*/
|
|
2685
|
-
|
|
2805
|
+
breakevenAvailable(event: BreakevenContract): void | Promise<void>;
|
|
2686
2806
|
/**
|
|
2687
2807
|
* Handles partial profit level events (10%, 20%, 30%, etc).
|
|
2688
2808
|
*
|
|
@@ -2692,7 +2812,7 @@ interface IAction {
|
|
|
2692
2812
|
*
|
|
2693
2813
|
* @param event - Profit milestone data with level and price
|
|
2694
2814
|
*/
|
|
2695
|
-
|
|
2815
|
+
partialProfitAvailable(event: PartialProfitContract): void | Promise<void>;
|
|
2696
2816
|
/**
|
|
2697
2817
|
* Handles partial loss level events (-10%, -20%, -30%, etc).
|
|
2698
2818
|
*
|
|
@@ -2702,17 +2822,27 @@ interface IAction {
|
|
|
2702
2822
|
*
|
|
2703
2823
|
* @param event - Loss milestone data with level and price
|
|
2704
2824
|
*/
|
|
2705
|
-
|
|
2825
|
+
partialLossAvailable(event: PartialLossContract): void | Promise<void>;
|
|
2706
2826
|
/**
|
|
2707
|
-
* Handles ping events during scheduled signal monitoring.
|
|
2827
|
+
* Handles scheduled ping events during scheduled signal monitoring.
|
|
2708
2828
|
*
|
|
2709
|
-
* Emitted by: StrategyConnectionService via
|
|
2710
|
-
* Source:
|
|
2829
|
+
* Emitted by: StrategyConnectionService via schedulePingSubject
|
|
2830
|
+
* Source: CREATE_COMMIT_SCHEDULE_PING_FN callback in StrategyConnectionService
|
|
2711
2831
|
* Frequency: Every minute while scheduled signal is waiting for activation
|
|
2712
2832
|
*
|
|
2713
2833
|
* @param event - Scheduled signal monitoring data
|
|
2714
2834
|
*/
|
|
2715
|
-
|
|
2835
|
+
pingScheduled(event: SchedulePingContract): void | Promise<void>;
|
|
2836
|
+
/**
|
|
2837
|
+
* Handles active ping events during active pending signal monitoring.
|
|
2838
|
+
*
|
|
2839
|
+
* Emitted by: StrategyConnectionService via activePingSubject
|
|
2840
|
+
* Source: CREATE_COMMIT_ACTIVE_PING_FN callback in StrategyConnectionService
|
|
2841
|
+
* Frequency: Every minute while pending signal is active
|
|
2842
|
+
*
|
|
2843
|
+
* @param event - Active pending signal monitoring data
|
|
2844
|
+
*/
|
|
2845
|
+
pingActive(event: ActivePingContract): void | Promise<void>;
|
|
2716
2846
|
/**
|
|
2717
2847
|
* Handles risk rejection events when signals fail risk validation.
|
|
2718
2848
|
*
|
|
@@ -3518,7 +3648,7 @@ type OptimizerName = string;
|
|
|
3518
3648
|
* console.log(strategy.getSignal); // async function
|
|
3519
3649
|
* ```
|
|
3520
3650
|
*/
|
|
3521
|
-
declare function
|
|
3651
|
+
declare function getStrategySchema(strategyName: StrategyName): IStrategySchema;
|
|
3522
3652
|
/**
|
|
3523
3653
|
* Retrieves a registered exchange schema by name.
|
|
3524
3654
|
*
|
|
@@ -3533,7 +3663,7 @@ declare function getStrategy(strategyName: StrategyName): IStrategySchema;
|
|
|
3533
3663
|
* console.log(exchange.formatPrice); // async function
|
|
3534
3664
|
* ```
|
|
3535
3665
|
*/
|
|
3536
|
-
declare function
|
|
3666
|
+
declare function getExchangeSchema(exchangeName: ExchangeName): IExchangeSchema;
|
|
3537
3667
|
/**
|
|
3538
3668
|
* Retrieves a registered frame schema by name.
|
|
3539
3669
|
*
|
|
@@ -3549,7 +3679,7 @@ declare function getExchange(exchangeName: ExchangeName): IExchangeSchema;
|
|
|
3549
3679
|
* console.log(frame.endDate); // Date object
|
|
3550
3680
|
* ```
|
|
3551
3681
|
*/
|
|
3552
|
-
declare function
|
|
3682
|
+
declare function getFrameSchema(frameName: FrameName): IFrameSchema;
|
|
3553
3683
|
/**
|
|
3554
3684
|
* Retrieves a registered walker schema by name.
|
|
3555
3685
|
*
|
|
@@ -3566,7 +3696,7 @@ declare function getFrame(frameName: FrameName): IFrameSchema;
|
|
|
3566
3696
|
* console.log(walker.metric); // "sharpeRatio"
|
|
3567
3697
|
* ```
|
|
3568
3698
|
*/
|
|
3569
|
-
declare function
|
|
3699
|
+
declare function getWalkerSchema(walkerName: WalkerName): IWalkerSchema;
|
|
3570
3700
|
/**
|
|
3571
3701
|
* Retrieves a registered sizing schema by name.
|
|
3572
3702
|
*
|
|
@@ -3582,7 +3712,7 @@ declare function getWalker(walkerName: WalkerName): IWalkerSchema;
|
|
|
3582
3712
|
* console.log(sizing.maxPositionPercentage); // 10
|
|
3583
3713
|
* ```
|
|
3584
3714
|
*/
|
|
3585
|
-
declare function
|
|
3715
|
+
declare function getSizingSchema(sizingName: SizingName): ISizingSchema;
|
|
3586
3716
|
/**
|
|
3587
3717
|
* Retrieves a registered risk schema by name.
|
|
3588
3718
|
*
|
|
@@ -3597,7 +3727,7 @@ declare function getSizing(sizingName: SizingName): ISizingSchema;
|
|
|
3597
3727
|
* console.log(risk.validations); // Array of validation functions
|
|
3598
3728
|
* ```
|
|
3599
3729
|
*/
|
|
3600
|
-
declare function
|
|
3730
|
+
declare function getRiskSchema(riskName: RiskName): IRiskSchema;
|
|
3601
3731
|
/**
|
|
3602
3732
|
* Retrieves a registered optimizer schema by name.
|
|
3603
3733
|
*
|
|
@@ -3614,7 +3744,7 @@ declare function getRisk(riskName: RiskName): IRiskSchema;
|
|
|
3614
3744
|
* console.log(optimizer.getPrompt); // async function
|
|
3615
3745
|
* ```
|
|
3616
3746
|
*/
|
|
3617
|
-
declare function
|
|
3747
|
+
declare function getOptimizerSchema(optimizerName: OptimizerName): IOptimizerSchema;
|
|
3618
3748
|
/**
|
|
3619
3749
|
* Retrieves a registered action schema by name.
|
|
3620
3750
|
*
|
|
@@ -3629,30 +3759,8 @@ declare function getOptimizer(optimizerName: OptimizerName): IOptimizerSchema;
|
|
|
3629
3759
|
* console.log(action.callbacks); // Optional lifecycle callbacks
|
|
3630
3760
|
* ```
|
|
3631
3761
|
*/
|
|
3632
|
-
declare function
|
|
3762
|
+
declare function getActionSchema(actionName: ActionName): IActionSchema;
|
|
3633
3763
|
|
|
3634
|
-
/**
|
|
3635
|
-
* Stops the strategy from generating new signals.
|
|
3636
|
-
*
|
|
3637
|
-
* Sets internal flag to prevent strategy from opening new signals.
|
|
3638
|
-
* Current active signal (if any) will complete normally.
|
|
3639
|
-
* Backtest/Live mode will stop at the next safe point (idle state or after signal closes).
|
|
3640
|
-
*
|
|
3641
|
-
* Automatically detects backtest/live mode from execution context.
|
|
3642
|
-
*
|
|
3643
|
-
* @param symbol - Trading pair symbol
|
|
3644
|
-
* @param strategyName - Strategy name to stop
|
|
3645
|
-
* @returns Promise that resolves when stop flag is set
|
|
3646
|
-
*
|
|
3647
|
-
* @example
|
|
3648
|
-
* ```typescript
|
|
3649
|
-
* import { stop } from "backtest-kit";
|
|
3650
|
-
*
|
|
3651
|
-
* // Stop strategy after some condition
|
|
3652
|
-
* await stop("BTCUSDT", "my-strategy");
|
|
3653
|
-
* ```
|
|
3654
|
-
*/
|
|
3655
|
-
declare function stop(symbol: string): Promise<void>;
|
|
3656
3764
|
/**
|
|
3657
3765
|
* Cancels the scheduled signal without stopping the strategy.
|
|
3658
3766
|
*
|
|
@@ -3675,7 +3783,7 @@ declare function stop(symbol: string): Promise<void>;
|
|
|
3675
3783
|
* await cancel("BTCUSDT", "my-strategy", "manual-cancel-001");
|
|
3676
3784
|
* ```
|
|
3677
3785
|
*/
|
|
3678
|
-
declare function
|
|
3786
|
+
declare function commitCancel(symbol: string, cancelId?: string): Promise<void>;
|
|
3679
3787
|
/**
|
|
3680
3788
|
* Executes partial close at profit level (moving toward TP).
|
|
3681
3789
|
*
|
|
@@ -3703,7 +3811,7 @@ declare function cancel(symbol: string, cancelId?: string): Promise<void>;
|
|
|
3703
3811
|
* }
|
|
3704
3812
|
* ```
|
|
3705
3813
|
*/
|
|
3706
|
-
declare function
|
|
3814
|
+
declare function commitPartialProfit(symbol: string, percentToClose: number): Promise<boolean>;
|
|
3707
3815
|
/**
|
|
3708
3816
|
* Executes partial close at loss level (moving toward SL).
|
|
3709
3817
|
*
|
|
@@ -3731,7 +3839,7 @@ declare function partialProfit(symbol: string, percentToClose: number): Promise<
|
|
|
3731
3839
|
* }
|
|
3732
3840
|
* ```
|
|
3733
3841
|
*/
|
|
3734
|
-
declare function
|
|
3842
|
+
declare function commitPartialLoss(symbol: string, percentToClose: number): Promise<boolean>;
|
|
3735
3843
|
/**
|
|
3736
3844
|
* Adjusts the trailing stop-loss distance for an active pending signal.
|
|
3737
3845
|
*
|
|
@@ -3775,7 +3883,7 @@ declare function partialLoss(symbol: string, percentToClose: number): Promise<bo
|
|
|
3775
3883
|
* // success3 = true (ACCEPTED: newDistance = 10% - 7% = 3%, newSL = 97 > 95, better protection)
|
|
3776
3884
|
* ```
|
|
3777
3885
|
*/
|
|
3778
|
-
declare function
|
|
3886
|
+
declare function commitTrailingStop(symbol: string, percentShift: number, currentPrice: number): Promise<boolean>;
|
|
3779
3887
|
/**
|
|
3780
3888
|
* Adjusts the trailing take-profit distance for an active pending signal.
|
|
3781
3889
|
*
|
|
@@ -3819,7 +3927,7 @@ declare function trailingStop(symbol: string, percentShift: number, currentPrice
|
|
|
3819
3927
|
* // success3 = true (ACCEPTED: newDistance = 10% - 5% = 5%, newTP = 105 < 107, more conservative)
|
|
3820
3928
|
* ```
|
|
3821
3929
|
*/
|
|
3822
|
-
declare function
|
|
3930
|
+
declare function commitTrailingTake(symbol: string, percentShift: number, currentPrice: number): Promise<boolean>;
|
|
3823
3931
|
/**
|
|
3824
3932
|
* Moves stop-loss to breakeven when price reaches threshold.
|
|
3825
3933
|
*
|
|
@@ -3845,7 +3953,30 @@ declare function trailingTake(symbol: string, percentShift: number, currentPrice
|
|
|
3845
3953
|
* }
|
|
3846
3954
|
* ```
|
|
3847
3955
|
*/
|
|
3848
|
-
declare function
|
|
3956
|
+
declare function commitBreakeven(symbol: string): Promise<boolean>;
|
|
3957
|
+
|
|
3958
|
+
/**
|
|
3959
|
+
* Stops the strategy from generating new signals.
|
|
3960
|
+
*
|
|
3961
|
+
* Sets internal flag to prevent strategy from opening new signals.
|
|
3962
|
+
* Current active signal (if any) will complete normally.
|
|
3963
|
+
* Backtest/Live mode will stop at the next safe point (idle state or after signal closes).
|
|
3964
|
+
*
|
|
3965
|
+
* Automatically detects backtest/live mode from execution context.
|
|
3966
|
+
*
|
|
3967
|
+
* @param symbol - Trading pair symbol
|
|
3968
|
+
* @param strategyName - Strategy name to stop
|
|
3969
|
+
* @returns Promise that resolves when stop flag is set
|
|
3970
|
+
*
|
|
3971
|
+
* @example
|
|
3972
|
+
* ```typescript
|
|
3973
|
+
* import { stop } from "backtest-kit";
|
|
3974
|
+
*
|
|
3975
|
+
* // Stop strategy after some condition
|
|
3976
|
+
* await stop("BTCUSDT", "my-strategy");
|
|
3977
|
+
* ```
|
|
3978
|
+
*/
|
|
3979
|
+
declare function stop(symbol: string): Promise<void>;
|
|
3849
3980
|
|
|
3850
3981
|
/**
|
|
3851
3982
|
* Unified breakeven event data for report generation.
|
|
@@ -4298,7 +4429,7 @@ declare function getDefaultColumns(): Readonly<{
|
|
|
4298
4429
|
* });
|
|
4299
4430
|
* ```
|
|
4300
4431
|
*/
|
|
4301
|
-
declare function
|
|
4432
|
+
declare function addStrategySchema(strategySchema: IStrategySchema): void;
|
|
4302
4433
|
/**
|
|
4303
4434
|
* Registers an exchange data source in the framework.
|
|
4304
4435
|
*
|
|
@@ -4334,7 +4465,7 @@ declare function addStrategy(strategySchema: IStrategySchema): void;
|
|
|
4334
4465
|
* });
|
|
4335
4466
|
* ```
|
|
4336
4467
|
*/
|
|
4337
|
-
declare function
|
|
4468
|
+
declare function addExchangeSchema(exchangeSchema: IExchangeSchema): void;
|
|
4338
4469
|
/**
|
|
4339
4470
|
* Registers a timeframe generator for backtesting.
|
|
4340
4471
|
*
|
|
@@ -4365,7 +4496,7 @@ declare function addExchange(exchangeSchema: IExchangeSchema): void;
|
|
|
4365
4496
|
* });
|
|
4366
4497
|
* ```
|
|
4367
4498
|
*/
|
|
4368
|
-
declare function
|
|
4499
|
+
declare function addFrameSchema(frameSchema: IFrameSchema): void;
|
|
4369
4500
|
/**
|
|
4370
4501
|
* Registers a walker for strategy comparison.
|
|
4371
4502
|
*
|
|
@@ -4403,7 +4534,7 @@ declare function addFrame(frameSchema: IFrameSchema): void;
|
|
|
4403
4534
|
* });
|
|
4404
4535
|
* ```
|
|
4405
4536
|
*/
|
|
4406
|
-
declare function
|
|
4537
|
+
declare function addWalkerSchema(walkerSchema: IWalkerSchema): void;
|
|
4407
4538
|
/**
|
|
4408
4539
|
* Registers a position sizing configuration in the framework.
|
|
4409
4540
|
*
|
|
@@ -4456,7 +4587,7 @@ declare function addWalker(walkerSchema: IWalkerSchema): void;
|
|
|
4456
4587
|
* });
|
|
4457
4588
|
* ```
|
|
4458
4589
|
*/
|
|
4459
|
-
declare function
|
|
4590
|
+
declare function addSizingSchema(sizingSchema: ISizingSchema): void;
|
|
4460
4591
|
/**
|
|
4461
4592
|
* Registers a risk management configuration in the framework.
|
|
4462
4593
|
*
|
|
@@ -4518,7 +4649,7 @@ declare function addSizing(sizingSchema: ISizingSchema): void;
|
|
|
4518
4649
|
* });
|
|
4519
4650
|
* ```
|
|
4520
4651
|
*/
|
|
4521
|
-
declare function
|
|
4652
|
+
declare function addRiskSchema(riskSchema: IRiskSchema): void;
|
|
4522
4653
|
/**
|
|
4523
4654
|
* Registers an optimizer configuration in the framework.
|
|
4524
4655
|
*
|
|
@@ -4606,7 +4737,7 @@ declare function addRisk(riskSchema: IRiskSchema): void;
|
|
|
4606
4737
|
* });
|
|
4607
4738
|
* ```
|
|
4608
4739
|
*/
|
|
4609
|
-
declare function
|
|
4740
|
+
declare function addOptimizerSchema(optimizerSchema: IOptimizerSchema): void;
|
|
4610
4741
|
/**
|
|
4611
4742
|
* Registers an action handler in the framework.
|
|
4612
4743
|
*
|
|
@@ -4675,7 +4806,7 @@ declare function addOptimizer(optimizerSchema: IOptimizerSchema): void;
|
|
|
4675
4806
|
* });
|
|
4676
4807
|
* ```
|
|
4677
4808
|
*/
|
|
4678
|
-
declare function
|
|
4809
|
+
declare function addActionSchema(actionSchema: IActionSchema): void;
|
|
4679
4810
|
|
|
4680
4811
|
/**
|
|
4681
4812
|
* Partial strategy schema for override operations.
|
|
@@ -4892,7 +5023,7 @@ type TActionSchema = {
|
|
|
4892
5023
|
* });
|
|
4893
5024
|
* ```
|
|
4894
5025
|
*/
|
|
4895
|
-
declare function
|
|
5026
|
+
declare function overrideStrategySchema(strategySchema: TStrategySchema): Promise<IStrategySchema>;
|
|
4896
5027
|
/**
|
|
4897
5028
|
* Overrides an existing exchange data source in the framework.
|
|
4898
5029
|
*
|
|
@@ -4914,7 +5045,7 @@ declare function overrideStrategy(strategySchema: TStrategySchema): Promise<IStr
|
|
|
4914
5045
|
* });
|
|
4915
5046
|
* ```
|
|
4916
5047
|
*/
|
|
4917
|
-
declare function
|
|
5048
|
+
declare function overrideExchangeSchema(exchangeSchema: TExchangeSchema): Promise<IExchangeSchema>;
|
|
4918
5049
|
/**
|
|
4919
5050
|
* Overrides an existing timeframe configuration for backtesting.
|
|
4920
5051
|
*
|
|
@@ -4936,7 +5067,7 @@ declare function overrideExchange(exchangeSchema: TExchangeSchema): Promise<IExc
|
|
|
4936
5067
|
* });
|
|
4937
5068
|
* ```
|
|
4938
5069
|
*/
|
|
4939
|
-
declare function
|
|
5070
|
+
declare function overrideFrameSchema(frameSchema: TFrameSchema): Promise<IFrameSchema>;
|
|
4940
5071
|
/**
|
|
4941
5072
|
* Overrides an existing walker configuration for strategy comparison.
|
|
4942
5073
|
*
|
|
@@ -4959,7 +5090,7 @@ declare function overrideFrame(frameSchema: TFrameSchema): Promise<IFrameSchema>
|
|
|
4959
5090
|
* });
|
|
4960
5091
|
* ```
|
|
4961
5092
|
*/
|
|
4962
|
-
declare function
|
|
5093
|
+
declare function overrideWalkerSchema(walkerSchema: TWalkerSchema): Promise<IWalkerSchema>;
|
|
4963
5094
|
/**
|
|
4964
5095
|
* Overrides an existing position sizing configuration in the framework.
|
|
4965
5096
|
*
|
|
@@ -4985,7 +5116,7 @@ declare function overrideWalker(walkerSchema: TWalkerSchema): Promise<IWalkerSch
|
|
|
4985
5116
|
* });
|
|
4986
5117
|
* ```
|
|
4987
5118
|
*/
|
|
4988
|
-
declare function
|
|
5119
|
+
declare function overrideSizingSchema(sizingSchema: TSizingSchema): Promise<ISizingSchema>;
|
|
4989
5120
|
/**
|
|
4990
5121
|
* Overrides an existing risk management configuration in the framework.
|
|
4991
5122
|
*
|
|
@@ -5006,7 +5137,7 @@ declare function overrideSizing(sizingSchema: TSizingSchema): Promise<ISizingSch
|
|
|
5006
5137
|
* });
|
|
5007
5138
|
* ```
|
|
5008
5139
|
*/
|
|
5009
|
-
declare function
|
|
5140
|
+
declare function overrideRiskSchema(riskSchema: TRiskSchema): Promise<IRiskSchema>;
|
|
5010
5141
|
/**
|
|
5011
5142
|
* Overrides an existing optimizer configuration in the framework.
|
|
5012
5143
|
*
|
|
@@ -5034,7 +5165,7 @@ declare function overrideRisk(riskSchema: TRiskSchema): Promise<IRiskSchema>;
|
|
|
5034
5165
|
* });
|
|
5035
5166
|
* ```
|
|
5036
5167
|
*/
|
|
5037
|
-
declare function
|
|
5168
|
+
declare function overrideOptimizerSchema(optimizerSchema: TOptimizerSchema): Promise<IOptimizerSchema>;
|
|
5038
5169
|
/**
|
|
5039
5170
|
* Overrides an existing action handler configuration in the framework.
|
|
5040
5171
|
*
|
|
@@ -5095,7 +5226,7 @@ declare function overrideOptimizer(optimizerSchema: TOptimizerSchema): Promise<I
|
|
|
5095
5226
|
* });
|
|
5096
5227
|
* ```
|
|
5097
5228
|
*/
|
|
5098
|
-
declare function
|
|
5229
|
+
declare function overrideActionSchema(actionSchema: TActionSchema): Promise<IActionSchema>;
|
|
5099
5230
|
|
|
5100
5231
|
/**
|
|
5101
5232
|
* Returns a list of all registered exchange schemas.
|
|
@@ -5122,7 +5253,7 @@ declare function overrideAction(actionSchema: TActionSchema): Promise<IActionSch
|
|
|
5122
5253
|
* // [{ exchangeName: "binance", note: "Binance cryptocurrency exchange", ... }]
|
|
5123
5254
|
* ```
|
|
5124
5255
|
*/
|
|
5125
|
-
declare function
|
|
5256
|
+
declare function listExchangeSchema(): Promise<IExchangeSchema[]>;
|
|
5126
5257
|
/**
|
|
5127
5258
|
* Returns a list of all registered strategy schemas.
|
|
5128
5259
|
*
|
|
@@ -5153,7 +5284,7 @@ declare function listExchanges(): Promise<IExchangeSchema[]>;
|
|
|
5153
5284
|
* // [{ strategyName: "my-strategy", note: "Simple moving average...", ... }]
|
|
5154
5285
|
* ```
|
|
5155
5286
|
*/
|
|
5156
|
-
declare function
|
|
5287
|
+
declare function listStrategySchema(): Promise<IStrategySchema[]>;
|
|
5157
5288
|
/**
|
|
5158
5289
|
* Returns a list of all registered frame schemas.
|
|
5159
5290
|
*
|
|
@@ -5179,7 +5310,7 @@ declare function listStrategies(): Promise<IStrategySchema[]>;
|
|
|
5179
5310
|
* // [{ frameName: "1d-backtest", note: "One day backtest...", ... }]
|
|
5180
5311
|
* ```
|
|
5181
5312
|
*/
|
|
5182
|
-
declare function
|
|
5313
|
+
declare function listFrameSchema(): Promise<IFrameSchema[]>;
|
|
5183
5314
|
/**
|
|
5184
5315
|
* Returns a list of all registered walker schemas.
|
|
5185
5316
|
*
|
|
@@ -5206,7 +5337,7 @@ declare function listFrames(): Promise<IFrameSchema[]>;
|
|
|
5206
5337
|
* // [{ walkerName: "llm-prompt-optimizer", note: "Compare LLM...", ... }]
|
|
5207
5338
|
* ```
|
|
5208
5339
|
*/
|
|
5209
|
-
declare function
|
|
5340
|
+
declare function listWalkerSchema(): Promise<IWalkerSchema[]>;
|
|
5210
5341
|
/**
|
|
5211
5342
|
* Returns a list of all registered sizing schemas.
|
|
5212
5343
|
*
|
|
@@ -5242,7 +5373,7 @@ declare function listWalkers(): Promise<IWalkerSchema[]>;
|
|
|
5242
5373
|
* // ]
|
|
5243
5374
|
* ```
|
|
5244
5375
|
*/
|
|
5245
|
-
declare function
|
|
5376
|
+
declare function listSizingSchema(): Promise<ISizingSchema[]>;
|
|
5246
5377
|
/**
|
|
5247
5378
|
* Returns a list of all registered risk schemas.
|
|
5248
5379
|
*
|
|
@@ -5275,7 +5406,7 @@ declare function listSizings(): Promise<ISizingSchema[]>;
|
|
|
5275
5406
|
* // ]
|
|
5276
5407
|
* ```
|
|
5277
5408
|
*/
|
|
5278
|
-
declare function
|
|
5409
|
+
declare function listRiskSchema(): Promise<IRiskSchema[]>;
|
|
5279
5410
|
/**
|
|
5280
5411
|
* Returns a list of all registered optimizer schemas.
|
|
5281
5412
|
*
|
|
@@ -5312,7 +5443,7 @@ declare function listRisks(): Promise<IRiskSchema[]>;
|
|
|
5312
5443
|
* // [{ optimizerName: "llm-strategy-generator", note: "Generates...", ... }]
|
|
5313
5444
|
* ```
|
|
5314
5445
|
*/
|
|
5315
|
-
declare function
|
|
5446
|
+
declare function listOptimizerSchema(): Promise<IOptimizerSchema[]>;
|
|
5316
5447
|
|
|
5317
5448
|
/**
|
|
5318
5449
|
* Contract for background execution completion events.
|
|
@@ -6151,7 +6282,7 @@ declare function listenValidation(fn: (error: Error) => void): () => void;
|
|
|
6151
6282
|
* unsubscribe();
|
|
6152
6283
|
* ```
|
|
6153
6284
|
*/
|
|
6154
|
-
declare function
|
|
6285
|
+
declare function listenPartialProfitAvailable(fn: (event: PartialProfitContract) => void): () => void;
|
|
6155
6286
|
/**
|
|
6156
6287
|
* Subscribes to filtered partial profit level events with one-time execution.
|
|
6157
6288
|
*
|
|
@@ -6182,7 +6313,7 @@ declare function listenPartialProfit(fn: (event: PartialProfitContract) => void)
|
|
|
6182
6313
|
* cancel();
|
|
6183
6314
|
* ```
|
|
6184
6315
|
*/
|
|
6185
|
-
declare function
|
|
6316
|
+
declare function listenPartialProfitAvailableOnce(filterFn: (event: PartialProfitContract) => boolean, fn: (event: PartialProfitContract) => void): () => void;
|
|
6186
6317
|
/**
|
|
6187
6318
|
* Subscribes to partial loss level events with queued async processing.
|
|
6188
6319
|
*
|
|
@@ -6207,7 +6338,7 @@ declare function listenPartialProfitOnce(filterFn: (event: PartialProfitContract
|
|
|
6207
6338
|
* unsubscribe();
|
|
6208
6339
|
* ```
|
|
6209
6340
|
*/
|
|
6210
|
-
declare function
|
|
6341
|
+
declare function listenPartialLossAvailable(fn: (event: PartialLossContract) => void): () => void;
|
|
6211
6342
|
/**
|
|
6212
6343
|
* Subscribes to filtered partial loss level events with one-time execution.
|
|
6213
6344
|
*
|
|
@@ -6238,7 +6369,7 @@ declare function listenPartialLoss(fn: (event: PartialLossContract) => void): ()
|
|
|
6238
6369
|
* cancel();
|
|
6239
6370
|
* ```
|
|
6240
6371
|
*/
|
|
6241
|
-
declare function
|
|
6372
|
+
declare function listenPartialLossAvailableOnce(filterFn: (event: PartialLossContract) => boolean, fn: (event: PartialLossContract) => void): () => void;
|
|
6242
6373
|
/**
|
|
6243
6374
|
* Subscribes to breakeven protection events with queued async processing.
|
|
6244
6375
|
*
|
|
@@ -6265,7 +6396,7 @@ declare function listenPartialLossOnce(filterFn: (event: PartialLossContract) =>
|
|
|
6265
6396
|
* unsubscribe();
|
|
6266
6397
|
* ```
|
|
6267
6398
|
*/
|
|
6268
|
-
declare function
|
|
6399
|
+
declare function listenBreakevenAvailable(fn: (event: BreakevenContract) => void): () => void;
|
|
6269
6400
|
/**
|
|
6270
6401
|
* Subscribes to filtered breakeven protection events with one-time execution.
|
|
6271
6402
|
*
|
|
@@ -6296,7 +6427,7 @@ declare function listenBreakeven(fn: (event: BreakevenContract) => void): () =>
|
|
|
6296
6427
|
* cancel();
|
|
6297
6428
|
* ```
|
|
6298
6429
|
*/
|
|
6299
|
-
declare function
|
|
6430
|
+
declare function listenBreakevenAvailableOnce(filterFn: (event: BreakevenContract) => boolean, fn: (event: BreakevenContract) => void): () => void;
|
|
6300
6431
|
/**
|
|
6301
6432
|
* Subscribes to risk rejection events with queued async processing.
|
|
6302
6433
|
*
|
|
@@ -6383,7 +6514,7 @@ declare function listenRiskOnce(filterFn: (event: RiskContract) => boolean, fn:
|
|
|
6383
6514
|
* unsubscribe();
|
|
6384
6515
|
* ```
|
|
6385
6516
|
*/
|
|
6386
|
-
declare function
|
|
6517
|
+
declare function listenSchedulePing(fn: (event: SchedulePingContract) => void): () => void;
|
|
6387
6518
|
/**
|
|
6388
6519
|
* Subscribes to filtered ping events with one-time execution.
|
|
6389
6520
|
*
|
|
@@ -6414,7 +6545,66 @@ declare function listenPing(fn: (event: PingContract) => void): () => void;
|
|
|
6414
6545
|
* cancel();
|
|
6415
6546
|
* ```
|
|
6416
6547
|
*/
|
|
6417
|
-
declare function
|
|
6548
|
+
declare function listenSchedulePingOnce(filterFn: (event: SchedulePingContract) => boolean, fn: (event: SchedulePingContract) => void): () => void;
|
|
6549
|
+
/**
|
|
6550
|
+
* Subscribes to active ping events with queued async processing.
|
|
6551
|
+
*
|
|
6552
|
+
* Listens for active pending signal monitoring events emitted every minute.
|
|
6553
|
+
* Useful for tracking active signal lifecycle and implementing dynamic management logic.
|
|
6554
|
+
*
|
|
6555
|
+
* Events are processed sequentially in order received, even if callback is async.
|
|
6556
|
+
* Uses queued wrapper to prevent concurrent execution of the callback.
|
|
6557
|
+
*
|
|
6558
|
+
* @param fn - Callback function to handle active ping events
|
|
6559
|
+
* @returns Unsubscribe function to stop listening
|
|
6560
|
+
*
|
|
6561
|
+
* @example
|
|
6562
|
+
* ```typescript
|
|
6563
|
+
* import { listenActivePing } from "./function/event";
|
|
6564
|
+
*
|
|
6565
|
+
* const unsubscribe = listenActivePing((event) => {
|
|
6566
|
+
* console.log(`[${event.backtest ? "Backtest" : "Live"}] Active Ping`);
|
|
6567
|
+
* console.log(`Symbol: ${event.symbol}, Strategy: ${event.strategyName}`);
|
|
6568
|
+
* console.log(`Signal ID: ${event.data.id}, Position: ${event.data.position}`);
|
|
6569
|
+
* console.log(`Timestamp: ${new Date(event.timestamp).toISOString()}`);
|
|
6570
|
+
* });
|
|
6571
|
+
*
|
|
6572
|
+
* // Later: stop listening
|
|
6573
|
+
* unsubscribe();
|
|
6574
|
+
* ```
|
|
6575
|
+
*/
|
|
6576
|
+
declare function listenActivePing(fn: (event: ActivePingContract) => void): () => void;
|
|
6577
|
+
/**
|
|
6578
|
+
* Subscribes to filtered active ping events with one-time execution.
|
|
6579
|
+
*
|
|
6580
|
+
* Listens for events matching the filter predicate, then executes callback once
|
|
6581
|
+
* and automatically unsubscribes. Useful for waiting for specific active ping conditions.
|
|
6582
|
+
*
|
|
6583
|
+
* @param filterFn - Predicate to filter which events trigger the callback
|
|
6584
|
+
* @param fn - Callback function to handle the filtered event (called only once)
|
|
6585
|
+
* @returns Unsubscribe function to cancel the listener before it fires
|
|
6586
|
+
*
|
|
6587
|
+
* @example
|
|
6588
|
+
* ```typescript
|
|
6589
|
+
* import { listenActivePingOnce } from "./function/event";
|
|
6590
|
+
*
|
|
6591
|
+
* // Wait for first active ping on BTCUSDT
|
|
6592
|
+
* listenActivePingOnce(
|
|
6593
|
+
* (event) => event.symbol === "BTCUSDT",
|
|
6594
|
+
* (event) => console.log("First BTCUSDT active ping received")
|
|
6595
|
+
* );
|
|
6596
|
+
*
|
|
6597
|
+
* // Wait for active ping in backtest mode
|
|
6598
|
+
* const cancel = listenActivePingOnce(
|
|
6599
|
+
* (event) => event.backtest === true,
|
|
6600
|
+
* (event) => console.log("Backtest active ping received at", new Date(event.timestamp))
|
|
6601
|
+
* );
|
|
6602
|
+
*
|
|
6603
|
+
* // Cancel if needed before event fires
|
|
6604
|
+
* cancel();
|
|
6605
|
+
* ```
|
|
6606
|
+
*/
|
|
6607
|
+
declare function listenActivePingOnce(filterFn: (event: ActivePingContract) => boolean, fn: (event: ActivePingContract) => void): () => void;
|
|
6418
6608
|
|
|
6419
6609
|
/**
|
|
6420
6610
|
* Checks if trade context is active (execution and method contexts).
|
|
@@ -6537,6 +6727,35 @@ declare function getDate(): Promise<Date>;
|
|
|
6537
6727
|
* ```
|
|
6538
6728
|
*/
|
|
6539
6729
|
declare function getMode(): Promise<"backtest" | "live">;
|
|
6730
|
+
/**
|
|
6731
|
+
* Gets the current trading symbol from execution context.
|
|
6732
|
+
*
|
|
6733
|
+
* @returns Promise resolving to the current trading symbol (e.g., "BTCUSDT")
|
|
6734
|
+
* @throws Error if execution context is not active
|
|
6735
|
+
*
|
|
6736
|
+
* @example
|
|
6737
|
+
* ```typescript
|
|
6738
|
+
* const symbol = await getSymbol();
|
|
6739
|
+
* console.log(symbol); // "BTCUSDT"
|
|
6740
|
+
* ```
|
|
6741
|
+
*/
|
|
6742
|
+
declare function getSymbol(): Promise<string>;
|
|
6743
|
+
/**
|
|
6744
|
+
* Gets the current method context.
|
|
6745
|
+
*
|
|
6746
|
+
* Returns the context object from the method context service, which contains
|
|
6747
|
+
* information about the current method execution environment.
|
|
6748
|
+
*
|
|
6749
|
+
* @returns Promise resolving to the current method context object
|
|
6750
|
+
* @throws Error if method context is not active
|
|
6751
|
+
*
|
|
6752
|
+
* @example
|
|
6753
|
+
* ```typescript
|
|
6754
|
+
* const context = await getContext();
|
|
6755
|
+
* console.log(context); // { ...method context data... }
|
|
6756
|
+
* ```
|
|
6757
|
+
*/
|
|
6758
|
+
declare function getContext(): Promise<IMethodContext>;
|
|
6540
6759
|
/**
|
|
6541
6760
|
* Fetches order book for a trading pair from the registered exchange.
|
|
6542
6761
|
*
|
|
@@ -6627,7 +6846,7 @@ declare function getOrderBook(symbol: string, depth?: number): Promise<IOrderBoo
|
|
|
6627
6846
|
* // ./dump/strategy/{uuid}/06_llm_output.md (final signal)
|
|
6628
6847
|
* ```
|
|
6629
6848
|
*/
|
|
6630
|
-
declare function
|
|
6849
|
+
declare function dumpSignalData(signalId: string | number, history: MessageModel[], signal: ISignalDto, outputDir?: string): Promise<void>;
|
|
6631
6850
|
|
|
6632
6851
|
/**
|
|
6633
6852
|
* Portfolio heatmap statistics for a single symbol.
|
|
@@ -6955,40 +7174,42 @@ type NotificationModel = SignalOpenedNotification | SignalClosedNotification | P
|
|
|
6955
7174
|
* Contains all information about a tick event regardless of action type.
|
|
6956
7175
|
*/
|
|
6957
7176
|
interface TickEvent {
|
|
6958
|
-
/** Event timestamp in milliseconds (pendingAt for opened/closed events) */
|
|
7177
|
+
/** Event timestamp in milliseconds (scheduledAt for scheduled events, pendingAt for opened/closed events) */
|
|
6959
7178
|
timestamp: number;
|
|
6960
7179
|
/** Event action type */
|
|
6961
|
-
action: "idle" | "opened" | "active" | "closed";
|
|
7180
|
+
action: "idle" | "scheduled" | "waiting" | "opened" | "active" | "closed" | "cancelled";
|
|
6962
7181
|
/** Trading pair symbol (only for non-idle events) */
|
|
6963
7182
|
symbol?: string;
|
|
6964
|
-
/** Signal ID (only for opened/active/closed) */
|
|
7183
|
+
/** Signal ID (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6965
7184
|
signalId?: string;
|
|
6966
|
-
/** Position type (only for opened/active/closed) */
|
|
7185
|
+
/** Position type (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6967
7186
|
position?: string;
|
|
6968
|
-
/** Signal note (only for opened/active/closed) */
|
|
7187
|
+
/** Signal note (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6969
7188
|
note?: string;
|
|
6970
7189
|
/** Current price */
|
|
6971
7190
|
currentPrice: number;
|
|
6972
|
-
/** Open price (only for opened/active/closed) */
|
|
7191
|
+
/** Open price (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6973
7192
|
priceOpen?: number;
|
|
6974
|
-
/** Take profit price (only for opened/active/closed) */
|
|
7193
|
+
/** Take profit price (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6975
7194
|
priceTakeProfit?: number;
|
|
6976
|
-
/** Stop loss price (only for opened/active/closed) */
|
|
7195
|
+
/** Stop loss price (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6977
7196
|
priceStopLoss?: number;
|
|
6978
|
-
/** Original take profit price before modifications (only for opened/active/closed) */
|
|
7197
|
+
/** Original take profit price before modifications (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6979
7198
|
originalPriceTakeProfit?: number;
|
|
6980
|
-
/** Original stop loss price before modifications (only for opened/active/closed) */
|
|
7199
|
+
/** Original stop loss price before modifications (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6981
7200
|
originalPriceStopLoss?: number;
|
|
6982
|
-
/** Total executed percentage from partial closes (only for opened/active/closed) */
|
|
7201
|
+
/** Total executed percentage from partial closes (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
6983
7202
|
totalExecuted?: number;
|
|
6984
|
-
/** Percentage progress towards take profit (only for active) */
|
|
7203
|
+
/** Percentage progress towards take profit (only for active/waiting) */
|
|
6985
7204
|
percentTp?: number;
|
|
6986
|
-
/** Percentage progress towards stop loss (only for active) */
|
|
7205
|
+
/** Percentage progress towards stop loss (only for active/waiting) */
|
|
6987
7206
|
percentSl?: number;
|
|
6988
|
-
/** PNL percentage (for active: unrealized, for closed: realized) */
|
|
7207
|
+
/** PNL percentage (for active/waiting: unrealized, for closed: realized) */
|
|
6989
7208
|
pnl?: number;
|
|
6990
7209
|
/** Close reason (only for closed) */
|
|
6991
7210
|
closeReason?: string;
|
|
7211
|
+
/** Cancel reason (only for cancelled) */
|
|
7212
|
+
cancelReason?: string;
|
|
6992
7213
|
/** Duration in minutes (only for closed) */
|
|
6993
7214
|
duration?: number;
|
|
6994
7215
|
}
|
|
@@ -8927,14 +9148,14 @@ declare class BacktestUtils {
|
|
|
8927
9148
|
* @example
|
|
8928
9149
|
* ```typescript
|
|
8929
9150
|
* // Cancel scheduled signal with custom ID
|
|
8930
|
-
* await Backtest.
|
|
9151
|
+
* await Backtest.commitCancel("BTCUSDT", "my-strategy", {
|
|
8931
9152
|
* exchangeName: "binance",
|
|
8932
9153
|
* frameName: "frame1",
|
|
8933
9154
|
* strategyName: "my-strategy"
|
|
8934
9155
|
* }, "manual-cancel-001");
|
|
8935
9156
|
* ```
|
|
8936
9157
|
*/
|
|
8937
|
-
|
|
9158
|
+
commitCancel: (symbol: string, context: {
|
|
8938
9159
|
strategyName: StrategyName;
|
|
8939
9160
|
exchangeName: ExchangeName;
|
|
8940
9161
|
frameName: FrameName;
|
|
@@ -8958,7 +9179,7 @@ declare class BacktestUtils {
|
|
|
8958
9179
|
* @example
|
|
8959
9180
|
* ```typescript
|
|
8960
9181
|
* // Close 30% of LONG position at profit
|
|
8961
|
-
* const success = await Backtest.
|
|
9182
|
+
* const success = await Backtest.commitPartialProfit("BTCUSDT", 30, 45000, {
|
|
8962
9183
|
* exchangeName: "binance",
|
|
8963
9184
|
* frameName: "frame1",
|
|
8964
9185
|
* strategyName: "my-strategy"
|
|
@@ -8968,7 +9189,7 @@ declare class BacktestUtils {
|
|
|
8968
9189
|
* }
|
|
8969
9190
|
* ```
|
|
8970
9191
|
*/
|
|
8971
|
-
|
|
9192
|
+
commitPartialProfit: (symbol: string, percentToClose: number, currentPrice: number, context: {
|
|
8972
9193
|
strategyName: StrategyName;
|
|
8973
9194
|
exchangeName: ExchangeName;
|
|
8974
9195
|
frameName: FrameName;
|
|
@@ -8992,7 +9213,7 @@ declare class BacktestUtils {
|
|
|
8992
9213
|
* @example
|
|
8993
9214
|
* ```typescript
|
|
8994
9215
|
* // Close 40% of LONG position at loss
|
|
8995
|
-
* const success = await Backtest.
|
|
9216
|
+
* const success = await Backtest.commitPartialLoss("BTCUSDT", 40, 38000, {
|
|
8996
9217
|
* exchangeName: "binance",
|
|
8997
9218
|
* frameName: "frame1",
|
|
8998
9219
|
* strategyName: "my-strategy"
|
|
@@ -9002,7 +9223,7 @@ declare class BacktestUtils {
|
|
|
9002
9223
|
* }
|
|
9003
9224
|
* ```
|
|
9004
9225
|
*/
|
|
9005
|
-
|
|
9226
|
+
commitPartialLoss: (symbol: string, percentToClose: number, currentPrice: number, context: {
|
|
9006
9227
|
strategyName: StrategyName;
|
|
9007
9228
|
exchangeName: ExchangeName;
|
|
9008
9229
|
frameName: FrameName;
|
|
@@ -9035,7 +9256,7 @@ declare class BacktestUtils {
|
|
|
9035
9256
|
* // LONG: entry=100, originalSL=90, distance=10%, currentPrice=102
|
|
9036
9257
|
*
|
|
9037
9258
|
* // First call: tighten by 5%
|
|
9038
|
-
* await Backtest.
|
|
9259
|
+
* await Backtest.commitTrailingStop("BTCUSDT", -5, 102, {
|
|
9039
9260
|
* exchangeName: "binance",
|
|
9040
9261
|
* frameName: "frame1",
|
|
9041
9262
|
* strategyName: "my-strategy"
|
|
@@ -9043,15 +9264,15 @@ declare class BacktestUtils {
|
|
|
9043
9264
|
* // newDistance = 10% - 5% = 5%, newSL = 95
|
|
9044
9265
|
*
|
|
9045
9266
|
* // Second call: try weaker protection (smaller percentShift)
|
|
9046
|
-
* await Backtest.
|
|
9267
|
+
* await Backtest.commitTrailingStop("BTCUSDT", -3, 102, context);
|
|
9047
9268
|
* // SKIPPED: newSL=97 < 95 (worse protection, larger % absorbs smaller)
|
|
9048
9269
|
*
|
|
9049
9270
|
* // Third call: stronger protection (larger percentShift)
|
|
9050
|
-
* await Backtest.
|
|
9271
|
+
* await Backtest.commitTrailingStop("BTCUSDT", -7, 102, context);
|
|
9051
9272
|
* // ACCEPTED: newDistance = 10% - 7% = 3%, newSL = 97 > 95 (better protection)
|
|
9052
9273
|
* ```
|
|
9053
9274
|
*/
|
|
9054
|
-
|
|
9275
|
+
commitTrailingStop: (symbol: string, percentShift: number, currentPrice: number, context: {
|
|
9055
9276
|
strategyName: StrategyName;
|
|
9056
9277
|
exchangeName: ExchangeName;
|
|
9057
9278
|
frameName: FrameName;
|
|
@@ -9084,7 +9305,7 @@ declare class BacktestUtils {
|
|
|
9084
9305
|
* // LONG: entry=100, originalTP=110, distance=10%, currentPrice=102
|
|
9085
9306
|
*
|
|
9086
9307
|
* // First call: bring TP closer by 3%
|
|
9087
|
-
* await Backtest.
|
|
9308
|
+
* await Backtest.commitTrailingTake("BTCUSDT", -3, 102, {
|
|
9088
9309
|
* exchangeName: "binance",
|
|
9089
9310
|
* frameName: "frame1",
|
|
9090
9311
|
* strategyName: "my-strategy"
|
|
@@ -9092,15 +9313,15 @@ declare class BacktestUtils {
|
|
|
9092
9313
|
* // newDistance = 10% - 3% = 7%, newTP = 107
|
|
9093
9314
|
*
|
|
9094
9315
|
* // Second call: try to move TP further (less conservative)
|
|
9095
|
-
* await Backtest.
|
|
9316
|
+
* await Backtest.commitTrailingTake("BTCUSDT", 2, 102, context);
|
|
9096
9317
|
* // SKIPPED: newTP=112 > 107 (less conservative, larger % absorbs smaller)
|
|
9097
9318
|
*
|
|
9098
9319
|
* // Third call: even more conservative
|
|
9099
|
-
* await Backtest.
|
|
9320
|
+
* await Backtest.commitTrailingTake("BTCUSDT", -5, 102, context);
|
|
9100
9321
|
* // ACCEPTED: newDistance = 10% - 5% = 5%, newTP = 105 < 107 (more conservative)
|
|
9101
9322
|
* ```
|
|
9102
9323
|
*/
|
|
9103
|
-
|
|
9324
|
+
commitTrailingTake: (symbol: string, percentShift: number, currentPrice: number, context: {
|
|
9104
9325
|
strategyName: StrategyName;
|
|
9105
9326
|
exchangeName: ExchangeName;
|
|
9106
9327
|
frameName: FrameName;
|
|
@@ -9118,7 +9339,7 @@ declare class BacktestUtils {
|
|
|
9118
9339
|
*
|
|
9119
9340
|
* @example
|
|
9120
9341
|
* ```typescript
|
|
9121
|
-
* const moved = await Backtest.
|
|
9342
|
+
* const moved = await Backtest.commitBreakeven(
|
|
9122
9343
|
* "BTCUSDT",
|
|
9123
9344
|
* 112,
|
|
9124
9345
|
* { strategyName: "my-strategy", exchangeName: "binance", frameName: "1h" }
|
|
@@ -9126,7 +9347,7 @@ declare class BacktestUtils {
|
|
|
9126
9347
|
* console.log(moved); // true (SL moved to entry price)
|
|
9127
9348
|
* ```
|
|
9128
9349
|
*/
|
|
9129
|
-
|
|
9350
|
+
commitBreakeven: (symbol: string, currentPrice: number, context: {
|
|
9130
9351
|
strategyName: StrategyName;
|
|
9131
9352
|
exchangeName: ExchangeName;
|
|
9132
9353
|
frameName: FrameName;
|
|
@@ -9510,7 +9731,7 @@ declare class LiveUtils {
|
|
|
9510
9731
|
run: (symbol: string, context: {
|
|
9511
9732
|
strategyName: StrategyName;
|
|
9512
9733
|
exchangeName: ExchangeName;
|
|
9513
|
-
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
9734
|
+
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
|
|
9514
9735
|
/**
|
|
9515
9736
|
* Runs live trading in background without yielding results.
|
|
9516
9737
|
*
|
|
@@ -9640,14 +9861,14 @@ declare class LiveUtils {
|
|
|
9640
9861
|
* @example
|
|
9641
9862
|
* ```typescript
|
|
9642
9863
|
* // Cancel scheduled signal in live trading with custom ID
|
|
9643
|
-
* await Live.
|
|
9864
|
+
* await Live.commitCancel("BTCUSDT", "my-strategy", {
|
|
9644
9865
|
* exchangeName: "binance",
|
|
9645
9866
|
* frameName: "",
|
|
9646
9867
|
* strategyName: "my-strategy"
|
|
9647
9868
|
* }, "manual-cancel-001");
|
|
9648
9869
|
* ```
|
|
9649
9870
|
*/
|
|
9650
|
-
|
|
9871
|
+
commitCancel: (symbol: string, context: {
|
|
9651
9872
|
strategyName: StrategyName;
|
|
9652
9873
|
exchangeName: ExchangeName;
|
|
9653
9874
|
}, cancelId?: string) => Promise<void>;
|
|
@@ -9670,7 +9891,7 @@ declare class LiveUtils {
|
|
|
9670
9891
|
* @example
|
|
9671
9892
|
* ```typescript
|
|
9672
9893
|
* // Close 30% of LONG position at profit
|
|
9673
|
-
* const success = await Live.
|
|
9894
|
+
* const success = await Live.commitPartialProfit("BTCUSDT", 30, 45000, {
|
|
9674
9895
|
* exchangeName: "binance",
|
|
9675
9896
|
* strategyName: "my-strategy"
|
|
9676
9897
|
* });
|
|
@@ -9679,7 +9900,7 @@ declare class LiveUtils {
|
|
|
9679
9900
|
* }
|
|
9680
9901
|
* ```
|
|
9681
9902
|
*/
|
|
9682
|
-
|
|
9903
|
+
commitPartialProfit: (symbol: string, percentToClose: number, currentPrice: number, context: {
|
|
9683
9904
|
strategyName: StrategyName;
|
|
9684
9905
|
exchangeName: ExchangeName;
|
|
9685
9906
|
}) => Promise<boolean>;
|
|
@@ -9702,7 +9923,7 @@ declare class LiveUtils {
|
|
|
9702
9923
|
* @example
|
|
9703
9924
|
* ```typescript
|
|
9704
9925
|
* // Close 40% of LONG position at loss
|
|
9705
|
-
* const success = await Live.
|
|
9926
|
+
* const success = await Live.commitPartialLoss("BTCUSDT", 40, 38000, {
|
|
9706
9927
|
* exchangeName: "binance",
|
|
9707
9928
|
* strategyName: "my-strategy"
|
|
9708
9929
|
* });
|
|
@@ -9711,7 +9932,7 @@ declare class LiveUtils {
|
|
|
9711
9932
|
* }
|
|
9712
9933
|
* ```
|
|
9713
9934
|
*/
|
|
9714
|
-
|
|
9935
|
+
commitPartialLoss: (symbol: string, percentToClose: number, currentPrice: number, context: {
|
|
9715
9936
|
strategyName: StrategyName;
|
|
9716
9937
|
exchangeName: ExchangeName;
|
|
9717
9938
|
}) => Promise<boolean>;
|
|
@@ -9743,22 +9964,22 @@ declare class LiveUtils {
|
|
|
9743
9964
|
* // LONG: entry=100, originalSL=90, distance=10%, currentPrice=102
|
|
9744
9965
|
*
|
|
9745
9966
|
* // First call: tighten by 5%
|
|
9746
|
-
* const success1 = await Live.
|
|
9967
|
+
* const success1 = await Live.commitTrailingStop("BTCUSDT", -5, 102, {
|
|
9747
9968
|
* exchangeName: "binance",
|
|
9748
9969
|
* strategyName: "my-strategy"
|
|
9749
9970
|
* });
|
|
9750
9971
|
* // success1 = true, newDistance = 10% - 5% = 5%, newSL = 95
|
|
9751
9972
|
*
|
|
9752
9973
|
* // Second call: try weaker protection (smaller percentShift)
|
|
9753
|
-
* const success2 = await Live.
|
|
9974
|
+
* const success2 = await Live.commitTrailingStop("BTCUSDT", -3, 102, context);
|
|
9754
9975
|
* // success2 = false (SKIPPED: newSL=97 < 95, worse protection, larger % absorbs smaller)
|
|
9755
9976
|
*
|
|
9756
9977
|
* // Third call: stronger protection (larger percentShift)
|
|
9757
|
-
* const success3 = await Live.
|
|
9978
|
+
* const success3 = await Live.commitTrailingStop("BTCUSDT", -7, 102, context);
|
|
9758
9979
|
* // success3 = true (ACCEPTED: newDistance = 10% - 7% = 3%, newSL = 97 > 95, better protection)
|
|
9759
9980
|
* ```
|
|
9760
9981
|
*/
|
|
9761
|
-
|
|
9982
|
+
commitTrailingStop: (symbol: string, percentShift: number, currentPrice: number, context: {
|
|
9762
9983
|
strategyName: StrategyName;
|
|
9763
9984
|
exchangeName: ExchangeName;
|
|
9764
9985
|
}) => Promise<boolean>;
|
|
@@ -9790,22 +10011,22 @@ declare class LiveUtils {
|
|
|
9790
10011
|
* // LONG: entry=100, originalTP=110, distance=10%, currentPrice=102
|
|
9791
10012
|
*
|
|
9792
10013
|
* // First call: bring TP closer by 3%
|
|
9793
|
-
* const success1 = await Live.
|
|
10014
|
+
* const success1 = await Live.commitTrailingTake("BTCUSDT", -3, 102, {
|
|
9794
10015
|
* exchangeName: "binance",
|
|
9795
10016
|
* strategyName: "my-strategy"
|
|
9796
10017
|
* });
|
|
9797
10018
|
* // success1 = true, newDistance = 10% - 3% = 7%, newTP = 107
|
|
9798
10019
|
*
|
|
9799
10020
|
* // Second call: try to move TP further (less conservative)
|
|
9800
|
-
* const success2 = await Live.
|
|
10021
|
+
* const success2 = await Live.commitTrailingTake("BTCUSDT", 2, 102, context);
|
|
9801
10022
|
* // success2 = false (SKIPPED: newTP=112 > 107, less conservative, larger % absorbs smaller)
|
|
9802
10023
|
*
|
|
9803
10024
|
* // Third call: even more conservative
|
|
9804
|
-
* const success3 = await Live.
|
|
10025
|
+
* const success3 = await Live.commitTrailingTake("BTCUSDT", -5, 102, context);
|
|
9805
10026
|
* // success3 = true (ACCEPTED: newDistance = 10% - 5% = 5%, newTP = 105 < 107, more conservative)
|
|
9806
10027
|
* ```
|
|
9807
10028
|
*/
|
|
9808
|
-
|
|
10029
|
+
commitTrailingTake: (symbol: string, percentShift: number, currentPrice: number, context: {
|
|
9809
10030
|
strategyName: StrategyName;
|
|
9810
10031
|
exchangeName: ExchangeName;
|
|
9811
10032
|
}) => Promise<boolean>;
|
|
@@ -9822,7 +10043,7 @@ declare class LiveUtils {
|
|
|
9822
10043
|
*
|
|
9823
10044
|
* @example
|
|
9824
10045
|
* ```typescript
|
|
9825
|
-
* const moved = await Live.
|
|
10046
|
+
* const moved = await Live.commitBreakeven(
|
|
9826
10047
|
* "BTCUSDT",
|
|
9827
10048
|
* 112,
|
|
9828
10049
|
* { strategyName: "my-strategy", exchangeName: "binance" }
|
|
@@ -9830,7 +10051,7 @@ declare class LiveUtils {
|
|
|
9830
10051
|
* console.log(moved); // true (SL moved to entry price)
|
|
9831
10052
|
* ```
|
|
9832
10053
|
*/
|
|
9833
|
-
|
|
10054
|
+
commitBreakeven: (symbol: string, currentPrice: number, context: {
|
|
9834
10055
|
strategyName: StrategyName;
|
|
9835
10056
|
exchangeName: ExchangeName;
|
|
9836
10057
|
}) => Promise<boolean>;
|
|
@@ -12995,10 +13216,11 @@ declare const Breakeven: BreakevenUtils;
|
|
|
12995
13216
|
* - signal() - Called on every tick/candle (all modes)
|
|
12996
13217
|
* - signalLive() - Called only in live mode
|
|
12997
13218
|
* - signalBacktest() - Called only in backtest mode
|
|
12998
|
-
* -
|
|
12999
|
-
* -
|
|
13000
|
-
* -
|
|
13001
|
-
* -
|
|
13219
|
+
* - breakevenAvailable() - Called when SL moved to entry
|
|
13220
|
+
* - partialProfitAvailable() - Called on profit milestones (10%, 20%, etc.)
|
|
13221
|
+
* - partialLossAvailable() - Called on loss milestones (-10%, -20%, etc.)
|
|
13222
|
+
* - pingScheduled() - Called every minute during scheduled signal monitoring
|
|
13223
|
+
* - pingActive() - Called every minute during active pending signal monitoring
|
|
13002
13224
|
* - riskRejection() - Called when signal rejected by risk management
|
|
13003
13225
|
*
|
|
13004
13226
|
* @example
|
|
@@ -13039,7 +13261,7 @@ declare const Breakeven: BreakevenUtils;
|
|
|
13039
13261
|
* }
|
|
13040
13262
|
*
|
|
13041
13263
|
* // Register the action
|
|
13042
|
-
*
|
|
13264
|
+
* addActionSchema({
|
|
13043
13265
|
* actionName: "telegram-notifier",
|
|
13044
13266
|
* handler: TelegramNotifier
|
|
13045
13267
|
* });
|
|
@@ -13078,14 +13300,16 @@ declare class ActionBase implements IPublicAction {
|
|
|
13078
13300
|
readonly strategyName: StrategyName;
|
|
13079
13301
|
readonly frameName: FrameName;
|
|
13080
13302
|
readonly actionName: ActionName;
|
|
13303
|
+
readonly backtest: boolean;
|
|
13081
13304
|
/**
|
|
13082
13305
|
* Creates a new ActionBase instance.
|
|
13083
13306
|
*
|
|
13084
13307
|
* @param strategyName - Strategy identifier this action is attached to
|
|
13085
13308
|
* @param frameName - Timeframe identifier this action is attached to
|
|
13086
13309
|
* @param actionName - Action identifier
|
|
13310
|
+
* @param backtest - If running in backtest
|
|
13087
13311
|
*/
|
|
13088
|
-
constructor(strategyName: StrategyName, frameName: FrameName, actionName: ActionName);
|
|
13312
|
+
constructor(strategyName: StrategyName, frameName: FrameName, actionName: ActionName, backtest: boolean);
|
|
13089
13313
|
/**
|
|
13090
13314
|
* Initializes the action handler.
|
|
13091
13315
|
*
|
|
@@ -13189,7 +13413,7 @@ declare class ActionBase implements IPublicAction {
|
|
|
13189
13413
|
* Called once per signal when price moves far enough to cover fees and slippage.
|
|
13190
13414
|
* Breakeven threshold: (CC_PERCENT_SLIPPAGE + CC_PERCENT_FEE) * 2 + CC_BREAKEVEN_THRESHOLD
|
|
13191
13415
|
*
|
|
13192
|
-
* Triggered by: ActionCoreService.
|
|
13416
|
+
* Triggered by: ActionCoreService.breakevenAvailable() via BreakevenConnectionService
|
|
13193
13417
|
* Source: breakevenSubject.next() in CREATE_COMMIT_BREAKEVEN_FN callback
|
|
13194
13418
|
* Frequency: Once per signal when threshold reached
|
|
13195
13419
|
*
|
|
@@ -13199,7 +13423,7 @@ declare class ActionBase implements IPublicAction {
|
|
|
13199
13423
|
*
|
|
13200
13424
|
* @example
|
|
13201
13425
|
* ```typescript
|
|
13202
|
-
* async
|
|
13426
|
+
* async breakevenAvailable(event: BreakevenContract) {
|
|
13203
13427
|
* await this.telegram.send(
|
|
13204
13428
|
* `[${event.strategyName}] Breakeven reached! ` +
|
|
13205
13429
|
* `Signal: ${event.data.side} @ ${event.currentPrice}`
|
|
@@ -13207,14 +13431,14 @@ declare class ActionBase implements IPublicAction {
|
|
|
13207
13431
|
* }
|
|
13208
13432
|
* ```
|
|
13209
13433
|
*/
|
|
13210
|
-
|
|
13434
|
+
breakevenAvailable(event: BreakevenContract, source?: string): void | Promise<void>;
|
|
13211
13435
|
/**
|
|
13212
13436
|
* Handles partial profit level events (10%, 20%, 30%, etc).
|
|
13213
13437
|
*
|
|
13214
13438
|
* Called once per profit level per signal (deduplicated).
|
|
13215
13439
|
* Use to track profit milestones and adjust position management.
|
|
13216
13440
|
*
|
|
13217
|
-
* Triggered by: ActionCoreService.
|
|
13441
|
+
* Triggered by: ActionCoreService.partialProfitAvailable() via PartialConnectionService
|
|
13218
13442
|
* Source: partialProfitSubject.next() in CREATE_COMMIT_PROFIT_FN callback
|
|
13219
13443
|
* Frequency: Once per profit level per signal
|
|
13220
13444
|
*
|
|
@@ -13224,7 +13448,7 @@ declare class ActionBase implements IPublicAction {
|
|
|
13224
13448
|
*
|
|
13225
13449
|
* @example
|
|
13226
13450
|
* ```typescript
|
|
13227
|
-
* async
|
|
13451
|
+
* async partialProfitAvailable(event: PartialProfitContract) {
|
|
13228
13452
|
* await this.telegram.send(
|
|
13229
13453
|
* `[${event.strategyName}] Profit ${event.level}% reached! ` +
|
|
13230
13454
|
* `Current price: ${event.currentPrice}`
|
|
@@ -13233,14 +13457,14 @@ declare class ActionBase implements IPublicAction {
|
|
|
13233
13457
|
* }
|
|
13234
13458
|
* ```
|
|
13235
13459
|
*/
|
|
13236
|
-
|
|
13460
|
+
partialProfitAvailable(event: PartialProfitContract, source?: string): void | Promise<void>;
|
|
13237
13461
|
/**
|
|
13238
13462
|
* Handles partial loss level events (-10%, -20%, -30%, etc).
|
|
13239
13463
|
*
|
|
13240
13464
|
* Called once per loss level per signal (deduplicated).
|
|
13241
13465
|
* Use to track loss milestones and implement risk management actions.
|
|
13242
13466
|
*
|
|
13243
|
-
* Triggered by: ActionCoreService.
|
|
13467
|
+
* Triggered by: ActionCoreService.partialLossAvailable() via PartialConnectionService
|
|
13244
13468
|
* Source: partialLossSubject.next() in CREATE_COMMIT_LOSS_FN callback
|
|
13245
13469
|
* Frequency: Once per loss level per signal
|
|
13246
13470
|
*
|
|
@@ -13250,7 +13474,7 @@ declare class ActionBase implements IPublicAction {
|
|
|
13250
13474
|
*
|
|
13251
13475
|
* @example
|
|
13252
13476
|
* ```typescript
|
|
13253
|
-
* async
|
|
13477
|
+
* async partialLossAvailable(event: PartialLossContract) {
|
|
13254
13478
|
* await this.telegram.send(
|
|
13255
13479
|
* `[${event.strategyName}] Loss ${event.level}% reached! ` +
|
|
13256
13480
|
* `Current price: ${event.currentPrice}`
|
|
@@ -13259,31 +13483,55 @@ declare class ActionBase implements IPublicAction {
|
|
|
13259
13483
|
* }
|
|
13260
13484
|
* ```
|
|
13261
13485
|
*/
|
|
13262
|
-
|
|
13486
|
+
partialLossAvailable(event: PartialLossContract, source?: string): void | Promise<void>;
|
|
13263
13487
|
/**
|
|
13264
|
-
* Handles ping events during scheduled signal monitoring.
|
|
13488
|
+
* Handles scheduled ping events during scheduled signal monitoring.
|
|
13265
13489
|
*
|
|
13266
13490
|
* Called every minute while a scheduled signal is waiting for activation.
|
|
13267
13491
|
* Use to monitor pending signals and track wait time.
|
|
13268
13492
|
*
|
|
13269
|
-
* Triggered by: ActionCoreService.
|
|
13270
|
-
* Source:
|
|
13493
|
+
* Triggered by: ActionCoreService.pingScheduled() via StrategyConnectionService
|
|
13494
|
+
* Source: schedulePingSubject.next() in CREATE_COMMIT_SCHEDULE_PING_FN callback
|
|
13271
13495
|
* Frequency: Every minute while scheduled signal is waiting
|
|
13272
13496
|
*
|
|
13273
|
-
* Default implementation: Logs ping event.
|
|
13497
|
+
* Default implementation: Logs scheduled ping event.
|
|
13274
13498
|
*
|
|
13275
13499
|
* @param event - Scheduled signal monitoring data with symbol, strategy info, signal data, timestamp
|
|
13276
13500
|
*
|
|
13277
13501
|
* @example
|
|
13278
13502
|
* ```typescript
|
|
13279
|
-
*
|
|
13503
|
+
* pingScheduled(event: SchedulePingContract) {
|
|
13280
13504
|
* const waitTime = Date.now() - event.data.timestampScheduled;
|
|
13281
13505
|
* const waitMinutes = Math.floor(waitTime / 60000);
|
|
13282
13506
|
* console.log(`Scheduled signal waiting ${waitMinutes} minutes`);
|
|
13283
13507
|
* }
|
|
13284
13508
|
* ```
|
|
13285
13509
|
*/
|
|
13286
|
-
|
|
13510
|
+
pingScheduled(event: SchedulePingContract, source?: string): void | Promise<void>;
|
|
13511
|
+
/**
|
|
13512
|
+
* Handles active ping events during active pending signal monitoring.
|
|
13513
|
+
*
|
|
13514
|
+
* Called every minute while a pending signal is active (position open).
|
|
13515
|
+
* Use to monitor active positions and track lifecycle.
|
|
13516
|
+
*
|
|
13517
|
+
* Triggered by: ActionCoreService.pingActive() via StrategyConnectionService
|
|
13518
|
+
* Source: activePingSubject.next() in CREATE_COMMIT_ACTIVE_PING_FN callback
|
|
13519
|
+
* Frequency: Every minute while pending signal is active
|
|
13520
|
+
*
|
|
13521
|
+
* Default implementation: Logs active ping event.
|
|
13522
|
+
*
|
|
13523
|
+
* @param event - Active pending signal monitoring data with symbol, strategy info, signal data, timestamp
|
|
13524
|
+
*
|
|
13525
|
+
* @example
|
|
13526
|
+
* ```typescript
|
|
13527
|
+
* pingActive(event: ActivePingContract) {
|
|
13528
|
+
* const holdTime = Date.now() - event.data.pendingAt;
|
|
13529
|
+
* const holdMinutes = Math.floor(holdTime / 60000);
|
|
13530
|
+
* console.log(`Active signal holding ${holdMinutes} minutes`);
|
|
13531
|
+
* }
|
|
13532
|
+
* ```
|
|
13533
|
+
*/
|
|
13534
|
+
pingActive(event: ActivePingContract, source?: string): void | Promise<void>;
|
|
13287
13535
|
/**
|
|
13288
13536
|
* Handles risk rejection events when signals fail risk validation.
|
|
13289
13537
|
*
|
|
@@ -13475,12 +13723,19 @@ declare const breakevenSubject: Subject<BreakevenContract>;
|
|
|
13475
13723
|
*/
|
|
13476
13724
|
declare const riskSubject: Subject<RiskContract>;
|
|
13477
13725
|
/**
|
|
13478
|
-
*
|
|
13726
|
+
* Schedule ping emitter for scheduled signal monitoring events.
|
|
13479
13727
|
* Emits every minute when a scheduled signal is being monitored (waiting for activation).
|
|
13480
13728
|
* Allows users to track scheduled signal lifecycle and implement custom cancellation logic.
|
|
13481
13729
|
*/
|
|
13482
|
-
declare const
|
|
13730
|
+
declare const schedulePingSubject: Subject<SchedulePingContract>;
|
|
13731
|
+
/**
|
|
13732
|
+
* Active ping emitter for active pending signal monitoring events.
|
|
13733
|
+
* Emits every minute when an active pending signal is being monitored.
|
|
13734
|
+
* Allows users to track active signal lifecycle and implement custom dynamic management logic.
|
|
13735
|
+
*/
|
|
13736
|
+
declare const activePingSubject: Subject<ActivePingContract>;
|
|
13483
13737
|
|
|
13738
|
+
declare const emitters_activePingSubject: typeof activePingSubject;
|
|
13484
13739
|
declare const emitters_breakevenSubject: typeof breakevenSubject;
|
|
13485
13740
|
declare const emitters_doneBacktestSubject: typeof doneBacktestSubject;
|
|
13486
13741
|
declare const emitters_doneLiveSubject: typeof doneLiveSubject;
|
|
@@ -13490,11 +13745,11 @@ declare const emitters_exitEmitter: typeof exitEmitter;
|
|
|
13490
13745
|
declare const emitters_partialLossSubject: typeof partialLossSubject;
|
|
13491
13746
|
declare const emitters_partialProfitSubject: typeof partialProfitSubject;
|
|
13492
13747
|
declare const emitters_performanceEmitter: typeof performanceEmitter;
|
|
13493
|
-
declare const emitters_pingSubject: typeof pingSubject;
|
|
13494
13748
|
declare const emitters_progressBacktestEmitter: typeof progressBacktestEmitter;
|
|
13495
13749
|
declare const emitters_progressOptimizerEmitter: typeof progressOptimizerEmitter;
|
|
13496
13750
|
declare const emitters_progressWalkerEmitter: typeof progressWalkerEmitter;
|
|
13497
13751
|
declare const emitters_riskSubject: typeof riskSubject;
|
|
13752
|
+
declare const emitters_schedulePingSubject: typeof schedulePingSubject;
|
|
13498
13753
|
declare const emitters_signalBacktestEmitter: typeof signalBacktestEmitter;
|
|
13499
13754
|
declare const emitters_signalEmitter: typeof signalEmitter;
|
|
13500
13755
|
declare const emitters_signalLiveEmitter: typeof signalLiveEmitter;
|
|
@@ -13503,7 +13758,7 @@ declare const emitters_walkerCompleteSubject: typeof walkerCompleteSubject;
|
|
|
13503
13758
|
declare const emitters_walkerEmitter: typeof walkerEmitter;
|
|
13504
13759
|
declare const emitters_walkerStopSubject: typeof walkerStopSubject;
|
|
13505
13760
|
declare namespace emitters {
|
|
13506
|
-
export { emitters_breakevenSubject as breakevenSubject, 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,
|
|
13761
|
+
export { emitters_activePingSubject as activePingSubject, emitters_breakevenSubject as breakevenSubject, 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_schedulePingSubject as schedulePingSubject, 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 };
|
|
13507
13762
|
}
|
|
13508
13763
|
|
|
13509
13764
|
/**
|
|
@@ -14043,13 +14298,13 @@ declare class ActionCoreService implements TAction$1 {
|
|
|
14043
14298
|
* Routes breakeven event to all registered actions for the strategy.
|
|
14044
14299
|
*
|
|
14045
14300
|
* Retrieves action list from strategy schema (IStrategySchema.actions)
|
|
14046
|
-
* and invokes the
|
|
14301
|
+
* and invokes the breakevenAvailable handler on each ClientAction instance sequentially.
|
|
14047
14302
|
*
|
|
14048
14303
|
* @param backtest - Whether running in backtest mode (true) or live mode (false)
|
|
14049
14304
|
* @param event - Breakeven milestone data (stop-loss moved to entry price)
|
|
14050
14305
|
* @param context - Strategy execution context with strategyName, exchangeName, frameName
|
|
14051
14306
|
*/
|
|
14052
|
-
|
|
14307
|
+
breakevenAvailable: (backtest: boolean, event: BreakevenContract, context: {
|
|
14053
14308
|
strategyName: StrategyName;
|
|
14054
14309
|
exchangeName: ExchangeName;
|
|
14055
14310
|
frameName: FrameName;
|
|
@@ -14058,13 +14313,13 @@ declare class ActionCoreService implements TAction$1 {
|
|
|
14058
14313
|
* Routes partial profit event to all registered actions for the strategy.
|
|
14059
14314
|
*
|
|
14060
14315
|
* Retrieves action list from strategy schema (IStrategySchema.actions)
|
|
14061
|
-
* and invokes the
|
|
14316
|
+
* and invokes the partialProfitAvailable handler on each ClientAction instance sequentially.
|
|
14062
14317
|
*
|
|
14063
14318
|
* @param backtest - Whether running in backtest mode (true) or live mode (false)
|
|
14064
14319
|
* @param event - Profit milestone data with level (10%, 20%, etc.) and price
|
|
14065
14320
|
* @param context - Strategy execution context with strategyName, exchangeName, frameName
|
|
14066
14321
|
*/
|
|
14067
|
-
|
|
14322
|
+
partialProfitAvailable: (backtest: boolean, event: PartialProfitContract, context: {
|
|
14068
14323
|
strategyName: StrategyName;
|
|
14069
14324
|
exchangeName: ExchangeName;
|
|
14070
14325
|
frameName: FrameName;
|
|
@@ -14073,29 +14328,45 @@ declare class ActionCoreService implements TAction$1 {
|
|
|
14073
14328
|
* Routes partial loss event to all registered actions for the strategy.
|
|
14074
14329
|
*
|
|
14075
14330
|
* Retrieves action list from strategy schema (IStrategySchema.actions)
|
|
14076
|
-
* and invokes the
|
|
14331
|
+
* and invokes the partialLossAvailable handler on each ClientAction instance sequentially.
|
|
14077
14332
|
*
|
|
14078
14333
|
* @param backtest - Whether running in backtest mode (true) or live mode (false)
|
|
14079
14334
|
* @param event - Loss milestone data with level (-10%, -20%, etc.) and price
|
|
14080
14335
|
* @param context - Strategy execution context with strategyName, exchangeName, frameName
|
|
14081
14336
|
*/
|
|
14082
|
-
|
|
14337
|
+
partialLossAvailable: (backtest: boolean, event: PartialLossContract, context: {
|
|
14083
14338
|
strategyName: StrategyName;
|
|
14084
14339
|
exchangeName: ExchangeName;
|
|
14085
14340
|
frameName: FrameName;
|
|
14086
14341
|
}) => Promise<void>;
|
|
14087
14342
|
/**
|
|
14088
|
-
* Routes ping event to all registered actions for the strategy.
|
|
14343
|
+
* Routes scheduled ping event to all registered actions for the strategy.
|
|
14089
14344
|
*
|
|
14090
14345
|
* Retrieves action list from strategy schema (IStrategySchema.actions)
|
|
14091
|
-
* and invokes the
|
|
14346
|
+
* and invokes the pingScheduled handler on each ClientAction instance sequentially.
|
|
14092
14347
|
* Called every minute during scheduled signal monitoring.
|
|
14093
14348
|
*
|
|
14094
14349
|
* @param backtest - Whether running in backtest mode (true) or live mode (false)
|
|
14095
14350
|
* @param event - Scheduled signal monitoring data
|
|
14096
14351
|
* @param context - Strategy execution context with strategyName, exchangeName, frameName
|
|
14097
14352
|
*/
|
|
14098
|
-
|
|
14353
|
+
pingScheduled: (backtest: boolean, event: SchedulePingContract, context: {
|
|
14354
|
+
strategyName: StrategyName;
|
|
14355
|
+
exchangeName: ExchangeName;
|
|
14356
|
+
frameName: FrameName;
|
|
14357
|
+
}) => Promise<void>;
|
|
14358
|
+
/**
|
|
14359
|
+
* Routes active ping event to all registered actions for the strategy.
|
|
14360
|
+
*
|
|
14361
|
+
* Retrieves action list from strategy schema (IStrategySchema.actions)
|
|
14362
|
+
* and invokes the pingActive handler on each ClientAction instance sequentially.
|
|
14363
|
+
* Called every minute during active pending signal monitoring.
|
|
14364
|
+
*
|
|
14365
|
+
* @param backtest - Whether running in backtest mode (true) or live mode (false)
|
|
14366
|
+
* @param event - Active pending signal monitoring data
|
|
14367
|
+
* @param context - Strategy execution context with strategyName, exchangeName, frameName
|
|
14368
|
+
*/
|
|
14369
|
+
pingActive: (backtest: boolean, event: ActivePingContract, context: {
|
|
14099
14370
|
strategyName: StrategyName;
|
|
14100
14371
|
exchangeName: ExchangeName;
|
|
14101
14372
|
frameName: FrameName;
|
|
@@ -15109,19 +15380,23 @@ declare class ClientAction implements IAction {
|
|
|
15109
15380
|
/**
|
|
15110
15381
|
* Handles breakeven events when stop-loss is moved to entry price.
|
|
15111
15382
|
*/
|
|
15112
|
-
|
|
15383
|
+
breakevenAvailable(event: BreakevenContract): Promise<void>;
|
|
15113
15384
|
/**
|
|
15114
15385
|
* Handles partial profit level events (10%, 20%, 30%, etc).
|
|
15115
15386
|
*/
|
|
15116
|
-
|
|
15387
|
+
partialProfitAvailable(event: PartialProfitContract): Promise<void>;
|
|
15117
15388
|
/**
|
|
15118
15389
|
* Handles partial loss level events (-10%, -20%, -30%, etc).
|
|
15119
15390
|
*/
|
|
15120
|
-
|
|
15391
|
+
partialLossAvailable(event: PartialLossContract): Promise<void>;
|
|
15392
|
+
/**
|
|
15393
|
+
* Handles scheduled ping events during scheduled signal monitoring.
|
|
15394
|
+
*/
|
|
15395
|
+
pingScheduled(event: SchedulePingContract): Promise<void>;
|
|
15121
15396
|
/**
|
|
15122
|
-
* Handles ping events during
|
|
15397
|
+
* Handles active ping events during active pending signal monitoring.
|
|
15123
15398
|
*/
|
|
15124
|
-
|
|
15399
|
+
pingActive(event: ActivePingContract): Promise<void>;
|
|
15125
15400
|
/**
|
|
15126
15401
|
* Handles risk rejection events when signals fail risk validation.
|
|
15127
15402
|
*/
|
|
@@ -15245,7 +15520,7 @@ declare class ActionConnectionService implements TAction {
|
|
|
15245
15520
|
* @param backtest - Whether running in backtest mode
|
|
15246
15521
|
* @param context - Execution context with action name, strategy name, exchange name, frame name
|
|
15247
15522
|
*/
|
|
15248
|
-
|
|
15523
|
+
breakevenAvailable: (event: BreakevenContract, backtest: boolean, context: {
|
|
15249
15524
|
actionName: ActionName;
|
|
15250
15525
|
strategyName: StrategyName;
|
|
15251
15526
|
exchangeName: ExchangeName;
|
|
@@ -15258,7 +15533,7 @@ declare class ActionConnectionService implements TAction {
|
|
|
15258
15533
|
* @param backtest - Whether running in backtest mode
|
|
15259
15534
|
* @param context - Execution context with action name, strategy name, exchange name, frame name
|
|
15260
15535
|
*/
|
|
15261
|
-
|
|
15536
|
+
partialProfitAvailable: (event: PartialProfitContract, backtest: boolean, context: {
|
|
15262
15537
|
actionName: ActionName;
|
|
15263
15538
|
strategyName: StrategyName;
|
|
15264
15539
|
exchangeName: ExchangeName;
|
|
@@ -15271,20 +15546,33 @@ declare class ActionConnectionService implements TAction {
|
|
|
15271
15546
|
* @param backtest - Whether running in backtest mode
|
|
15272
15547
|
* @param context - Execution context with action name, strategy name, exchange name, frame name
|
|
15273
15548
|
*/
|
|
15274
|
-
|
|
15549
|
+
partialLossAvailable: (event: PartialLossContract, backtest: boolean, context: {
|
|
15550
|
+
actionName: ActionName;
|
|
15551
|
+
strategyName: StrategyName;
|
|
15552
|
+
exchangeName: ExchangeName;
|
|
15553
|
+
frameName: FrameName;
|
|
15554
|
+
}) => Promise<void>;
|
|
15555
|
+
/**
|
|
15556
|
+
* Routes scheduled ping event to appropriate ClientAction instance.
|
|
15557
|
+
*
|
|
15558
|
+
* @param event - Scheduled ping event data
|
|
15559
|
+
* @param backtest - Whether running in backtest mode
|
|
15560
|
+
* @param context - Execution context with action name, strategy name, exchange name, frame name
|
|
15561
|
+
*/
|
|
15562
|
+
pingScheduled: (event: SchedulePingContract, backtest: boolean, context: {
|
|
15275
15563
|
actionName: ActionName;
|
|
15276
15564
|
strategyName: StrategyName;
|
|
15277
15565
|
exchangeName: ExchangeName;
|
|
15278
15566
|
frameName: FrameName;
|
|
15279
15567
|
}) => Promise<void>;
|
|
15280
15568
|
/**
|
|
15281
|
-
* Routes ping event to appropriate ClientAction instance.
|
|
15569
|
+
* Routes active ping event to appropriate ClientAction instance.
|
|
15282
15570
|
*
|
|
15283
|
-
* @param event -
|
|
15571
|
+
* @param event - Active ping event data
|
|
15284
15572
|
* @param backtest - Whether running in backtest mode
|
|
15285
15573
|
* @param context - Execution context with action name, strategy name, exchange name, frame name
|
|
15286
15574
|
*/
|
|
15287
|
-
|
|
15575
|
+
pingActive: (event: ActivePingContract, backtest: boolean, context: {
|
|
15288
15576
|
actionName: ActionName;
|
|
15289
15577
|
strategyName: StrategyName;
|
|
15290
15578
|
exchangeName: ExchangeName;
|
|
@@ -16454,7 +16742,7 @@ declare class LiveLogicPrivateService {
|
|
|
16454
16742
|
* }
|
|
16455
16743
|
* ```
|
|
16456
16744
|
*/
|
|
16457
|
-
run(symbol: string): AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
16745
|
+
run(symbol: string): AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
|
|
16458
16746
|
}
|
|
16459
16747
|
|
|
16460
16748
|
/**
|
|
@@ -16583,7 +16871,7 @@ declare class LiveLogicPublicService implements TLiveLogicPrivateService {
|
|
|
16583
16871
|
run: (symbol: string, context: {
|
|
16584
16872
|
strategyName: StrategyName;
|
|
16585
16873
|
exchangeName: ExchangeName;
|
|
16586
|
-
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
16874
|
+
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
|
|
16587
16875
|
}
|
|
16588
16876
|
|
|
16589
16877
|
/**
|
|
@@ -16619,7 +16907,7 @@ declare class LiveCommandService implements TLiveLogicPublicService {
|
|
|
16619
16907
|
run: (symbol: string, context: {
|
|
16620
16908
|
strategyName: StrategyName;
|
|
16621
16909
|
exchangeName: ExchangeName;
|
|
16622
|
-
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed, void, unknown>;
|
|
16910
|
+
}) => AsyncGenerator<IStrategyTickResultOpened | IStrategyTickResultClosed | IStrategyTickResultCancelled, void, unknown>;
|
|
16623
16911
|
}
|
|
16624
16912
|
|
|
16625
16913
|
/**
|
|
@@ -18528,4 +18816,4 @@ declare const backtest: {
|
|
|
18528
18816
|
loggerService: LoggerService;
|
|
18529
18817
|
};
|
|
18530
18818
|
|
|
18531
|
-
export { ActionBase, Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, type BootstrapNotification, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, 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, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Notification, type NotificationModel, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter,
|
|
18819
|
+
export { ActionBase, type ActivePingContract, Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, type BootstrapNotification, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, 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, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Notification, type NotificationModel, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, type ProgressBacktestContract, type ProgressBacktestNotification, type ProgressOptimizerContract, 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, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addOptimizerSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitBreakeven, commitCancel, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, dumpSignalData, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getOptimizerSchema, getOrderBook, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listOptimizerSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideOptimizerSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, roundTicks, set, setColumns, setConfig, setLogger, stop, validate };
|