backtest-kit 6.5.0 → 6.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/index.cjs +364 -53
- package/build/index.mjs +364 -54
- package/package.json +2 -2
- package/types.d.ts +211 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backtest-kit",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.2",
|
|
4
4
|
"description": "A TypeScript library for trading system backtest",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Petr Tripolsky",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"url": "http://paypal.me/tripolskypetr"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"homepage": "https://backtest-kit.github.io/documents/
|
|
15
|
+
"homepage": "https://backtest-kit.github.io/documents/article_05_ai_strategy_workflow.html",
|
|
16
16
|
"keywords": [
|
|
17
17
|
"backtesting",
|
|
18
18
|
"backtest",
|
package/types.d.ts
CHANGED
|
@@ -8743,6 +8743,52 @@ declare function dumpJson(dto: {
|
|
|
8743
8743
|
description: string;
|
|
8744
8744
|
}): Promise<void>;
|
|
8745
8745
|
|
|
8746
|
+
/**
|
|
8747
|
+
* Full context required to run a function inside both method and execution scopes.
|
|
8748
|
+
*
|
|
8749
|
+
* Combines `IMethodContext` (schema routing: exchange, strategy, frame names) with
|
|
8750
|
+
* `IExecutionContext` (runtime state: symbol, timestamp, backtest flag).
|
|
8751
|
+
*
|
|
8752
|
+
* Passed as a single object to `runInContextInternal`, which splits and distributes
|
|
8753
|
+
* the fields between `MethodContextService` and `ExecutionContextService`.
|
|
8754
|
+
*/
|
|
8755
|
+
interface IRunContext extends IMethodContext, IExecutionContext {
|
|
8756
|
+
}
|
|
8757
|
+
/**
|
|
8758
|
+
* A zero-argument function that may be synchronous or asynchronous.
|
|
8759
|
+
*
|
|
8760
|
+
* @template T - Return type of the function.
|
|
8761
|
+
*/
|
|
8762
|
+
type Function$1<T extends unknown = any> = () => T | Promise<T>;
|
|
8763
|
+
/**
|
|
8764
|
+
* Runs a function inside a mock method and execution context.
|
|
8765
|
+
*
|
|
8766
|
+
* Useful in tests and scripts that need to call context-dependent services
|
|
8767
|
+
* (e.g. `getBacktestTimeframe`) without a real backtest runner.
|
|
8768
|
+
*
|
|
8769
|
+
* All context fields are optional; the defaults produce a minimal live-mode
|
|
8770
|
+
* environment pointing at placeholder schema names:
|
|
8771
|
+
* - `exchangeName` → `"mock-exchange"`
|
|
8772
|
+
* - `strategyName` → `"mock-strategy"`
|
|
8773
|
+
* - `frameName` → `"mock-frame"`
|
|
8774
|
+
* - `symbol` → `"BTCUSDT"`
|
|
8775
|
+
* - `backtest` → `false` (live mode)
|
|
8776
|
+
* - `when` → current minute boundary (`alignToInterval(new Date(), "1m")`)
|
|
8777
|
+
*
|
|
8778
|
+
* @param run - Zero-argument function to execute within the context.
|
|
8779
|
+
* @param context - Partial `IRunContext`; any omitted field falls back to its default.
|
|
8780
|
+
* @returns Promise resolving to the return value of `run`.
|
|
8781
|
+
*
|
|
8782
|
+
* @example
|
|
8783
|
+
* ```typescript
|
|
8784
|
+
* const price = await runInMockContext(
|
|
8785
|
+
* () => getEffectivePrice("BTCUSDT"),
|
|
8786
|
+
* { exchangeName: "binance", strategyName: "my-strategy", frameName: "1d" },
|
|
8787
|
+
* );
|
|
8788
|
+
* ```
|
|
8789
|
+
*/
|
|
8790
|
+
declare function runInMockContext<T extends unknown = any>(run: Function$1<T>, { exchangeName, frameName, strategyName, symbol, backtest: isBacktest, when, }: Partial<IRunContext>): Promise<T>;
|
|
8791
|
+
|
|
8746
8792
|
/**
|
|
8747
8793
|
* Portfolio heatmap statistics for a single symbol.
|
|
8748
8794
|
* Aggregated metrics across all strategies for one trading pair.
|
|
@@ -25085,36 +25131,139 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25085
25131
|
exchangeName: ExchangeName;
|
|
25086
25132
|
frameName: FrameName;
|
|
25087
25133
|
}) => Promise<number | null>;
|
|
25134
|
+
/**
|
|
25135
|
+
* Returns the effective (DCA-averaged) entry price for the current pending signal.
|
|
25136
|
+
*
|
|
25137
|
+
* This is the harmonic mean of all _entry prices, which is the correct
|
|
25138
|
+
* cost-basis price used in all PNL calculations.
|
|
25139
|
+
* With no DCA entries, equals the original priceOpen.
|
|
25140
|
+
*
|
|
25141
|
+
* Returns null if no pending signal exists.
|
|
25142
|
+
*
|
|
25143
|
+
* @param backtest - Whether running in backtest mode
|
|
25144
|
+
* @param symbol - Trading pair symbol
|
|
25145
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25146
|
+
* @returns Promise resolving to effective entry price or null
|
|
25147
|
+
*/
|
|
25088
25148
|
getPositionEffectivePrice: (backtest: boolean, symbol: string, context: {
|
|
25089
25149
|
strategyName: StrategyName;
|
|
25090
25150
|
exchangeName: ExchangeName;
|
|
25091
25151
|
frameName: FrameName;
|
|
25092
25152
|
}) => Promise<number | null>;
|
|
25153
|
+
/**
|
|
25154
|
+
* Returns the number of DCA entries made for the current pending signal.
|
|
25155
|
+
*
|
|
25156
|
+
* 1 = original entry only (no DCA).
|
|
25157
|
+
* Increases by 1 with each successful commitAverageBuy().
|
|
25158
|
+
*
|
|
25159
|
+
* Returns null if no pending signal exists.
|
|
25160
|
+
*
|
|
25161
|
+
* @param backtest - Whether running in backtest mode
|
|
25162
|
+
* @param symbol - Trading pair symbol
|
|
25163
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25164
|
+
* @returns Promise resolving to entry count or null
|
|
25165
|
+
*/
|
|
25093
25166
|
getPositionInvestedCount: (backtest: boolean, symbol: string, context: {
|
|
25094
25167
|
strategyName: StrategyName;
|
|
25095
25168
|
exchangeName: ExchangeName;
|
|
25096
25169
|
frameName: FrameName;
|
|
25097
25170
|
}) => Promise<number | null>;
|
|
25171
|
+
/**
|
|
25172
|
+
* Returns the total invested cost basis in dollars for the current pending signal.
|
|
25173
|
+
*
|
|
25174
|
+
* Equal to entryCount × $100 (COST_BASIS_PER_ENTRY).
|
|
25175
|
+
* 1 entry = $100, 2 entries = $200, etc.
|
|
25176
|
+
*
|
|
25177
|
+
* Returns null if no pending signal exists.
|
|
25178
|
+
*
|
|
25179
|
+
* @param backtest - Whether running in backtest mode
|
|
25180
|
+
* @param symbol - Trading pair symbol
|
|
25181
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25182
|
+
* @returns Promise resolving to total invested cost in dollars or null
|
|
25183
|
+
*/
|
|
25098
25184
|
getPositionInvestedCost: (backtest: boolean, symbol: string, context: {
|
|
25099
25185
|
strategyName: StrategyName;
|
|
25100
25186
|
exchangeName: ExchangeName;
|
|
25101
25187
|
frameName: FrameName;
|
|
25102
25188
|
}) => Promise<number | null>;
|
|
25189
|
+
/**
|
|
25190
|
+
* Returns the unrealized PNL percentage for the current pending signal at currentPrice.
|
|
25191
|
+
*
|
|
25192
|
+
* Accounts for partial closes, DCA entries, slippage and fees
|
|
25193
|
+
* (delegates to toProfitLossDto).
|
|
25194
|
+
*
|
|
25195
|
+
* Returns null if no pending signal exists.
|
|
25196
|
+
*
|
|
25197
|
+
* @param backtest - Whether running in backtest mode
|
|
25198
|
+
* @param symbol - Trading pair symbol
|
|
25199
|
+
* @param currentPrice - Current market price
|
|
25200
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25201
|
+
* @returns Promise resolving to pnlPercentage or null
|
|
25202
|
+
*/
|
|
25103
25203
|
getPositionPnlPercent: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25104
25204
|
strategyName: StrategyName;
|
|
25105
25205
|
exchangeName: ExchangeName;
|
|
25106
25206
|
frameName: FrameName;
|
|
25107
25207
|
}) => Promise<number | null>;
|
|
25208
|
+
/**
|
|
25209
|
+
* Returns the unrealized PNL in dollars for the current pending signal at currentPrice.
|
|
25210
|
+
*
|
|
25211
|
+
* Calculated as: pnlPercentage / 100 × totalInvestedCost
|
|
25212
|
+
* Accounts for partial closes, DCA entries, slippage and fees.
|
|
25213
|
+
*
|
|
25214
|
+
* Returns null if no pending signal exists.
|
|
25215
|
+
*
|
|
25216
|
+
* @param backtest - Whether running in backtest mode
|
|
25217
|
+
* @param symbol - Trading pair symbol
|
|
25218
|
+
* @param currentPrice - Current market price
|
|
25219
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25220
|
+
* @returns Promise resolving to pnl in dollars or null
|
|
25221
|
+
*/
|
|
25108
25222
|
getPositionPnlCost: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25109
25223
|
strategyName: StrategyName;
|
|
25110
25224
|
exchangeName: ExchangeName;
|
|
25111
25225
|
frameName: FrameName;
|
|
25112
25226
|
}) => Promise<number | null>;
|
|
25227
|
+
/**
|
|
25228
|
+
* Returns the list of DCA entry prices for the current pending signal.
|
|
25229
|
+
*
|
|
25230
|
+
* The first element is always the original priceOpen (initial entry).
|
|
25231
|
+
* Each subsequent element is a price added by commitAverageBuy().
|
|
25232
|
+
*
|
|
25233
|
+
* Returns null if no pending signal exists.
|
|
25234
|
+
* Returns a single-element array [priceOpen] if no DCA entries were made.
|
|
25235
|
+
*
|
|
25236
|
+
* @param backtest - Whether running in backtest mode
|
|
25237
|
+
* @param symbol - Trading pair symbol
|
|
25238
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25239
|
+
* @returns Promise resolving to array of entry prices or null
|
|
25240
|
+
*
|
|
25241
|
+
* @example
|
|
25242
|
+
* ```typescript
|
|
25243
|
+
* // No DCA: [43000]
|
|
25244
|
+
* // One DCA: [43000, 42000]
|
|
25245
|
+
* // Two DCA: [43000, 42000, 41500]
|
|
25246
|
+
* ```
|
|
25247
|
+
*/
|
|
25113
25248
|
getPositionLevels: (backtest: boolean, symbol: string, context: {
|
|
25114
25249
|
strategyName: StrategyName;
|
|
25115
25250
|
exchangeName: ExchangeName;
|
|
25116
25251
|
frameName: FrameName;
|
|
25117
25252
|
}) => Promise<number[] | null>;
|
|
25253
|
+
/**
|
|
25254
|
+
* Returns the list of partial closes for the current pending signal.
|
|
25255
|
+
*
|
|
25256
|
+
* Each entry records a partial profit or loss close event with its type,
|
|
25257
|
+
* percent closed, price at close, cost basis snapshot, and entry count at close.
|
|
25258
|
+
*
|
|
25259
|
+
* Returns null if no pending signal exists.
|
|
25260
|
+
* Returns an empty array if no partial closes have been executed.
|
|
25261
|
+
*
|
|
25262
|
+
* @param backtest - Whether running in backtest mode
|
|
25263
|
+
* @param symbol - Trading pair symbol
|
|
25264
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25265
|
+
* @returns Promise resolving to array of partial close records or null
|
|
25266
|
+
*/
|
|
25118
25267
|
getPositionPartials: (backtest: boolean, symbol: string, context: {
|
|
25119
25268
|
strategyName: StrategyName;
|
|
25120
25269
|
exchangeName: ExchangeName;
|
|
@@ -25127,6 +25276,27 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25127
25276
|
entryCountAtClose: number;
|
|
25128
25277
|
timestamp: number;
|
|
25129
25278
|
}[]>;
|
|
25279
|
+
/**
|
|
25280
|
+
* Returns the list of DCA entry prices and costs for the current pending signal.
|
|
25281
|
+
*
|
|
25282
|
+
* Each entry records the price and cost of a single position entry.
|
|
25283
|
+
* The first element is always the original priceOpen (initial entry).
|
|
25284
|
+
* Each subsequent element is an entry added by averageBuy().
|
|
25285
|
+
*
|
|
25286
|
+
* Returns null if no pending signal exists.
|
|
25287
|
+
* Returns a single-element array [{ price: priceOpen, cost }] if no DCA entries were made.
|
|
25288
|
+
*
|
|
25289
|
+
* @param backtest - Whether running in backtest mode
|
|
25290
|
+
* @param symbol - Trading pair symbol
|
|
25291
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25292
|
+
* @returns Promise resolving to array of entry records or null
|
|
25293
|
+
*
|
|
25294
|
+
* @example
|
|
25295
|
+
* ```typescript
|
|
25296
|
+
* // No DCA: [{ price: 43000, cost: 100 }]
|
|
25297
|
+
* // One DCA: [{ price: 43000, cost: 100 }, { price: 42000, cost: 100 }]
|
|
25298
|
+
* ```
|
|
25299
|
+
*/
|
|
25130
25300
|
getPositionEntries: (backtest: boolean, symbol: string, context: {
|
|
25131
25301
|
strategyName: StrategyName;
|
|
25132
25302
|
exchangeName: ExchangeName;
|
|
@@ -25425,6 +25595,22 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25425
25595
|
exchangeName: ExchangeName;
|
|
25426
25596
|
frameName: FrameName;
|
|
25427
25597
|
}) => Promise<boolean>;
|
|
25598
|
+
/**
|
|
25599
|
+
* Checks whether `trailingStop` would succeed without executing it.
|
|
25600
|
+
* Validates context, then delegates to StrategyConnectionService.validateTrailingStop().
|
|
25601
|
+
*
|
|
25602
|
+
* @param backtest - Whether running in backtest mode
|
|
25603
|
+
* @param symbol - Trading pair symbol
|
|
25604
|
+
* @param percentShift - Percentage shift of ORIGINAL SL distance [-100, 100], excluding 0
|
|
25605
|
+
* @param currentPrice - Current market price to validate against
|
|
25606
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25607
|
+
* @returns Promise<boolean> - true if `trailingStop` would execute, false otherwise
|
|
25608
|
+
*/
|
|
25609
|
+
validateTrailingStop: (backtest: boolean, symbol: string, percentShift: number, currentPrice: number, context: {
|
|
25610
|
+
strategyName: StrategyName;
|
|
25611
|
+
exchangeName: ExchangeName;
|
|
25612
|
+
frameName: FrameName;
|
|
25613
|
+
}) => Promise<boolean>;
|
|
25428
25614
|
/**
|
|
25429
25615
|
* Adjusts the trailing stop-loss distance for an active pending signal.
|
|
25430
25616
|
*
|
|
@@ -25438,7 +25624,7 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25438
25624
|
* @param percentShift - Percentage adjustment to SL distance (-100 to 100)
|
|
25439
25625
|
* @param currentPrice - Current market price to check for intrusion
|
|
25440
25626
|
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25441
|
-
* @returns Promise
|
|
25627
|
+
* @returns Promise<boolean> - true if trailing SL was updated, false otherwise
|
|
25442
25628
|
*
|
|
25443
25629
|
* @example
|
|
25444
25630
|
* ```typescript
|
|
@@ -25453,23 +25639,23 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25453
25639
|
* );
|
|
25454
25640
|
* ```
|
|
25455
25641
|
*/
|
|
25456
|
-
|
|
25642
|
+
trailingStop: (backtest: boolean, symbol: string, percentShift: number, currentPrice: number, context: {
|
|
25457
25643
|
strategyName: StrategyName;
|
|
25458
25644
|
exchangeName: ExchangeName;
|
|
25459
25645
|
frameName: FrameName;
|
|
25460
25646
|
}) => Promise<boolean>;
|
|
25461
25647
|
/**
|
|
25462
|
-
* Checks whether `
|
|
25463
|
-
* Validates context, then delegates to StrategyConnectionService.
|
|
25648
|
+
* Checks whether `trailingTake` would succeed without executing it.
|
|
25649
|
+
* Validates context, then delegates to StrategyConnectionService.validateTrailingTake().
|
|
25464
25650
|
*
|
|
25465
25651
|
* @param backtest - Whether running in backtest mode
|
|
25466
25652
|
* @param symbol - Trading pair symbol
|
|
25467
|
-
* @param percentShift - Percentage
|
|
25653
|
+
* @param percentShift - Percentage adjustment to ORIGINAL TP distance [-100, 100], excluding 0
|
|
25468
25654
|
* @param currentPrice - Current market price to validate against
|
|
25469
25655
|
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25470
|
-
* @returns Promise<boolean> - true if `
|
|
25656
|
+
* @returns Promise<boolean> - true if `trailingTake` would execute, false otherwise
|
|
25471
25657
|
*/
|
|
25472
|
-
|
|
25658
|
+
validateTrailingTake: (backtest: boolean, symbol: string, percentShift: number, currentPrice: number, context: {
|
|
25473
25659
|
strategyName: StrategyName;
|
|
25474
25660
|
exchangeName: ExchangeName;
|
|
25475
25661
|
frameName: FrameName;
|
|
@@ -25483,7 +25669,7 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25483
25669
|
* @param percentShift - Percentage adjustment to TP distance (-100 to 100)
|
|
25484
25670
|
* @param currentPrice - Current market price to check for intrusion
|
|
25485
25671
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
25486
|
-
* @returns Promise
|
|
25672
|
+
* @returns Promise<boolean> - true if trailing TP was updated, false otherwise
|
|
25487
25673
|
*
|
|
25488
25674
|
* @example
|
|
25489
25675
|
* ```typescript
|
|
@@ -25498,23 +25684,22 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25498
25684
|
* );
|
|
25499
25685
|
* ```
|
|
25500
25686
|
*/
|
|
25501
|
-
|
|
25687
|
+
trailingTake: (backtest: boolean, symbol: string, percentShift: number, currentPrice: number, context: {
|
|
25502
25688
|
strategyName: StrategyName;
|
|
25503
25689
|
exchangeName: ExchangeName;
|
|
25504
25690
|
frameName: FrameName;
|
|
25505
25691
|
}) => Promise<boolean>;
|
|
25506
25692
|
/**
|
|
25507
|
-
* Checks whether `
|
|
25508
|
-
* Validates context, then delegates to StrategyConnectionService.
|
|
25693
|
+
* Checks whether `breakeven` would succeed without executing it.
|
|
25694
|
+
* Validates context, then delegates to StrategyConnectionService.validateBreakeven().
|
|
25509
25695
|
*
|
|
25510
25696
|
* @param backtest - Whether running in backtest mode
|
|
25511
25697
|
* @param symbol - Trading pair symbol
|
|
25512
|
-
* @param percentShift - Percentage adjustment to ORIGINAL TP distance [-100, 100], excluding 0
|
|
25513
25698
|
* @param currentPrice - Current market price to validate against
|
|
25514
25699
|
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25515
|
-
* @returns Promise<boolean> - true if `
|
|
25700
|
+
* @returns Promise<boolean> - true if `breakeven` would execute, false otherwise
|
|
25516
25701
|
*/
|
|
25517
|
-
|
|
25702
|
+
validateBreakeven: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25518
25703
|
strategyName: StrategyName;
|
|
25519
25704
|
exchangeName: ExchangeName;
|
|
25520
25705
|
frameName: FrameName;
|
|
@@ -25539,21 +25724,6 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25539
25724
|
* );
|
|
25540
25725
|
* ```
|
|
25541
25726
|
*/
|
|
25542
|
-
validateBreakeven: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25543
|
-
strategyName: StrategyName;
|
|
25544
|
-
exchangeName: ExchangeName;
|
|
25545
|
-
frameName: FrameName;
|
|
25546
|
-
}) => Promise<boolean>;
|
|
25547
|
-
/**
|
|
25548
|
-
* Checks whether `breakeven` would succeed without executing it.
|
|
25549
|
-
* Validates context, then delegates to StrategyConnectionService.validateBreakeven().
|
|
25550
|
-
*
|
|
25551
|
-
* @param backtest - Whether running in backtest mode
|
|
25552
|
-
* @param symbol - Trading pair symbol
|
|
25553
|
-
* @param currentPrice - Current market price to validate against
|
|
25554
|
-
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25555
|
-
* @returns Promise<boolean> - true if `breakeven` would execute, false otherwise
|
|
25556
|
-
*/
|
|
25557
25727
|
breakeven: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25558
25728
|
strategyName: StrategyName;
|
|
25559
25729
|
exchangeName: ExchangeName;
|
|
@@ -25588,16 +25758,14 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25588
25758
|
frameName: FrameName;
|
|
25589
25759
|
}, activateId?: string) => Promise<void>;
|
|
25590
25760
|
/**
|
|
25591
|
-
*
|
|
25592
|
-
*
|
|
25593
|
-
* Validates strategy existence and delegates to connection service
|
|
25594
|
-
* to add a new averaging entry to the position.
|
|
25761
|
+
* Checks whether `averageBuy` would succeed without executing it.
|
|
25762
|
+
* Validates context, then delegates to StrategyConnectionService.validateAverageBuy().
|
|
25595
25763
|
*
|
|
25596
25764
|
* @param backtest - Whether running in backtest mode
|
|
25597
25765
|
* @param symbol - Trading pair symbol
|
|
25598
|
-
* @param currentPrice - New entry price to
|
|
25766
|
+
* @param currentPrice - New entry price to validate
|
|
25599
25767
|
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25600
|
-
* @returns Promise<boolean> - true if
|
|
25768
|
+
* @returns Promise<boolean> - true if `averageBuy` would execute, false otherwise
|
|
25601
25769
|
*/
|
|
25602
25770
|
validateAverageBuy: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25603
25771
|
strategyName: StrategyName;
|
|
@@ -25605,14 +25773,17 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
25605
25773
|
frameName: FrameName;
|
|
25606
25774
|
}) => Promise<boolean>;
|
|
25607
25775
|
/**
|
|
25608
|
-
*
|
|
25609
|
-
*
|
|
25776
|
+
* Adds a new DCA entry to the active pending signal.
|
|
25777
|
+
*
|
|
25778
|
+
* Validates strategy existence and delegates to connection service
|
|
25779
|
+
* to add a new averaging entry to the position.
|
|
25610
25780
|
*
|
|
25611
25781
|
* @param backtest - Whether running in backtest mode
|
|
25612
25782
|
* @param symbol - Trading pair symbol
|
|
25613
|
-
* @param currentPrice - New entry price to
|
|
25783
|
+
* @param currentPrice - New entry price to add to the averaging history
|
|
25784
|
+
* @param cost - Cost basis for this entry in dollars
|
|
25614
25785
|
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
25615
|
-
* @returns Promise<boolean> - true if
|
|
25786
|
+
* @returns Promise<boolean> - true if entry added, false if rejected
|
|
25616
25787
|
*/
|
|
25617
25788
|
averageBuy: (backtest: boolean, symbol: string, currentPrice: number, context: {
|
|
25618
25789
|
strategyName: StrategyName;
|
|
@@ -28454,4 +28625,4 @@ declare const getTotalClosed: (signal: Signal) => {
|
|
|
28454
28625
|
remainingCostBasis: number;
|
|
28455
28626
|
};
|
|
28456
28627
|
|
|
28457
|
-
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, 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, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MeasureData, Memory, type MemoryData, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, 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 SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, 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, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
|
|
28628
|
+
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, type AverageBuyCommit, type AverageBuyCommitNotification, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, type BreakevenEvent, type BreakevenStatisticsModel, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, Cache, type CancelScheduledCommit, type CancelScheduledCommitNotification, type CandleData, type CandleInterval, type ClosePendingCommit, type ClosePendingCommitNotification, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, Dump, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, HighestProfit, type HighestProfitContract, type HighestProfitEvent, type HighestProfitStatisticsModel, type IActionSchema, type IActivateScheduledCommitRow, type IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type IBroker, type ICandleData, type ICommitRow, type IDumpContext, type IDumpInstance, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, type IMemoryInstance, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicAction, type IPublicCandleData, 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, Log, type LogData, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MeasureData, Memory, type MemoryData, type MessageModel, type MessageRole, type MessageToolCall, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, 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 SignalCloseContract, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenContract, type SignalOpenedNotification, type SignalScheduledNotification, type SignalSyncCloseNotification, type SignalSyncContract, type SignalSyncOpenNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, Sync, type SyncEvent, type SyncStatisticsModel, type TBrokerCtor, type TDumpInstanceCtor, type TLogCtor, type TMarkdownBase, type TMemoryInstanceCtor, 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, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
|