backtest-kit 3.7.1 → 3.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -1958,7 +1958,7 @@ interface ISignalRow extends ISignalDto {
1958
1958
  /** Percentage of position closed (0-100) */
1959
1959
  percent: number;
1960
1960
  /** Price at which this partial was executed */
1961
- price: number;
1961
+ currentPrice: number;
1962
1962
  /** Debug only timestamp in milliseconds */
1963
1963
  debugTimestamp?: number;
1964
1964
  /**
@@ -2611,6 +2611,33 @@ interface IStrategy {
2611
2611
  * @returns Promise resolving to held cost basis in dollars
2612
2612
  */
2613
2613
  getTotalCostClosed: (symbol: string) => Promise<number | null>;
2614
+ /**
2615
+ * Returns the effective (DCA-averaged) entry price for the current pending signal.
2616
+ * Returns null if no pending signal exists.
2617
+ */
2618
+ getPositionAveragePrice: (symbol: string) => Promise<number | null>;
2619
+ /**
2620
+ * Returns the number of DCA entries for the current pending signal.
2621
+ * 1 = original entry only. Returns null if no pending signal exists.
2622
+ */
2623
+ getPositionInvestedCount: (symbol: string) => Promise<number | null>;
2624
+ /**
2625
+ * Returns the total invested cost basis in dollars (entryCount × $100).
2626
+ * Returns null if no pending signal exists.
2627
+ */
2628
+ getPositionInvestedCost: (symbol: string) => Promise<number | null>;
2629
+ /**
2630
+ * Returns the unrealized PNL percentage at currentPrice.
2631
+ * Accounts for partial closes, DCA entries, slippage and fees.
2632
+ * Returns null if no pending signal exists.
2633
+ */
2634
+ getPositionPnlPercent: (symbol: string, currentPrice: number) => Promise<number | null>;
2635
+ /**
2636
+ * Returns the unrealized PNL in dollars at currentPrice.
2637
+ * Calculated as: pnlPercentage / 100 × totalInvestedCost.
2638
+ * Returns null if no pending signal exists.
2639
+ */
2640
+ getPositionPnlCost: (symbol: string, currentPrice: number) => Promise<number | null>;
2614
2641
  /**
2615
2642
  * Fast backtest using historical candles.
2616
2643
  * Iterates through candles, calculates VWAP, checks TP/SL on each candle.
@@ -4354,6 +4381,101 @@ declare function getScheduledSignal(symbol: string): Promise<IScheduledSignalRow
4354
4381
  * ```
4355
4382
  */
4356
4383
  declare function getBreakeven(symbol: string, currentPrice: number): Promise<boolean>;
4384
+ declare function getPositionAveragePrice(symbol: string): Promise<number | null>;
4385
+ declare function getPositionInvestedCount(symbol: string): Promise<number | null>;
4386
+ declare function getPositionInvestedCost(symbol: string): Promise<number | null>;
4387
+ declare function getPositionPnlPercent(symbol: string): Promise<number | null>;
4388
+ /**
4389
+ * Executes partial close at profit level by absolute dollar amount (moving toward TP).
4390
+ *
4391
+ * Convenience wrapper around commitPartialProfit that converts a dollar amount
4392
+ * to a percentage of the invested position cost automatically.
4393
+ * Price must be moving toward take profit (in profit direction).
4394
+ *
4395
+ * Automatically detects backtest/live mode from execution context.
4396
+ * Automatically fetches current price via getAveragePrice.
4397
+ *
4398
+ * @param symbol - Trading pair symbol
4399
+ * @param dollarAmount - Dollar value of position to close (e.g. 150 closes $150 worth)
4400
+ * @returns Promise<boolean> - true if partial close executed, false if skipped or no position
4401
+ *
4402
+ * @throws Error if currentPrice is not in profit direction:
4403
+ * - LONG: currentPrice must be > priceOpen
4404
+ * - SHORT: currentPrice must be < priceOpen
4405
+ *
4406
+ * @example
4407
+ * ```typescript
4408
+ * import { commitPartialProfitCost } from "backtest-kit";
4409
+ *
4410
+ * // Close $150 of a $300 position (50%) at profit
4411
+ * const success = await commitPartialProfitCost("BTCUSDT", 150);
4412
+ * if (success) {
4413
+ * console.log('Partial profit executed');
4414
+ * }
4415
+ * ```
4416
+ */
4417
+ declare function commitPartialProfitCost(symbol: string, dollarAmount: number): Promise<boolean>;
4418
+ /**
4419
+ * Executes partial close at loss level by absolute dollar amount (moving toward SL).
4420
+ *
4421
+ * Convenience wrapper around commitPartialLoss that converts a dollar amount
4422
+ * to a percentage of the invested position cost automatically.
4423
+ * Price must be moving toward stop loss (in loss direction).
4424
+ *
4425
+ * Automatically detects backtest/live mode from execution context.
4426
+ * Automatically fetches current price via getAveragePrice.
4427
+ *
4428
+ * @param symbol - Trading pair symbol
4429
+ * @param dollarAmount - Dollar value of position to close (e.g. 100 closes $100 worth)
4430
+ * @returns Promise<boolean> - true if partial close executed, false if skipped or no position
4431
+ *
4432
+ * @throws Error if currentPrice is not in loss direction:
4433
+ * - LONG: currentPrice must be < priceOpen
4434
+ * - SHORT: currentPrice must be > priceOpen
4435
+ *
4436
+ * @example
4437
+ * ```typescript
4438
+ * import { commitPartialLossCost } from "backtest-kit";
4439
+ *
4440
+ * // Close $100 of a $300 position (~33%) at loss
4441
+ * const success = await commitPartialLossCost("BTCUSDT", 100);
4442
+ * if (success) {
4443
+ * console.log('Partial loss executed');
4444
+ * }
4445
+ * ```
4446
+ */
4447
+ declare function commitPartialLossCost(symbol: string, dollarAmount: number): Promise<boolean>;
4448
+ declare function getPositionPnlCost(symbol: string): Promise<number | null>;
4449
+ /**
4450
+ * Returns the list of DCA entry prices for the current pending signal.
4451
+ *
4452
+ * The first element is always the original priceOpen (initial entry).
4453
+ * Each subsequent element is a price added by commitAverageBuy().
4454
+ *
4455
+ * Returns null if no pending signal exists.
4456
+ * Returns a single-element array [priceOpen] if no DCA entries were made.
4457
+ *
4458
+ * @param symbol - Trading pair symbol
4459
+ * @returns Promise resolving to array of entry prices or null
4460
+ *
4461
+ * @example
4462
+ * ```typescript
4463
+ * import { getPositionLevels } from "backtest-kit";
4464
+ *
4465
+ * const levels = await getPositionLevels("BTCUSDT");
4466
+ * // No DCA: [43000]
4467
+ * // One DCA: [43000, 42000]
4468
+ * ```
4469
+ */
4470
+ declare function getPositionLevels(symbol: string): Promise<number[] | null>;
4471
+ declare function getPositionPartials(symbol: string): Promise<{
4472
+ type: "profit" | "loss";
4473
+ percent: number;
4474
+ currentPrice: number;
4475
+ effectivePrice: number;
4476
+ entryCountAtClose: number;
4477
+ debugTimestamp?: number;
4478
+ }[]>;
4357
4479
 
4358
4480
  /**
4359
4481
  * Stops the strategy from generating new signals.
@@ -10625,6 +10747,48 @@ declare class BacktestUtils {
10625
10747
  exchangeName: ExchangeName;
10626
10748
  frameName: FrameName;
10627
10749
  }) => Promise<boolean>;
10750
+ getPositionAveragePrice: (symbol: string, context: {
10751
+ strategyName: StrategyName;
10752
+ exchangeName: ExchangeName;
10753
+ frameName: FrameName;
10754
+ }) => Promise<number | null>;
10755
+ getPositionInvestedCount: (symbol: string, context: {
10756
+ strategyName: StrategyName;
10757
+ exchangeName: ExchangeName;
10758
+ frameName: FrameName;
10759
+ }) => Promise<number | null>;
10760
+ getPositionInvestedCost: (symbol: string, context: {
10761
+ strategyName: StrategyName;
10762
+ exchangeName: ExchangeName;
10763
+ frameName: FrameName;
10764
+ }) => Promise<number | null>;
10765
+ getPositionPnlPercent: (symbol: string, currentPrice: number, context: {
10766
+ strategyName: StrategyName;
10767
+ exchangeName: ExchangeName;
10768
+ frameName: FrameName;
10769
+ }) => Promise<number | null>;
10770
+ getPositionPnlCost: (symbol: string, currentPrice: number, context: {
10771
+ strategyName: StrategyName;
10772
+ exchangeName: ExchangeName;
10773
+ frameName: FrameName;
10774
+ }) => Promise<number | null>;
10775
+ getPositionLevels: (symbol: string, context: {
10776
+ strategyName: StrategyName;
10777
+ exchangeName: ExchangeName;
10778
+ frameName: FrameName;
10779
+ }) => Promise<number[] | null>;
10780
+ getPositionPartials: (symbol: string, context: {
10781
+ strategyName: StrategyName;
10782
+ exchangeName: ExchangeName;
10783
+ frameName: FrameName;
10784
+ }) => Promise<{
10785
+ type: "profit" | "loss";
10786
+ percent: number;
10787
+ currentPrice: number;
10788
+ effectivePrice: number;
10789
+ entryCountAtClose: number;
10790
+ debugTimestamp?: number;
10791
+ }[]>;
10628
10792
  /**
10629
10793
  * Stops the strategy from generating new signals.
10630
10794
  *
@@ -10775,6 +10939,76 @@ declare class BacktestUtils {
10775
10939
  exchangeName: ExchangeName;
10776
10940
  frameName: FrameName;
10777
10941
  }) => Promise<boolean>;
10942
+ /**
10943
+ * Executes partial close at profit level by absolute dollar amount (moving toward TP).
10944
+ *
10945
+ * Convenience wrapper around commitPartialProfit that converts a dollar amount
10946
+ * to a percentage of the invested position cost automatically.
10947
+ * Price must be moving toward take profit (in profit direction).
10948
+ *
10949
+ * @param symbol - Trading pair symbol
10950
+ * @param dollarAmount - Dollar value of position to close (e.g. 150 closes $150 worth)
10951
+ * @param currentPrice - Current market price for this partial close
10952
+ * @param context - Execution context with strategyName, exchangeName, and frameName
10953
+ * @returns Promise<boolean> - true if partial close executed, false if skipped or no position
10954
+ *
10955
+ * @throws Error if currentPrice is not in profit direction:
10956
+ * - LONG: currentPrice must be > priceOpen
10957
+ * - SHORT: currentPrice must be < priceOpen
10958
+ *
10959
+ * @example
10960
+ * ```typescript
10961
+ * // Close $150 of a $300 position (50%) at profit
10962
+ * const success = await Backtest.commitPartialProfitCost("BTCUSDT", 150, 45000, {
10963
+ * exchangeName: "binance",
10964
+ * frameName: "frame1",
10965
+ * strategyName: "my-strategy"
10966
+ * });
10967
+ * if (success) {
10968
+ * console.log('Partial profit executed');
10969
+ * }
10970
+ * ```
10971
+ */
10972
+ commitPartialProfitCost: (symbol: string, dollarAmount: number, currentPrice: number, context: {
10973
+ strategyName: StrategyName;
10974
+ exchangeName: ExchangeName;
10975
+ frameName: FrameName;
10976
+ }) => Promise<boolean>;
10977
+ /**
10978
+ * Executes partial close at loss level by absolute dollar amount (moving toward SL).
10979
+ *
10980
+ * Convenience wrapper around commitPartialLoss that converts a dollar amount
10981
+ * to a percentage of the invested position cost automatically.
10982
+ * Price must be moving toward stop loss (in loss direction).
10983
+ *
10984
+ * @param symbol - Trading pair symbol
10985
+ * @param dollarAmount - Dollar value of position to close (e.g. 100 closes $100 worth)
10986
+ * @param currentPrice - Current market price for this partial close
10987
+ * @param context - Execution context with strategyName, exchangeName, and frameName
10988
+ * @returns Promise<boolean> - true if partial close executed, false if skipped or no position
10989
+ *
10990
+ * @throws Error if currentPrice is not in loss direction:
10991
+ * - LONG: currentPrice must be < priceOpen
10992
+ * - SHORT: currentPrice must be > priceOpen
10993
+ *
10994
+ * @example
10995
+ * ```typescript
10996
+ * // Close $100 of a $300 position (~33%) at loss
10997
+ * const success = await Backtest.commitPartialLossCost("BTCUSDT", 100, 38000, {
10998
+ * exchangeName: "binance",
10999
+ * frameName: "frame1",
11000
+ * strategyName: "my-strategy"
11001
+ * });
11002
+ * if (success) {
11003
+ * console.log('Partial loss executed');
11004
+ * }
11005
+ * ```
11006
+ */
11007
+ commitPartialLossCost: (symbol: string, dollarAmount: number, currentPrice: number, context: {
11008
+ strategyName: StrategyName;
11009
+ exchangeName: ExchangeName;
11010
+ frameName: FrameName;
11011
+ }) => Promise<boolean>;
10778
11012
  /**
10779
11013
  * Adjusts the trailing stop-loss distance for an active pending signal.
10780
11014
  *
@@ -11463,6 +11697,41 @@ declare class LiveUtils {
11463
11697
  strategyName: StrategyName;
11464
11698
  exchangeName: ExchangeName;
11465
11699
  }) => Promise<boolean>;
11700
+ getPositionAveragePrice: (symbol: string, context: {
11701
+ strategyName: StrategyName;
11702
+ exchangeName: ExchangeName;
11703
+ }) => Promise<number | null>;
11704
+ getPositionInvestedCount: (symbol: string, context: {
11705
+ strategyName: StrategyName;
11706
+ exchangeName: ExchangeName;
11707
+ }) => Promise<number | null>;
11708
+ getPositionInvestedCost: (symbol: string, context: {
11709
+ strategyName: StrategyName;
11710
+ exchangeName: ExchangeName;
11711
+ }) => Promise<number | null>;
11712
+ getPositionPnlPercent: (symbol: string, currentPrice: number, context: {
11713
+ strategyName: StrategyName;
11714
+ exchangeName: ExchangeName;
11715
+ }) => Promise<number | null>;
11716
+ getPositionPnlCost: (symbol: string, currentPrice: number, context: {
11717
+ strategyName: StrategyName;
11718
+ exchangeName: ExchangeName;
11719
+ }) => Promise<number | null>;
11720
+ getPositionLevels: (symbol: string, context: {
11721
+ strategyName: StrategyName;
11722
+ exchangeName: ExchangeName;
11723
+ }) => Promise<number[] | null>;
11724
+ getPositionPartials: (symbol: string, context: {
11725
+ strategyName: StrategyName;
11726
+ exchangeName: ExchangeName;
11727
+ }) => Promise<{
11728
+ type: "profit" | "loss";
11729
+ percent: number;
11730
+ currentPrice: number;
11731
+ effectivePrice: number;
11732
+ entryCountAtClose: number;
11733
+ debugTimestamp?: number;
11734
+ }[]>;
11466
11735
  /**
11467
11736
  * Stops the strategy from generating new signals.
11468
11737
  *
@@ -11600,6 +11869,72 @@ declare class LiveUtils {
11600
11869
  strategyName: StrategyName;
11601
11870
  exchangeName: ExchangeName;
11602
11871
  }) => Promise<boolean>;
11872
+ /**
11873
+ * Executes partial close at profit level by absolute dollar amount (moving toward TP).
11874
+ *
11875
+ * Convenience wrapper around commitPartialProfit that converts a dollar amount
11876
+ * to a percentage of the invested position cost automatically.
11877
+ * Price must be moving toward take profit (in profit direction).
11878
+ *
11879
+ * @param symbol - Trading pair symbol
11880
+ * @param dollarAmount - Dollar value of position to close (e.g. 150 closes $150 worth)
11881
+ * @param currentPrice - Current market price for this partial close
11882
+ * @param context - Execution context with strategyName and exchangeName
11883
+ * @returns Promise<boolean> - true if partial close executed, false if skipped or no position
11884
+ *
11885
+ * @throws Error if currentPrice is not in profit direction:
11886
+ * - LONG: currentPrice must be > priceOpen
11887
+ * - SHORT: currentPrice must be < priceOpen
11888
+ *
11889
+ * @example
11890
+ * ```typescript
11891
+ * // Close $150 of a $300 position (50%) at profit
11892
+ * const success = await Live.commitPartialProfitCost("BTCUSDT", 150, 45000, {
11893
+ * exchangeName: "binance",
11894
+ * strategyName: "my-strategy"
11895
+ * });
11896
+ * if (success) {
11897
+ * console.log('Partial profit executed');
11898
+ * }
11899
+ * ```
11900
+ */
11901
+ commitPartialProfitCost: (symbol: string, dollarAmount: number, currentPrice: number, context: {
11902
+ strategyName: StrategyName;
11903
+ exchangeName: ExchangeName;
11904
+ }) => Promise<boolean>;
11905
+ /**
11906
+ * Executes partial close at loss level by absolute dollar amount (moving toward SL).
11907
+ *
11908
+ * Convenience wrapper around commitPartialLoss that converts a dollar amount
11909
+ * to a percentage of the invested position cost automatically.
11910
+ * Price must be moving toward stop loss (in loss direction).
11911
+ *
11912
+ * @param symbol - Trading pair symbol
11913
+ * @param dollarAmount - Dollar value of position to close (e.g. 100 closes $100 worth)
11914
+ * @param currentPrice - Current market price for this partial close
11915
+ * @param context - Execution context with strategyName and exchangeName
11916
+ * @returns Promise<boolean> - true if partial close executed, false if skipped or no position
11917
+ *
11918
+ * @throws Error if currentPrice is not in loss direction:
11919
+ * - LONG: currentPrice must be < priceOpen
11920
+ * - SHORT: currentPrice must be > priceOpen
11921
+ *
11922
+ * @example
11923
+ * ```typescript
11924
+ * // Close $100 of a $300 position (~33%) at loss
11925
+ * const success = await Live.commitPartialLossCost("BTCUSDT", 100, 38000, {
11926
+ * exchangeName: "binance",
11927
+ * strategyName: "my-strategy"
11928
+ * });
11929
+ * if (success) {
11930
+ * console.log('Partial loss executed');
11931
+ * }
11932
+ * ```
11933
+ */
11934
+ commitPartialLossCost: (symbol: string, dollarAmount: number, currentPrice: number, context: {
11935
+ strategyName: StrategyName;
11936
+ exchangeName: ExchangeName;
11937
+ }) => Promise<boolean>;
11603
11938
  /**
11604
11939
  * Adjusts the trailing stop-loss distance for an active pending signal.
11605
11940
  *
@@ -15576,6 +15911,48 @@ declare class StrategyCoreService implements TStrategy$1 {
15576
15911
  exchangeName: ExchangeName;
15577
15912
  frameName: FrameName;
15578
15913
  }) => Promise<number | null>;
15914
+ getPositionAveragePrice: (backtest: boolean, symbol: string, context: {
15915
+ strategyName: StrategyName;
15916
+ exchangeName: ExchangeName;
15917
+ frameName: FrameName;
15918
+ }) => Promise<number | null>;
15919
+ getPositionInvestedCount: (backtest: boolean, symbol: string, context: {
15920
+ strategyName: StrategyName;
15921
+ exchangeName: ExchangeName;
15922
+ frameName: FrameName;
15923
+ }) => Promise<number | null>;
15924
+ getPositionInvestedCost: (backtest: boolean, symbol: string, context: {
15925
+ strategyName: StrategyName;
15926
+ exchangeName: ExchangeName;
15927
+ frameName: FrameName;
15928
+ }) => Promise<number | null>;
15929
+ getPositionPnlPercent: (backtest: boolean, symbol: string, currentPrice: number, context: {
15930
+ strategyName: StrategyName;
15931
+ exchangeName: ExchangeName;
15932
+ frameName: FrameName;
15933
+ }) => Promise<number | null>;
15934
+ getPositionPnlCost: (backtest: boolean, symbol: string, currentPrice: number, context: {
15935
+ strategyName: StrategyName;
15936
+ exchangeName: ExchangeName;
15937
+ frameName: FrameName;
15938
+ }) => Promise<number | null>;
15939
+ getPositionLevels: (backtest: boolean, symbol: string, context: {
15940
+ strategyName: StrategyName;
15941
+ exchangeName: ExchangeName;
15942
+ frameName: FrameName;
15943
+ }) => Promise<number[] | null>;
15944
+ getPositionPartials: (backtest: boolean, symbol: string, context: {
15945
+ strategyName: StrategyName;
15946
+ exchangeName: ExchangeName;
15947
+ frameName: FrameName;
15948
+ }) => Promise<{
15949
+ type: "profit" | "loss";
15950
+ percent: number;
15951
+ currentPrice: number;
15952
+ effectivePrice: number;
15953
+ entryCountAtClose: number;
15954
+ debugTimestamp?: number;
15955
+ }[]>;
15579
15956
  /**
15580
15957
  * Retrieves the currently active scheduled signal for the symbol.
15581
15958
  * If no scheduled signal exists, returns null.
@@ -17391,6 +17768,36 @@ declare const get: (object: any, path: any) => any;
17391
17768
  */
17392
17769
  declare const set: (object: any, path: any, value: any) => boolean;
17393
17770
 
17771
+ /**
17772
+ * Calculate the percentage difference between two numbers.
17773
+ * @param {number} a - The first number.
17774
+ * @param {number} b - The second number.
17775
+ * @returns {number} The percentage difference between the two numbers.
17776
+ */
17777
+ declare const percentDiff: (a?: number, b?: number) => number;
17778
+
17779
+ /**
17780
+ * Calculate the percentage change from yesterday's value to today's value.
17781
+ * @param {number} yesterdayValue - The value from yesterday.
17782
+ * @param {number} todayValue - The value from today.
17783
+ * @returns {number} The percentage change from yesterday to today.
17784
+ */
17785
+ declare const percentValue: (yesterdayValue: number, todayValue: number) => number;
17786
+
17787
+ /**
17788
+ * Convert an absolute dollar amount to a percentage of the invested position cost.
17789
+ * Use the result as the `percent` argument to `commitPartialProfit` / `commitPartialLoss`.
17790
+ *
17791
+ * @param dollarAmount - Dollar value to close (e.g. 150)
17792
+ * @param investedCost - Total invested cost from `getPositionInvestedCost` (e.g. 300)
17793
+ * @returns Percentage of the position to close (0–100)
17794
+ *
17795
+ * @example
17796
+ * const percent = investedCostToPercent(150, 300); // 50
17797
+ * await commitPartialProfit("BTCUSDT", percent);
17798
+ */
17799
+ declare const investedCostToPercent: (dollarAmount: number, investedCost: number) => number;
17800
+
17394
17801
  /**
17395
17802
  * Client implementation for exchange data access.
17396
17803
  *
@@ -18458,6 +18865,48 @@ declare class StrategyConnectionService implements TStrategy {
18458
18865
  exchangeName: ExchangeName;
18459
18866
  frameName: FrameName;
18460
18867
  }) => Promise<number | null>;
18868
+ getPositionAveragePrice: (backtest: boolean, symbol: string, context: {
18869
+ strategyName: StrategyName;
18870
+ exchangeName: ExchangeName;
18871
+ frameName: FrameName;
18872
+ }) => Promise<number | null>;
18873
+ getPositionInvestedCount: (backtest: boolean, symbol: string, context: {
18874
+ strategyName: StrategyName;
18875
+ exchangeName: ExchangeName;
18876
+ frameName: FrameName;
18877
+ }) => Promise<number | null>;
18878
+ getPositionInvestedCost: (backtest: boolean, symbol: string, context: {
18879
+ strategyName: StrategyName;
18880
+ exchangeName: ExchangeName;
18881
+ frameName: FrameName;
18882
+ }) => Promise<number | null>;
18883
+ getPositionPnlPercent: (backtest: boolean, symbol: string, currentPrice: number, context: {
18884
+ strategyName: StrategyName;
18885
+ exchangeName: ExchangeName;
18886
+ frameName: FrameName;
18887
+ }) => Promise<number | null>;
18888
+ getPositionPnlCost: (backtest: boolean, symbol: string, currentPrice: number, context: {
18889
+ strategyName: StrategyName;
18890
+ exchangeName: ExchangeName;
18891
+ frameName: FrameName;
18892
+ }) => Promise<number | null>;
18893
+ getPositionLevels: (backtest: boolean, symbol: string, context: {
18894
+ strategyName: StrategyName;
18895
+ exchangeName: ExchangeName;
18896
+ frameName: FrameName;
18897
+ }) => Promise<number[] | null>;
18898
+ getPositionPartials: (backtest: boolean, symbol: string, context: {
18899
+ strategyName: StrategyName;
18900
+ exchangeName: ExchangeName;
18901
+ frameName: FrameName;
18902
+ }) => Promise<{
18903
+ type: "profit" | "loss";
18904
+ percent: number;
18905
+ currentPrice: number;
18906
+ effectivePrice: number;
18907
+ entryCountAtClose: number;
18908
+ debugTimestamp?: number;
18909
+ }[]>;
18461
18910
  /**
18462
18911
  * Retrieves the currently active scheduled signal for the strategy.
18463
18912
  * If no scheduled signal exists, returns null.
@@ -22113,4 +22562,4 @@ declare const getTotalClosed: (signal: ISignalRow) => {
22113
22562
  remainingCostBasis: number;
22114
22563
  };
22115
22564
 
22116
- 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 IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, 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, 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, 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 TLogCtor, 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, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, 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, shutdown, stopStrategy, toProfitLossDto, validate, waitForCandle, warmCandles };
22565
+ 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 IAggregatedTradeData, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type ILog, type ILogEntry, type ILogger, type IMarkdownDumpOptions, 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, 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, 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 TLogCtor, 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, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitTrailingStop, commitTrailingTake, dumpMessages, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionAveragePrice, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasTradeContext, investedCostToPercent, 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, percentDiff, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, stopStrategy, toProfitLossDto, validate, waitForCandle, warmCandles };