backtest-kit 4.0.2 → 5.0.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/build/index.cjs +442 -25
- package/build/index.mjs +441 -26
- package/package.json +1 -1
- package/types.d.ts +271 -11
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1792,6 +1792,9 @@ interface IAction {
|
|
|
1792
1792
|
*
|
|
1793
1793
|
* NOTE: Exceptions are NOT swallowed here — they propagate to CREATE_SYNC_FN.
|
|
1794
1794
|
*
|
|
1795
|
+
* @deprecated This method is not recommended for use. Implement custom logic in signal(), signalLive(), or signalBacktest() instead.
|
|
1796
|
+
* If you need to implement custom logic on signal open/close, please use signal(), signalBacktest(), signalLive() instead.
|
|
1797
|
+
* If Action::signalSync throws the exchange will not execute the order!
|
|
1795
1798
|
* @param event - Sync event with action "signal-open" or "signal-close"
|
|
1796
1799
|
*/
|
|
1797
1800
|
signalSync(event: SignalSyncContract): void | Promise<void>;
|
|
@@ -4370,6 +4373,17 @@ declare function getRiskSchema(riskName: RiskName): IRiskSchema;
|
|
|
4370
4373
|
*/
|
|
4371
4374
|
declare function getActionSchema(actionName: ActionName): IActionSchema;
|
|
4372
4375
|
|
|
4376
|
+
/**
|
|
4377
|
+
* Tolerance zone configuration for DCA overlap detection.
|
|
4378
|
+
* Percentages are in 0–100 format (e.g. 5 means 5%).
|
|
4379
|
+
*/
|
|
4380
|
+
interface IPositionOverlapLadder {
|
|
4381
|
+
/** Upper tolerance in percent (0–100): how far above each DCA level to flag as overlap */
|
|
4382
|
+
upperPercent: number;
|
|
4383
|
+
/** Lower tolerance in percent (0–100): how far below each DCA level to flag as overlap */
|
|
4384
|
+
lowerPercent: number;
|
|
4385
|
+
}
|
|
4386
|
+
|
|
4373
4387
|
/**
|
|
4374
4388
|
* Cancels the scheduled signal without stopping the strategy.
|
|
4375
4389
|
*
|
|
@@ -4760,9 +4774,101 @@ declare function getScheduledSignal(symbol: string): Promise<IScheduledSignalRow
|
|
|
4760
4774
|
* ```
|
|
4761
4775
|
*/
|
|
4762
4776
|
declare function getBreakeven(symbol: string, currentPrice: number): Promise<boolean>;
|
|
4777
|
+
/**
|
|
4778
|
+
* Returns the effective (DCA-weighted) entry price for the current pending signal.
|
|
4779
|
+
*
|
|
4780
|
+
* Uses cost-weighted harmonic mean: Σcost / Σ(cost/price).
|
|
4781
|
+
* When partial closes exist, the price is computed iteratively using
|
|
4782
|
+
* costBasisAtClose snapshots from each partial, then blended with any
|
|
4783
|
+
* DCA entries added after the last partial.
|
|
4784
|
+
* With no DCA entries, equals the original priceOpen.
|
|
4785
|
+
*
|
|
4786
|
+
* Returns null if no pending signal exists.
|
|
4787
|
+
*
|
|
4788
|
+
* Automatically detects backtest/live mode from execution context.
|
|
4789
|
+
*
|
|
4790
|
+
* @param symbol - Trading pair symbol
|
|
4791
|
+
* @returns Promise resolving to effective entry price or null
|
|
4792
|
+
*
|
|
4793
|
+
* @example
|
|
4794
|
+
* ```typescript
|
|
4795
|
+
* import { getPositionAveragePrice } from "backtest-kit";
|
|
4796
|
+
*
|
|
4797
|
+
* const avgPrice = await getPositionAveragePrice("BTCUSDT");
|
|
4798
|
+
* // No DCA: avgPrice === priceOpen
|
|
4799
|
+
* // After DCA at lower price: avgPrice < priceOpen
|
|
4800
|
+
* ```
|
|
4801
|
+
*/
|
|
4763
4802
|
declare function getPositionAveragePrice(symbol: string): Promise<number | null>;
|
|
4803
|
+
/**
|
|
4804
|
+
* Returns the number of DCA entries made for the current pending signal.
|
|
4805
|
+
*
|
|
4806
|
+
* 1 = original entry only (no DCA).
|
|
4807
|
+
* Increases by 1 with each successful commitAverageBuy().
|
|
4808
|
+
*
|
|
4809
|
+
* Returns null if no pending signal exists.
|
|
4810
|
+
*
|
|
4811
|
+
* Automatically detects backtest/live mode from execution context.
|
|
4812
|
+
*
|
|
4813
|
+
* @param symbol - Trading pair symbol
|
|
4814
|
+
* @returns Promise resolving to entry count or null
|
|
4815
|
+
*
|
|
4816
|
+
* @example
|
|
4817
|
+
* ```typescript
|
|
4818
|
+
* import { getPositionInvestedCount } from "backtest-kit";
|
|
4819
|
+
*
|
|
4820
|
+
* const count = await getPositionInvestedCount("BTCUSDT");
|
|
4821
|
+
* // No DCA: count === 1
|
|
4822
|
+
* // After one DCA: count === 2
|
|
4823
|
+
* ```
|
|
4824
|
+
*/
|
|
4764
4825
|
declare function getPositionInvestedCount(symbol: string): Promise<number | null>;
|
|
4826
|
+
/**
|
|
4827
|
+
* Returns the total invested cost basis in dollars for the current pending signal.
|
|
4828
|
+
*
|
|
4829
|
+
* Equal to the sum of all _entry costs (Σ entry.cost).
|
|
4830
|
+
* Each entry cost is set at the time of commitAverageBuy (defaults to CC_POSITION_ENTRY_COST).
|
|
4831
|
+
*
|
|
4832
|
+
* Returns null if no pending signal exists.
|
|
4833
|
+
*
|
|
4834
|
+
* Automatically detects backtest/live mode from execution context.
|
|
4835
|
+
*
|
|
4836
|
+
* @param symbol - Trading pair symbol
|
|
4837
|
+
* @returns Promise resolving to total invested cost in dollars or null
|
|
4838
|
+
*
|
|
4839
|
+
* @example
|
|
4840
|
+
* ```typescript
|
|
4841
|
+
* import { getPositionInvestedCost } from "backtest-kit";
|
|
4842
|
+
*
|
|
4843
|
+
* const cost = await getPositionInvestedCost("BTCUSDT");
|
|
4844
|
+
* // No DCA, default cost: cost === 100
|
|
4845
|
+
* // After one DCA with default cost: cost === 200
|
|
4846
|
+
* ```
|
|
4847
|
+
*/
|
|
4765
4848
|
declare function getPositionInvestedCost(symbol: string): Promise<number | null>;
|
|
4849
|
+
/**
|
|
4850
|
+
* Returns the unrealized PNL percentage for the current pending signal at current market price.
|
|
4851
|
+
*
|
|
4852
|
+
* Accounts for partial closes, DCA entries, slippage and fees
|
|
4853
|
+
* (delegates to toProfitLossDto).
|
|
4854
|
+
*
|
|
4855
|
+
* Returns null if no pending signal exists.
|
|
4856
|
+
*
|
|
4857
|
+
* Automatically detects backtest/live mode from execution context.
|
|
4858
|
+
* Automatically fetches current price via getAveragePrice.
|
|
4859
|
+
*
|
|
4860
|
+
* @param symbol - Trading pair symbol
|
|
4861
|
+
* @returns Promise resolving to PNL percentage or null
|
|
4862
|
+
*
|
|
4863
|
+
* @example
|
|
4864
|
+
* ```typescript
|
|
4865
|
+
* import { getPositionPnlPercent } from "backtest-kit";
|
|
4866
|
+
*
|
|
4867
|
+
* const pnlPct = await getPositionPnlPercent("BTCUSDT");
|
|
4868
|
+
* // LONG at 100, current=105: pnlPct ≈ 5
|
|
4869
|
+
* // LONG at 100, current=95: pnlPct ≈ -5
|
|
4870
|
+
* ```
|
|
4871
|
+
*/
|
|
4766
4872
|
declare function getPositionPnlPercent(symbol: string): Promise<number | null>;
|
|
4767
4873
|
/**
|
|
4768
4874
|
* Executes partial close at profit level by absolute dollar amount (moving toward TP).
|
|
@@ -4824,6 +4930,29 @@ declare function commitPartialProfitCost(symbol: string, dollarAmount: number):
|
|
|
4824
4930
|
* ```
|
|
4825
4931
|
*/
|
|
4826
4932
|
declare function commitPartialLossCost(symbol: string, dollarAmount: number): Promise<boolean>;
|
|
4933
|
+
/**
|
|
4934
|
+
* Returns the unrealized PNL in dollars for the current pending signal at current market price.
|
|
4935
|
+
*
|
|
4936
|
+
* Calculated as: pnlPercentage / 100 × totalInvestedCost.
|
|
4937
|
+
* Accounts for partial closes, DCA entries, slippage and fees.
|
|
4938
|
+
*
|
|
4939
|
+
* Returns null if no pending signal exists.
|
|
4940
|
+
*
|
|
4941
|
+
* Automatically detects backtest/live mode from execution context.
|
|
4942
|
+
* Automatically fetches current price via getAveragePrice.
|
|
4943
|
+
*
|
|
4944
|
+
* @param symbol - Trading pair symbol
|
|
4945
|
+
* @returns Promise resolving to PNL in dollars or null
|
|
4946
|
+
*
|
|
4947
|
+
* @example
|
|
4948
|
+
* ```typescript
|
|
4949
|
+
* import { getPositionPnlCost } from "backtest-kit";
|
|
4950
|
+
*
|
|
4951
|
+
* const pnlCost = await getPositionPnlCost("BTCUSDT");
|
|
4952
|
+
* // LONG at 100, invested $100, current=105: pnlCost ≈ 5
|
|
4953
|
+
* // LONG at 100, invested $200 (DCA), current=95: pnlCost ≈ -10
|
|
4954
|
+
* ```
|
|
4955
|
+
*/
|
|
4827
4956
|
declare function getPositionPnlCost(symbol: string): Promise<number | null>;
|
|
4828
4957
|
/**
|
|
4829
4958
|
* Returns the list of DCA entry prices for the current pending signal.
|
|
@@ -4883,6 +5012,58 @@ declare function getPositionPartials(symbol: string): Promise<{
|
|
|
4883
5012
|
entryCountAtClose: number;
|
|
4884
5013
|
debugTimestamp?: number;
|
|
4885
5014
|
}[]>;
|
|
5015
|
+
/**
|
|
5016
|
+
* Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
|
|
5017
|
+
* Use this to prevent duplicate DCA entries at the same price area.
|
|
5018
|
+
*
|
|
5019
|
+
* Returns true if currentPrice is within [level - lowerStep, level + upperStep] for any level,
|
|
5020
|
+
* where step = level * percent / 100.
|
|
5021
|
+
* Returns false if no pending signal exists.
|
|
5022
|
+
*
|
|
5023
|
+
* @param symbol - Trading pair symbol
|
|
5024
|
+
* @param currentPrice - Price to check against existing DCA levels
|
|
5025
|
+
* @param ladder - Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)
|
|
5026
|
+
* @returns Promise<boolean> - true if price overlaps an existing entry level (DCA not recommended)
|
|
5027
|
+
*
|
|
5028
|
+
* @example
|
|
5029
|
+
* ```typescript
|
|
5030
|
+
* import { getPositionEntryOverlap } from "backtest-kit";
|
|
5031
|
+
*
|
|
5032
|
+
* // LONG with levels [43000, 42000], check if 42100 is too close to 42000
|
|
5033
|
+
* const overlap = await getPositionEntryOverlap("BTCUSDT", 42100, { upperPercent: 5, lowerPercent: 5 });
|
|
5034
|
+
* // overlap = true (42100 is within 5% of 42000 = [39900, 44100])
|
|
5035
|
+
* if (!overlap) {
|
|
5036
|
+
* await commitAverageBuy("BTCUSDT");
|
|
5037
|
+
* }
|
|
5038
|
+
* ```
|
|
5039
|
+
*/
|
|
5040
|
+
declare function getPositionEntryOverlap(symbol: string, currentPrice: number, ladder?: IPositionOverlapLadder): Promise<boolean>;
|
|
5041
|
+
/**
|
|
5042
|
+
* Checks whether the current price falls within the tolerance zone of any existing partial close price.
|
|
5043
|
+
* Use this to prevent duplicate partial closes at the same price area.
|
|
5044
|
+
*
|
|
5045
|
+
* Returns true if currentPrice is within [partial.currentPrice - lowerStep, partial.currentPrice + upperStep]
|
|
5046
|
+
* for any partial, where step = partial.currentPrice * percent / 100.
|
|
5047
|
+
* Returns false if no pending signal exists or no partials have been executed yet.
|
|
5048
|
+
*
|
|
5049
|
+
* @param symbol - Trading pair symbol
|
|
5050
|
+
* @param currentPrice - Price to check against existing partial close prices
|
|
5051
|
+
* @param ladder - Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)
|
|
5052
|
+
* @returns Promise<boolean> - true if price overlaps an existing partial price (partial not recommended)
|
|
5053
|
+
*
|
|
5054
|
+
* @example
|
|
5055
|
+
* ```typescript
|
|
5056
|
+
* import { getPositionPartialOverlap } from "backtest-kit";
|
|
5057
|
+
*
|
|
5058
|
+
* // Partials at [45000], check if 45100 is too close
|
|
5059
|
+
* const overlap = await getPositionPartialOverlap("BTCUSDT", 45100, { upperPercent: 1.5, lowerPercent: 1.5 });
|
|
5060
|
+
* // overlap = true (45100 is within 1.5% of 45000)
|
|
5061
|
+
* if (!overlap) {
|
|
5062
|
+
* await commitPartialProfit("BTCUSDT", 50);
|
|
5063
|
+
* }
|
|
5064
|
+
* ```
|
|
5065
|
+
*/
|
|
5066
|
+
declare function getPositionPartialOverlap(symbol: string, currentPrice: number, ladder?: IPositionOverlapLadder): Promise<boolean>;
|
|
4886
5067
|
|
|
4887
5068
|
/**
|
|
4888
5069
|
* Stops the strategy from generating new signals.
|
|
@@ -5165,9 +5346,17 @@ declare const GLOBAL_CONFIG: {
|
|
|
5165
5346
|
* Allows to commitAverageBuy if currentPrice is not the lowest price since entry, but still lower than priceOpen.
|
|
5166
5347
|
* This can help improve average entry price in cases where price has rebounded after entry but is still below priceOpen, without waiting for a new lower price.
|
|
5167
5348
|
*
|
|
5168
|
-
* Default:
|
|
5349
|
+
* Default: false (DCA logic enabled only when antirecord is broken)
|
|
5169
5350
|
*/
|
|
5170
5351
|
CC_ENABLE_DCA_EVERYWHERE: boolean;
|
|
5352
|
+
/**
|
|
5353
|
+
* Enables PPPL (Partial Profit, Partial Loss) logic even if this breaks a direction of exits
|
|
5354
|
+
* Allows to take partial profit or loss on a position even if it results in a mix of profit and loss exits
|
|
5355
|
+
* This can help lock in profits or cut losses on part of the position without waiting for a perfect exit scenario.
|
|
5356
|
+
*
|
|
5357
|
+
* Default: false (PPPL logic is only applied when it does not break the direction of exits, ensuring clearer profit/loss outcomes)
|
|
5358
|
+
*/
|
|
5359
|
+
CC_ENABLE_PPPL_EVERYWHERE: boolean;
|
|
5171
5360
|
/**
|
|
5172
5361
|
* Cost of entering a position (in USD).
|
|
5173
5362
|
* This is used as a default value for calculating position size and risk management when cost data is not provided by the strategy
|
|
@@ -5288,6 +5477,7 @@ declare function getConfig(): {
|
|
|
5288
5477
|
CC_MAX_LOG_LINES: number;
|
|
5289
5478
|
CC_ENABLE_CANDLE_FETCH_MUTEX: boolean;
|
|
5290
5479
|
CC_ENABLE_DCA_EVERYWHERE: boolean;
|
|
5480
|
+
CC_ENABLE_PPPL_EVERYWHERE: boolean;
|
|
5291
5481
|
CC_POSITION_ENTRY_COST: number;
|
|
5292
5482
|
};
|
|
5293
5483
|
/**
|
|
@@ -5329,6 +5519,7 @@ declare function getDefaultConfig(): Readonly<{
|
|
|
5329
5519
|
CC_MAX_LOG_LINES: number;
|
|
5330
5520
|
CC_ENABLE_CANDLE_FETCH_MUTEX: boolean;
|
|
5331
5521
|
CC_ENABLE_DCA_EVERYWHERE: boolean;
|
|
5522
|
+
CC_ENABLE_PPPL_EVERYWHERE: boolean;
|
|
5332
5523
|
CC_POSITION_ENTRY_COST: number;
|
|
5333
5524
|
}>;
|
|
5334
5525
|
/**
|
|
@@ -11673,6 +11864,44 @@ declare class BacktestUtils {
|
|
|
11673
11864
|
price: number;
|
|
11674
11865
|
cost: number;
|
|
11675
11866
|
}[]>;
|
|
11867
|
+
/**
|
|
11868
|
+
* Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
|
|
11869
|
+
* Use this to prevent duplicate DCA entries at the same price area.
|
|
11870
|
+
*
|
|
11871
|
+
* Returns true if currentPrice is within [level - lowerStep, level + upperStep] for any level,
|
|
11872
|
+
* where step = level * percent / 100.
|
|
11873
|
+
* Returns false if no pending signal exists.
|
|
11874
|
+
*
|
|
11875
|
+
* @param symbol - Trading pair symbol
|
|
11876
|
+
* @param currentPrice - Price to check against existing DCA levels
|
|
11877
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
11878
|
+
* @param ladder - Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)
|
|
11879
|
+
* @returns true if price overlaps an existing entry level (DCA not recommended)
|
|
11880
|
+
*/
|
|
11881
|
+
getPositionEntryOverlap: (symbol: string, currentPrice: number, context: {
|
|
11882
|
+
strategyName: StrategyName;
|
|
11883
|
+
exchangeName: ExchangeName;
|
|
11884
|
+
frameName: FrameName;
|
|
11885
|
+
}, ladder?: IPositionOverlapLadder) => Promise<boolean>;
|
|
11886
|
+
/**
|
|
11887
|
+
* Checks whether the current price falls within the tolerance zone of any existing partial close price.
|
|
11888
|
+
* Use this to prevent duplicate partial closes at the same price area.
|
|
11889
|
+
*
|
|
11890
|
+
* Returns true if currentPrice is within [partial.currentPrice - lowerStep, partial.currentPrice + upperStep]
|
|
11891
|
+
* for any partial, where step = partial.currentPrice * percent / 100.
|
|
11892
|
+
* Returns false if no pending signal exists or no partials have been executed yet.
|
|
11893
|
+
*
|
|
11894
|
+
* @param symbol - Trading pair symbol
|
|
11895
|
+
* @param currentPrice - Price to check against existing partial close prices
|
|
11896
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
11897
|
+
* @param ladder - Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)
|
|
11898
|
+
* @returns true if price overlaps an existing partial price (partial not recommended)
|
|
11899
|
+
*/
|
|
11900
|
+
getPositionPartialOverlap: (symbol: string, currentPrice: number, context: {
|
|
11901
|
+
strategyName: StrategyName;
|
|
11902
|
+
exchangeName: ExchangeName;
|
|
11903
|
+
frameName: FrameName;
|
|
11904
|
+
}, ladder?: IPositionOverlapLadder) => Promise<boolean>;
|
|
11676
11905
|
/**
|
|
11677
11906
|
* Stops the strategy from generating new signals.
|
|
11678
11907
|
*
|
|
@@ -12755,6 +12984,42 @@ declare class LiveUtils {
|
|
|
12755
12984
|
price: number;
|
|
12756
12985
|
cost: number;
|
|
12757
12986
|
}[]>;
|
|
12987
|
+
/**
|
|
12988
|
+
* Checks whether the current price falls within the tolerance zone of any existing DCA entry level.
|
|
12989
|
+
* Use this to prevent duplicate DCA entries at the same price area.
|
|
12990
|
+
*
|
|
12991
|
+
* Returns true if currentPrice is within [level - lowerStep, level + upperStep] for any level,
|
|
12992
|
+
* where step = level * percent / 100.
|
|
12993
|
+
* Returns false if no pending signal exists.
|
|
12994
|
+
*
|
|
12995
|
+
* @param symbol - Trading pair symbol
|
|
12996
|
+
* @param currentPrice - Price to check against existing DCA levels
|
|
12997
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
12998
|
+
* @param ladder - Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)
|
|
12999
|
+
* @returns true if price overlaps an existing entry level (DCA not recommended)
|
|
13000
|
+
*/
|
|
13001
|
+
getPositionEntryOverlap: (symbol: string, currentPrice: number, context: {
|
|
13002
|
+
strategyName: StrategyName;
|
|
13003
|
+
exchangeName: ExchangeName;
|
|
13004
|
+
}, ladder?: IPositionOverlapLadder) => Promise<boolean>;
|
|
13005
|
+
/**
|
|
13006
|
+
* Checks whether the current price falls within the tolerance zone of any existing partial close price.
|
|
13007
|
+
* Use this to prevent duplicate partial closes at the same price area.
|
|
13008
|
+
*
|
|
13009
|
+
* Returns true if currentPrice is within [partial.currentPrice - lowerStep, partial.currentPrice + upperStep]
|
|
13010
|
+
* for any partial, where step = partial.currentPrice * percent / 100.
|
|
13011
|
+
* Returns false if no pending signal exists or no partials have been executed yet.
|
|
13012
|
+
*
|
|
13013
|
+
* @param symbol - Trading pair symbol
|
|
13014
|
+
* @param currentPrice - Price to check against existing partial close prices
|
|
13015
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
13016
|
+
* @param ladder - Tolerance zone config; percentages in 0–100 format (default: 1.5% up and down)
|
|
13017
|
+
* @returns true if price overlaps an existing partial price (partial not recommended)
|
|
13018
|
+
*/
|
|
13019
|
+
getPositionPartialOverlap: (symbol: string, currentPrice: number, context: {
|
|
13020
|
+
strategyName: StrategyName;
|
|
13021
|
+
exchangeName: ExchangeName;
|
|
13022
|
+
}, ladder?: IPositionOverlapLadder) => Promise<boolean>;
|
|
12758
13023
|
/**
|
|
12759
13024
|
* Stops the strategy from generating new signals.
|
|
12760
13025
|
*
|
|
@@ -18239,15 +18504,6 @@ declare class ActionBase implements IPublicAction {
|
|
|
18239
18504
|
* ```
|
|
18240
18505
|
*/
|
|
18241
18506
|
riskRejection(event: RiskContract, source?: string): void | Promise<void>;
|
|
18242
|
-
/**
|
|
18243
|
-
* Gate for position open/close via limit order. Default allows all.
|
|
18244
|
-
* Throw to reject — framework retries next tick.
|
|
18245
|
-
*
|
|
18246
|
-
* NOTE: Exceptions are NOT swallowed — they propagate to CREATE_SYNC_FN.
|
|
18247
|
-
*
|
|
18248
|
-
* @param event - Sync event with action "signal-open" or "signal-close"
|
|
18249
|
-
*/
|
|
18250
|
-
signalSync(_event: SignalSyncContract, source?: string): void | Promise<void>;
|
|
18251
18507
|
/**
|
|
18252
18508
|
* Cleans up resources and subscriptions when action handler is disposed.
|
|
18253
18509
|
*
|
|
@@ -18483,6 +18739,8 @@ type BrokerTrailingStopPayload = {
|
|
|
18483
18739
|
currentPrice: number;
|
|
18484
18740
|
/** Absolute stop-loss price after applying percentShift */
|
|
18485
18741
|
newStopLossPrice: number;
|
|
18742
|
+
/** Active take profit price at the time of the trailing update */
|
|
18743
|
+
takeProfitPrice: number;
|
|
18486
18744
|
/** Position direction */
|
|
18487
18745
|
position: "long" | "short";
|
|
18488
18746
|
/** Strategy/exchange/frame routing context */
|
|
@@ -18523,6 +18781,8 @@ type BrokerTrailingTakePayload = {
|
|
|
18523
18781
|
currentPrice: number;
|
|
18524
18782
|
/** Absolute take-profit price after applying percentShift */
|
|
18525
18783
|
newTakeProfitPrice: number;
|
|
18784
|
+
/** Active take profit price at the time of the trailing update */
|
|
18785
|
+
takeProfitPrice: number;
|
|
18526
18786
|
/** Position direction */
|
|
18527
18787
|
position: "long" | "short";
|
|
18528
18788
|
/** Strategy/exchange/frame routing context */
|
|
@@ -25172,4 +25432,4 @@ declare const getTotalClosed: (signal: Signal) => {
|
|
|
25172
25432
|
remainingCostBasis: number;
|
|
25173
25433
|
};
|
|
25174
25434
|
|
|
25175
|
-
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, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, 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 IBroker, 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 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 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, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, 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, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };
|
|
25435
|
+
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, Broker, type BrokerAverageBuyPayload, BrokerBase, type BrokerBreakevenPayload, type BrokerPartialLossPayload, type BrokerPartialProfitPayload, type BrokerSignalClosePayload, type BrokerSignalOpenPayload, type BrokerTrailingStopPayload, type BrokerTrailingTakePayload, 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 IBroker, 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 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 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, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, 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, getPositionEntryOverlap, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionPartialOverlap, 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, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, roundTicks, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, waitForCandle, warmCandles };
|