backtest-kit 1.5.42 → 1.5.43

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 CHANGED
@@ -13700,17 +13700,105 @@ init();
13700
13700
  var backtest$1 = backtest;
13701
13701
 
13702
13702
  const METHOD_NAME = "validate.validate";
13703
+ /**
13704
+ * Retrieves all registered exchanges as a map
13705
+ * @private
13706
+ * @returns Map of exchange names
13707
+ */
13708
+ const getExchangeMap = async () => {
13709
+ const exchangeMap = {};
13710
+ for (const { exchangeName } of await backtest$1.exchangeValidationService.list()) {
13711
+ Object.assign(exchangeMap, { [exchangeName]: exchangeName });
13712
+ }
13713
+ return exchangeMap;
13714
+ };
13715
+ /**
13716
+ * Retrieves all registered frames as a map
13717
+ * @private
13718
+ * @returns Map of frame names
13719
+ */
13720
+ const getFrameMap = async () => {
13721
+ const frameMap = {};
13722
+ for (const { frameName } of await backtest$1.frameValidationService.list()) {
13723
+ Object.assign(frameMap, { [frameName]: frameName });
13724
+ }
13725
+ return frameMap;
13726
+ };
13727
+ /**
13728
+ * Retrieves all registered strategies as a map
13729
+ * @private
13730
+ * @returns Map of strategy names
13731
+ */
13732
+ const getStrategyMap = async () => {
13733
+ const strategyMap = {};
13734
+ for (const { strategyName } of await backtest$1.strategyValidationService.list()) {
13735
+ Object.assign(strategyMap, { [strategyName]: strategyName });
13736
+ }
13737
+ return strategyMap;
13738
+ };
13739
+ /**
13740
+ * Retrieves all registered risk profiles as a map
13741
+ * @private
13742
+ * @returns Map of risk names
13743
+ */
13744
+ const getRiskMap = async () => {
13745
+ const riskMap = {};
13746
+ for (const { riskName } of await backtest$1.riskValidationService.list()) {
13747
+ Object.assign(riskMap, { [riskName]: riskName });
13748
+ }
13749
+ return riskMap;
13750
+ };
13751
+ /**
13752
+ * Retrieves all registered sizing strategies as a map
13753
+ * @private
13754
+ * @returns Map of sizing names
13755
+ */
13756
+ const getSizingMap = async () => {
13757
+ const sizingMap = {};
13758
+ for (const { sizingName } of await backtest$1.sizingValidationService.list()) {
13759
+ Object.assign(sizingMap, { [sizingName]: sizingName });
13760
+ }
13761
+ return sizingMap;
13762
+ };
13763
+ /**
13764
+ * Retrieves all registered optimizers as a map
13765
+ * @private
13766
+ * @returns Map of optimizer names
13767
+ */
13768
+ const getOptimizerMap = async () => {
13769
+ const optimizerMap = {};
13770
+ for (const { optimizerName } of await backtest$1.optimizerValidationService.list()) {
13771
+ Object.assign(optimizerMap, { [optimizerName]: optimizerName });
13772
+ }
13773
+ return optimizerMap;
13774
+ };
13775
+ /**
13776
+ * Retrieves all registered walkers as a map
13777
+ * @private
13778
+ * @returns Map of walker names
13779
+ */
13780
+ const getWalkerMap = async () => {
13781
+ const walkerMap = {};
13782
+ for (const { walkerName } of await backtest$1.walkerValidationService.list()) {
13783
+ Object.assign(walkerMap, { [walkerName]: walkerName });
13784
+ }
13785
+ return walkerMap;
13786
+ };
13703
13787
  /**
13704
13788
  * Internal validation function that processes all provided entity enums.
13705
13789
  *
13706
13790
  * Iterates through each enum's values and validates them against their
13707
13791
  * respective validation services. Uses memoized validation for performance.
13708
13792
  *
13793
+ * If entity enums are not provided, fetches all registered entities from
13794
+ * their respective validation services and validates them.
13795
+ *
13709
13796
  * @private
13710
13797
  * @param args - Validation arguments containing entity name enums
13711
13798
  * @throws {Error} If any entity name is not found in its registry
13712
13799
  */
13713
- const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}, RiskName = {}, SizingName = {}, OptimizerName = {}, WalkerName = {}, }) => {
13800
+ const validateInternal = async (args) => {
13801
+ const { ExchangeName = await getExchangeMap(), FrameName = await getFrameMap(), StrategyName = await getStrategyMap(), RiskName = await getRiskMap(), SizingName = await getSizingMap(), OptimizerName = await getOptimizerMap(), WalkerName = await getWalkerMap(), } = args;
13714
13802
  for (const exchangeName of Object.values(ExchangeName)) {
13715
13803
  backtest$1.exchangeValidationService.validate(exchangeName, METHOD_NAME);
13716
13804
  }
@@ -13740,15 +13828,26 @@ const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}
13740
13828
  * strategies, risks, sizings, optimizers, walkers) and validates that each entity
13741
13829
  * name exists in its respective registry. Validation results are memoized for performance.
13742
13830
  *
13831
+ * If no arguments are provided (or specific entity types are omitted), the function
13832
+ * automatically fetches and validates ALL registered entities from their respective
13833
+ * validation services. This is useful for comprehensive validation of the entire setup.
13834
+ *
13743
13835
  * Use this before running backtests or optimizations to ensure all referenced
13744
13836
  * entities are properly registered and configured.
13745
13837
  *
13746
13838
  * @public
13747
- * @param args - Partial validation arguments containing entity name enums to validate
13839
+ * @param args - Partial validation arguments containing entity name enums to validate.
13840
+ * If empty or omitted, validates all registered entities.
13748
13841
  * @throws {Error} If any entity name is not found in its validation service
13749
13842
  *
13750
13843
  * @example
13751
13844
  * ```typescript
13845
+ * // Validate ALL registered entities (exchanges, frames, strategies, etc.)
13846
+ * await validate({});
13847
+ * ```
13848
+ *
13849
+ * @example
13850
+ * ```typescript
13752
13851
  * // Define your entity name enums
13753
13852
  * enum ExchangeName {
13754
13853
  * BINANCE = "binance",
@@ -13759,8 +13858,8 @@ const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}
13759
13858
  * MOMENTUM_BTC = "momentum-btc"
13760
13859
  * }
13761
13860
  *
13762
- * // Validate all entities before running backtest
13763
- * validate({
13861
+ * // Validate specific entities before running backtest
13862
+ * await validate({
13764
13863
  * ExchangeName,
13765
13864
  * StrategyName,
13766
13865
  * });
@@ -13769,15 +13868,15 @@ const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}
13769
13868
  * @example
13770
13869
  * ```typescript
13771
13870
  * // Validate specific entity types
13772
- * validate({
13871
+ * await validate({
13773
13872
  * RiskName: { CONSERVATIVE: "conservative" },
13774
13873
  * SizingName: { FIXED_1000: "fixed-1000" },
13775
13874
  * });
13776
13875
  * ```
13777
13876
  */
13778
- function validate(args) {
13877
+ async function validate(args = {}) {
13779
13878
  backtest$1.loggerService.log(METHOD_NAME);
13780
- return validateInternal(args);
13879
+ return await validateInternal(args);
13781
13880
  }
13782
13881
 
13783
13882
  /**
package/build/index.mjs CHANGED
@@ -13698,17 +13698,105 @@ init();
13698
13698
  var backtest$1 = backtest;
13699
13699
 
13700
13700
  const METHOD_NAME = "validate.validate";
13701
+ /**
13702
+ * Retrieves all registered exchanges as a map
13703
+ * @private
13704
+ * @returns Map of exchange names
13705
+ */
13706
+ const getExchangeMap = async () => {
13707
+ const exchangeMap = {};
13708
+ for (const { exchangeName } of await backtest$1.exchangeValidationService.list()) {
13709
+ Object.assign(exchangeMap, { [exchangeName]: exchangeName });
13710
+ }
13711
+ return exchangeMap;
13712
+ };
13713
+ /**
13714
+ * Retrieves all registered frames as a map
13715
+ * @private
13716
+ * @returns Map of frame names
13717
+ */
13718
+ const getFrameMap = async () => {
13719
+ const frameMap = {};
13720
+ for (const { frameName } of await backtest$1.frameValidationService.list()) {
13721
+ Object.assign(frameMap, { [frameName]: frameName });
13722
+ }
13723
+ return frameMap;
13724
+ };
13725
+ /**
13726
+ * Retrieves all registered strategies as a map
13727
+ * @private
13728
+ * @returns Map of strategy names
13729
+ */
13730
+ const getStrategyMap = async () => {
13731
+ const strategyMap = {};
13732
+ for (const { strategyName } of await backtest$1.strategyValidationService.list()) {
13733
+ Object.assign(strategyMap, { [strategyName]: strategyName });
13734
+ }
13735
+ return strategyMap;
13736
+ };
13737
+ /**
13738
+ * Retrieves all registered risk profiles as a map
13739
+ * @private
13740
+ * @returns Map of risk names
13741
+ */
13742
+ const getRiskMap = async () => {
13743
+ const riskMap = {};
13744
+ for (const { riskName } of await backtest$1.riskValidationService.list()) {
13745
+ Object.assign(riskMap, { [riskName]: riskName });
13746
+ }
13747
+ return riskMap;
13748
+ };
13749
+ /**
13750
+ * Retrieves all registered sizing strategies as a map
13751
+ * @private
13752
+ * @returns Map of sizing names
13753
+ */
13754
+ const getSizingMap = async () => {
13755
+ const sizingMap = {};
13756
+ for (const { sizingName } of await backtest$1.sizingValidationService.list()) {
13757
+ Object.assign(sizingMap, { [sizingName]: sizingName });
13758
+ }
13759
+ return sizingMap;
13760
+ };
13761
+ /**
13762
+ * Retrieves all registered optimizers as a map
13763
+ * @private
13764
+ * @returns Map of optimizer names
13765
+ */
13766
+ const getOptimizerMap = async () => {
13767
+ const optimizerMap = {};
13768
+ for (const { optimizerName } of await backtest$1.optimizerValidationService.list()) {
13769
+ Object.assign(optimizerMap, { [optimizerName]: optimizerName });
13770
+ }
13771
+ return optimizerMap;
13772
+ };
13773
+ /**
13774
+ * Retrieves all registered walkers as a map
13775
+ * @private
13776
+ * @returns Map of walker names
13777
+ */
13778
+ const getWalkerMap = async () => {
13779
+ const walkerMap = {};
13780
+ for (const { walkerName } of await backtest$1.walkerValidationService.list()) {
13781
+ Object.assign(walkerMap, { [walkerName]: walkerName });
13782
+ }
13783
+ return walkerMap;
13784
+ };
13701
13785
  /**
13702
13786
  * Internal validation function that processes all provided entity enums.
13703
13787
  *
13704
13788
  * Iterates through each enum's values and validates them against their
13705
13789
  * respective validation services. Uses memoized validation for performance.
13706
13790
  *
13791
+ * If entity enums are not provided, fetches all registered entities from
13792
+ * their respective validation services and validates them.
13793
+ *
13707
13794
  * @private
13708
13795
  * @param args - Validation arguments containing entity name enums
13709
13796
  * @throws {Error} If any entity name is not found in its registry
13710
13797
  */
13711
- const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}, RiskName = {}, SizingName = {}, OptimizerName = {}, WalkerName = {}, }) => {
13798
+ const validateInternal = async (args) => {
13799
+ const { ExchangeName = await getExchangeMap(), FrameName = await getFrameMap(), StrategyName = await getStrategyMap(), RiskName = await getRiskMap(), SizingName = await getSizingMap(), OptimizerName = await getOptimizerMap(), WalkerName = await getWalkerMap(), } = args;
13712
13800
  for (const exchangeName of Object.values(ExchangeName)) {
13713
13801
  backtest$1.exchangeValidationService.validate(exchangeName, METHOD_NAME);
13714
13802
  }
@@ -13738,15 +13826,26 @@ const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}
13738
13826
  * strategies, risks, sizings, optimizers, walkers) and validates that each entity
13739
13827
  * name exists in its respective registry. Validation results are memoized for performance.
13740
13828
  *
13829
+ * If no arguments are provided (or specific entity types are omitted), the function
13830
+ * automatically fetches and validates ALL registered entities from their respective
13831
+ * validation services. This is useful for comprehensive validation of the entire setup.
13832
+ *
13741
13833
  * Use this before running backtests or optimizations to ensure all referenced
13742
13834
  * entities are properly registered and configured.
13743
13835
  *
13744
13836
  * @public
13745
- * @param args - Partial validation arguments containing entity name enums to validate
13837
+ * @param args - Partial validation arguments containing entity name enums to validate.
13838
+ * If empty or omitted, validates all registered entities.
13746
13839
  * @throws {Error} If any entity name is not found in its validation service
13747
13840
  *
13748
13841
  * @example
13749
13842
  * ```typescript
13843
+ * // Validate ALL registered entities (exchanges, frames, strategies, etc.)
13844
+ * await validate({});
13845
+ * ```
13846
+ *
13847
+ * @example
13848
+ * ```typescript
13750
13849
  * // Define your entity name enums
13751
13850
  * enum ExchangeName {
13752
13851
  * BINANCE = "binance",
@@ -13757,8 +13856,8 @@ const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}
13757
13856
  * MOMENTUM_BTC = "momentum-btc"
13758
13857
  * }
13759
13858
  *
13760
- * // Validate all entities before running backtest
13761
- * validate({
13859
+ * // Validate specific entities before running backtest
13860
+ * await validate({
13762
13861
  * ExchangeName,
13763
13862
  * StrategyName,
13764
13863
  * });
@@ -13767,15 +13866,15 @@ const validateInternal = ({ ExchangeName = {}, FrameName = {}, StrategyName = {}
13767
13866
  * @example
13768
13867
  * ```typescript
13769
13868
  * // Validate specific entity types
13770
- * validate({
13869
+ * await validate({
13771
13870
  * RiskName: { CONSERVATIVE: "conservative" },
13772
13871
  * SizingName: { FIXED_1000: "fixed-1000" },
13773
13872
  * });
13774
13873
  * ```
13775
13874
  */
13776
- function validate(args) {
13875
+ async function validate(args = {}) {
13777
13876
  backtest$1.loggerService.log(METHOD_NAME);
13778
- return validateInternal(args);
13877
+ return await validateInternal(args);
13779
13878
  }
13780
13879
 
13781
13880
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "1.5.42",
3
+ "version": "1.5.43",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -62,15 +62,26 @@ interface ValidateArgs<T = Enum> {
62
62
  * strategies, risks, sizings, optimizers, walkers) and validates that each entity
63
63
  * name exists in its respective registry. Validation results are memoized for performance.
64
64
  *
65
+ * If no arguments are provided (or specific entity types are omitted), the function
66
+ * automatically fetches and validates ALL registered entities from their respective
67
+ * validation services. This is useful for comprehensive validation of the entire setup.
68
+ *
65
69
  * Use this before running backtests or optimizations to ensure all referenced
66
70
  * entities are properly registered and configured.
67
71
  *
68
72
  * @public
69
- * @param args - Partial validation arguments containing entity name enums to validate
73
+ * @param args - Partial validation arguments containing entity name enums to validate.
74
+ * If empty or omitted, validates all registered entities.
70
75
  * @throws {Error} If any entity name is not found in its validation service
71
76
  *
72
77
  * @example
73
78
  * ```typescript
79
+ * // Validate ALL registered entities (exchanges, frames, strategies, etc.)
80
+ * await validate({});
81
+ * ```
82
+ *
83
+ * @example
84
+ * ```typescript
74
85
  * // Define your entity name enums
75
86
  * enum ExchangeName {
76
87
  * BINANCE = "binance",
@@ -81,8 +92,8 @@ interface ValidateArgs<T = Enum> {
81
92
  * MOMENTUM_BTC = "momentum-btc"
82
93
  * }
83
94
  *
84
- * // Validate all entities before running backtest
85
- * validate({
95
+ * // Validate specific entities before running backtest
96
+ * await validate({
86
97
  * ExchangeName,
87
98
  * StrategyName,
88
99
  * });
@@ -91,13 +102,13 @@ interface ValidateArgs<T = Enum> {
91
102
  * @example
92
103
  * ```typescript
93
104
  * // Validate specific entity types
94
- * validate({
105
+ * await validate({
95
106
  * RiskName: { CONSERVATIVE: "conservative" },
96
107
  * SizingName: { FIXED_1000: "fixed-1000" },
97
108
  * });
98
109
  * ```
99
110
  */
100
- declare function validate(args: Partial<Args>): void;
111
+ declare function validate(args?: Partial<Args>): Promise<void>;
101
112
 
102
113
  declare const GLOBAL_CONFIG: {
103
114
  /**