backtest-kit 2.0.12 → 2.1.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 +2134 -1438
- package/build/index.mjs +2154 -1460
- package/package.json +1 -1
- package/types.d.ts +277 -22
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1204,7 +1204,7 @@ interface IStrategySchema {
|
|
|
1204
1204
|
* Reason why signal was closed.
|
|
1205
1205
|
* Used in discriminated union for type-safe handling.
|
|
1206
1206
|
*/
|
|
1207
|
-
type StrategyCloseReason = "time_expired" | "take_profit" | "stop_loss";
|
|
1207
|
+
type StrategyCloseReason = "time_expired" | "take_profit" | "stop_loss" | "closed";
|
|
1208
1208
|
/**
|
|
1209
1209
|
* Reason why scheduled signal was cancelled.
|
|
1210
1210
|
* Used in discriminated union for type-safe handling.
|
|
@@ -1355,7 +1355,7 @@ interface IStrategyTickResultClosed {
|
|
|
1355
1355
|
signal: IPublicSignalRow;
|
|
1356
1356
|
/** Final VWAP price at close */
|
|
1357
1357
|
currentPrice: number;
|
|
1358
|
-
/** Why signal closed (time_expired | take_profit | stop_loss) */
|
|
1358
|
+
/** Why signal closed (time_expired | take_profit | stop_loss | closed) */
|
|
1359
1359
|
closeReason: StrategyCloseReason;
|
|
1360
1360
|
/** Unix timestamp in milliseconds when signal closed */
|
|
1361
1361
|
closeTimestamp: number;
|
|
@@ -1371,6 +1371,8 @@ interface IStrategyTickResultClosed {
|
|
|
1371
1371
|
symbol: string;
|
|
1372
1372
|
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
1373
1373
|
backtest: boolean;
|
|
1374
|
+
/** Close ID (only for user-initiated closes with reason "closed") */
|
|
1375
|
+
closeId?: string;
|
|
1374
1376
|
}
|
|
1375
1377
|
/**
|
|
1376
1378
|
* Tick result: scheduled signal cancelled without opening position.
|
|
@@ -1520,7 +1522,7 @@ interface IStrategy {
|
|
|
1520
1522
|
* await cancel();
|
|
1521
1523
|
* ```
|
|
1522
1524
|
*/
|
|
1523
|
-
|
|
1525
|
+
stopStrategy: (symbol: string, backtest: boolean) => Promise<void>;
|
|
1524
1526
|
/**
|
|
1525
1527
|
* Cancels the scheduled signal without stopping the strategy.
|
|
1526
1528
|
*
|
|
@@ -1537,11 +1539,33 @@ interface IStrategy {
|
|
|
1537
1539
|
* @example
|
|
1538
1540
|
* ```typescript
|
|
1539
1541
|
* // Cancel scheduled signal without stopping strategy
|
|
1540
|
-
* await strategy.
|
|
1542
|
+
* await strategy.cancelScheduled("BTCUSDT");
|
|
1541
1543
|
* // Strategy continues, can generate new signals
|
|
1542
1544
|
* ```
|
|
1543
1545
|
*/
|
|
1544
|
-
|
|
1546
|
+
cancelScheduled: (symbol: string, backtest: boolean, cancelId?: string) => Promise<void>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Closes the pending signal without stopping the strategy.
|
|
1549
|
+
*
|
|
1550
|
+
* Clears the pending signal (active position).
|
|
1551
|
+
* Does NOT affect scheduled signals or strategy operation.
|
|
1552
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
1553
|
+
*
|
|
1554
|
+
* Use case: Close an active position that is no longer desired without stopping the entire strategy.
|
|
1555
|
+
*
|
|
1556
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
1557
|
+
* @param backtest - Whether running in backtest mode
|
|
1558
|
+
* @param closeId - Optional identifier for this close operation
|
|
1559
|
+
* @returns Promise that resolves when pending signal is cleared
|
|
1560
|
+
*
|
|
1561
|
+
* @example
|
|
1562
|
+
* ```typescript
|
|
1563
|
+
* // Close pending signal without stopping strategy
|
|
1564
|
+
* await strategy.closePending("BTCUSDT", false, "user-close-123");
|
|
1565
|
+
* // Strategy continues, can generate new signals
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
closePending: (symbol: string, backtest: boolean, closeId?: string) => Promise<void>;
|
|
1545
1569
|
/**
|
|
1546
1570
|
* Executes partial close at profit level (moving toward TP).
|
|
1547
1571
|
*
|
|
@@ -3777,13 +3801,35 @@ declare function getActionSchema(actionName: ActionName): IActionSchema;
|
|
|
3777
3801
|
*
|
|
3778
3802
|
* @example
|
|
3779
3803
|
* ```typescript
|
|
3780
|
-
* import {
|
|
3804
|
+
* import { commitCancelScheduled } from "backtest-kit";
|
|
3781
3805
|
*
|
|
3782
3806
|
* // Cancel scheduled signal with custom ID
|
|
3783
|
-
* await
|
|
3807
|
+
* await commitCancelScheduled("BTCUSDT", "manual-cancel-001");
|
|
3808
|
+
* ```
|
|
3809
|
+
*/
|
|
3810
|
+
declare function commitCancelScheduled(symbol: string, cancelId?: string): Promise<void>;
|
|
3811
|
+
/**
|
|
3812
|
+
* Closes the pending signal without stopping the strategy.
|
|
3813
|
+
*
|
|
3814
|
+
* Clears the pending signal (active position).
|
|
3815
|
+
* Does NOT affect scheduled signals or strategy operation.
|
|
3816
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
3817
|
+
*
|
|
3818
|
+
* Automatically detects backtest/live mode from execution context.
|
|
3819
|
+
*
|
|
3820
|
+
* @param symbol - Trading pair symbol
|
|
3821
|
+
* @param closeId - Optional close ID for tracking user-initiated closes
|
|
3822
|
+
* @returns Promise that resolves when pending signal is closed
|
|
3823
|
+
*
|
|
3824
|
+
* @example
|
|
3825
|
+
* ```typescript
|
|
3826
|
+
* import { commitClosePending } from "backtest-kit";
|
|
3827
|
+
*
|
|
3828
|
+
* // Close pending signal with custom ID
|
|
3829
|
+
* await commitClosePending("BTCUSDT", "manual-close-001");
|
|
3784
3830
|
* ```
|
|
3785
3831
|
*/
|
|
3786
|
-
declare function
|
|
3832
|
+
declare function commitClosePending(symbol: string, closeId?: string): Promise<void>;
|
|
3787
3833
|
/**
|
|
3788
3834
|
* Executes partial close at profit level (moving toward TP).
|
|
3789
3835
|
*
|
|
@@ -3976,7 +4022,7 @@ declare function commitBreakeven(symbol: string): Promise<boolean>;
|
|
|
3976
4022
|
* await stop("BTCUSDT", "my-strategy");
|
|
3977
4023
|
* ```
|
|
3978
4024
|
*/
|
|
3979
|
-
declare function
|
|
4025
|
+
declare function stopStrategy(symbol: string): Promise<void>;
|
|
3980
4026
|
|
|
3981
4027
|
/**
|
|
3982
4028
|
* Unified breakeven event data for report generation.
|
|
@@ -7619,8 +7665,8 @@ interface IEntity {
|
|
|
7619
7665
|
* Custom adapters should implement this interface.
|
|
7620
7666
|
*
|
|
7621
7667
|
* Architecture:
|
|
7622
|
-
* - IPersistBase: Public API for custom adapters (
|
|
7623
|
-
* - PersistBase: Default implementation with
|
|
7668
|
+
* - IPersistBase: Public API for custom adapters (5 methods: waitForInit, readValue, hasValue, writeValue, keys)
|
|
7669
|
+
* - PersistBase: Default implementation with keys() method for validation and iteration
|
|
7624
7670
|
* - TPersistBaseCtor: Constructor type requiring IPersistBase
|
|
7625
7671
|
*/
|
|
7626
7672
|
interface IPersistBase<Entity extends IEntity | null = IEntity> {
|
|
@@ -7656,6 +7702,15 @@ interface IPersistBase<Entity extends IEntity | null = IEntity> {
|
|
|
7656
7702
|
* @throws Error if write fails
|
|
7657
7703
|
*/
|
|
7658
7704
|
writeValue(entityId: EntityId, entity: Entity): Promise<void>;
|
|
7705
|
+
/**
|
|
7706
|
+
* Async generator yielding all entity IDs.
|
|
7707
|
+
* Sorted alphanumerically.
|
|
7708
|
+
* Used for iteration and validation.
|
|
7709
|
+
*
|
|
7710
|
+
* @returns AsyncGenerator yielding entity IDs
|
|
7711
|
+
* @throws Error if reading fails
|
|
7712
|
+
*/
|
|
7713
|
+
keys(): AsyncGenerator<EntityId>;
|
|
7659
7714
|
}
|
|
7660
7715
|
/**
|
|
7661
7716
|
* Base class for file-based persistence with atomic writes.
|
|
@@ -8175,6 +8230,82 @@ declare class PersistBreakevenUtils {
|
|
|
8175
8230
|
* ```
|
|
8176
8231
|
*/
|
|
8177
8232
|
declare const PersistBreakevenAdapter: PersistBreakevenUtils;
|
|
8233
|
+
/**
|
|
8234
|
+
* Type for persisted candle cache data.
|
|
8235
|
+
* Each candle is stored as a separate JSON file.
|
|
8236
|
+
*/
|
|
8237
|
+
type CandleData = ICandleData;
|
|
8238
|
+
/**
|
|
8239
|
+
* Utility class for managing candles cache persistence.
|
|
8240
|
+
*
|
|
8241
|
+
* Features:
|
|
8242
|
+
* - Each candle stored as separate JSON file: ${exchangeName}/${symbol}/${interval}/${timestamp}.json
|
|
8243
|
+
* - Cache validation: returns cached data if file count matches requested limit
|
|
8244
|
+
* - Automatic cache invalidation and refresh when data is incomplete
|
|
8245
|
+
* - Atomic read/write operations
|
|
8246
|
+
*
|
|
8247
|
+
* Used by ClientExchange for candle data caching.
|
|
8248
|
+
*/
|
|
8249
|
+
declare class PersistCandleUtils {
|
|
8250
|
+
private PersistCandlesFactory;
|
|
8251
|
+
private getCandlesStorage;
|
|
8252
|
+
/**
|
|
8253
|
+
* Registers a custom persistence adapter.
|
|
8254
|
+
*
|
|
8255
|
+
* @param Ctor - Custom PersistBase constructor
|
|
8256
|
+
*/
|
|
8257
|
+
usePersistCandleAdapter(Ctor: TPersistBaseCtor<string, CandleData>): void;
|
|
8258
|
+
/**
|
|
8259
|
+
* Reads cached candles for a specific exchange, symbol, and interval.
|
|
8260
|
+
* Returns candles only if cache contains exactly the requested limit.
|
|
8261
|
+
*
|
|
8262
|
+
* @param symbol - Trading pair symbol
|
|
8263
|
+
* @param interval - Candle interval
|
|
8264
|
+
* @param exchangeName - Exchange identifier
|
|
8265
|
+
* @param limit - Number of candles requested
|
|
8266
|
+
* @param sinceTimestamp - Start timestamp (inclusive)
|
|
8267
|
+
* @param untilTimestamp - End timestamp (exclusive)
|
|
8268
|
+
* @returns Promise resolving to array of candles or null if cache is incomplete
|
|
8269
|
+
*/
|
|
8270
|
+
readCandlesData: (symbol: string, interval: CandleInterval, exchangeName: ExchangeName, limit: number, sinceTimestamp: number, untilTimestamp: number) => Promise<CandleData[] | null>;
|
|
8271
|
+
/**
|
|
8272
|
+
* Writes candles to cache with atomic file writes.
|
|
8273
|
+
* Each candle is stored as a separate JSON file named by its timestamp.
|
|
8274
|
+
*
|
|
8275
|
+
* @param candles - Array of candle data to cache
|
|
8276
|
+
* @param symbol - Trading pair symbol
|
|
8277
|
+
* @param interval - Candle interval
|
|
8278
|
+
* @param exchangeName - Exchange identifier
|
|
8279
|
+
* @returns Promise that resolves when all writes are complete
|
|
8280
|
+
*/
|
|
8281
|
+
writeCandlesData: (candles: CandleData[], symbol: string, interval: CandleInterval, exchangeName: ExchangeName) => Promise<void>;
|
|
8282
|
+
/**
|
|
8283
|
+
* Switches to the default JSON persist adapter.
|
|
8284
|
+
* All future persistence writes will use JSON storage.
|
|
8285
|
+
*/
|
|
8286
|
+
useJson(): void;
|
|
8287
|
+
/**
|
|
8288
|
+
* Switches to a dummy persist adapter that discards all writes.
|
|
8289
|
+
* All future persistence writes will be no-ops.
|
|
8290
|
+
*/
|
|
8291
|
+
useDummy(): void;
|
|
8292
|
+
}
|
|
8293
|
+
/**
|
|
8294
|
+
* Global singleton instance of PersistCandleUtils.
|
|
8295
|
+
* Used by ClientExchange for candle data caching.
|
|
8296
|
+
*
|
|
8297
|
+
* @example
|
|
8298
|
+
* ```typescript
|
|
8299
|
+
* // Read cached candles
|
|
8300
|
+
* const candles = await PersistCandleAdapter.readCandlesData(
|
|
8301
|
+
* "BTCUSDT", "1m", "binance", 100, since.getTime(), until.getTime()
|
|
8302
|
+
* );
|
|
8303
|
+
*
|
|
8304
|
+
* // Write candles to cache
|
|
8305
|
+
* await PersistCandleAdapter.writeCandlesData(candles, "BTCUSDT", "1m", "binance");
|
|
8306
|
+
* ```
|
|
8307
|
+
*/
|
|
8308
|
+
declare const PersistCandleAdapter: PersistCandleUtils;
|
|
8178
8309
|
|
|
8179
8310
|
declare const WAIT_FOR_INIT_SYMBOL$1: unique symbol;
|
|
8180
8311
|
declare const WRITE_SAFE_SYMBOL$1: unique symbol;
|
|
@@ -9171,11 +9302,38 @@ declare class BacktestUtils {
|
|
|
9171
9302
|
* }, "manual-cancel-001");
|
|
9172
9303
|
* ```
|
|
9173
9304
|
*/
|
|
9174
|
-
|
|
9305
|
+
commitCancelScheduled: (symbol: string, context: {
|
|
9175
9306
|
strategyName: StrategyName;
|
|
9176
9307
|
exchangeName: ExchangeName;
|
|
9177
9308
|
frameName: FrameName;
|
|
9178
9309
|
}, cancelId?: string) => Promise<void>;
|
|
9310
|
+
/**
|
|
9311
|
+
* Closes the pending signal without stopping the strategy.
|
|
9312
|
+
*
|
|
9313
|
+
* Clears the pending signal (active position).
|
|
9314
|
+
* Does NOT affect scheduled signals or strategy operation.
|
|
9315
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
9316
|
+
*
|
|
9317
|
+
* @param symbol - Trading pair symbol
|
|
9318
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
9319
|
+
* @param closeId - Optional close ID for user-initiated closes
|
|
9320
|
+
* @returns Promise that resolves when pending signal is closed
|
|
9321
|
+
*
|
|
9322
|
+
* @example
|
|
9323
|
+
* ```typescript
|
|
9324
|
+
* // Close pending signal with custom ID
|
|
9325
|
+
* await Backtest.commitClose("BTCUSDT", {
|
|
9326
|
+
* exchangeName: "binance",
|
|
9327
|
+
* strategyName: "my-strategy",
|
|
9328
|
+
* frameName: "1m"
|
|
9329
|
+
* }, "manual-close-001");
|
|
9330
|
+
* ```
|
|
9331
|
+
*/
|
|
9332
|
+
commitClosePending: (symbol: string, context: {
|
|
9333
|
+
strategyName: StrategyName;
|
|
9334
|
+
exchangeName: ExchangeName;
|
|
9335
|
+
frameName: FrameName;
|
|
9336
|
+
}, closeId?: string) => Promise<void>;
|
|
9179
9337
|
/**
|
|
9180
9338
|
* Executes partial close at profit level (moving toward TP).
|
|
9181
9339
|
*
|
|
@@ -9884,10 +10042,35 @@ declare class LiveUtils {
|
|
|
9884
10042
|
* }, "manual-cancel-001");
|
|
9885
10043
|
* ```
|
|
9886
10044
|
*/
|
|
9887
|
-
|
|
10045
|
+
commitCancelScheduled: (symbol: string, context: {
|
|
9888
10046
|
strategyName: StrategyName;
|
|
9889
10047
|
exchangeName: ExchangeName;
|
|
9890
10048
|
}, cancelId?: string) => Promise<void>;
|
|
10049
|
+
/**
|
|
10050
|
+
* Closes the pending signal without stopping the strategy.
|
|
10051
|
+
*
|
|
10052
|
+
* Clears the pending signal (active position).
|
|
10053
|
+
* Does NOT affect scheduled signals or strategy operation.
|
|
10054
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
10055
|
+
*
|
|
10056
|
+
* @param symbol - Trading pair symbol
|
|
10057
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
10058
|
+
* @param closeId - Optional close ID for user-initiated closes
|
|
10059
|
+
* @returns Promise that resolves when pending signal is closed
|
|
10060
|
+
*
|
|
10061
|
+
* @example
|
|
10062
|
+
* ```typescript
|
|
10063
|
+
* // Close pending signal with custom ID
|
|
10064
|
+
* await Live.commitClose("BTCUSDT", {
|
|
10065
|
+
* exchangeName: "binance",
|
|
10066
|
+
* strategyName: "my-strategy"
|
|
10067
|
+
* }, "manual-close-001");
|
|
10068
|
+
* ```
|
|
10069
|
+
*/
|
|
10070
|
+
commitClosePending: (symbol: string, context: {
|
|
10071
|
+
strategyName: StrategyName;
|
|
10072
|
+
exchangeName: ExchangeName;
|
|
10073
|
+
}, closeId?: string) => Promise<void>;
|
|
9891
10074
|
/**
|
|
9892
10075
|
* Executes partial close at profit level (moving toward TP).
|
|
9893
10076
|
*
|
|
@@ -12557,7 +12740,7 @@ declare class ExchangeUtils {
|
|
|
12557
12740
|
*/
|
|
12558
12741
|
getCandles: (symbol: string, interval: CandleInterval, limit: number, context: {
|
|
12559
12742
|
exchangeName: ExchangeName;
|
|
12560
|
-
}) => Promise<
|
|
12743
|
+
}) => Promise<any>;
|
|
12561
12744
|
/**
|
|
12562
12745
|
* Calculates VWAP (Volume Weighted Average Price) from last N 1m candles.
|
|
12563
12746
|
*
|
|
@@ -14235,6 +14418,35 @@ declare class ClientExchange implements IExchange {
|
|
|
14235
14418
|
* @returns Promise resolving to formatted price as string
|
|
14236
14419
|
*/
|
|
14237
14420
|
formatPrice(symbol: string, price: number): Promise<string>;
|
|
14421
|
+
/**
|
|
14422
|
+
* Fetches raw candles with flexible date/limit parameters.
|
|
14423
|
+
*
|
|
14424
|
+
* Compatibility layer that:
|
|
14425
|
+
* - RAW MODE (sDate + eDate + limit): fetches exactly as specified, NO look-ahead bias protection
|
|
14426
|
+
* - Other modes: respects execution context and prevents look-ahead bias
|
|
14427
|
+
*
|
|
14428
|
+
* Parameter combinations:
|
|
14429
|
+
* 1. sDate + eDate + limit: RAW MODE - fetches exactly as specified, no validation against when
|
|
14430
|
+
* 2. sDate + eDate: calculates limit from date range, validates endTimestamp <= when
|
|
14431
|
+
* 3. eDate + limit: calculates sDate backward, validates endTimestamp <= when
|
|
14432
|
+
* 4. sDate + limit: fetches forward, validates endTimestamp <= when
|
|
14433
|
+
* 5. Only limit: uses execution.context.when as reference (backward)
|
|
14434
|
+
*
|
|
14435
|
+
* Edge cases:
|
|
14436
|
+
* - If calculated limit is 0 or negative: throws error
|
|
14437
|
+
* - If sDate >= eDate: throws error
|
|
14438
|
+
* - If startTimestamp >= endTimestamp: throws error
|
|
14439
|
+
* - If endTimestamp > when (non-RAW modes only): throws error to prevent look-ahead bias
|
|
14440
|
+
*
|
|
14441
|
+
* @param symbol - Trading pair symbol
|
|
14442
|
+
* @param interval - Candle interval
|
|
14443
|
+
* @param limit - Optional number of candles to fetch
|
|
14444
|
+
* @param sDate - Optional start date in milliseconds
|
|
14445
|
+
* @param eDate - Optional end date in milliseconds
|
|
14446
|
+
* @returns Promise resolving to array of candles
|
|
14447
|
+
* @throws Error if parameters are invalid or conflicting
|
|
14448
|
+
*/
|
|
14449
|
+
getRawCandles(symbol: string, interval: CandleInterval, limit?: number, sDate?: number, eDate?: number): Promise<ICandleData[]>;
|
|
14238
14450
|
/**
|
|
14239
14451
|
* Fetches order book for a trading pair.
|
|
14240
14452
|
*
|
|
@@ -15204,7 +15416,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
|
|
|
15204
15416
|
/**
|
|
15205
15417
|
* Stops the specified strategy from generating new signals.
|
|
15206
15418
|
*
|
|
15207
|
-
* Delegates to ClientStrategy.
|
|
15419
|
+
* Delegates to ClientStrategy.stopStrategy() which sets internal flag to prevent
|
|
15208
15420
|
* getSignal from being called on subsequent ticks.
|
|
15209
15421
|
*
|
|
15210
15422
|
* @param backtest - Whether running in backtest mode
|
|
@@ -15212,7 +15424,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
|
|
|
15212
15424
|
* @param ctx - Context with strategyName, exchangeName, frameName
|
|
15213
15425
|
* @returns Promise that resolves when stop flag is set
|
|
15214
15426
|
*/
|
|
15215
|
-
|
|
15427
|
+
stopStrategy: (backtest: boolean, symbol: string, context: {
|
|
15216
15428
|
strategyName: StrategyName;
|
|
15217
15429
|
exchangeName: ExchangeName;
|
|
15218
15430
|
frameName: FrameName;
|
|
@@ -15249,7 +15461,7 @@ declare class StrategyConnectionService implements TStrategy$1 {
|
|
|
15249
15461
|
/**
|
|
15250
15462
|
* Cancels the scheduled signal for the specified strategy.
|
|
15251
15463
|
*
|
|
15252
|
-
* Delegates to ClientStrategy.
|
|
15464
|
+
* Delegates to ClientStrategy.cancelScheduled() which clears the scheduled signal
|
|
15253
15465
|
* without stopping the strategy or affecting pending signals.
|
|
15254
15466
|
*
|
|
15255
15467
|
* Note: Cancelled event will be emitted on next tick() call when strategy
|
|
@@ -15261,11 +15473,32 @@ declare class StrategyConnectionService implements TStrategy$1 {
|
|
|
15261
15473
|
* @param cancelId - Optional cancellation ID for user-initiated cancellations
|
|
15262
15474
|
* @returns Promise that resolves when scheduled signal is cancelled
|
|
15263
15475
|
*/
|
|
15264
|
-
|
|
15476
|
+
cancelScheduled: (backtest: boolean, symbol: string, context: {
|
|
15265
15477
|
strategyName: StrategyName;
|
|
15266
15478
|
exchangeName: ExchangeName;
|
|
15267
15479
|
frameName: FrameName;
|
|
15268
15480
|
}, cancelId?: string) => Promise<void>;
|
|
15481
|
+
/**
|
|
15482
|
+
* Closes the pending signal without stopping the strategy.
|
|
15483
|
+
*
|
|
15484
|
+
* Clears the pending signal (active position).
|
|
15485
|
+
* Does NOT affect scheduled signals or strategy operation.
|
|
15486
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
15487
|
+
*
|
|
15488
|
+
* Note: Closed event will be emitted on next tick() call when strategy
|
|
15489
|
+
* detects the pending signal was closed.
|
|
15490
|
+
*
|
|
15491
|
+
* @param backtest - Whether running in backtest mode
|
|
15492
|
+
* @param symbol - Trading pair symbol
|
|
15493
|
+
* @param context - Context with strategyName, exchangeName, frameName
|
|
15494
|
+
* @param closeId - Optional close ID for user-initiated closes
|
|
15495
|
+
* @returns Promise that resolves when pending signal is closed
|
|
15496
|
+
*/
|
|
15497
|
+
closePending: (backtest: boolean, symbol: string, context: {
|
|
15498
|
+
strategyName: StrategyName;
|
|
15499
|
+
exchangeName: ExchangeName;
|
|
15500
|
+
frameName: FrameName;
|
|
15501
|
+
}, closeId?: string) => Promise<void>;
|
|
15269
15502
|
/**
|
|
15270
15503
|
* Executes partial close at profit level (moving toward TP).
|
|
15271
15504
|
*
|
|
@@ -16173,7 +16406,7 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
16173
16406
|
* @param ctx - Context with strategyName, exchangeName, frameName
|
|
16174
16407
|
* @returns Promise that resolves when stop flag is set
|
|
16175
16408
|
*/
|
|
16176
|
-
|
|
16409
|
+
stopStrategy: (backtest: boolean, symbol: string, context: {
|
|
16177
16410
|
strategyName: StrategyName;
|
|
16178
16411
|
exchangeName: ExchangeName;
|
|
16179
16412
|
frameName: FrameName;
|
|
@@ -16181,7 +16414,7 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
16181
16414
|
/**
|
|
16182
16415
|
* Cancels the scheduled signal without stopping the strategy.
|
|
16183
16416
|
*
|
|
16184
|
-
* Delegates to StrategyConnectionService.
|
|
16417
|
+
* Delegates to StrategyConnectionService.cancelScheduled() to clear scheduled signal
|
|
16185
16418
|
* and emit cancelled event through emitters.
|
|
16186
16419
|
* Does not require execution context.
|
|
16187
16420
|
*
|
|
@@ -16191,11 +16424,33 @@ declare class StrategyCoreService implements TStrategy {
|
|
|
16191
16424
|
* @param cancelId - Optional cancellation ID for user-initiated cancellations
|
|
16192
16425
|
* @returns Promise that resolves when scheduled signal is cancelled
|
|
16193
16426
|
*/
|
|
16194
|
-
|
|
16427
|
+
cancelScheduled: (backtest: boolean, symbol: string, context: {
|
|
16195
16428
|
strategyName: StrategyName;
|
|
16196
16429
|
exchangeName: ExchangeName;
|
|
16197
16430
|
frameName: FrameName;
|
|
16198
16431
|
}, cancelId?: string) => Promise<void>;
|
|
16432
|
+
/**
|
|
16433
|
+
* Closes the pending signal without stopping the strategy.
|
|
16434
|
+
*
|
|
16435
|
+
* Clears the pending signal (active position).
|
|
16436
|
+
* Does NOT affect scheduled signals or strategy operation.
|
|
16437
|
+
* Does NOT set stop flag - strategy can continue generating new signals.
|
|
16438
|
+
*
|
|
16439
|
+
* Delegates to StrategyConnectionService.closePending() to clear pending signal
|
|
16440
|
+
* and emit closed event through emitters.
|
|
16441
|
+
* Does not require execution context.
|
|
16442
|
+
*
|
|
16443
|
+
* @param backtest - Whether running in backtest mode
|
|
16444
|
+
* @param symbol - Trading pair symbol
|
|
16445
|
+
* @param context - Context with strategyName, exchangeName, frameName
|
|
16446
|
+
* @param closeId - Optional close ID for user-initiated closes
|
|
16447
|
+
* @returns Promise that resolves when pending signal is closed
|
|
16448
|
+
*/
|
|
16449
|
+
closePending: (backtest: boolean, symbol: string, context: {
|
|
16450
|
+
strategyName: StrategyName;
|
|
16451
|
+
exchangeName: ExchangeName;
|
|
16452
|
+
frameName: FrameName;
|
|
16453
|
+
}, closeId?: string) => Promise<void>;
|
|
16199
16454
|
/**
|
|
16200
16455
|
* Disposes the ClientStrategy instance for the given context.
|
|
16201
16456
|
*
|
|
@@ -19200,4 +19455,4 @@ declare const backtest: {
|
|
|
19200
19455
|
loggerService: LoggerService;
|
|
19201
19456
|
};
|
|
19202
19457
|
|
|
19203
|
-
export { ActionBase, type ActivePingContract, Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Notification, type NotificationModel, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, type ProgressBacktestContract, type ProgressBacktestNotification, type ProgressOptimizerContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addOptimizerSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitBreakeven,
|
|
19458
|
+
export { ActionBase, type ActivePingContract, Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleData, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOptimizerCallbacks, type IOptimizerData, type IOptimizerFetchArgs, type IOptimizerFilterArgs, type IOptimizerRange, type IOptimizerSchema, type IOptimizerSource, type IOptimizerStrategy, type IOptimizerTemplate, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, type MessageModel, type MessageRole, MethodContextService, type MetricStats, Notification, type NotificationModel, Optimizer, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, type ProgressBacktestContract, type ProgressBacktestNotification, type ProgressOptimizerContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addOptimizerSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitSignalPromptHistory, commitTrailingStop, commitTrailingTake, dumpSignalData, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getOptimizerSchema, getOrderBook, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listOptimizerSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenOptimizerProgress, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideOptimizerSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|