backtest-kit 1.5.7 → 1.5.8
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 +56 -13
- package/build/index.mjs +56 -13
- package/package.json +1 -1
- package/types.d.ts +2 -2
package/build/index.cjs
CHANGED
|
@@ -13517,13 +13517,6 @@ class BacktestInstance {
|
|
|
13517
13517
|
symbol,
|
|
13518
13518
|
context,
|
|
13519
13519
|
});
|
|
13520
|
-
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_RUN);
|
|
13521
|
-
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_RUN);
|
|
13522
|
-
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_RUN);
|
|
13523
|
-
{
|
|
13524
|
-
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13525
|
-
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_RUN);
|
|
13526
|
-
}
|
|
13527
13520
|
{
|
|
13528
13521
|
backtest$1.backtestMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
13529
13522
|
backtest$1.scheduleMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
@@ -13711,6 +13704,15 @@ class BacktestUtils {
|
|
|
13711
13704
|
* @returns Async generator yielding closed signals with PNL
|
|
13712
13705
|
*/
|
|
13713
13706
|
this.run = (symbol, context) => {
|
|
13707
|
+
{
|
|
13708
|
+
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_RUN);
|
|
13709
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_RUN);
|
|
13710
|
+
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_RUN);
|
|
13711
|
+
}
|
|
13712
|
+
{
|
|
13713
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13714
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_RUN);
|
|
13715
|
+
}
|
|
13714
13716
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
13715
13717
|
return instance.run(symbol, context);
|
|
13716
13718
|
};
|
|
@@ -13736,6 +13738,11 @@ class BacktestUtils {
|
|
|
13736
13738
|
* ```
|
|
13737
13739
|
*/
|
|
13738
13740
|
this.background = (symbol, context) => {
|
|
13741
|
+
{
|
|
13742
|
+
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13743
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13744
|
+
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13745
|
+
}
|
|
13739
13746
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
13740
13747
|
return instance.background(symbol, context);
|
|
13741
13748
|
};
|
|
@@ -13757,6 +13764,7 @@ class BacktestUtils {
|
|
|
13757
13764
|
* ```
|
|
13758
13765
|
*/
|
|
13759
13766
|
this.stop = async (symbol, strategyName) => {
|
|
13767
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_STOP);
|
|
13760
13768
|
const instance = this._getInstance(symbol, strategyName);
|
|
13761
13769
|
return await instance.stop(symbol, strategyName);
|
|
13762
13770
|
};
|
|
@@ -13774,6 +13782,7 @@ class BacktestUtils {
|
|
|
13774
13782
|
* ```
|
|
13775
13783
|
*/
|
|
13776
13784
|
this.getData = async (symbol, strategyName) => {
|
|
13785
|
+
backtest$1.strategyValidationService.validate(strategyName, "BacktestUtils.getData");
|
|
13777
13786
|
const instance = this._getInstance(symbol, strategyName);
|
|
13778
13787
|
return await instance.getData(symbol, strategyName);
|
|
13779
13788
|
};
|
|
@@ -13791,6 +13800,7 @@ class BacktestUtils {
|
|
|
13791
13800
|
* ```
|
|
13792
13801
|
*/
|
|
13793
13802
|
this.getReport = async (symbol, strategyName) => {
|
|
13803
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_GET_REPORT);
|
|
13794
13804
|
const instance = this._getInstance(symbol, strategyName);
|
|
13795
13805
|
return await instance.getReport(symbol, strategyName);
|
|
13796
13806
|
};
|
|
@@ -13811,6 +13821,7 @@ class BacktestUtils {
|
|
|
13811
13821
|
* ```
|
|
13812
13822
|
*/
|
|
13813
13823
|
this.dump = async (symbol, strategyName, path) => {
|
|
13824
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_DUMP);
|
|
13814
13825
|
const instance = this._getInstance(symbol, strategyName);
|
|
13815
13826
|
return await instance.dump(symbol, strategyName, path);
|
|
13816
13827
|
};
|
|
@@ -13977,12 +13988,6 @@ class LiveInstance {
|
|
|
13977
13988
|
symbol,
|
|
13978
13989
|
context,
|
|
13979
13990
|
});
|
|
13980
|
-
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_RUN);
|
|
13981
|
-
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_RUN);
|
|
13982
|
-
{
|
|
13983
|
-
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13984
|
-
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_RUN);
|
|
13985
|
-
}
|
|
13986
13991
|
{
|
|
13987
13992
|
backtest$1.liveMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
13988
13993
|
backtest$1.scheduleMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
@@ -14183,6 +14188,14 @@ class LiveUtils {
|
|
|
14183
14188
|
* @returns Infinite async generator yielding opened and closed signals
|
|
14184
14189
|
*/
|
|
14185
14190
|
this.run = (symbol, context) => {
|
|
14191
|
+
{
|
|
14192
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_RUN);
|
|
14193
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_RUN);
|
|
14194
|
+
}
|
|
14195
|
+
{
|
|
14196
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
14197
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_RUN);
|
|
14198
|
+
}
|
|
14186
14199
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14187
14200
|
return instance.run(symbol, context);
|
|
14188
14201
|
};
|
|
@@ -14208,6 +14221,8 @@ class LiveUtils {
|
|
|
14208
14221
|
* ```
|
|
14209
14222
|
*/
|
|
14210
14223
|
this.background = (symbol, context) => {
|
|
14224
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14225
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14211
14226
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14212
14227
|
return instance.background(symbol, context);
|
|
14213
14228
|
};
|
|
@@ -14229,6 +14244,7 @@ class LiveUtils {
|
|
|
14229
14244
|
* ```
|
|
14230
14245
|
*/
|
|
14231
14246
|
this.stop = async (symbol, strategyName) => {
|
|
14247
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_STOP);
|
|
14232
14248
|
const instance = this._getInstance(symbol, strategyName);
|
|
14233
14249
|
return await instance.stop(symbol, strategyName);
|
|
14234
14250
|
};
|
|
@@ -14246,6 +14262,7 @@ class LiveUtils {
|
|
|
14246
14262
|
* ```
|
|
14247
14263
|
*/
|
|
14248
14264
|
this.getData = async (symbol, strategyName) => {
|
|
14265
|
+
backtest$1.strategyValidationService.validate(strategyName, "LiveUtils.getData");
|
|
14249
14266
|
const instance = this._getInstance(symbol, strategyName);
|
|
14250
14267
|
return await instance.getData(symbol, strategyName);
|
|
14251
14268
|
};
|
|
@@ -14263,6 +14280,7 @@ class LiveUtils {
|
|
|
14263
14280
|
* ```
|
|
14264
14281
|
*/
|
|
14265
14282
|
this.getReport = async (symbol, strategyName) => {
|
|
14283
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_GET_REPORT);
|
|
14266
14284
|
const instance = this._getInstance(symbol, strategyName);
|
|
14267
14285
|
return await instance.getReport(symbol, strategyName);
|
|
14268
14286
|
};
|
|
@@ -14283,6 +14301,7 @@ class LiveUtils {
|
|
|
14283
14301
|
* ```
|
|
14284
14302
|
*/
|
|
14285
14303
|
this.dump = async (symbol, strategyName, path) => {
|
|
14304
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_DUMP);
|
|
14286
14305
|
const instance = this._getInstance(symbol, strategyName);
|
|
14287
14306
|
return await instance.dump(symbol, strategyName, path);
|
|
14288
14307
|
};
|
|
@@ -14883,6 +14902,16 @@ class WalkerUtils {
|
|
|
14883
14902
|
* @returns Async generator yielding progress updates after each strategy
|
|
14884
14903
|
*/
|
|
14885
14904
|
this.run = (symbol, context) => {
|
|
14905
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_RUN);
|
|
14906
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14907
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_RUN);
|
|
14908
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_RUN);
|
|
14909
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14910
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_RUN);
|
|
14911
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14912
|
+
const riskName = strategySchema.riskName;
|
|
14913
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_RUN);
|
|
14914
|
+
}
|
|
14886
14915
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14887
14916
|
return instance.run(symbol, context);
|
|
14888
14917
|
};
|
|
@@ -14906,6 +14935,16 @@ class WalkerUtils {
|
|
|
14906
14935
|
* ```
|
|
14907
14936
|
*/
|
|
14908
14937
|
this.background = (symbol, context) => {
|
|
14938
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14939
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14940
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14941
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14942
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14943
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14944
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14945
|
+
const riskName = strategySchema.riskName;
|
|
14946
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14947
|
+
}
|
|
14909
14948
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14910
14949
|
return instance.background(symbol, context);
|
|
14911
14950
|
};
|
|
@@ -14933,6 +14972,7 @@ class WalkerUtils {
|
|
|
14933
14972
|
* ```
|
|
14934
14973
|
*/
|
|
14935
14974
|
this.stop = async (symbol, walkerName) => {
|
|
14975
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_STOP);
|
|
14936
14976
|
const instance = this._getInstance(symbol, walkerName);
|
|
14937
14977
|
return await instance.stop(symbol, walkerName);
|
|
14938
14978
|
};
|
|
@@ -14950,6 +14990,7 @@ class WalkerUtils {
|
|
|
14950
14990
|
* ```
|
|
14951
14991
|
*/
|
|
14952
14992
|
this.getData = async (symbol, walkerName) => {
|
|
14993
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_DATA);
|
|
14953
14994
|
const instance = this._getInstance(symbol, walkerName);
|
|
14954
14995
|
return await instance.getData(symbol, walkerName);
|
|
14955
14996
|
};
|
|
@@ -14967,6 +15008,7 @@ class WalkerUtils {
|
|
|
14967
15008
|
* ```
|
|
14968
15009
|
*/
|
|
14969
15010
|
this.getReport = async (symbol, walkerName) => {
|
|
15011
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_REPORT);
|
|
14970
15012
|
const instance = this._getInstance(symbol, walkerName);
|
|
14971
15013
|
return await instance.getReport(symbol, walkerName);
|
|
14972
15014
|
};
|
|
@@ -14987,6 +15029,7 @@ class WalkerUtils {
|
|
|
14987
15029
|
* ```
|
|
14988
15030
|
*/
|
|
14989
15031
|
this.dump = async (symbol, walkerName, path) => {
|
|
15032
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_DUMP);
|
|
14990
15033
|
const instance = this._getInstance(symbol, walkerName);
|
|
14991
15034
|
return await instance.dump(symbol, walkerName, path);
|
|
14992
15035
|
};
|
package/build/index.mjs
CHANGED
|
@@ -13515,13 +13515,6 @@ class BacktestInstance {
|
|
|
13515
13515
|
symbol,
|
|
13516
13516
|
context,
|
|
13517
13517
|
});
|
|
13518
|
-
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_RUN);
|
|
13519
|
-
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_RUN);
|
|
13520
|
-
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_RUN);
|
|
13521
|
-
{
|
|
13522
|
-
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13523
|
-
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_RUN);
|
|
13524
|
-
}
|
|
13525
13518
|
{
|
|
13526
13519
|
backtest$1.backtestMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
13527
13520
|
backtest$1.scheduleMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
@@ -13709,6 +13702,15 @@ class BacktestUtils {
|
|
|
13709
13702
|
* @returns Async generator yielding closed signals with PNL
|
|
13710
13703
|
*/
|
|
13711
13704
|
this.run = (symbol, context) => {
|
|
13705
|
+
{
|
|
13706
|
+
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_RUN);
|
|
13707
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_RUN);
|
|
13708
|
+
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_RUN);
|
|
13709
|
+
}
|
|
13710
|
+
{
|
|
13711
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13712
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_RUN);
|
|
13713
|
+
}
|
|
13712
13714
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
13713
13715
|
return instance.run(symbol, context);
|
|
13714
13716
|
};
|
|
@@ -13734,6 +13736,11 @@ class BacktestUtils {
|
|
|
13734
13736
|
* ```
|
|
13735
13737
|
*/
|
|
13736
13738
|
this.background = (symbol, context) => {
|
|
13739
|
+
{
|
|
13740
|
+
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13741
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13742
|
+
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13743
|
+
}
|
|
13737
13744
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
13738
13745
|
return instance.background(symbol, context);
|
|
13739
13746
|
};
|
|
@@ -13755,6 +13762,7 @@ class BacktestUtils {
|
|
|
13755
13762
|
* ```
|
|
13756
13763
|
*/
|
|
13757
13764
|
this.stop = async (symbol, strategyName) => {
|
|
13765
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_STOP);
|
|
13758
13766
|
const instance = this._getInstance(symbol, strategyName);
|
|
13759
13767
|
return await instance.stop(symbol, strategyName);
|
|
13760
13768
|
};
|
|
@@ -13772,6 +13780,7 @@ class BacktestUtils {
|
|
|
13772
13780
|
* ```
|
|
13773
13781
|
*/
|
|
13774
13782
|
this.getData = async (symbol, strategyName) => {
|
|
13783
|
+
backtest$1.strategyValidationService.validate(strategyName, "BacktestUtils.getData");
|
|
13775
13784
|
const instance = this._getInstance(symbol, strategyName);
|
|
13776
13785
|
return await instance.getData(symbol, strategyName);
|
|
13777
13786
|
};
|
|
@@ -13789,6 +13798,7 @@ class BacktestUtils {
|
|
|
13789
13798
|
* ```
|
|
13790
13799
|
*/
|
|
13791
13800
|
this.getReport = async (symbol, strategyName) => {
|
|
13801
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_GET_REPORT);
|
|
13792
13802
|
const instance = this._getInstance(symbol, strategyName);
|
|
13793
13803
|
return await instance.getReport(symbol, strategyName);
|
|
13794
13804
|
};
|
|
@@ -13809,6 +13819,7 @@ class BacktestUtils {
|
|
|
13809
13819
|
* ```
|
|
13810
13820
|
*/
|
|
13811
13821
|
this.dump = async (symbol, strategyName, path) => {
|
|
13822
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_DUMP);
|
|
13812
13823
|
const instance = this._getInstance(symbol, strategyName);
|
|
13813
13824
|
return await instance.dump(symbol, strategyName, path);
|
|
13814
13825
|
};
|
|
@@ -13975,12 +13986,6 @@ class LiveInstance {
|
|
|
13975
13986
|
symbol,
|
|
13976
13987
|
context,
|
|
13977
13988
|
});
|
|
13978
|
-
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_RUN);
|
|
13979
|
-
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_RUN);
|
|
13980
|
-
{
|
|
13981
|
-
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13982
|
-
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_RUN);
|
|
13983
|
-
}
|
|
13984
13989
|
{
|
|
13985
13990
|
backtest$1.liveMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
13986
13991
|
backtest$1.scheduleMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
@@ -14181,6 +14186,14 @@ class LiveUtils {
|
|
|
14181
14186
|
* @returns Infinite async generator yielding opened and closed signals
|
|
14182
14187
|
*/
|
|
14183
14188
|
this.run = (symbol, context) => {
|
|
14189
|
+
{
|
|
14190
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_RUN);
|
|
14191
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_RUN);
|
|
14192
|
+
}
|
|
14193
|
+
{
|
|
14194
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
14195
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_RUN);
|
|
14196
|
+
}
|
|
14184
14197
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14185
14198
|
return instance.run(symbol, context);
|
|
14186
14199
|
};
|
|
@@ -14206,6 +14219,8 @@ class LiveUtils {
|
|
|
14206
14219
|
* ```
|
|
14207
14220
|
*/
|
|
14208
14221
|
this.background = (symbol, context) => {
|
|
14222
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14223
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14209
14224
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14210
14225
|
return instance.background(symbol, context);
|
|
14211
14226
|
};
|
|
@@ -14227,6 +14242,7 @@ class LiveUtils {
|
|
|
14227
14242
|
* ```
|
|
14228
14243
|
*/
|
|
14229
14244
|
this.stop = async (symbol, strategyName) => {
|
|
14245
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_STOP);
|
|
14230
14246
|
const instance = this._getInstance(symbol, strategyName);
|
|
14231
14247
|
return await instance.stop(symbol, strategyName);
|
|
14232
14248
|
};
|
|
@@ -14244,6 +14260,7 @@ class LiveUtils {
|
|
|
14244
14260
|
* ```
|
|
14245
14261
|
*/
|
|
14246
14262
|
this.getData = async (symbol, strategyName) => {
|
|
14263
|
+
backtest$1.strategyValidationService.validate(strategyName, "LiveUtils.getData");
|
|
14247
14264
|
const instance = this._getInstance(symbol, strategyName);
|
|
14248
14265
|
return await instance.getData(symbol, strategyName);
|
|
14249
14266
|
};
|
|
@@ -14261,6 +14278,7 @@ class LiveUtils {
|
|
|
14261
14278
|
* ```
|
|
14262
14279
|
*/
|
|
14263
14280
|
this.getReport = async (symbol, strategyName) => {
|
|
14281
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_GET_REPORT);
|
|
14264
14282
|
const instance = this._getInstance(symbol, strategyName);
|
|
14265
14283
|
return await instance.getReport(symbol, strategyName);
|
|
14266
14284
|
};
|
|
@@ -14281,6 +14299,7 @@ class LiveUtils {
|
|
|
14281
14299
|
* ```
|
|
14282
14300
|
*/
|
|
14283
14301
|
this.dump = async (symbol, strategyName, path) => {
|
|
14302
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_DUMP);
|
|
14284
14303
|
const instance = this._getInstance(symbol, strategyName);
|
|
14285
14304
|
return await instance.dump(symbol, strategyName, path);
|
|
14286
14305
|
};
|
|
@@ -14881,6 +14900,16 @@ class WalkerUtils {
|
|
|
14881
14900
|
* @returns Async generator yielding progress updates after each strategy
|
|
14882
14901
|
*/
|
|
14883
14902
|
this.run = (symbol, context) => {
|
|
14903
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_RUN);
|
|
14904
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14905
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_RUN);
|
|
14906
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_RUN);
|
|
14907
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14908
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_RUN);
|
|
14909
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14910
|
+
const riskName = strategySchema.riskName;
|
|
14911
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_RUN);
|
|
14912
|
+
}
|
|
14884
14913
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14885
14914
|
return instance.run(symbol, context);
|
|
14886
14915
|
};
|
|
@@ -14904,6 +14933,16 @@ class WalkerUtils {
|
|
|
14904
14933
|
* ```
|
|
14905
14934
|
*/
|
|
14906
14935
|
this.background = (symbol, context) => {
|
|
14936
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14937
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14938
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14939
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14940
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14941
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14942
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14943
|
+
const riskName = strategySchema.riskName;
|
|
14944
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14945
|
+
}
|
|
14907
14946
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14908
14947
|
return instance.background(symbol, context);
|
|
14909
14948
|
};
|
|
@@ -14931,6 +14970,7 @@ class WalkerUtils {
|
|
|
14931
14970
|
* ```
|
|
14932
14971
|
*/
|
|
14933
14972
|
this.stop = async (symbol, walkerName) => {
|
|
14973
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_STOP);
|
|
14934
14974
|
const instance = this._getInstance(symbol, walkerName);
|
|
14935
14975
|
return await instance.stop(symbol, walkerName);
|
|
14936
14976
|
};
|
|
@@ -14948,6 +14988,7 @@ class WalkerUtils {
|
|
|
14948
14988
|
* ```
|
|
14949
14989
|
*/
|
|
14950
14990
|
this.getData = async (symbol, walkerName) => {
|
|
14991
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_DATA);
|
|
14951
14992
|
const instance = this._getInstance(symbol, walkerName);
|
|
14952
14993
|
return await instance.getData(symbol, walkerName);
|
|
14953
14994
|
};
|
|
@@ -14965,6 +15006,7 @@ class WalkerUtils {
|
|
|
14965
15006
|
* ```
|
|
14966
15007
|
*/
|
|
14967
15008
|
this.getReport = async (symbol, walkerName) => {
|
|
15009
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_REPORT);
|
|
14968
15010
|
const instance = this._getInstance(symbol, walkerName);
|
|
14969
15011
|
return await instance.getReport(symbol, walkerName);
|
|
14970
15012
|
};
|
|
@@ -14985,6 +15027,7 @@ class WalkerUtils {
|
|
|
14985
15027
|
* ```
|
|
14986
15028
|
*/
|
|
14987
15029
|
this.dump = async (symbol, walkerName, path) => {
|
|
15030
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_DUMP);
|
|
14988
15031
|
const instance = this._getInstance(symbol, walkerName);
|
|
14989
15032
|
return await instance.dump(symbol, walkerName, path);
|
|
14990
15033
|
};
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -4711,7 +4711,7 @@ type TPersistBase = InstanceType<typeof PersistBase>;
|
|
|
4711
4711
|
* Constructor type for PersistBase.
|
|
4712
4712
|
* Used for custom persistence adapters.
|
|
4713
4713
|
*/
|
|
4714
|
-
type TPersistBaseCtor<EntityName extends string = string, Entity extends IEntity = IEntity> = new (entityName: EntityName, baseDir: string) => IPersistBase<Entity>;
|
|
4714
|
+
type TPersistBaseCtor<EntityName extends string = string, Entity extends IEntity | null = IEntity> = new (entityName: EntityName, baseDir: string) => IPersistBase<Entity>;
|
|
4715
4715
|
/**
|
|
4716
4716
|
* Entity identifier - string or number.
|
|
4717
4717
|
*/
|
|
@@ -4725,7 +4725,7 @@ interface IEntity {
|
|
|
4725
4725
|
* Persistence interface for CRUD operations.
|
|
4726
4726
|
* Implemented by PersistBase.
|
|
4727
4727
|
*/
|
|
4728
|
-
interface IPersistBase<Entity extends IEntity = IEntity> {
|
|
4728
|
+
interface IPersistBase<Entity extends IEntity | null = IEntity> {
|
|
4729
4729
|
/**
|
|
4730
4730
|
* Initialize persistence directory and validate existing files.
|
|
4731
4731
|
* Uses singleshot to ensure one-time execution.
|