backtest-kit 1.5.7 → 1.5.9
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 +122 -13
- package/build/index.mjs +122 -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,13 @@ class BacktestUtils {
|
|
|
13736
13738
|
* ```
|
|
13737
13739
|
*/
|
|
13738
13740
|
this.background = (symbol, context) => {
|
|
13741
|
+
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13742
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13743
|
+
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13744
|
+
{
|
|
13745
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13746
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13747
|
+
}
|
|
13739
13748
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
13740
13749
|
return instance.background(symbol, context);
|
|
13741
13750
|
};
|
|
@@ -13757,6 +13766,11 @@ class BacktestUtils {
|
|
|
13757
13766
|
* ```
|
|
13758
13767
|
*/
|
|
13759
13768
|
this.stop = async (symbol, strategyName) => {
|
|
13769
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_STOP);
|
|
13770
|
+
{
|
|
13771
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13772
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_STOP);
|
|
13773
|
+
}
|
|
13760
13774
|
const instance = this._getInstance(symbol, strategyName);
|
|
13761
13775
|
return await instance.stop(symbol, strategyName);
|
|
13762
13776
|
};
|
|
@@ -13774,6 +13788,11 @@ class BacktestUtils {
|
|
|
13774
13788
|
* ```
|
|
13775
13789
|
*/
|
|
13776
13790
|
this.getData = async (symbol, strategyName) => {
|
|
13791
|
+
backtest$1.strategyValidationService.validate(strategyName, "BacktestUtils.getData");
|
|
13792
|
+
{
|
|
13793
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13794
|
+
riskName && backtest$1.riskValidationService.validate(riskName, "BacktestUtils.getData");
|
|
13795
|
+
}
|
|
13777
13796
|
const instance = this._getInstance(symbol, strategyName);
|
|
13778
13797
|
return await instance.getData(symbol, strategyName);
|
|
13779
13798
|
};
|
|
@@ -13791,6 +13810,11 @@ class BacktestUtils {
|
|
|
13791
13810
|
* ```
|
|
13792
13811
|
*/
|
|
13793
13812
|
this.getReport = async (symbol, strategyName) => {
|
|
13813
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_GET_REPORT);
|
|
13814
|
+
{
|
|
13815
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13816
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_GET_REPORT);
|
|
13817
|
+
}
|
|
13794
13818
|
const instance = this._getInstance(symbol, strategyName);
|
|
13795
13819
|
return await instance.getReport(symbol, strategyName);
|
|
13796
13820
|
};
|
|
@@ -13811,6 +13835,11 @@ class BacktestUtils {
|
|
|
13811
13835
|
* ```
|
|
13812
13836
|
*/
|
|
13813
13837
|
this.dump = async (symbol, strategyName, path) => {
|
|
13838
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_DUMP);
|
|
13839
|
+
{
|
|
13840
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13841
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_DUMP);
|
|
13842
|
+
}
|
|
13814
13843
|
const instance = this._getInstance(symbol, strategyName);
|
|
13815
13844
|
return await instance.dump(symbol, strategyName, path);
|
|
13816
13845
|
};
|
|
@@ -13977,12 +14006,6 @@ class LiveInstance {
|
|
|
13977
14006
|
symbol,
|
|
13978
14007
|
context,
|
|
13979
14008
|
});
|
|
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
14009
|
{
|
|
13987
14010
|
backtest$1.liveMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
13988
14011
|
backtest$1.scheduleMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
@@ -14183,6 +14206,14 @@ class LiveUtils {
|
|
|
14183
14206
|
* @returns Infinite async generator yielding opened and closed signals
|
|
14184
14207
|
*/
|
|
14185
14208
|
this.run = (symbol, context) => {
|
|
14209
|
+
{
|
|
14210
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_RUN);
|
|
14211
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_RUN);
|
|
14212
|
+
}
|
|
14213
|
+
{
|
|
14214
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
14215
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_RUN);
|
|
14216
|
+
}
|
|
14186
14217
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14187
14218
|
return instance.run(symbol, context);
|
|
14188
14219
|
};
|
|
@@ -14208,6 +14239,12 @@ class LiveUtils {
|
|
|
14208
14239
|
* ```
|
|
14209
14240
|
*/
|
|
14210
14241
|
this.background = (symbol, context) => {
|
|
14242
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14243
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14244
|
+
{
|
|
14245
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
14246
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14247
|
+
}
|
|
14211
14248
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14212
14249
|
return instance.background(symbol, context);
|
|
14213
14250
|
};
|
|
@@ -14229,6 +14266,11 @@ class LiveUtils {
|
|
|
14229
14266
|
* ```
|
|
14230
14267
|
*/
|
|
14231
14268
|
this.stop = async (symbol, strategyName) => {
|
|
14269
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_STOP);
|
|
14270
|
+
{
|
|
14271
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14272
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_STOP);
|
|
14273
|
+
}
|
|
14232
14274
|
const instance = this._getInstance(symbol, strategyName);
|
|
14233
14275
|
return await instance.stop(symbol, strategyName);
|
|
14234
14276
|
};
|
|
@@ -14246,6 +14288,11 @@ class LiveUtils {
|
|
|
14246
14288
|
* ```
|
|
14247
14289
|
*/
|
|
14248
14290
|
this.getData = async (symbol, strategyName) => {
|
|
14291
|
+
backtest$1.strategyValidationService.validate(strategyName, "LiveUtils.getData");
|
|
14292
|
+
{
|
|
14293
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14294
|
+
riskName && backtest$1.riskValidationService.validate(riskName, "LiveUtils.getData");
|
|
14295
|
+
}
|
|
14249
14296
|
const instance = this._getInstance(symbol, strategyName);
|
|
14250
14297
|
return await instance.getData(symbol, strategyName);
|
|
14251
14298
|
};
|
|
@@ -14263,6 +14310,11 @@ class LiveUtils {
|
|
|
14263
14310
|
* ```
|
|
14264
14311
|
*/
|
|
14265
14312
|
this.getReport = async (symbol, strategyName) => {
|
|
14313
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_GET_REPORT);
|
|
14314
|
+
{
|
|
14315
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14316
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_GET_REPORT);
|
|
14317
|
+
}
|
|
14266
14318
|
const instance = this._getInstance(symbol, strategyName);
|
|
14267
14319
|
return await instance.getReport(symbol, strategyName);
|
|
14268
14320
|
};
|
|
@@ -14283,6 +14335,11 @@ class LiveUtils {
|
|
|
14283
14335
|
* ```
|
|
14284
14336
|
*/
|
|
14285
14337
|
this.dump = async (symbol, strategyName, path) => {
|
|
14338
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_DUMP);
|
|
14339
|
+
{
|
|
14340
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14341
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_DUMP);
|
|
14342
|
+
}
|
|
14286
14343
|
const instance = this._getInstance(symbol, strategyName);
|
|
14287
14344
|
return await instance.dump(symbol, strategyName, path);
|
|
14288
14345
|
};
|
|
@@ -14883,6 +14940,16 @@ class WalkerUtils {
|
|
|
14883
14940
|
* @returns Async generator yielding progress updates after each strategy
|
|
14884
14941
|
*/
|
|
14885
14942
|
this.run = (symbol, context) => {
|
|
14943
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_RUN);
|
|
14944
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14945
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_RUN);
|
|
14946
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_RUN);
|
|
14947
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14948
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_RUN);
|
|
14949
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14950
|
+
const riskName = strategySchema.riskName;
|
|
14951
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_RUN);
|
|
14952
|
+
}
|
|
14886
14953
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14887
14954
|
return instance.run(symbol, context);
|
|
14888
14955
|
};
|
|
@@ -14906,6 +14973,16 @@ class WalkerUtils {
|
|
|
14906
14973
|
* ```
|
|
14907
14974
|
*/
|
|
14908
14975
|
this.background = (symbol, context) => {
|
|
14976
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14977
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14978
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14979
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14980
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14981
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14982
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14983
|
+
const riskName = strategySchema.riskName;
|
|
14984
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14985
|
+
}
|
|
14909
14986
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14910
14987
|
return instance.background(symbol, context);
|
|
14911
14988
|
};
|
|
@@ -14933,6 +15010,14 @@ class WalkerUtils {
|
|
|
14933
15010
|
* ```
|
|
14934
15011
|
*/
|
|
14935
15012
|
this.stop = async (symbol, walkerName) => {
|
|
15013
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_STOP);
|
|
15014
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15015
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15016
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_STOP);
|
|
15017
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15018
|
+
const riskName = strategySchema.riskName;
|
|
15019
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_STOP);
|
|
15020
|
+
}
|
|
14936
15021
|
const instance = this._getInstance(symbol, walkerName);
|
|
14937
15022
|
return await instance.stop(symbol, walkerName);
|
|
14938
15023
|
};
|
|
@@ -14950,6 +15035,14 @@ class WalkerUtils {
|
|
|
14950
15035
|
* ```
|
|
14951
15036
|
*/
|
|
14952
15037
|
this.getData = async (symbol, walkerName) => {
|
|
15038
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_DATA);
|
|
15039
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15040
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15041
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_GET_DATA);
|
|
15042
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15043
|
+
const riskName = strategySchema.riskName;
|
|
15044
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_GET_DATA);
|
|
15045
|
+
}
|
|
14953
15046
|
const instance = this._getInstance(symbol, walkerName);
|
|
14954
15047
|
return await instance.getData(symbol, walkerName);
|
|
14955
15048
|
};
|
|
@@ -14967,6 +15060,14 @@ class WalkerUtils {
|
|
|
14967
15060
|
* ```
|
|
14968
15061
|
*/
|
|
14969
15062
|
this.getReport = async (symbol, walkerName) => {
|
|
15063
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_REPORT);
|
|
15064
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15065
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15066
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_GET_REPORT);
|
|
15067
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15068
|
+
const riskName = strategySchema.riskName;
|
|
15069
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_GET_REPORT);
|
|
15070
|
+
}
|
|
14970
15071
|
const instance = this._getInstance(symbol, walkerName);
|
|
14971
15072
|
return await instance.getReport(symbol, walkerName);
|
|
14972
15073
|
};
|
|
@@ -14987,6 +15088,14 @@ class WalkerUtils {
|
|
|
14987
15088
|
* ```
|
|
14988
15089
|
*/
|
|
14989
15090
|
this.dump = async (symbol, walkerName, path) => {
|
|
15091
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_DUMP);
|
|
15092
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15093
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15094
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_DUMP);
|
|
15095
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15096
|
+
const riskName = strategySchema.riskName;
|
|
15097
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_DUMP);
|
|
15098
|
+
}
|
|
14990
15099
|
const instance = this._getInstance(symbol, walkerName);
|
|
14991
15100
|
return await instance.dump(symbol, walkerName, path);
|
|
14992
15101
|
};
|
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,13 @@ class BacktestUtils {
|
|
|
13734
13736
|
* ```
|
|
13735
13737
|
*/
|
|
13736
13738
|
this.background = (symbol, context) => {
|
|
13739
|
+
backtest$1.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13740
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13741
|
+
backtest$1.frameValidationService.validate(context.frameName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13742
|
+
{
|
|
13743
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
13744
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_BACKGROUND);
|
|
13745
|
+
}
|
|
13737
13746
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
13738
13747
|
return instance.background(symbol, context);
|
|
13739
13748
|
};
|
|
@@ -13755,6 +13764,11 @@ class BacktestUtils {
|
|
|
13755
13764
|
* ```
|
|
13756
13765
|
*/
|
|
13757
13766
|
this.stop = async (symbol, strategyName) => {
|
|
13767
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_STOP);
|
|
13768
|
+
{
|
|
13769
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13770
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_STOP);
|
|
13771
|
+
}
|
|
13758
13772
|
const instance = this._getInstance(symbol, strategyName);
|
|
13759
13773
|
return await instance.stop(symbol, strategyName);
|
|
13760
13774
|
};
|
|
@@ -13772,6 +13786,11 @@ class BacktestUtils {
|
|
|
13772
13786
|
* ```
|
|
13773
13787
|
*/
|
|
13774
13788
|
this.getData = async (symbol, strategyName) => {
|
|
13789
|
+
backtest$1.strategyValidationService.validate(strategyName, "BacktestUtils.getData");
|
|
13790
|
+
{
|
|
13791
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13792
|
+
riskName && backtest$1.riskValidationService.validate(riskName, "BacktestUtils.getData");
|
|
13793
|
+
}
|
|
13775
13794
|
const instance = this._getInstance(symbol, strategyName);
|
|
13776
13795
|
return await instance.getData(symbol, strategyName);
|
|
13777
13796
|
};
|
|
@@ -13789,6 +13808,11 @@ class BacktestUtils {
|
|
|
13789
13808
|
* ```
|
|
13790
13809
|
*/
|
|
13791
13810
|
this.getReport = async (symbol, strategyName) => {
|
|
13811
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_GET_REPORT);
|
|
13812
|
+
{
|
|
13813
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13814
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_GET_REPORT);
|
|
13815
|
+
}
|
|
13792
13816
|
const instance = this._getInstance(symbol, strategyName);
|
|
13793
13817
|
return await instance.getReport(symbol, strategyName);
|
|
13794
13818
|
};
|
|
@@ -13809,6 +13833,11 @@ class BacktestUtils {
|
|
|
13809
13833
|
* ```
|
|
13810
13834
|
*/
|
|
13811
13835
|
this.dump = async (symbol, strategyName, path) => {
|
|
13836
|
+
backtest$1.strategyValidationService.validate(strategyName, BACKTEST_METHOD_NAME_DUMP);
|
|
13837
|
+
{
|
|
13838
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
13839
|
+
riskName && backtest$1.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_DUMP);
|
|
13840
|
+
}
|
|
13812
13841
|
const instance = this._getInstance(symbol, strategyName);
|
|
13813
13842
|
return await instance.dump(symbol, strategyName, path);
|
|
13814
13843
|
};
|
|
@@ -13975,12 +14004,6 @@ class LiveInstance {
|
|
|
13975
14004
|
symbol,
|
|
13976
14005
|
context,
|
|
13977
14006
|
});
|
|
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
14007
|
{
|
|
13985
14008
|
backtest$1.liveMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
13986
14009
|
backtest$1.scheduleMarkdownService.clear({ symbol, strategyName: context.strategyName });
|
|
@@ -14181,6 +14204,14 @@ class LiveUtils {
|
|
|
14181
14204
|
* @returns Infinite async generator yielding opened and closed signals
|
|
14182
14205
|
*/
|
|
14183
14206
|
this.run = (symbol, context) => {
|
|
14207
|
+
{
|
|
14208
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_RUN);
|
|
14209
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_RUN);
|
|
14210
|
+
}
|
|
14211
|
+
{
|
|
14212
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
14213
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_RUN);
|
|
14214
|
+
}
|
|
14184
14215
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14185
14216
|
return instance.run(symbol, context);
|
|
14186
14217
|
};
|
|
@@ -14206,6 +14237,12 @@ class LiveUtils {
|
|
|
14206
14237
|
* ```
|
|
14207
14238
|
*/
|
|
14208
14239
|
this.background = (symbol, context) => {
|
|
14240
|
+
backtest$1.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14241
|
+
backtest$1.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14242
|
+
{
|
|
14243
|
+
const { riskName } = backtest$1.strategySchemaService.get(context.strategyName);
|
|
14244
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_BACKGROUND);
|
|
14245
|
+
}
|
|
14209
14246
|
const instance = this._getInstance(symbol, context.strategyName);
|
|
14210
14247
|
return instance.background(symbol, context);
|
|
14211
14248
|
};
|
|
@@ -14227,6 +14264,11 @@ class LiveUtils {
|
|
|
14227
14264
|
* ```
|
|
14228
14265
|
*/
|
|
14229
14266
|
this.stop = async (symbol, strategyName) => {
|
|
14267
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_STOP);
|
|
14268
|
+
{
|
|
14269
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14270
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_STOP);
|
|
14271
|
+
}
|
|
14230
14272
|
const instance = this._getInstance(symbol, strategyName);
|
|
14231
14273
|
return await instance.stop(symbol, strategyName);
|
|
14232
14274
|
};
|
|
@@ -14244,6 +14286,11 @@ class LiveUtils {
|
|
|
14244
14286
|
* ```
|
|
14245
14287
|
*/
|
|
14246
14288
|
this.getData = async (symbol, strategyName) => {
|
|
14289
|
+
backtest$1.strategyValidationService.validate(strategyName, "LiveUtils.getData");
|
|
14290
|
+
{
|
|
14291
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14292
|
+
riskName && backtest$1.riskValidationService.validate(riskName, "LiveUtils.getData");
|
|
14293
|
+
}
|
|
14247
14294
|
const instance = this._getInstance(symbol, strategyName);
|
|
14248
14295
|
return await instance.getData(symbol, strategyName);
|
|
14249
14296
|
};
|
|
@@ -14261,6 +14308,11 @@ class LiveUtils {
|
|
|
14261
14308
|
* ```
|
|
14262
14309
|
*/
|
|
14263
14310
|
this.getReport = async (symbol, strategyName) => {
|
|
14311
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_GET_REPORT);
|
|
14312
|
+
{
|
|
14313
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14314
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_GET_REPORT);
|
|
14315
|
+
}
|
|
14264
14316
|
const instance = this._getInstance(symbol, strategyName);
|
|
14265
14317
|
return await instance.getReport(symbol, strategyName);
|
|
14266
14318
|
};
|
|
@@ -14281,6 +14333,11 @@ class LiveUtils {
|
|
|
14281
14333
|
* ```
|
|
14282
14334
|
*/
|
|
14283
14335
|
this.dump = async (symbol, strategyName, path) => {
|
|
14336
|
+
backtest$1.strategyValidationService.validate(strategyName, LIVE_METHOD_NAME_DUMP);
|
|
14337
|
+
{
|
|
14338
|
+
const { riskName } = backtest$1.strategySchemaService.get(strategyName);
|
|
14339
|
+
riskName && backtest$1.riskValidationService.validate(riskName, LIVE_METHOD_NAME_DUMP);
|
|
14340
|
+
}
|
|
14284
14341
|
const instance = this._getInstance(symbol, strategyName);
|
|
14285
14342
|
return await instance.dump(symbol, strategyName, path);
|
|
14286
14343
|
};
|
|
@@ -14881,6 +14938,16 @@ class WalkerUtils {
|
|
|
14881
14938
|
* @returns Async generator yielding progress updates after each strategy
|
|
14882
14939
|
*/
|
|
14883
14940
|
this.run = (symbol, context) => {
|
|
14941
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_RUN);
|
|
14942
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14943
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_RUN);
|
|
14944
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_RUN);
|
|
14945
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14946
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_RUN);
|
|
14947
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14948
|
+
const riskName = strategySchema.riskName;
|
|
14949
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_RUN);
|
|
14950
|
+
}
|
|
14884
14951
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14885
14952
|
return instance.run(symbol, context);
|
|
14886
14953
|
};
|
|
@@ -14904,6 +14971,16 @@ class WalkerUtils {
|
|
|
14904
14971
|
* ```
|
|
14905
14972
|
*/
|
|
14906
14973
|
this.background = (symbol, context) => {
|
|
14974
|
+
backtest$1.walkerValidationService.validate(context.walkerName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14975
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(context.walkerName);
|
|
14976
|
+
backtest$1.exchangeValidationService.validate(walkerSchema.exchangeName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14977
|
+
backtest$1.frameValidationService.validate(walkerSchema.frameName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14978
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
14979
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14980
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
14981
|
+
const riskName = strategySchema.riskName;
|
|
14982
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_BACKGROUND);
|
|
14983
|
+
}
|
|
14907
14984
|
const instance = this._getInstance(symbol, context.walkerName);
|
|
14908
14985
|
return instance.background(symbol, context);
|
|
14909
14986
|
};
|
|
@@ -14931,6 +15008,14 @@ class WalkerUtils {
|
|
|
14931
15008
|
* ```
|
|
14932
15009
|
*/
|
|
14933
15010
|
this.stop = async (symbol, walkerName) => {
|
|
15011
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_STOP);
|
|
15012
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15013
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15014
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_STOP);
|
|
15015
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15016
|
+
const riskName = strategySchema.riskName;
|
|
15017
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_STOP);
|
|
15018
|
+
}
|
|
14934
15019
|
const instance = this._getInstance(symbol, walkerName);
|
|
14935
15020
|
return await instance.stop(symbol, walkerName);
|
|
14936
15021
|
};
|
|
@@ -14948,6 +15033,14 @@ class WalkerUtils {
|
|
|
14948
15033
|
* ```
|
|
14949
15034
|
*/
|
|
14950
15035
|
this.getData = async (symbol, walkerName) => {
|
|
15036
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_DATA);
|
|
15037
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15038
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15039
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_GET_DATA);
|
|
15040
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15041
|
+
const riskName = strategySchema.riskName;
|
|
15042
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_GET_DATA);
|
|
15043
|
+
}
|
|
14951
15044
|
const instance = this._getInstance(symbol, walkerName);
|
|
14952
15045
|
return await instance.getData(symbol, walkerName);
|
|
14953
15046
|
};
|
|
@@ -14965,6 +15058,14 @@ class WalkerUtils {
|
|
|
14965
15058
|
* ```
|
|
14966
15059
|
*/
|
|
14967
15060
|
this.getReport = async (symbol, walkerName) => {
|
|
15061
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_GET_REPORT);
|
|
15062
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15063
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15064
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_GET_REPORT);
|
|
15065
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15066
|
+
const riskName = strategySchema.riskName;
|
|
15067
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_GET_REPORT);
|
|
15068
|
+
}
|
|
14968
15069
|
const instance = this._getInstance(symbol, walkerName);
|
|
14969
15070
|
return await instance.getReport(symbol, walkerName);
|
|
14970
15071
|
};
|
|
@@ -14985,6 +15086,14 @@ class WalkerUtils {
|
|
|
14985
15086
|
* ```
|
|
14986
15087
|
*/
|
|
14987
15088
|
this.dump = async (symbol, walkerName, path) => {
|
|
15089
|
+
backtest$1.walkerValidationService.validate(walkerName, WALKER_METHOD_NAME_DUMP);
|
|
15090
|
+
const walkerSchema = backtest$1.walkerSchemaService.get(walkerName);
|
|
15091
|
+
for (const strategyName of walkerSchema.strategies) {
|
|
15092
|
+
backtest$1.strategyValidationService.validate(strategyName, WALKER_METHOD_NAME_DUMP);
|
|
15093
|
+
const strategySchema = backtest$1.strategySchemaService.get(strategyName);
|
|
15094
|
+
const riskName = strategySchema.riskName;
|
|
15095
|
+
riskName && backtest$1.riskValidationService.validate(riskName, WALKER_METHOD_NAME_DUMP);
|
|
15096
|
+
}
|
|
14988
15097
|
const instance = this._getInstance(symbol, walkerName);
|
|
14989
15098
|
return await instance.dump(symbol, walkerName, path);
|
|
14990
15099
|
};
|
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.
|