backtest-kit 2.2.17 → 2.2.19
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 +1042 -242
- package/build/index.mjs +1041 -243
- package/package.json +1 -1
- package/types.d.ts +434 -143
package/types.d.ts
CHANGED
|
@@ -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.
|
|
@@ -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
|
}
|
|
@@ -7471,6 +7627,22 @@ interface StrategyEvent {
|
|
|
7471
7627
|
createdAt: string;
|
|
7472
7628
|
/** True if backtest mode, false if live mode */
|
|
7473
7629
|
backtest: boolean;
|
|
7630
|
+
/** Trade direction: "long" (buy) or "short" (sell) */
|
|
7631
|
+
position?: "long" | "short";
|
|
7632
|
+
/** Entry price for the position */
|
|
7633
|
+
priceOpen?: number;
|
|
7634
|
+
/** Effective take profit price (with trailing if set) */
|
|
7635
|
+
priceTakeProfit?: number;
|
|
7636
|
+
/** Effective stop loss price (with trailing if set) */
|
|
7637
|
+
priceStopLoss?: number;
|
|
7638
|
+
/** Original take profit price before any trailing adjustments */
|
|
7639
|
+
originalPriceTakeProfit?: number;
|
|
7640
|
+
/** Original stop loss price before any trailing adjustments */
|
|
7641
|
+
originalPriceStopLoss?: number;
|
|
7642
|
+
/** Signal creation timestamp in milliseconds (when signal was first created/scheduled) */
|
|
7643
|
+
scheduledAt?: number;
|
|
7644
|
+
/** Pending timestamp in milliseconds (when position became pending/active at priceOpen) */
|
|
7645
|
+
pendingAt?: number;
|
|
7474
7646
|
}
|
|
7475
7647
|
/**
|
|
7476
7648
|
* Statistical data calculated from strategy events.
|
|
@@ -12562,219 +12734,258 @@ declare class RiskUtils {
|
|
|
12562
12734
|
*/
|
|
12563
12735
|
declare const Risk: RiskUtils;
|
|
12564
12736
|
|
|
12737
|
+
/**
|
|
12738
|
+
* Type alias for signal storage row identifier.
|
|
12739
|
+
* Extracted from IStorageSignalRow for type safety and reusability.
|
|
12740
|
+
*/
|
|
12565
12741
|
type StorageId = IStorageSignalRow["id"];
|
|
12566
12742
|
/**
|
|
12567
|
-
*
|
|
12568
|
-
*
|
|
12569
|
-
* Stores trading signal history for admin dashboard display during backtesting
|
|
12570
|
-
* with automatic initialization, deduplication, and storage limits.
|
|
12571
|
-
*
|
|
12572
|
-
* @example
|
|
12573
|
-
* ```typescript
|
|
12574
|
-
* import { StorageBacktestUtils } from "./classes/Storage";
|
|
12575
|
-
*
|
|
12576
|
-
* const storage = new StorageBacktestUtils();
|
|
12577
|
-
*
|
|
12578
|
-
* // Handle signal events
|
|
12579
|
-
* await storage.handleOpened(tickResult);
|
|
12580
|
-
* await storage.handleClosed(tickResult);
|
|
12581
|
-
*
|
|
12582
|
-
* // Query signals
|
|
12583
|
-
* const signal = await storage.findById("signal-123");
|
|
12584
|
-
* const allSignals = await storage.list();
|
|
12585
|
-
* ```
|
|
12743
|
+
* Base interface for storage adapters.
|
|
12744
|
+
* All storage adapters must implement this interface.
|
|
12586
12745
|
*/
|
|
12587
|
-
|
|
12588
|
-
private _signals;
|
|
12746
|
+
interface IStorageUtils {
|
|
12589
12747
|
/**
|
|
12590
|
-
*
|
|
12591
|
-
*
|
|
12748
|
+
* Handles signal opened event.
|
|
12749
|
+
* @param tick - The opened signal tick data
|
|
12592
12750
|
*/
|
|
12593
|
-
|
|
12751
|
+
handleOpened(tick: IStrategyTickResultOpened): Promise<void>;
|
|
12594
12752
|
/**
|
|
12595
|
-
*
|
|
12596
|
-
*
|
|
12597
|
-
|
|
12598
|
-
|
|
12753
|
+
* Handles signal closed event.
|
|
12754
|
+
* @param tick - The closed signal tick data
|
|
12755
|
+
*/
|
|
12756
|
+
handleClosed(tick: IStrategyTickResultClosed): Promise<void>;
|
|
12757
|
+
/**
|
|
12758
|
+
* Handles signal scheduled event.
|
|
12759
|
+
* @param tick - The scheduled signal tick data
|
|
12760
|
+
*/
|
|
12761
|
+
handleScheduled(tick: IStrategyTickResultScheduled): Promise<void>;
|
|
12762
|
+
/**
|
|
12763
|
+
* Handles signal cancelled event.
|
|
12764
|
+
* @param tick - The cancelled signal tick data
|
|
12765
|
+
*/
|
|
12766
|
+
handleCancelled(tick: IStrategyTickResultCancelled): Promise<void>;
|
|
12767
|
+
/**
|
|
12768
|
+
* Finds a signal by its ID.
|
|
12769
|
+
* @param id - The signal ID to search for
|
|
12770
|
+
* @returns The signal row or null if not found
|
|
12771
|
+
*/
|
|
12772
|
+
findById(id: StorageId): Promise<IStorageSignalRow | null>;
|
|
12773
|
+
/**
|
|
12774
|
+
* Lists all stored signals.
|
|
12775
|
+
* @returns Array of all signal rows
|
|
12599
12776
|
*/
|
|
12600
|
-
|
|
12777
|
+
list(): Promise<IStorageSignalRow[]>;
|
|
12778
|
+
}
|
|
12779
|
+
/**
|
|
12780
|
+
* Constructor type for storage adapters.
|
|
12781
|
+
* Used for custom storage implementations.
|
|
12782
|
+
*/
|
|
12783
|
+
type TStorageUtilsCtor = new () => IStorageUtils;
|
|
12784
|
+
/**
|
|
12785
|
+
* Backtest storage adapter with pluggable storage backend.
|
|
12786
|
+
*
|
|
12787
|
+
* Features:
|
|
12788
|
+
* - Adapter pattern for swappable storage implementations
|
|
12789
|
+
* - Default adapter: StoragePersistBacktestUtils (persistent storage)
|
|
12790
|
+
* - Alternative adapters: StorageMemoryBacktestUtils, StorageDummyBacktestUtils
|
|
12791
|
+
* - Convenience methods: usePersist(), useMemory(), useDummy()
|
|
12792
|
+
*/
|
|
12793
|
+
declare class StorageBacktestAdapter implements IStorageUtils {
|
|
12794
|
+
/** Internal storage utils instance */
|
|
12795
|
+
private _signalBacktestUtils;
|
|
12601
12796
|
/**
|
|
12602
12797
|
* Handles signal opened event.
|
|
12603
|
-
*
|
|
12604
|
-
* @param tick -
|
|
12605
|
-
* @returns Promise resolving when storage is updated
|
|
12798
|
+
* Proxies call to the underlying storage adapter.
|
|
12799
|
+
* @param tick - The opened signal tick data
|
|
12606
12800
|
*/
|
|
12607
12801
|
handleOpened: (tick: IStrategyTickResultOpened) => Promise<void>;
|
|
12608
12802
|
/**
|
|
12609
12803
|
* Handles signal closed event.
|
|
12610
|
-
*
|
|
12611
|
-
* @param tick -
|
|
12612
|
-
* @returns Promise resolving when storage is updated
|
|
12804
|
+
* Proxies call to the underlying storage adapter.
|
|
12805
|
+
* @param tick - The closed signal tick data
|
|
12613
12806
|
*/
|
|
12614
12807
|
handleClosed: (tick: IStrategyTickResultClosed) => Promise<void>;
|
|
12615
12808
|
/**
|
|
12616
12809
|
* Handles signal scheduled event.
|
|
12617
|
-
*
|
|
12618
|
-
* @param tick -
|
|
12619
|
-
* @returns Promise resolving when storage is updated
|
|
12810
|
+
* Proxies call to the underlying storage adapter.
|
|
12811
|
+
* @param tick - The scheduled signal tick data
|
|
12620
12812
|
*/
|
|
12621
12813
|
handleScheduled: (tick: IStrategyTickResultScheduled) => Promise<void>;
|
|
12622
12814
|
/**
|
|
12623
12815
|
* Handles signal cancelled event.
|
|
12624
|
-
*
|
|
12625
|
-
* @param tick -
|
|
12626
|
-
* @returns Promise resolving when storage is updated
|
|
12816
|
+
* Proxies call to the underlying storage adapter.
|
|
12817
|
+
* @param tick - The cancelled signal tick data
|
|
12627
12818
|
*/
|
|
12628
12819
|
handleCancelled: (tick: IStrategyTickResultCancelled) => Promise<void>;
|
|
12629
12820
|
/**
|
|
12630
|
-
* Finds a signal by its
|
|
12631
|
-
*
|
|
12632
|
-
* @param id -
|
|
12633
|
-
* @returns
|
|
12821
|
+
* Finds a signal by its ID.
|
|
12822
|
+
* Proxies call to the underlying storage adapter.
|
|
12823
|
+
* @param id - The signal ID to search for
|
|
12824
|
+
* @returns The signal row or null if not found
|
|
12634
12825
|
*/
|
|
12635
12826
|
findById: (id: StorageId) => Promise<IStorageSignalRow | null>;
|
|
12636
12827
|
/**
|
|
12637
|
-
* Lists all stored
|
|
12638
|
-
*
|
|
12639
|
-
* @returns
|
|
12828
|
+
* Lists all stored signals.
|
|
12829
|
+
* Proxies call to the underlying storage adapter.
|
|
12830
|
+
* @returns Array of all signal rows
|
|
12640
12831
|
*/
|
|
12641
12832
|
list: () => Promise<IStorageSignalRow[]>;
|
|
12642
|
-
}
|
|
12643
|
-
/**
|
|
12644
|
-
* Utility class for managing live trading signal history.
|
|
12645
|
-
*
|
|
12646
|
-
* Stores trading signal history for admin dashboard display during live trading
|
|
12647
|
-
* with automatic initialization, deduplication, and storage limits.
|
|
12648
|
-
*
|
|
12649
|
-
* @example
|
|
12650
|
-
* ```typescript
|
|
12651
|
-
* import { StorageLiveUtils } from "./classes/Storage";
|
|
12652
|
-
*
|
|
12653
|
-
* const storage = new StorageLiveUtils();
|
|
12654
|
-
*
|
|
12655
|
-
* // Handle signal events
|
|
12656
|
-
* await storage.handleOpened(tickResult);
|
|
12657
|
-
* await storage.handleClosed(tickResult);
|
|
12658
|
-
*
|
|
12659
|
-
* // Query signals
|
|
12660
|
-
* const signal = await storage.findById("signal-123");
|
|
12661
|
-
* const allSignals = await storage.list();
|
|
12662
|
-
* ```
|
|
12663
|
-
*/
|
|
12664
|
-
declare class StorageLiveUtils {
|
|
12665
|
-
private _signals;
|
|
12666
12833
|
/**
|
|
12667
|
-
*
|
|
12668
|
-
*
|
|
12834
|
+
* Sets the storage adapter constructor.
|
|
12835
|
+
* All future storage operations will use this adapter.
|
|
12836
|
+
*
|
|
12837
|
+
* @param Ctor - Constructor for storage adapter
|
|
12669
12838
|
*/
|
|
12670
|
-
|
|
12839
|
+
useStorageAdapter: (Ctor: TStorageUtilsCtor) => void;
|
|
12671
12840
|
/**
|
|
12672
|
-
*
|
|
12673
|
-
*
|
|
12674
|
-
|
|
12675
|
-
|
|
12841
|
+
* Switches to dummy storage adapter.
|
|
12842
|
+
* All future storage writes will be no-ops.
|
|
12843
|
+
*/
|
|
12844
|
+
useDummy: () => void;
|
|
12845
|
+
/**
|
|
12846
|
+
* Switches to persistent storage adapter (default).
|
|
12847
|
+
* Signals will be persisted to disk.
|
|
12848
|
+
*/
|
|
12849
|
+
usePersist: () => void;
|
|
12850
|
+
/**
|
|
12851
|
+
* Switches to in-memory storage adapter.
|
|
12852
|
+
* Signals will be stored in memory only.
|
|
12676
12853
|
*/
|
|
12677
|
-
|
|
12854
|
+
useMemory: () => void;
|
|
12855
|
+
}
|
|
12856
|
+
/**
|
|
12857
|
+
* Live trading storage adapter with pluggable storage backend.
|
|
12858
|
+
*
|
|
12859
|
+
* Features:
|
|
12860
|
+
* - Adapter pattern for swappable storage implementations
|
|
12861
|
+
* - Default adapter: StoragePersistLiveUtils (persistent storage)
|
|
12862
|
+
* - Alternative adapters: StorageMemoryLiveUtils, StorageDummyLiveUtils
|
|
12863
|
+
* - Convenience methods: usePersist(), useMemory(), useDummy()
|
|
12864
|
+
*/
|
|
12865
|
+
declare class StorageLiveAdapter implements IStorageUtils {
|
|
12866
|
+
/** Internal storage utils instance */
|
|
12867
|
+
private _signalLiveUtils;
|
|
12678
12868
|
/**
|
|
12679
12869
|
* Handles signal opened event.
|
|
12680
|
-
*
|
|
12681
|
-
* @param tick -
|
|
12682
|
-
* @returns Promise resolving when history is updated
|
|
12870
|
+
* Proxies call to the underlying storage adapter.
|
|
12871
|
+
* @param tick - The opened signal tick data
|
|
12683
12872
|
*/
|
|
12684
12873
|
handleOpened: (tick: IStrategyTickResultOpened) => Promise<void>;
|
|
12685
12874
|
/**
|
|
12686
12875
|
* Handles signal closed event.
|
|
12687
|
-
*
|
|
12688
|
-
* @param tick -
|
|
12689
|
-
* @returns Promise resolving when history is updated
|
|
12876
|
+
* Proxies call to the underlying storage adapter.
|
|
12877
|
+
* @param tick - The closed signal tick data
|
|
12690
12878
|
*/
|
|
12691
12879
|
handleClosed: (tick: IStrategyTickResultClosed) => Promise<void>;
|
|
12692
12880
|
/**
|
|
12693
12881
|
* Handles signal scheduled event.
|
|
12694
|
-
*
|
|
12695
|
-
* @param tick -
|
|
12696
|
-
* @returns Promise resolving when history is updated
|
|
12882
|
+
* Proxies call to the underlying storage adapter.
|
|
12883
|
+
* @param tick - The scheduled signal tick data
|
|
12697
12884
|
*/
|
|
12698
12885
|
handleScheduled: (tick: IStrategyTickResultScheduled) => Promise<void>;
|
|
12699
12886
|
/**
|
|
12700
12887
|
* Handles signal cancelled event.
|
|
12701
|
-
*
|
|
12702
|
-
* @param tick -
|
|
12703
|
-
* @returns Promise resolving when history is updated
|
|
12888
|
+
* Proxies call to the underlying storage adapter.
|
|
12889
|
+
* @param tick - The cancelled signal tick data
|
|
12704
12890
|
*/
|
|
12705
12891
|
handleCancelled: (tick: IStrategyTickResultCancelled) => Promise<void>;
|
|
12706
12892
|
/**
|
|
12707
|
-
* Finds a signal by its
|
|
12708
|
-
*
|
|
12709
|
-
* @param id -
|
|
12710
|
-
* @returns
|
|
12893
|
+
* Finds a signal by its ID.
|
|
12894
|
+
* Proxies call to the underlying storage adapter.
|
|
12895
|
+
* @param id - The signal ID to search for
|
|
12896
|
+
* @returns The signal row or null if not found
|
|
12711
12897
|
*/
|
|
12712
12898
|
findById: (id: StorageId) => Promise<IStorageSignalRow | null>;
|
|
12713
12899
|
/**
|
|
12714
|
-
* Lists all stored
|
|
12715
|
-
*
|
|
12716
|
-
* @returns
|
|
12900
|
+
* Lists all stored signals.
|
|
12901
|
+
* Proxies call to the underlying storage adapter.
|
|
12902
|
+
* @returns Array of all signal rows
|
|
12717
12903
|
*/
|
|
12718
12904
|
list: () => Promise<IStorageSignalRow[]>;
|
|
12905
|
+
/**
|
|
12906
|
+
* Sets the storage adapter constructor.
|
|
12907
|
+
* All future storage operations will use this adapter.
|
|
12908
|
+
*
|
|
12909
|
+
* @param Ctor - Constructor for storage adapter
|
|
12910
|
+
*/
|
|
12911
|
+
useStorageAdapter: (Ctor: TStorageUtilsCtor) => void;
|
|
12912
|
+
/**
|
|
12913
|
+
* Switches to dummy storage adapter.
|
|
12914
|
+
* All future storage writes will be no-ops.
|
|
12915
|
+
*/
|
|
12916
|
+
useDummy: () => void;
|
|
12917
|
+
/**
|
|
12918
|
+
* Switches to persistent storage adapter (default).
|
|
12919
|
+
* Signals will be persisted to disk.
|
|
12920
|
+
*/
|
|
12921
|
+
usePersist: () => void;
|
|
12922
|
+
/**
|
|
12923
|
+
* Switches to in-memory storage adapter.
|
|
12924
|
+
* Signals will be stored in memory only.
|
|
12925
|
+
*/
|
|
12926
|
+
useMemory: () => void;
|
|
12719
12927
|
}
|
|
12720
12928
|
/**
|
|
12721
|
-
* Main storage adapter
|
|
12929
|
+
* Main storage adapter that manages both backtest and live signal storage.
|
|
12722
12930
|
*
|
|
12723
|
-
*
|
|
12724
|
-
*
|
|
12725
|
-
*
|
|
12726
|
-
*
|
|
12727
|
-
*
|
|
12728
|
-
* ```typescript
|
|
12729
|
-
* import { Storage } from "./classes/Storage";
|
|
12730
|
-
*
|
|
12731
|
-
* // Enable signal history tracking
|
|
12732
|
-
* const unsubscribe = Storage.enable();
|
|
12733
|
-
*
|
|
12734
|
-
* // Query signals
|
|
12735
|
-
* const backtestSignals = await Storage.listSignalBacktest();
|
|
12736
|
-
* const liveSignals = await Storage.listSignalLive();
|
|
12737
|
-
* const signal = await Storage.findSignalById("signal-123");
|
|
12738
|
-
*
|
|
12739
|
-
* // Disable tracking
|
|
12740
|
-
* Storage.disable();
|
|
12741
|
-
* ```
|
|
12931
|
+
* Features:
|
|
12932
|
+
* - Subscribes to signal emitters for automatic storage updates
|
|
12933
|
+
* - Provides unified access to both backtest and live signals
|
|
12934
|
+
* - Singleshot enable pattern prevents duplicate subscriptions
|
|
12935
|
+
* - Cleanup function for proper unsubscription
|
|
12742
12936
|
*/
|
|
12743
12937
|
declare class StorageAdapter {
|
|
12744
|
-
_signalLiveUtils: StorageLiveUtils;
|
|
12745
|
-
_signalBacktestUtils: StorageBacktestUtils;
|
|
12746
12938
|
/**
|
|
12747
|
-
* Enables signal
|
|
12939
|
+
* Enables signal storage by subscribing to signal emitters.
|
|
12940
|
+
* Uses singleshot to ensure one-time subscription.
|
|
12748
12941
|
*
|
|
12749
|
-
* @returns Cleanup function
|
|
12942
|
+
* @returns Cleanup function that unsubscribes from all emitters
|
|
12750
12943
|
*/
|
|
12751
12944
|
enable: (() => () => void) & functools_kit.ISingleshotClearable;
|
|
12752
12945
|
/**
|
|
12753
|
-
* Disables signal
|
|
12946
|
+
* Disables signal storage by unsubscribing from all emitters.
|
|
12947
|
+
* Safe to call multiple times.
|
|
12754
12948
|
*/
|
|
12755
12949
|
disable: () => void;
|
|
12756
12950
|
/**
|
|
12757
|
-
* Finds a signal by ID across both backtest and live
|
|
12951
|
+
* Finds a signal by ID across both backtest and live storage.
|
|
12758
12952
|
*
|
|
12759
|
-
* @param id -
|
|
12760
|
-
* @returns
|
|
12761
|
-
* @throws Error if
|
|
12953
|
+
* @param id - The signal ID to search for
|
|
12954
|
+
* @returns The signal row or throws if not found
|
|
12955
|
+
* @throws Error if StorageAdapter is not enabled
|
|
12956
|
+
* @throws Error if signal is not found in either storage
|
|
12762
12957
|
*/
|
|
12763
12958
|
findSignalById: (id: StorageId) => Promise<IStorageSignalRow | null>;
|
|
12764
12959
|
/**
|
|
12765
|
-
* Lists all backtest
|
|
12960
|
+
* Lists all backtest signals from storage.
|
|
12766
12961
|
*
|
|
12767
|
-
* @returns
|
|
12962
|
+
* @returns Array of all backtest signal rows
|
|
12963
|
+
* @throws Error if StorageAdapter is not enabled
|
|
12768
12964
|
*/
|
|
12769
12965
|
listSignalBacktest: () => Promise<IStorageSignalRow[]>;
|
|
12770
12966
|
/**
|
|
12771
|
-
* Lists all live
|
|
12967
|
+
* Lists all live signals from storage.
|
|
12772
12968
|
*
|
|
12773
|
-
* @returns
|
|
12969
|
+
* @returns Array of all live signal rows
|
|
12970
|
+
* @throws Error if StorageAdapter is not enabled
|
|
12774
12971
|
*/
|
|
12775
12972
|
listSignalLive: () => Promise<IStorageSignalRow[]>;
|
|
12776
12973
|
}
|
|
12974
|
+
/**
|
|
12975
|
+
* Global singleton instance of StorageAdapter.
|
|
12976
|
+
* Provides unified signal storage management for backtest and live trading.
|
|
12977
|
+
*/
|
|
12777
12978
|
declare const Storage: StorageAdapter;
|
|
12979
|
+
/**
|
|
12980
|
+
* Global singleton instance of StorageLiveAdapter.
|
|
12981
|
+
* Provides live trading signal storage with pluggable backends.
|
|
12982
|
+
*/
|
|
12983
|
+
declare const StorageLive: StorageLiveAdapter;
|
|
12984
|
+
/**
|
|
12985
|
+
* Global singleton instance of StorageBacktestAdapter.
|
|
12986
|
+
* Provides backtest signal storage with pluggable backends.
|
|
12987
|
+
*/
|
|
12988
|
+
declare const StorageBacktest: StorageBacktestAdapter;
|
|
12778
12989
|
|
|
12779
12990
|
/**
|
|
12780
12991
|
* Utility class for exchange operations.
|
|
@@ -14062,12 +14273,20 @@ declare class StrategyMarkdownService {
|
|
|
14062
14273
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14063
14274
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14064
14275
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14276
|
+
* @param position - Trade direction: "long" or "short"
|
|
14277
|
+
* @param priceOpen - Entry price for the position
|
|
14278
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14279
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14280
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14281
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14282
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14283
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14065
14284
|
*/
|
|
14066
14285
|
partialProfit: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14067
14286
|
strategyName: StrategyName;
|
|
14068
14287
|
exchangeName: ExchangeName;
|
|
14069
14288
|
frameName: FrameName;
|
|
14070
|
-
}, timestamp: number) => Promise<void>;
|
|
14289
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14071
14290
|
/**
|
|
14072
14291
|
* Records a partial-loss event when a portion of the position is closed at loss.
|
|
14073
14292
|
*
|
|
@@ -14077,12 +14296,20 @@ declare class StrategyMarkdownService {
|
|
|
14077
14296
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14078
14297
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14079
14298
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14299
|
+
* @param position - Trade direction: "long" or "short"
|
|
14300
|
+
* @param priceOpen - Entry price for the position
|
|
14301
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14302
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14303
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14304
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14305
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14306
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14080
14307
|
*/
|
|
14081
14308
|
partialLoss: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14082
14309
|
strategyName: StrategyName;
|
|
14083
14310
|
exchangeName: ExchangeName;
|
|
14084
14311
|
frameName: FrameName;
|
|
14085
|
-
}, timestamp: number) => Promise<void>;
|
|
14312
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14086
14313
|
/**
|
|
14087
14314
|
* Records a trailing-stop event when the stop-loss is adjusted.
|
|
14088
14315
|
*
|
|
@@ -14092,12 +14319,20 @@ declare class StrategyMarkdownService {
|
|
|
14092
14319
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14093
14320
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14094
14321
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14322
|
+
* @param position - Trade direction: "long" or "short"
|
|
14323
|
+
* @param priceOpen - Entry price for the position
|
|
14324
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14325
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14326
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14327
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14328
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14329
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14095
14330
|
*/
|
|
14096
14331
|
trailingStop: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14097
14332
|
strategyName: StrategyName;
|
|
14098
14333
|
exchangeName: ExchangeName;
|
|
14099
14334
|
frameName: FrameName;
|
|
14100
|
-
}, timestamp: number) => Promise<void>;
|
|
14335
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14101
14336
|
/**
|
|
14102
14337
|
* Records a trailing-take event when the take-profit is adjusted.
|
|
14103
14338
|
*
|
|
@@ -14107,12 +14342,20 @@ declare class StrategyMarkdownService {
|
|
|
14107
14342
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14108
14343
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14109
14344
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14345
|
+
* @param position - Trade direction: "long" or "short"
|
|
14346
|
+
* @param priceOpen - Entry price for the position
|
|
14347
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14348
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14349
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14350
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14351
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14352
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14110
14353
|
*/
|
|
14111
14354
|
trailingTake: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
14112
14355
|
strategyName: StrategyName;
|
|
14113
14356
|
exchangeName: ExchangeName;
|
|
14114
14357
|
frameName: FrameName;
|
|
14115
|
-
}, timestamp: number) => Promise<void>;
|
|
14358
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14116
14359
|
/**
|
|
14117
14360
|
* Records a breakeven event when the stop-loss is moved to entry price.
|
|
14118
14361
|
*
|
|
@@ -14121,12 +14364,20 @@ declare class StrategyMarkdownService {
|
|
|
14121
14364
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
14122
14365
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
14123
14366
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
14367
|
+
* @param position - Trade direction: "long" or "short"
|
|
14368
|
+
* @param priceOpen - Entry price for the position
|
|
14369
|
+
* @param priceTakeProfit - Effective take profit price
|
|
14370
|
+
* @param priceStopLoss - Effective stop loss price
|
|
14371
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
14372
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
14373
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
14374
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
14124
14375
|
*/
|
|
14125
14376
|
breakeven: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
|
|
14126
14377
|
strategyName: StrategyName;
|
|
14127
14378
|
exchangeName: ExchangeName;
|
|
14128
14379
|
frameName: FrameName;
|
|
14129
|
-
}, timestamp: number) => Promise<void>;
|
|
14380
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
14130
14381
|
/**
|
|
14131
14382
|
* Retrieves aggregated statistics from accumulated strategy events.
|
|
14132
14383
|
*
|
|
@@ -19544,12 +19795,20 @@ declare class StrategyReportService {
|
|
|
19544
19795
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19545
19796
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19546
19797
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19798
|
+
* @param position - Trade direction: "long" or "short"
|
|
19799
|
+
* @param priceOpen - Entry price for the position
|
|
19800
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19801
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19802
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19803
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19804
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19805
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19547
19806
|
*/
|
|
19548
19807
|
partialProfit: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19549
19808
|
strategyName: StrategyName;
|
|
19550
19809
|
exchangeName: ExchangeName;
|
|
19551
19810
|
frameName: FrameName;
|
|
19552
|
-
}, timestamp: number) => Promise<void>;
|
|
19811
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19553
19812
|
/**
|
|
19554
19813
|
* Logs a partial-loss event when a portion of the position is closed at loss.
|
|
19555
19814
|
*
|
|
@@ -19559,12 +19818,20 @@ declare class StrategyReportService {
|
|
|
19559
19818
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19560
19819
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19561
19820
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19821
|
+
* @param position - Trade direction: "long" or "short"
|
|
19822
|
+
* @param priceOpen - Entry price for the position
|
|
19823
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19824
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19825
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19826
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19827
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19828
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19562
19829
|
*/
|
|
19563
19830
|
partialLoss: (symbol: string, percentToClose: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19564
19831
|
strategyName: StrategyName;
|
|
19565
19832
|
exchangeName: ExchangeName;
|
|
19566
19833
|
frameName: FrameName;
|
|
19567
|
-
}, timestamp: number) => Promise<void>;
|
|
19834
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19568
19835
|
/**
|
|
19569
19836
|
* Logs a trailing-stop event when the stop-loss is adjusted.
|
|
19570
19837
|
*
|
|
@@ -19574,12 +19841,20 @@ declare class StrategyReportService {
|
|
|
19574
19841
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19575
19842
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19576
19843
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19844
|
+
* @param position - Trade direction: "long" or "short"
|
|
19845
|
+
* @param priceOpen - Entry price for the position
|
|
19846
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19847
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19848
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19849
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19850
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19851
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19577
19852
|
*/
|
|
19578
19853
|
trailingStop: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19579
19854
|
strategyName: StrategyName;
|
|
19580
19855
|
exchangeName: ExchangeName;
|
|
19581
19856
|
frameName: FrameName;
|
|
19582
|
-
}, timestamp: number) => Promise<void>;
|
|
19857
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19583
19858
|
/**
|
|
19584
19859
|
* Logs a trailing-take event when the take-profit is adjusted.
|
|
19585
19860
|
*
|
|
@@ -19589,12 +19864,20 @@ declare class StrategyReportService {
|
|
|
19589
19864
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19590
19865
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19591
19866
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19867
|
+
* @param position - Trade direction: "long" or "short"
|
|
19868
|
+
* @param priceOpen - Entry price for the position
|
|
19869
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19870
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19871
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19872
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19873
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19874
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19592
19875
|
*/
|
|
19593
19876
|
trailingTake: (symbol: string, percentShift: number, currentPrice: number, isBacktest: boolean, context: {
|
|
19594
19877
|
strategyName: StrategyName;
|
|
19595
19878
|
exchangeName: ExchangeName;
|
|
19596
19879
|
frameName: FrameName;
|
|
19597
|
-
}, timestamp: number) => Promise<void>;
|
|
19880
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19598
19881
|
/**
|
|
19599
19882
|
* Logs a breakeven event when the stop-loss is moved to entry price.
|
|
19600
19883
|
*
|
|
@@ -19603,12 +19886,20 @@ declare class StrategyReportService {
|
|
|
19603
19886
|
* @param isBacktest - Whether this is a backtest or live trading event
|
|
19604
19887
|
* @param context - Strategy context with strategyName, exchangeName, frameName
|
|
19605
19888
|
* @param timestamp - Timestamp from StrategyCommitContract (execution context time)
|
|
19889
|
+
* @param position - Trade direction: "long" or "short"
|
|
19890
|
+
* @param priceOpen - Entry price for the position
|
|
19891
|
+
* @param priceTakeProfit - Effective take profit price
|
|
19892
|
+
* @param priceStopLoss - Effective stop loss price
|
|
19893
|
+
* @param originalPriceTakeProfit - Original take profit before trailing
|
|
19894
|
+
* @param originalPriceStopLoss - Original stop loss before trailing
|
|
19895
|
+
* @param scheduledAt - Signal creation timestamp in milliseconds
|
|
19896
|
+
* @param pendingAt - Pending timestamp in milliseconds
|
|
19606
19897
|
*/
|
|
19607
19898
|
breakeven: (symbol: string, currentPrice: number, isBacktest: boolean, context: {
|
|
19608
19899
|
strategyName: StrategyName;
|
|
19609
19900
|
exchangeName: ExchangeName;
|
|
19610
19901
|
frameName: FrameName;
|
|
19611
|
-
}, timestamp: number) => Promise<void>;
|
|
19902
|
+
}, timestamp: number, position: "long" | "short", priceOpen: number, priceTakeProfit: number, priceStopLoss: number, originalPriceTakeProfit: number, originalPriceStopLoss: number, scheduledAt: number, pendingAt: number) => Promise<void>;
|
|
19612
19903
|
/**
|
|
19613
19904
|
* Initializes the service for event logging.
|
|
19614
19905
|
*
|
|
@@ -19697,4 +19988,4 @@ declare const backtest: {
|
|
|
19697
19988
|
loggerService: LoggerService;
|
|
19698
19989
|
};
|
|
19699
19990
|
|
|
19700
|
-
export { ActionBase, type ActivePingContract, 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 IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, 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 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, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, 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, 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, type StorageData, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, 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, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, 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, stopStrategy, validate };
|
|
19991
|
+
export { ActionBase, type ActivePingContract, 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 IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, 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, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, 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, 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 TMarkdownBase, 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, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, 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, stopStrategy, validate };
|