backtest-kit 3.2.0 → 3.3.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 +1 -1
- package/build/index.cjs +786 -89
- package/build/index.mjs +786 -90
- package/package.json +1 -1
- package/types.d.ts +391 -17
package/types.d.ts
CHANGED
|
@@ -2117,6 +2117,13 @@ interface SignalCommitBase {
|
|
|
2117
2117
|
signalId: string;
|
|
2118
2118
|
/** Timestamp from execution context (tick's when or backtest candle timestamp) */
|
|
2119
2119
|
timestamp: number;
|
|
2120
|
+
/**
|
|
2121
|
+
* Total number of DCA entries at the time of this event (_entry.length).
|
|
2122
|
+
* 1 = no averaging done (only initial entry). 2+ = averaged positions.
|
|
2123
|
+
*/
|
|
2124
|
+
totalEntries: number;
|
|
2125
|
+
/** Original entry price at signal creation (unchanged by DCA averaging). */
|
|
2126
|
+
originalPriceOpen: number;
|
|
2120
2127
|
}
|
|
2121
2128
|
/**
|
|
2122
2129
|
* Cancel scheduled signal event.
|
|
@@ -2269,6 +2276,34 @@ interface BreakevenCommit extends SignalCommitBase {
|
|
|
2269
2276
|
/** Position activation timestamp in milliseconds (when price reached priceOpen) */
|
|
2270
2277
|
pendingAt: number;
|
|
2271
2278
|
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Average-buy (DCA) event.
|
|
2281
|
+
* Emitted when a new averaging entry is added to an open position.
|
|
2282
|
+
*/
|
|
2283
|
+
interface AverageBuyCommit extends SignalCommitBase {
|
|
2284
|
+
/** Discriminator for average-buy action */
|
|
2285
|
+
action: "average-buy";
|
|
2286
|
+
/** Price at which the new averaging entry was executed */
|
|
2287
|
+
currentPrice: number;
|
|
2288
|
+
/** Effective (averaged) entry price after this addition */
|
|
2289
|
+
effectivePriceOpen: number;
|
|
2290
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
2291
|
+
position: "long" | "short";
|
|
2292
|
+
/** Original entry price (signal.priceOpen, unchanged by averaging) */
|
|
2293
|
+
priceOpen: number;
|
|
2294
|
+
/** Effective take profit price (may differ from original after trailing) */
|
|
2295
|
+
priceTakeProfit: number;
|
|
2296
|
+
/** Effective stop loss price (may differ from original after trailing) */
|
|
2297
|
+
priceStopLoss: number;
|
|
2298
|
+
/** Original take profit price before any trailing adjustments */
|
|
2299
|
+
originalPriceTakeProfit: number;
|
|
2300
|
+
/** Original stop loss price before any trailing adjustments */
|
|
2301
|
+
originalPriceStopLoss: number;
|
|
2302
|
+
/** Signal creation timestamp in milliseconds */
|
|
2303
|
+
scheduledAt: number;
|
|
2304
|
+
/** Position activation timestamp in milliseconds (when price reached priceOpen) */
|
|
2305
|
+
pendingAt: number;
|
|
2306
|
+
}
|
|
2272
2307
|
/**
|
|
2273
2308
|
* Activate scheduled signal event.
|
|
2274
2309
|
*/
|
|
@@ -2309,7 +2344,7 @@ interface ActivateScheduledCommit extends SignalCommitBase {
|
|
|
2309
2344
|
* Consumers must retrieve signal data from StrategyCoreService using
|
|
2310
2345
|
* getPendingSignal() or getScheduledSignal() methods.
|
|
2311
2346
|
*/
|
|
2312
|
-
type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit | ActivateScheduledCommit;
|
|
2347
|
+
type StrategyCommitContract = CancelScheduledCommit | ClosePendingCommit | PartialProfitCommit | PartialLossCommit | TrailingStopCommit | TrailingTakeCommit | BreakevenCommit | AverageBuyCommit | ActivateScheduledCommit;
|
|
2313
2348
|
|
|
2314
2349
|
/**
|
|
2315
2350
|
* Signal generation interval for throttling.
|
|
@@ -2386,6 +2421,17 @@ interface ISignalRow extends ISignalDto {
|
|
|
2386
2421
|
* Original priceStopLoss is preserved in persistence but ignored during execution.
|
|
2387
2422
|
*/
|
|
2388
2423
|
_trailingPriceStopLoss?: number;
|
|
2424
|
+
/**
|
|
2425
|
+
* DCA (Dollar Cost Averaging) entry history.
|
|
2426
|
+
* First element is always the original priceOpen at signal creation.
|
|
2427
|
+
* Each subsequent element is a new averaging entry added by averageBuy().
|
|
2428
|
+
* Effective entry price = simple arithmetic mean of all price values.
|
|
2429
|
+
* Original priceOpen is preserved unchanged for identity/audit purposes.
|
|
2430
|
+
*/
|
|
2431
|
+
_entry?: Array<{
|
|
2432
|
+
/** Price at which this entry was executed */
|
|
2433
|
+
price: number;
|
|
2434
|
+
}>;
|
|
2389
2435
|
/**
|
|
2390
2436
|
* Trailing take-profit price that overrides priceTakeProfit when set.
|
|
2391
2437
|
* Created and managed by trailingTake() method for dynamic TP adjustment.
|
|
@@ -2437,6 +2483,16 @@ interface IPublicSignalRow extends ISignalRow {
|
|
|
2437
2483
|
* Range: 0-100. Value of 0 means no partial closes, 100 means position fully closed through partials.
|
|
2438
2484
|
*/
|
|
2439
2485
|
partialExecuted: number;
|
|
2486
|
+
/**
|
|
2487
|
+
* Total number of entries in the DCA _entry history (_entry.length).
|
|
2488
|
+
* 1 = no averaging done (only initial entry). 2+ = averaged positions.
|
|
2489
|
+
*/
|
|
2490
|
+
totalEntries: number;
|
|
2491
|
+
/**
|
|
2492
|
+
* Original entry price set at signal creation (unchanged by averaging).
|
|
2493
|
+
* Mirrors signal.priceOpen which is preserved for identity/audit purposes.
|
|
2494
|
+
*/
|
|
2495
|
+
originalPriceOpen: number;
|
|
2440
2496
|
}
|
|
2441
2497
|
/**
|
|
2442
2498
|
* Base storage signal row fields shared by all status variants.
|
|
@@ -2554,6 +2610,17 @@ interface IBreakevenCommitRow extends ICommitRowBase {
|
|
|
2554
2610
|
/** Price at which breakeven was set */
|
|
2555
2611
|
currentPrice: number;
|
|
2556
2612
|
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Queued average-buy (DCA) commit.
|
|
2615
|
+
*/
|
|
2616
|
+
interface IAverageBuyCommitRow extends ICommitRowBase {
|
|
2617
|
+
/** Discriminator */
|
|
2618
|
+
action: "average-buy";
|
|
2619
|
+
/** Price at which the new averaging entry was executed */
|
|
2620
|
+
currentPrice: number;
|
|
2621
|
+
/** Total number of entries in _entry after this addition */
|
|
2622
|
+
totalEntries: number;
|
|
2623
|
+
}
|
|
2557
2624
|
/**
|
|
2558
2625
|
* Queued trailing stop commit.
|
|
2559
2626
|
*/
|
|
@@ -2591,7 +2658,7 @@ interface IActivateScheduledCommitRow extends ICommitRowBase {
|
|
|
2591
2658
|
* Discriminated union of all queued commit events.
|
|
2592
2659
|
* These are stored in _commitQueue and processed in tick()/backtest().
|
|
2593
2660
|
*/
|
|
2594
|
-
type ICommitRow = IPartialProfitCommitRow | IPartialLossCommitRow | IBreakevenCommitRow | ITrailingStopCommitRow | ITrailingTakeCommitRow | IActivateScheduledCommitRow;
|
|
2661
|
+
type ICommitRow = IPartialProfitCommitRow | IPartialLossCommitRow | IBreakevenCommitRow | IAverageBuyCommitRow | ITrailingStopCommitRow | ITrailingTakeCommitRow | IActivateScheduledCommitRow;
|
|
2595
2662
|
/**
|
|
2596
2663
|
* Optional lifecycle callbacks for signal events.
|
|
2597
2664
|
* Called when signals are opened, active, idle, closed, scheduled, or cancelled.
|
|
@@ -3288,6 +3355,27 @@ interface IStrategy {
|
|
|
3288
3355
|
* ```
|
|
3289
3356
|
*/
|
|
3290
3357
|
breakeven: (symbol: string, currentPrice: number, backtest: boolean) => Promise<boolean>;
|
|
3358
|
+
/**
|
|
3359
|
+
* Adds a new averaging entry to an open position (DCA — Dollar Cost Averaging).
|
|
3360
|
+
*
|
|
3361
|
+
* Appends currentPrice to the _entry array. The effective entry price used in all
|
|
3362
|
+
* distance and PNL calculations becomes the simple arithmetic mean of all _entry prices.
|
|
3363
|
+
* Original priceOpen is preserved unchanged for identity/audit purposes.
|
|
3364
|
+
*
|
|
3365
|
+
* Rejection rules (returns false without throwing):
|
|
3366
|
+
* - LONG: currentPrice >= last entry price (must average down, not up or equal)
|
|
3367
|
+
* - SHORT: currentPrice <= last entry price (must average down, not up or equal)
|
|
3368
|
+
*
|
|
3369
|
+
* Validations (throws):
|
|
3370
|
+
* - No pending signal exists
|
|
3371
|
+
* - currentPrice is not a positive finite number
|
|
3372
|
+
*
|
|
3373
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
3374
|
+
* @param currentPrice - New entry price to add to the averaging history
|
|
3375
|
+
* @param backtest - Whether running in backtest mode
|
|
3376
|
+
* @returns Promise<boolean> - true if entry added, false if rejected by direction check
|
|
3377
|
+
*/
|
|
3378
|
+
averageBuy: (symbol: string, currentPrice: number, backtest: boolean) => Promise<boolean>;
|
|
3291
3379
|
/**
|
|
3292
3380
|
* Disposes the strategy instance and cleans up resources.
|
|
3293
3381
|
*
|
|
@@ -4005,6 +4093,31 @@ declare function commitBreakeven(symbol: string): Promise<boolean>;
|
|
|
4005
4093
|
* ```
|
|
4006
4094
|
*/
|
|
4007
4095
|
declare function commitActivateScheduled(symbol: string, activateId?: string): Promise<void>;
|
|
4096
|
+
/**
|
|
4097
|
+
* Adds a new DCA entry to the active pending signal.
|
|
4098
|
+
*
|
|
4099
|
+
* Adds a new averaging entry at the current market price to the position's
|
|
4100
|
+
* entry history. Updates effectivePriceOpen (mean of all entries) and emits
|
|
4101
|
+
* an average-buy commit event.
|
|
4102
|
+
*
|
|
4103
|
+
* Automatically detects backtest/live mode from execution context.
|
|
4104
|
+
* Automatically fetches current price via getAveragePrice.
|
|
4105
|
+
*
|
|
4106
|
+
* @param symbol - Trading pair symbol
|
|
4107
|
+
* @returns Promise<boolean> - true if entry added, false if rejected
|
|
4108
|
+
*
|
|
4109
|
+
* @example
|
|
4110
|
+
* ```typescript
|
|
4111
|
+
* import { commitAverageBuy } from "backtest-kit";
|
|
4112
|
+
*
|
|
4113
|
+
* // Add DCA entry at current market price
|
|
4114
|
+
* const success = await commitAverageBuy("BTCUSDT");
|
|
4115
|
+
* if (success) {
|
|
4116
|
+
* console.log("DCA entry added");
|
|
4117
|
+
* }
|
|
4118
|
+
* ```
|
|
4119
|
+
*/
|
|
4120
|
+
declare function commitAverageBuy(symbol: string): Promise<boolean>;
|
|
4008
4121
|
|
|
4009
4122
|
/**
|
|
4010
4123
|
* Stops the strategy from generating new signals.
|
|
@@ -4056,6 +4169,10 @@ interface BreakevenEvent {
|
|
|
4056
4169
|
originalPriceTakeProfit?: number;
|
|
4057
4170
|
/** Original stop loss price set at signal creation */
|
|
4058
4171
|
originalPriceStopLoss?: number;
|
|
4172
|
+
/** Total number of DCA entries (present when averageBuy was applied) */
|
|
4173
|
+
totalEntries?: number;
|
|
4174
|
+
/** Original entry price before DCA averaging (present when averageBuy was applied) */
|
|
4175
|
+
originalPriceOpen?: number;
|
|
4059
4176
|
/** Total executed percentage from partial closes */
|
|
4060
4177
|
partialExecuted?: number;
|
|
4061
4178
|
/** Human-readable description of signal reason */
|
|
@@ -6896,6 +7013,10 @@ interface SignalOpenedNotification {
|
|
|
6896
7013
|
originalPriceTakeProfit: number;
|
|
6897
7014
|
/** Original stop loss price before any trailing adjustments */
|
|
6898
7015
|
originalPriceStopLoss: number;
|
|
7016
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7017
|
+
originalPriceOpen: number;
|
|
7018
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7019
|
+
totalEntries: number;
|
|
6899
7020
|
/** Optional human-readable description of signal reason */
|
|
6900
7021
|
note?: string;
|
|
6901
7022
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
@@ -6940,6 +7061,10 @@ interface SignalClosedNotification {
|
|
|
6940
7061
|
originalPriceTakeProfit: number;
|
|
6941
7062
|
/** Original stop loss price before any trailing adjustments */
|
|
6942
7063
|
originalPriceStopLoss: number;
|
|
7064
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7065
|
+
originalPriceOpen: number;
|
|
7066
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7067
|
+
totalEntries: number;
|
|
6943
7068
|
/** Profit/loss as percentage (e.g., 1.5 for +1.5%, -2.3 for -2.3%) */
|
|
6944
7069
|
pnlPercentage: number;
|
|
6945
7070
|
/** Why signal closed (time_expired | take_profit | stop_loss | closed) */
|
|
@@ -6992,6 +7117,10 @@ interface PartialProfitAvailableNotification {
|
|
|
6992
7117
|
originalPriceTakeProfit: number;
|
|
6993
7118
|
/** Original stop loss price before any trailing adjustments */
|
|
6994
7119
|
originalPriceStopLoss: number;
|
|
7120
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7121
|
+
originalPriceOpen: number;
|
|
7122
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7123
|
+
totalEntries: number;
|
|
6995
7124
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6996
7125
|
scheduledAt: number;
|
|
6997
7126
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7036,6 +7165,10 @@ interface PartialLossAvailableNotification {
|
|
|
7036
7165
|
originalPriceTakeProfit: number;
|
|
7037
7166
|
/** Original stop loss price before any trailing adjustments */
|
|
7038
7167
|
originalPriceStopLoss: number;
|
|
7168
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7169
|
+
originalPriceOpen: number;
|
|
7170
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7171
|
+
totalEntries: number;
|
|
7039
7172
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7040
7173
|
scheduledAt: number;
|
|
7041
7174
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7078,6 +7211,10 @@ interface BreakevenAvailableNotification {
|
|
|
7078
7211
|
originalPriceTakeProfit: number;
|
|
7079
7212
|
/** Original stop loss price before any trailing adjustments */
|
|
7080
7213
|
originalPriceStopLoss: number;
|
|
7214
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7215
|
+
originalPriceOpen: number;
|
|
7216
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7217
|
+
totalEntries: number;
|
|
7081
7218
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7082
7219
|
scheduledAt: number;
|
|
7083
7220
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7122,6 +7259,10 @@ interface PartialProfitCommitNotification {
|
|
|
7122
7259
|
originalPriceTakeProfit: number;
|
|
7123
7260
|
/** Original stop loss price before any trailing adjustments */
|
|
7124
7261
|
originalPriceStopLoss: number;
|
|
7262
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7263
|
+
originalPriceOpen: number;
|
|
7264
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7265
|
+
totalEntries: number;
|
|
7125
7266
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7126
7267
|
scheduledAt: number;
|
|
7127
7268
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7166,6 +7307,10 @@ interface PartialLossCommitNotification {
|
|
|
7166
7307
|
originalPriceTakeProfit: number;
|
|
7167
7308
|
/** Original stop loss price before any trailing adjustments */
|
|
7168
7309
|
originalPriceStopLoss: number;
|
|
7310
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7311
|
+
originalPriceOpen: number;
|
|
7312
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7313
|
+
totalEntries: number;
|
|
7169
7314
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7170
7315
|
scheduledAt: number;
|
|
7171
7316
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7208,6 +7353,58 @@ interface BreakevenCommitNotification {
|
|
|
7208
7353
|
originalPriceTakeProfit: number;
|
|
7209
7354
|
/** Original stop loss price before any trailing adjustments */
|
|
7210
7355
|
originalPriceStopLoss: number;
|
|
7356
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7357
|
+
originalPriceOpen: number;
|
|
7358
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7359
|
+
totalEntries: number;
|
|
7360
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7361
|
+
scheduledAt: number;
|
|
7362
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
7363
|
+
pendingAt: number;
|
|
7364
|
+
/** Unix timestamp in milliseconds when the notification was created */
|
|
7365
|
+
createdAt: number;
|
|
7366
|
+
}
|
|
7367
|
+
/**
|
|
7368
|
+
* Average-buy (DCA) commit notification.
|
|
7369
|
+
* Emitted when a new averaging entry is added to an open position.
|
|
7370
|
+
*/
|
|
7371
|
+
interface AverageBuyCommitNotification {
|
|
7372
|
+
/** Discriminator for type-safe union */
|
|
7373
|
+
type: "average_buy.commit";
|
|
7374
|
+
/** Unique notification identifier */
|
|
7375
|
+
id: string;
|
|
7376
|
+
/** Unix timestamp in milliseconds when the averaging entry was executed */
|
|
7377
|
+
timestamp: number;
|
|
7378
|
+
/** Whether this notification is from backtest mode (true) or live mode (false) */
|
|
7379
|
+
backtest: boolean;
|
|
7380
|
+
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
7381
|
+
symbol: string;
|
|
7382
|
+
/** Strategy name that generated this signal */
|
|
7383
|
+
strategyName: StrategyName;
|
|
7384
|
+
/** Exchange name where signal was executed */
|
|
7385
|
+
exchangeName: ExchangeName;
|
|
7386
|
+
/** Unique signal identifier (UUID v4) */
|
|
7387
|
+
signalId: string;
|
|
7388
|
+
/** Price at which the new averaging entry was executed */
|
|
7389
|
+
currentPrice: number;
|
|
7390
|
+
/** Averaged (effective) entry price after this addition */
|
|
7391
|
+
effectivePriceOpen: number;
|
|
7392
|
+
/** Total number of DCA entries after this addition */
|
|
7393
|
+
totalEntries: number;
|
|
7394
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
7395
|
+
position: "long" | "short";
|
|
7396
|
+
/** Original entry price (unchanged by averaging) */
|
|
7397
|
+
priceOpen: number;
|
|
7398
|
+
/** Effective take profit price (with trailing if set) */
|
|
7399
|
+
priceTakeProfit: number;
|
|
7400
|
+
/** Effective stop loss price (with trailing if set) */
|
|
7401
|
+
priceStopLoss: number;
|
|
7402
|
+
/** Original take profit price before any trailing adjustments */
|
|
7403
|
+
originalPriceTakeProfit: number;
|
|
7404
|
+
/** Original stop loss price before any trailing adjustments */
|
|
7405
|
+
originalPriceStopLoss: number;
|
|
7406
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7407
|
+
originalPriceOpen: number;
|
|
7211
7408
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7212
7409
|
scheduledAt: number;
|
|
7213
7410
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7250,6 +7447,10 @@ interface ActivateScheduledCommitNotification {
|
|
|
7250
7447
|
originalPriceTakeProfit: number;
|
|
7251
7448
|
/** Original stop loss price before any trailing adjustments */
|
|
7252
7449
|
originalPriceStopLoss: number;
|
|
7450
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7451
|
+
originalPriceOpen: number;
|
|
7452
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7453
|
+
totalEntries: number;
|
|
7253
7454
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7254
7455
|
scheduledAt: number;
|
|
7255
7456
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7296,6 +7497,10 @@ interface TrailingStopCommitNotification {
|
|
|
7296
7497
|
originalPriceTakeProfit: number;
|
|
7297
7498
|
/** Original stop loss price before any trailing adjustments */
|
|
7298
7499
|
originalPriceStopLoss: number;
|
|
7500
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7501
|
+
originalPriceOpen: number;
|
|
7502
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7503
|
+
totalEntries: number;
|
|
7299
7504
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7300
7505
|
scheduledAt: number;
|
|
7301
7506
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7340,6 +7545,10 @@ interface TrailingTakeCommitNotification {
|
|
|
7340
7545
|
originalPriceTakeProfit: number;
|
|
7341
7546
|
/** Original stop loss price before any trailing adjustments */
|
|
7342
7547
|
originalPriceStopLoss: number;
|
|
7548
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7549
|
+
originalPriceOpen: number;
|
|
7550
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7551
|
+
totalEntries: number;
|
|
7343
7552
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7344
7553
|
scheduledAt: number;
|
|
7345
7554
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
@@ -7424,6 +7633,10 @@ interface SignalScheduledNotification {
|
|
|
7424
7633
|
originalPriceTakeProfit: number;
|
|
7425
7634
|
/** Original stop loss price before any trailing adjustments */
|
|
7426
7635
|
originalPriceStopLoss: number;
|
|
7636
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7637
|
+
originalPriceOpen: number;
|
|
7638
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7639
|
+
totalEntries: number;
|
|
7427
7640
|
/** Unix timestamp in milliseconds when signal was scheduled */
|
|
7428
7641
|
scheduledAt: number;
|
|
7429
7642
|
/** Current market price when signal was scheduled */
|
|
@@ -7464,6 +7677,10 @@ interface SignalCancelledNotification {
|
|
|
7464
7677
|
originalPriceTakeProfit: number;
|
|
7465
7678
|
/** Original stop loss price before any trailing adjustments */
|
|
7466
7679
|
originalPriceStopLoss: number;
|
|
7680
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7681
|
+
originalPriceOpen: number;
|
|
7682
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7683
|
+
totalEntries: number;
|
|
7467
7684
|
/** Why signal was cancelled (timeout | price_reject | user) */
|
|
7468
7685
|
cancelReason: string;
|
|
7469
7686
|
/** Optional cancellation identifier (provided when user calls cancel()) */
|
|
@@ -7551,7 +7768,7 @@ interface ValidationErrorNotification {
|
|
|
7551
7768
|
* }
|
|
7552
7769
|
* ```
|
|
7553
7770
|
*/
|
|
7554
|
-
type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification;
|
|
7771
|
+
type NotificationModel = SignalOpenedNotification | SignalClosedNotification | PartialProfitAvailableNotification | PartialLossAvailableNotification | BreakevenAvailableNotification | PartialProfitCommitNotification | PartialLossCommitNotification | BreakevenCommitNotification | AverageBuyCommitNotification | ActivateScheduledCommitNotification | TrailingStopCommitNotification | TrailingTakeCommitNotification | RiskRejectionNotification | SignalScheduledNotification | SignalCancelledNotification | InfoErrorNotification | CriticalErrorNotification | ValidationErrorNotification;
|
|
7555
7772
|
|
|
7556
7773
|
/**
|
|
7557
7774
|
* Unified tick event data for report generation.
|
|
@@ -7582,6 +7799,10 @@ interface TickEvent {
|
|
|
7582
7799
|
originalPriceTakeProfit?: number;
|
|
7583
7800
|
/** Original stop loss price before modifications (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
7584
7801
|
originalPriceStopLoss?: number;
|
|
7802
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
7803
|
+
originalPriceOpen?: number;
|
|
7804
|
+
/** Total number of DCA entries (_entry.length). 1 = no averaging. */
|
|
7805
|
+
totalEntries?: number;
|
|
7585
7806
|
/** Total executed percentage from partial closes (only for scheduled/waiting/opened/active/closed/cancelled) */
|
|
7586
7807
|
partialExecuted?: number;
|
|
7587
7808
|
/** Percentage progress towards take profit (only for active/waiting) */
|
|
@@ -7699,6 +7920,10 @@ interface ScheduledEvent {
|
|
|
7699
7920
|
originalPriceTakeProfit?: number;
|
|
7700
7921
|
/** Original stop loss price before modifications */
|
|
7701
7922
|
originalPriceStopLoss?: number;
|
|
7923
|
+
/** Total number of DCA entries (present when averageBuy was applied) */
|
|
7924
|
+
totalEntries?: number;
|
|
7925
|
+
/** Original entry price before DCA averaging (present when averageBuy was applied) */
|
|
7926
|
+
originalPriceOpen?: number;
|
|
7702
7927
|
/** Total executed percentage from partial closes */
|
|
7703
7928
|
partialExecuted?: number;
|
|
7704
7929
|
/** Close timestamp (only for cancelled) */
|
|
@@ -7881,6 +8106,10 @@ interface PartialEvent {
|
|
|
7881
8106
|
originalPriceTakeProfit?: number;
|
|
7882
8107
|
/** Original stop loss price set at signal creation */
|
|
7883
8108
|
originalPriceStopLoss?: number;
|
|
8109
|
+
/** Total number of DCA entries (present when averageBuy was applied) */
|
|
8110
|
+
totalEntries?: number;
|
|
8111
|
+
/** Original entry price before DCA averaging (present when averageBuy was applied) */
|
|
8112
|
+
originalPriceOpen?: number;
|
|
7884
8113
|
/** Total executed percentage from partial closes */
|
|
7885
8114
|
partialExecuted?: number;
|
|
7886
8115
|
/** Human-readable description of signal reason */
|
|
@@ -7973,7 +8202,7 @@ interface RiskStatisticsModel {
|
|
|
7973
8202
|
* Action types for strategy events.
|
|
7974
8203
|
* Represents all possible strategy management actions.
|
|
7975
8204
|
*/
|
|
7976
|
-
type StrategyActionType = "cancel-scheduled" | "close-pending" | "partial-profit" | "partial-loss" | "trailing-stop" | "trailing-take" | "breakeven" | "activate-scheduled";
|
|
8205
|
+
type StrategyActionType = "cancel-scheduled" | "close-pending" | "partial-profit" | "partial-loss" | "trailing-stop" | "trailing-take" | "breakeven" | "activate-scheduled" | "average-buy";
|
|
7977
8206
|
/**
|
|
7978
8207
|
* Unified strategy event data for markdown report generation.
|
|
7979
8208
|
* Contains all information about strategy management actions.
|
|
@@ -8021,10 +8250,16 @@ interface StrategyEvent {
|
|
|
8021
8250
|
originalPriceTakeProfit?: number;
|
|
8022
8251
|
/** Original stop loss price before any trailing adjustments */
|
|
8023
8252
|
originalPriceStopLoss?: number;
|
|
8253
|
+
/** Original entry price at signal creation (unchanged by DCA averaging) */
|
|
8254
|
+
originalPriceOpen?: number;
|
|
8024
8255
|
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
8025
8256
|
scheduledAt?: number;
|
|
8026
8257
|
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
8027
8258
|
pendingAt?: number;
|
|
8259
|
+
/** Averaged entry price after DCA addition (average-buy action only) */
|
|
8260
|
+
effectivePriceOpen?: number;
|
|
8261
|
+
/** Total number of DCA entries after this addition (average-buy action only) */
|
|
8262
|
+
totalEntries?: number;
|
|
8028
8263
|
}
|
|
8029
8264
|
/**
|
|
8030
8265
|
* Statistical data calculated from strategy events.
|
|
@@ -8060,6 +8295,8 @@ interface StrategyStatisticsModel {
|
|
|
8060
8295
|
breakevenCount: number;
|
|
8061
8296
|
/** Count of activate-scheduled events */
|
|
8062
8297
|
activateScheduledCount: number;
|
|
8298
|
+
/** Count of average-buy (DCA) events */
|
|
8299
|
+
averageBuyCount: number;
|
|
8063
8300
|
}
|
|
8064
8301
|
|
|
8065
8302
|
declare const BASE_WAIT_FOR_INIT_SYMBOL: unique symbol;
|
|
@@ -10124,6 +10361,35 @@ declare class BacktestUtils {
|
|
|
10124
10361
|
exchangeName: ExchangeName;
|
|
10125
10362
|
frameName: FrameName;
|
|
10126
10363
|
}, activateId?: string) => Promise<void>;
|
|
10364
|
+
/**
|
|
10365
|
+
* Adds a new DCA entry to the active pending signal.
|
|
10366
|
+
*
|
|
10367
|
+
* Adds a new averaging entry at currentPrice to the position's entry history.
|
|
10368
|
+
* Updates effectivePriceOpen (mean of all entries) and emits average-buy commit event.
|
|
10369
|
+
*
|
|
10370
|
+
* @param symbol - Trading pair symbol
|
|
10371
|
+
* @param currentPrice - New entry price to add to the averaging history
|
|
10372
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
10373
|
+
* @returns Promise<boolean> - true if entry added, false if rejected
|
|
10374
|
+
*
|
|
10375
|
+
* @example
|
|
10376
|
+
* ```typescript
|
|
10377
|
+
* // Add DCA entry at current price
|
|
10378
|
+
* const success = await Backtest.commitAverageBuy("BTCUSDT", 42000, {
|
|
10379
|
+
* strategyName: "my-strategy",
|
|
10380
|
+
* exchangeName: "binance",
|
|
10381
|
+
* frameName: "1h"
|
|
10382
|
+
* });
|
|
10383
|
+
* if (success) {
|
|
10384
|
+
* console.log('DCA entry added');
|
|
10385
|
+
* }
|
|
10386
|
+
* ```
|
|
10387
|
+
*/
|
|
10388
|
+
commitAverageBuy: (symbol: string, currentPrice: number, context: {
|
|
10389
|
+
strategyName: StrategyName;
|
|
10390
|
+
exchangeName: ExchangeName;
|
|
10391
|
+
frameName: FrameName;
|
|
10392
|
+
}) => Promise<boolean>;
|
|
10127
10393
|
/**
|
|
10128
10394
|
* Gets statistical data from all closed signals for a symbol-strategy pair.
|
|
10129
10395
|
*
|
|
@@ -10876,6 +11142,33 @@ declare class LiveUtils {
|
|
|
10876
11142
|
strategyName: StrategyName;
|
|
10877
11143
|
exchangeName: ExchangeName;
|
|
10878
11144
|
}, activateId?: string) => Promise<void>;
|
|
11145
|
+
/**
|
|
11146
|
+
* Adds a new DCA entry to the active pending signal.
|
|
11147
|
+
*
|
|
11148
|
+
* Adds a new averaging entry at currentPrice to the position's entry history.
|
|
11149
|
+
* Updates effectivePriceOpen (mean of all entries) and emits average-buy commit event.
|
|
11150
|
+
*
|
|
11151
|
+
* @param symbol - Trading pair symbol
|
|
11152
|
+
* @param currentPrice - New entry price to add to the averaging history
|
|
11153
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
11154
|
+
* @returns Promise<boolean> - true if entry added, false if rejected
|
|
11155
|
+
*
|
|
11156
|
+
* @example
|
|
11157
|
+
* ```typescript
|
|
11158
|
+
* // Add DCA entry at current price
|
|
11159
|
+
* const success = await Live.commitAverageBuy("BTCUSDT", 42000, {
|
|
11160
|
+
* strategyName: "my-strategy",
|
|
11161
|
+
* exchangeName: "binance"
|
|
11162
|
+
* });
|
|
11163
|
+
* if (success) {
|
|
11164
|
+
* console.log('DCA entry added');
|
|
11165
|
+
* }
|
|
11166
|
+
* ```
|
|
11167
|
+
*/
|
|
11168
|
+
commitAverageBuy: (symbol: string, currentPrice: number, context: {
|
|
11169
|
+
strategyName: StrategyName;
|
|
11170
|
+
exchangeName: ExchangeName;
|
|
11171
|
+
}) => Promise<boolean>;
|
|
10879
11172
|
/**
|
|
10880
11173
|
* Gets statistical data from all live trading events for a symbol-strategy pair.
|
|
10881
11174
|
*
|
|
@@ -14942,6 +15235,23 @@ declare class StrategyCoreService implements TStrategy$1 {
|
|
|
14942
15235
|
exchangeName: ExchangeName;
|
|
14943
15236
|
frameName: FrameName;
|
|
14944
15237
|
}, activateId?: string) => Promise<void>;
|
|
15238
|
+
/**
|
|
15239
|
+
* Adds a new DCA entry to the active pending signal.
|
|
15240
|
+
*
|
|
15241
|
+
* Validates strategy existence and delegates to connection service
|
|
15242
|
+
* to add a new averaging entry to the position.
|
|
15243
|
+
*
|
|
15244
|
+
* @param backtest - Whether running in backtest mode
|
|
15245
|
+
* @param symbol - Trading pair symbol
|
|
15246
|
+
* @param currentPrice - New entry price to add to the averaging history
|
|
15247
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
15248
|
+
* @returns Promise<boolean> - true if entry added, false if rejected
|
|
15249
|
+
*/
|
|
15250
|
+
averageBuy: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
15251
|
+
strategyName: StrategyName;
|
|
15252
|
+
exchangeName: ExchangeName;
|
|
15253
|
+
frameName: FrameName;
|
|
15254
|
+
}) => Promise<boolean>;
|
|
14945
15255
|
}
|
|
14946
15256
|
|
|
14947
15257
|
/**
|
|
@@ -15059,7 +15369,7 @@ declare class StrategyMarkdownService {
|
|
|
15059
15369
|
strategyName: StrategyName;
|
|
15060
15370
|
exchangeName: ExchangeName;
|
|
15061
15371
|
frameName: FrameName;
|
|
15062
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
15372
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
15063
15373
|
/**
|
|
15064
15374
|
* Records a partial-loss event when a portion of the position is closed at loss.
|
|
15065
15375
|
*
|
|
@@ -15082,7 +15392,7 @@ declare class StrategyMarkdownService {
|
|
|
15082
15392
|
strategyName: StrategyName;
|
|
15083
15393
|
exchangeName: ExchangeName;
|
|
15084
15394
|
frameName: FrameName;
|
|
15085
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
15395
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
15086
15396
|
/**
|
|
15087
15397
|
* Records a trailing-stop event when the stop-loss is adjusted.
|
|
15088
15398
|
*
|
|
@@ -15105,7 +15415,7 @@ declare class StrategyMarkdownService {
|
|
|
15105
15415
|
strategyName: StrategyName;
|
|
15106
15416
|
exchangeName: ExchangeName;
|
|
15107
15417
|
frameName: FrameName;
|
|
15108
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
15418
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
15109
15419
|
/**
|
|
15110
15420
|
* Records a trailing-take event when the take-profit is adjusted.
|
|
15111
15421
|
*
|
|
@@ -15128,7 +15438,7 @@ declare class StrategyMarkdownService {
|
|
|
15128
15438
|
strategyName: StrategyName;
|
|
15129
15439
|
exchangeName: ExchangeName;
|
|
15130
15440
|
frameName: FrameName;
|
|
15131
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
15441
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
15132
15442
|
/**
|
|
15133
15443
|
* Records a breakeven event when the stop-loss is moved to entry price.
|
|
15134
15444
|
*
|
|
@@ -15150,7 +15460,7 @@ declare class StrategyMarkdownService {
|
|
|
15150
15460
|
strategyName: StrategyName;
|
|
15151
15461
|
exchangeName: ExchangeName;
|
|
15152
15462
|
frameName: FrameName;
|
|
15153
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
15463
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
15154
15464
|
/**
|
|
15155
15465
|
* Records an activate-scheduled event when a scheduled signal is activated early.
|
|
15156
15466
|
*
|
|
@@ -15173,7 +15483,31 @@ declare class StrategyMarkdownService {
|
|
|
15173
15483
|
strategyName: StrategyName;
|
|
15174
15484
|
exchangeName: ExchangeName;
|
|
15175
15485
|
frameName: FrameName;
|
|
15176
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, activateId?: string) => Promise<void>;
|
|
15486
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number, activateId?: string) => Promise<void>;
|
|
15487
|
+
/**
|
|
15488
|
+
* Records an average-buy (DCA) event when a new averaging entry is added to an open position.
|
|
15489
|
+
*
|
|
15490
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
15491
|
+
* @param currentPrice - Price at which the new averaging entry was executed
|
|
15492
|
+
* @param effectivePriceOpen - Averaged entry price after this addition
|
|
15493
|
+
* @param totalEntries - Total number of DCA entries after this addition
|
|
15494
|
+
* @param isBacktest - Whether this is a backtest or live trading event
|
|
15495
|
+
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
15496
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
15497
|
+
* @param position - Trade direction: "long" or "short"
|
|
15498
|
+
* @param priceOpen - Original entry price (unchanged by averaging)
|
|
15499
|
+
* @param priceTakeProfit - Effective take profit price
|
|
15500
|
+
* @param priceStopLoss - Effective stop loss price
|
|
15501
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
15502
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
15503
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
15504
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
15505
|
+
*/
|
|
15506
|
+
averageBuy: (symbol: string, currentPrice: number, effectivePriceOpen: number, totalEntries: number, isBacktest: boolean, context: {
|
|
15507
|
+
strategyName: StrategyName;
|
|
15508
|
+
exchangeName: ExchangeName;
|
|
15509
|
+
frameName: FrameName;
|
|
15510
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, originalPriceOpen: number) => Promise<void>;
|
|
15177
15511
|
/**
|
|
15178
15512
|
* Retrieves aggregated statistics from accumulated strategy events.
|
|
15179
15513
|
*
|
|
@@ -17722,6 +18056,22 @@ declare class StrategyConnectionService implements TStrategy {
|
|
|
17722
18056
|
exchangeName: ExchangeName;
|
|
17723
18057
|
frameName: FrameName;
|
|
17724
18058
|
}, activateId?: string) => Promise<void>;
|
|
18059
|
+
/**
|
|
18060
|
+
* Adds a new DCA entry to the active pending signal.
|
|
18061
|
+
*
|
|
18062
|
+
* Delegates to ClientStrategy.averageBuy() with current execution context.
|
|
18063
|
+
*
|
|
18064
|
+
* @param backtest - Whether running in backtest mode
|
|
18065
|
+
* @param symbol - Trading pair symbol
|
|
18066
|
+
* @param currentPrice - New entry price to add to the averaging history
|
|
18067
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
18068
|
+
* @returns Promise<boolean> - true if entry added, false if rejected
|
|
18069
|
+
*/
|
|
18070
|
+
averageBuy: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
18071
|
+
strategyName: StrategyName;
|
|
18072
|
+
exchangeName: ExchangeName;
|
|
18073
|
+
frameName: FrameName;
|
|
18074
|
+
}) => Promise<boolean>;
|
|
17725
18075
|
}
|
|
17726
18076
|
|
|
17727
18077
|
/**
|
|
@@ -20678,7 +21028,7 @@ declare class StrategyReportService {
|
|
|
20678
21028
|
strategyName: StrategyName;
|
|
20679
21029
|
exchangeName: ExchangeName;
|
|
20680
21030
|
frameName: FrameName;
|
|
20681
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
21031
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
20682
21032
|
/**
|
|
20683
21033
|
* Logs a partial-loss event when a portion of the position is closed at loss.
|
|
20684
21034
|
*
|
|
@@ -20701,7 +21051,7 @@ declare class StrategyReportService {
|
|
|
20701
21051
|
strategyName: StrategyName;
|
|
20702
21052
|
exchangeName: ExchangeName;
|
|
20703
21053
|
frameName: FrameName;
|
|
20704
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
21054
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
20705
21055
|
/**
|
|
20706
21056
|
* Logs a trailing-stop event when the stop-loss is adjusted.
|
|
20707
21057
|
*
|
|
@@ -20724,7 +21074,7 @@ declare class StrategyReportService {
|
|
|
20724
21074
|
strategyName: StrategyName;
|
|
20725
21075
|
exchangeName: ExchangeName;
|
|
20726
21076
|
frameName: FrameName;
|
|
20727
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
21077
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
20728
21078
|
/**
|
|
20729
21079
|
* Logs a trailing-take event when the take-profit is adjusted.
|
|
20730
21080
|
*
|
|
@@ -20747,7 +21097,7 @@ declare class StrategyReportService {
|
|
|
20747
21097
|
strategyName: StrategyName;
|
|
20748
21098
|
exchangeName: ExchangeName;
|
|
20749
21099
|
frameName: FrameName;
|
|
20750
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
21100
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
20751
21101
|
/**
|
|
20752
21102
|
* Logs a breakeven event when the stop-loss is moved to entry price.
|
|
20753
21103
|
*
|
|
@@ -20769,7 +21119,7 @@ declare class StrategyReportService {
|
|
|
20769
21119
|
strategyName: StrategyName;
|
|
20770
21120
|
exchangeName: ExchangeName;
|
|
20771
21121
|
frameName: FrameName;
|
|
20772
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
21122
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number) => Promise<void>;
|
|
20773
21123
|
/**
|
|
20774
21124
|
* Logs an activate-scheduled event when a scheduled signal is activated early.
|
|
20775
21125
|
*
|
|
@@ -20792,7 +21142,31 @@ declare class StrategyReportService {
|
|
|
20792
21142
|
strategyName: StrategyName;
|
|
20793
21143
|
exchangeName: ExchangeName;
|
|
20794
21144
|
frameName: FrameName;
|
|
20795
|
-
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, activateId?: string) => Promise<void>;
|
|
21145
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, totalEntries: number, originalPriceOpen: number, activateId?: string) => Promise<void>;
|
|
21146
|
+
/**
|
|
21147
|
+
* Logs an average-buy (DCA) event when a new averaging entry is added to an open position.
|
|
21148
|
+
*
|
|
21149
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
21150
|
+
* @param currentPrice - Price at which the new averaging entry was executed
|
|
21151
|
+
* @param effectivePriceOpen - Averaged entry price after this addition
|
|
21152
|
+
* @param totalEntries - Total number of DCA entries after this addition
|
|
21153
|
+
* @param isBacktest - Whether this is a backtest or live trading event
|
|
21154
|
+
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
21155
|
+
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
21156
|
+
* @param position - Trade direction: "long" or "short"
|
|
21157
|
+
* @param priceOpen - Original entry price (unchanged by averaging)
|
|
21158
|
+
* @param priceTakeProfit - Effective take profit price
|
|
21159
|
+
* @param priceStopLoss - Effective stop loss price
|
|
21160
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
21161
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
21162
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
21163
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
21164
|
+
*/
|
|
21165
|
+
averageBuy: (symbol: string, currentPrice: number, effectivePriceOpen: number, totalEntries: number, isBacktest: boolean, context: {
|
|
21166
|
+
strategyName: StrategyName;
|
|
21167
|
+
exchangeName: ExchangeName;
|
|
21168
|
+
frameName: FrameName;
|
|
21169
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number, originalPriceOpen: number) => Promise<void>;
|
|
20796
21170
|
/**
|
|
20797
21171
|
* Initializes the service for event logging.
|
|
20798
21172
|
*
|
|
@@ -20881,4 +21255,4 @@ declare const backtest: {
|
|
|
20881
21255
|
loggerService: LoggerService;
|
|
20882
21256
|
};
|
|
20883
21257
|
|
|
20884
|
-
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate, waitForCandle, warmCandles };
|
|
21258
|
+
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate, waitForCandle, warmCandles };
|