backtest-kit 2.2.18 → 2.2.20
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 +340 -64
- package/build/index.mjs +340 -64
- package/package.json +1 -1
- package/types.d.ts +281 -17
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -559,7 +559,7 @@ interface IRiskCheckArgs {
|
|
|
559
559
|
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
560
560
|
symbol: string;
|
|
561
561
|
/** Pending signal to apply */
|
|
562
|
-
|
|
562
|
+
currentSignal: IPublicSignalRow;
|
|
563
563
|
/** Strategy name requesting to open a position */
|
|
564
564
|
strategyName: StrategyName;
|
|
565
565
|
/** Exchange name */
|
|
@@ -612,8 +612,8 @@ interface IRiskCallbacks {
|
|
|
612
612
|
* Extends IRiskCheckArgs with portfolio state data.
|
|
613
613
|
*/
|
|
614
614
|
interface IRiskValidationPayload extends IRiskCheckArgs {
|
|
615
|
-
/**
|
|
616
|
-
|
|
615
|
+
/** Current signal being validated (IRiskSignalRow is calculated internally so priceOpen always exist) */
|
|
616
|
+
currentSignal: IRiskSignalRow;
|
|
617
617
|
/** Number of currently active positions across all strategies */
|
|
618
618
|
activePositionCount: number;
|
|
619
619
|
/** List of currently active positions across all strategies */
|
|
@@ -1036,6 +1036,14 @@ interface PartialProfitCommit extends SignalCommitBase {
|
|
|
1036
1036
|
action: "partial-profit";
|
|
1037
1037
|
percentToClose: number;
|
|
1038
1038
|
currentPrice: number;
|
|
1039
|
+
position: "long" | "short";
|
|
1040
|
+
priceOpen: number;
|
|
1041
|
+
priceTakeProfit: number;
|
|
1042
|
+
priceStopLoss: number;
|
|
1043
|
+
originalPriceTakeProfit: number;
|
|
1044
|
+
originalPriceStopLoss: number;
|
|
1045
|
+
scheduledAt: number;
|
|
1046
|
+
pendingAt: number;
|
|
1039
1047
|
}
|
|
1040
1048
|
/**
|
|
1041
1049
|
* Partial loss event.
|
|
@@ -1044,6 +1052,14 @@ interface PartialLossCommit extends SignalCommitBase {
|
|
|
1044
1052
|
action: "partial-loss";
|
|
1045
1053
|
percentToClose: number;
|
|
1046
1054
|
currentPrice: number;
|
|
1055
|
+
position: "long" | "short";
|
|
1056
|
+
priceOpen: number;
|
|
1057
|
+
priceTakeProfit: number;
|
|
1058
|
+
priceStopLoss: number;
|
|
1059
|
+
originalPriceTakeProfit: number;
|
|
1060
|
+
originalPriceStopLoss: number;
|
|
1061
|
+
scheduledAt: number;
|
|
1062
|
+
pendingAt: number;
|
|
1047
1063
|
}
|
|
1048
1064
|
/**
|
|
1049
1065
|
* Trailing stop event.
|
|
@@ -1052,6 +1068,14 @@ interface TrailingStopCommit extends SignalCommitBase {
|
|
|
1052
1068
|
action: "trailing-stop";
|
|
1053
1069
|
percentShift: number;
|
|
1054
1070
|
currentPrice: number;
|
|
1071
|
+
position: "long" | "short";
|
|
1072
|
+
priceOpen: number;
|
|
1073
|
+
priceTakeProfit: number;
|
|
1074
|
+
priceStopLoss: number;
|
|
1075
|
+
originalPriceTakeProfit: number;
|
|
1076
|
+
originalPriceStopLoss: number;
|
|
1077
|
+
scheduledAt: number;
|
|
1078
|
+
pendingAt: number;
|
|
1055
1079
|
}
|
|
1056
1080
|
/**
|
|
1057
1081
|
* Trailing take event.
|
|
@@ -1060,6 +1084,14 @@ interface TrailingTakeCommit extends SignalCommitBase {
|
|
|
1060
1084
|
action: "trailing-take";
|
|
1061
1085
|
percentShift: number;
|
|
1062
1086
|
currentPrice: number;
|
|
1087
|
+
position: "long" | "short";
|
|
1088
|
+
priceOpen: number;
|
|
1089
|
+
priceTakeProfit: number;
|
|
1090
|
+
priceStopLoss: number;
|
|
1091
|
+
originalPriceTakeProfit: number;
|
|
1092
|
+
originalPriceStopLoss: number;
|
|
1093
|
+
scheduledAt: number;
|
|
1094
|
+
pendingAt: number;
|
|
1063
1095
|
}
|
|
1064
1096
|
/**
|
|
1065
1097
|
* Breakeven event.
|
|
@@ -1067,6 +1099,14 @@ interface TrailingTakeCommit extends SignalCommitBase {
|
|
|
1067
1099
|
interface BreakevenCommit extends SignalCommitBase {
|
|
1068
1100
|
action: "breakeven";
|
|
1069
1101
|
currentPrice: number;
|
|
1102
|
+
position: "long" | "short";
|
|
1103
|
+
priceOpen: number;
|
|
1104
|
+
priceTakeProfit: number;
|
|
1105
|
+
priceStopLoss: number;
|
|
1106
|
+
originalPriceTakeProfit: number;
|
|
1107
|
+
originalPriceStopLoss: number;
|
|
1108
|
+
scheduledAt: number;
|
|
1109
|
+
pendingAt: number;
|
|
1070
1110
|
}
|
|
1071
1111
|
/**
|
|
1072
1112
|
* Discriminated union for strategy management signal events.
|
|
@@ -2523,7 +2563,7 @@ interface RiskContract {
|
|
|
2523
2563
|
* Pending signal to apply.
|
|
2524
2564
|
* Contains signal details (position, priceOpen, priceTakeProfit, priceStopLoss, etc).
|
|
2525
2565
|
*/
|
|
2526
|
-
|
|
2566
|
+
currentSignal: ISignalDto;
|
|
2527
2567
|
/**
|
|
2528
2568
|
* Strategy name requesting to open a position.
|
|
2529
2569
|
* Identifies which strategy attempted to create the signal.
|
|
@@ -6664,6 +6704,18 @@ interface PartialProfitAvailableNotification {
|
|
|
6664
6704
|
priceOpen: number;
|
|
6665
6705
|
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6666
6706
|
position: "long" | "short";
|
|
6707
|
+
/** Effective take profit price (with trailing if set) */
|
|
6708
|
+
priceTakeProfit: number;
|
|
6709
|
+
/** Effective stop loss price (with trailing if set) */
|
|
6710
|
+
priceStopLoss: number;
|
|
6711
|
+
/** Original take profit price before any trailing adjustments */
|
|
6712
|
+
originalPriceTakeProfit: number;
|
|
6713
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6714
|
+
originalPriceStopLoss: number;
|
|
6715
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6716
|
+
scheduledAt: number;
|
|
6717
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6718
|
+
pendingAt: number;
|
|
6667
6719
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6668
6720
|
createdAt: number;
|
|
6669
6721
|
}
|
|
@@ -6696,6 +6748,18 @@ interface PartialLossAvailableNotification {
|
|
|
6696
6748
|
priceOpen: number;
|
|
6697
6749
|
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6698
6750
|
position: "long" | "short";
|
|
6751
|
+
/** Effective take profit price (with trailing if set) */
|
|
6752
|
+
priceTakeProfit: number;
|
|
6753
|
+
/** Effective stop loss price (with trailing if set) */
|
|
6754
|
+
priceStopLoss: number;
|
|
6755
|
+
/** Original take profit price before any trailing adjustments */
|
|
6756
|
+
originalPriceTakeProfit: number;
|
|
6757
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6758
|
+
originalPriceStopLoss: number;
|
|
6759
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6760
|
+
scheduledAt: number;
|
|
6761
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6762
|
+
pendingAt: number;
|
|
6699
6763
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6700
6764
|
createdAt: number;
|
|
6701
6765
|
}
|
|
@@ -6726,6 +6790,18 @@ interface BreakevenAvailableNotification {
|
|
|
6726
6790
|
priceOpen: number;
|
|
6727
6791
|
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6728
6792
|
position: "long" | "short";
|
|
6793
|
+
/** Effective take profit price (with trailing if set) */
|
|
6794
|
+
priceTakeProfit: number;
|
|
6795
|
+
/** Effective stop loss price (with trailing if set) */
|
|
6796
|
+
priceStopLoss: number;
|
|
6797
|
+
/** Original take profit price before any trailing adjustments */
|
|
6798
|
+
originalPriceTakeProfit: number;
|
|
6799
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6800
|
+
originalPriceStopLoss: number;
|
|
6801
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6802
|
+
scheduledAt: number;
|
|
6803
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6804
|
+
pendingAt: number;
|
|
6729
6805
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6730
6806
|
createdAt: number;
|
|
6731
6807
|
}
|
|
@@ -6752,6 +6828,22 @@ interface PartialProfitCommitNotification {
|
|
|
6752
6828
|
percentToClose: number;
|
|
6753
6829
|
/** Current market price when partial was executed */
|
|
6754
6830
|
currentPrice: number;
|
|
6831
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6832
|
+
position: "long" | "short";
|
|
6833
|
+
/** Entry price for the position */
|
|
6834
|
+
priceOpen: number;
|
|
6835
|
+
/** Effective take profit price (with trailing if set) */
|
|
6836
|
+
priceTakeProfit: number;
|
|
6837
|
+
/** Effective stop loss price (with trailing if set) */
|
|
6838
|
+
priceStopLoss: number;
|
|
6839
|
+
/** Original take profit price before any trailing adjustments */
|
|
6840
|
+
originalPriceTakeProfit: number;
|
|
6841
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6842
|
+
originalPriceStopLoss: number;
|
|
6843
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6844
|
+
scheduledAt: number;
|
|
6845
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6846
|
+
pendingAt: number;
|
|
6755
6847
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6756
6848
|
createdAt: number;
|
|
6757
6849
|
}
|
|
@@ -6778,6 +6870,22 @@ interface PartialLossCommitNotification {
|
|
|
6778
6870
|
percentToClose: number;
|
|
6779
6871
|
/** Current market price when partial was executed */
|
|
6780
6872
|
currentPrice: number;
|
|
6873
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6874
|
+
position: "long" | "short";
|
|
6875
|
+
/** Entry price for the position */
|
|
6876
|
+
priceOpen: number;
|
|
6877
|
+
/** Effective take profit price (with trailing if set) */
|
|
6878
|
+
priceTakeProfit: number;
|
|
6879
|
+
/** Effective stop loss price (with trailing if set) */
|
|
6880
|
+
priceStopLoss: number;
|
|
6881
|
+
/** Original take profit price before any trailing adjustments */
|
|
6882
|
+
originalPriceTakeProfit: number;
|
|
6883
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6884
|
+
originalPriceStopLoss: number;
|
|
6885
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6886
|
+
scheduledAt: number;
|
|
6887
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6888
|
+
pendingAt: number;
|
|
6781
6889
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6782
6890
|
createdAt: number;
|
|
6783
6891
|
}
|
|
@@ -6802,6 +6910,22 @@ interface BreakevenCommitNotification {
|
|
|
6802
6910
|
exchangeName: ExchangeName;
|
|
6803
6911
|
/** Current market price when breakeven was executed */
|
|
6804
6912
|
currentPrice: number;
|
|
6913
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6914
|
+
position: "long" | "short";
|
|
6915
|
+
/** Entry price for the position */
|
|
6916
|
+
priceOpen: number;
|
|
6917
|
+
/** Effective take profit price (with trailing if set) */
|
|
6918
|
+
priceTakeProfit: number;
|
|
6919
|
+
/** Effective stop loss price (with trailing if set, after breakeven this equals priceOpen) */
|
|
6920
|
+
priceStopLoss: number;
|
|
6921
|
+
/** Original take profit price before any trailing adjustments */
|
|
6922
|
+
originalPriceTakeProfit: number;
|
|
6923
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6924
|
+
originalPriceStopLoss: number;
|
|
6925
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6926
|
+
scheduledAt: number;
|
|
6927
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6928
|
+
pendingAt: number;
|
|
6805
6929
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6806
6930
|
createdAt: number;
|
|
6807
6931
|
}
|
|
@@ -6828,6 +6952,22 @@ interface TrailingStopCommitNotification {
|
|
|
6828
6952
|
percentShift: number;
|
|
6829
6953
|
/** Current market price when trailing stop was executed */
|
|
6830
6954
|
currentPrice: number;
|
|
6955
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6956
|
+
position: "long" | "short";
|
|
6957
|
+
/** Entry price for the position */
|
|
6958
|
+
priceOpen: number;
|
|
6959
|
+
/** Effective take profit price (with trailing if set) */
|
|
6960
|
+
priceTakeProfit: number;
|
|
6961
|
+
/** Effective stop loss price after trailing adjustment */
|
|
6962
|
+
priceStopLoss: number;
|
|
6963
|
+
/** Original take profit price before any trailing adjustments */
|
|
6964
|
+
originalPriceTakeProfit: number;
|
|
6965
|
+
/** Original stop loss price before any trailing adjustments */
|
|
6966
|
+
originalPriceStopLoss: number;
|
|
6967
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
6968
|
+
scheduledAt: number;
|
|
6969
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
6970
|
+
pendingAt: number;
|
|
6831
6971
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6832
6972
|
createdAt: number;
|
|
6833
6973
|
}
|
|
@@ -6854,6 +6994,22 @@ interface TrailingTakeCommitNotification {
|
|
|
6854
6994
|
percentShift: number;
|
|
6855
6995
|
/** Current market price when trailing take was executed */
|
|
6856
6996
|
currentPrice: number;
|
|
6997
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
6998
|
+
position: "long" | "short";
|
|
6999
|
+
/** Entry price for the position */
|
|
7000
|
+
priceOpen: number;
|
|
7001
|
+
/** Effective take profit price after trailing adjustment */
|
|
7002
|
+
priceTakeProfit: number;
|
|
7003
|
+
/** Effective stop loss price (with trailing if set) */
|
|
7004
|
+
priceStopLoss: number;
|
|
7005
|
+
/** Original take profit price before any trailing adjustments */
|
|
7006
|
+
originalPriceTakeProfit: number;
|
|
7007
|
+
/** Original stop loss price before any trailing adjustments */
|
|
7008
|
+
originalPriceStopLoss: number;
|
|
7009
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7010
|
+
scheduledAt: number;
|
|
7011
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
7012
|
+
pendingAt: number;
|
|
6857
7013
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6858
7014
|
createdAt: number;
|
|
6859
7015
|
}
|
|
@@ -6884,8 +7040,20 @@ interface RiskRejectionNotification {
|
|
|
6884
7040
|
activePositionCount: number;
|
|
6885
7041
|
/** Current market price when rejection occurred */
|
|
6886
7042
|
currentPrice: number;
|
|
6887
|
-
/**
|
|
6888
|
-
|
|
7043
|
+
/** Unique signal identifier from pending signal (may be undefined if not provided) */
|
|
7044
|
+
signalId: string | undefined;
|
|
7045
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
7046
|
+
position: "long" | "short";
|
|
7047
|
+
/** Entry price for the position (may be undefined if not provided) */
|
|
7048
|
+
priceOpen: number | undefined;
|
|
7049
|
+
/** Take profit target price */
|
|
7050
|
+
priceTakeProfit: number;
|
|
7051
|
+
/** Stop loss exit price */
|
|
7052
|
+
priceStopLoss: number;
|
|
7053
|
+
/** Expected duration in minutes before time_expired */
|
|
7054
|
+
minuteEstimatedTime: number;
|
|
7055
|
+
/** Optional human-readable description of signal reason */
|
|
7056
|
+
signalNote?: string;
|
|
6889
7057
|
/** Unix timestamp in milliseconds when the notification was created */
|
|
6890
7058
|
createdAt: number;
|
|
6891
7059
|
}
|
|
@@ -7391,7 +7559,7 @@ interface RiskEvent {
|
|
|
7391
7559
|
/** Trading pair symbol */
|
|
7392
7560
|
symbol: string;
|
|
7393
7561
|
/** Pending signal details */
|
|
7394
|
-
|
|
7562
|
+
currentSignal: IRiskSignalRow;
|
|
7395
7563
|
/** Strategy name */
|
|
7396
7564
|
strategyName: StrategyName;
|
|
7397
7565
|
/** Exchange name */
|
|
@@ -7471,6 +7639,22 @@ interface StrategyEvent {
|
|
|
7471
7639
|
createdAt: string;
|
|
7472
7640
|
/** True if backtest mode, false if live mode */
|
|
7473
7641
|
backtest: boolean;
|
|
7642
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
7643
|
+
position?: "long" | "short";
|
|
7644
|
+
/** Entry price for the position */
|
|
7645
|
+
priceOpen?: number;
|
|
7646
|
+
/** Effective take profit price (with trailing if set) */
|
|
7647
|
+
priceTakeProfit?: number;
|
|
7648
|
+
/** Effective stop loss price (with trailing if set) */
|
|
7649
|
+
priceStopLoss?: number;
|
|
7650
|
+
/** Original take profit price before any trailing adjustments */
|
|
7651
|
+
originalPriceTakeProfit?: number;
|
|
7652
|
+
/** Original stop loss price before any trailing adjustments */
|
|
7653
|
+
originalPriceStopLoss?: number;
|
|
7654
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7655
|
+
scheduledAt?: number;
|
|
7656
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
7657
|
+
pendingAt?: number;
|
|
7474
7658
|
}
|
|
7475
7659
|
/**
|
|
7476
7660
|
* Statistical data calculated from strategy events.
|
|
@@ -14101,12 +14285,20 @@ declare class StrategyMarkdownService {
|
|
|
14101
14285
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14102
14286
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14103
14287
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14288
|
+
* @param position - Trade direction: "long" or "short"
|
|
14289
|
+
* @param priceOpen - Entry price for the position
|
|
14290
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14291
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14292
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14293
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14294
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14295
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14104
14296
|
*/
|
|
14105
14297
|
partialProfit: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14106
14298
|
strategyName: StrategyName;
|
|
14107
14299
|
exchangeName: ExchangeName;
|
|
14108
14300
|
frameName: FrameName;
|
|
14109
|
-
}, timestamp: number) => Promise<void>;
|
|
14301
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14110
14302
|
/**
|
|
14111
14303
|
* Records a partial-loss event when a portion of the position is closed at loss.
|
|
14112
14304
|
*
|
|
@@ -14116,12 +14308,20 @@ declare class StrategyMarkdownService {
|
|
|
14116
14308
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14117
14309
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14118
14310
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14311
|
+
* @param position - Trade direction: "long" or "short"
|
|
14312
|
+
* @param priceOpen - Entry price for the position
|
|
14313
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14314
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14315
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14316
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14317
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14318
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14119
14319
|
*/
|
|
14120
14320
|
partialLoss: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14121
14321
|
strategyName: StrategyName;
|
|
14122
14322
|
exchangeName: ExchangeName;
|
|
14123
14323
|
frameName: FrameName;
|
|
14124
|
-
}, timestamp: number) => Promise<void>;
|
|
14324
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14125
14325
|
/**
|
|
14126
14326
|
* Records a trailing-stop event when the stop-loss is adjusted.
|
|
14127
14327
|
*
|
|
@@ -14131,12 +14331,20 @@ declare class StrategyMarkdownService {
|
|
|
14131
14331
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14132
14332
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14133
14333
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14334
|
+
* @param position - Trade direction: "long" or "short"
|
|
14335
|
+
* @param priceOpen - Entry price for the position
|
|
14336
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14337
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14338
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14339
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14340
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14341
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14134
14342
|
*/
|
|
14135
14343
|
trailingStop: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14136
14344
|
strategyName: StrategyName;
|
|
14137
14345
|
exchangeName: ExchangeName;
|
|
14138
14346
|
frameName: FrameName;
|
|
14139
|
-
}, timestamp: number) => Promise<void>;
|
|
14347
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14140
14348
|
/**
|
|
14141
14349
|
* Records a trailing-take event when the take-profit is adjusted.
|
|
14142
14350
|
*
|
|
@@ -14146,12 +14354,20 @@ declare class StrategyMarkdownService {
|
|
|
14146
14354
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14147
14355
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14148
14356
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14357
|
+
* @param position - Trade direction: "long" or "short"
|
|
14358
|
+
* @param priceOpen - Entry price for the position
|
|
14359
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14360
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14361
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14362
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14363
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14364
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14149
14365
|
*/
|
|
14150
14366
|
trailingTake: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14151
14367
|
strategyName: StrategyName;
|
|
14152
14368
|
exchangeName: ExchangeName;
|
|
14153
14369
|
frameName: FrameName;
|
|
14154
|
-
}, timestamp: number) => Promise<void>;
|
|
14370
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14155
14371
|
/**
|
|
14156
14372
|
* Records a breakeven event when the stop-loss is moved to entry price.
|
|
14157
14373
|
*
|
|
@@ -14160,12 +14376,20 @@ declare class StrategyMarkdownService {
|
|
|
14160
14376
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14161
14377
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14162
14378
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14379
|
+
* @param position - Trade direction: "long" or "short"
|
|
14380
|
+
* @param priceOpen - Entry price for the position
|
|
14381
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14382
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14383
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14384
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14385
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14386
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14163
14387
|
*/
|
|
14164
14388
|
breakeven: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
|
|
14165
14389
|
strategyName: StrategyName;
|
|
14166
14390
|
exchangeName: ExchangeName;
|
|
14167
14391
|
frameName: FrameName;
|
|
14168
|
-
}, timestamp: number) => Promise<void>;
|
|
14392
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14169
14393
|
/**
|
|
14170
14394
|
* Retrieves aggregated statistics from accumulated strategy events.
|
|
14171
14395
|
*
|
|
@@ -19583,12 +19807,20 @@ declare class StrategyReportService {
|
|
|
19583
19807
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19584
19808
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19585
19809
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19810
|
+
* @param position - Trade direction: "long" or "short"
|
|
19811
|
+
* @param priceOpen - Entry price for the position
|
|
19812
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19813
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19814
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19815
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19816
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19817
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19586
19818
|
*/
|
|
19587
19819
|
partialProfit: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19588
19820
|
strategyName: StrategyName;
|
|
19589
19821
|
exchangeName: ExchangeName;
|
|
19590
19822
|
frameName: FrameName;
|
|
19591
|
-
}, timestamp: number) => Promise<void>;
|
|
19823
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19592
19824
|
/**
|
|
19593
19825
|
* Logs a partial-loss event when a portion of the position is closed at loss.
|
|
19594
19826
|
*
|
|
@@ -19598,12 +19830,20 @@ declare class StrategyReportService {
|
|
|
19598
19830
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19599
19831
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19600
19832
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19833
|
+
* @param position - Trade direction: "long" or "short"
|
|
19834
|
+
* @param priceOpen - Entry price for the position
|
|
19835
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19836
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19837
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19838
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19839
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19840
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19601
19841
|
*/
|
|
19602
19842
|
partialLoss: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19603
19843
|
strategyName: StrategyName;
|
|
19604
19844
|
exchangeName: ExchangeName;
|
|
19605
19845
|
frameName: FrameName;
|
|
19606
|
-
}, timestamp: number) => Promise<void>;
|
|
19846
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19607
19847
|
/**
|
|
19608
19848
|
* Logs a trailing-stop event when the stop-loss is adjusted.
|
|
19609
19849
|
*
|
|
@@ -19613,12 +19853,20 @@ declare class StrategyReportService {
|
|
|
19613
19853
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19614
19854
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19615
19855
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19856
|
+
* @param position - Trade direction: "long" or "short"
|
|
19857
|
+
* @param priceOpen - Entry price for the position
|
|
19858
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19859
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19860
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19861
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19862
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19863
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19616
19864
|
*/
|
|
19617
19865
|
trailingStop: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19618
19866
|
strategyName: StrategyName;
|
|
19619
19867
|
exchangeName: ExchangeName;
|
|
19620
19868
|
frameName: FrameName;
|
|
19621
|
-
}, timestamp: number) => Promise<void>;
|
|
19869
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19622
19870
|
/**
|
|
19623
19871
|
* Logs a trailing-take event when the take-profit is adjusted.
|
|
19624
19872
|
*
|
|
@@ -19628,12 +19876,20 @@ declare class StrategyReportService {
|
|
|
19628
19876
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19629
19877
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19630
19878
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19879
|
+
* @param position - Trade direction: "long" or "short"
|
|
19880
|
+
* @param priceOpen - Entry price for the position
|
|
19881
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19882
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19883
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19884
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19885
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19886
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19631
19887
|
*/
|
|
19632
19888
|
trailingTake: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19633
19889
|
strategyName: StrategyName;
|
|
19634
19890
|
exchangeName: ExchangeName;
|
|
19635
19891
|
frameName: FrameName;
|
|
19636
|
-
}, timestamp: number) => Promise<void>;
|
|
19892
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19637
19893
|
/**
|
|
19638
19894
|
* Logs a breakeven event when the stop-loss is moved to entry price.
|
|
19639
19895
|
*
|
|
@@ -19642,12 +19898,20 @@ declare class StrategyReportService {
|
|
|
19642
19898
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19643
19899
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19644
19900
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19901
|
+
* @param position - Trade direction: "long" or "short"
|
|
19902
|
+
* @param priceOpen - Entry price for the position
|
|
19903
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19904
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19905
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19906
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19907
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19908
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19645
19909
|
*/
|
|
19646
19910
|
breakeven: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
|
|
19647
19911
|
strategyName: StrategyName;
|
|
19648
19912
|
exchangeName: ExchangeName;
|
|
19649
19913
|
frameName: FrameName;
|
|
19650
|
-
}, timestamp: number) => Promise<void>;
|
|
19914
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19651
19915
|
/**
|
|
19652
19916
|
* Initializes the service for event logging.
|
|
19653
19917
|
*
|