backtest-kit 8.0.0 → 8.1.1
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/LICENSE +21 -21
- package/README.md +1804 -1804
- package/build/index.cjs +55 -22
- package/build/index.mjs +55 -22
- package/package.json +86 -86
- package/types.d.ts +20 -2
package/build/index.cjs
CHANGED
|
@@ -590,6 +590,20 @@ const GLOBAL_CONFIG = {
|
|
|
590
590
|
* Default: false (PPPL logic is only applied when it does not break the direction of exits, ensuring clearer profit/loss outcomes)
|
|
591
591
|
*/
|
|
592
592
|
CC_ENABLE_PPPL_EVERYWHERE: false,
|
|
593
|
+
/**
|
|
594
|
+
* Enables long signals in strategies that are primarily designed for short signals.
|
|
595
|
+
* This allows the strategy to generate and manage long signals in addition to short signals, even if the original design was focused on short trading.
|
|
596
|
+
* This can help expand the strategy's applicability and take advantage of bullish market conditions, but may require additional logic to manage long signal behavior effectively.
|
|
597
|
+
*
|
|
598
|
+
* Default: false (long signals are only enabled in strategies that are designed for them, ensuring strategy logic is aligned with signal types)
|
|
599
|
+
*/
|
|
600
|
+
CC_ENABLE_LONG_SIGNAL: true,
|
|
601
|
+
/**
|
|
602
|
+
* Enables short signals in strategies that are primarily designed for long signals.
|
|
603
|
+
* This allows the strategy to generate and manage short signals in addition to long signals, even if the original design was focused on long trading.
|
|
604
|
+
* This can help expand the strategy's applicability and take advantage of bearish market conditions, but may require additional logic to manage short signal behavior effectively.
|
|
605
|
+
*/
|
|
606
|
+
CC_ENABLE_SHORT_SIGNAL: true,
|
|
593
607
|
/**
|
|
594
608
|
* Enables trailing logic (Trailing Take / Trailing Stop) without requiring absorption conditions.
|
|
595
609
|
* Allows trailing mechanisms to be activated regardless of whether absorption has been detected.
|
|
@@ -4710,6 +4724,12 @@ const validateCommonSignal = (signal) => {
|
|
|
4710
4724
|
if (signal.position !== "long" && signal.position !== "short") {
|
|
4711
4725
|
errors.push(`position must be "long" or "short", got "${signal.position}"`);
|
|
4712
4726
|
}
|
|
4727
|
+
if (signal.position === "long" && !GLOBAL_CONFIG.CC_ENABLE_LONG_SIGNAL) {
|
|
4728
|
+
errors.push(`Long signals are disabled (CC_ENABLE_LONG_SIGNAL=false)`);
|
|
4729
|
+
}
|
|
4730
|
+
if (signal.position === "short" && !GLOBAL_CONFIG.CC_ENABLE_SHORT_SIGNAL) {
|
|
4731
|
+
errors.push(`Short signals are disabled (CC_ENABLE_SHORT_SIGNAL=false)`);
|
|
4732
|
+
}
|
|
4713
4733
|
}
|
|
4714
4734
|
// ЗАЩИТА ОТ NaN/Infinity: все цены должны быть конечными числами
|
|
4715
4735
|
{
|
|
@@ -21906,10 +21926,10 @@ let ReportStorage$a = class ReportStorage {
|
|
|
21906
21926
|
const fallVariance = fallReturns.reduce((sum, r) => sum + Math.pow(r, 2), 0) / totalSignals;
|
|
21907
21927
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
21908
21928
|
const sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
21909
|
-
//
|
|
21910
|
-
const
|
|
21911
|
-
const calmarRatio =
|
|
21912
|
-
const recoveryFactor =
|
|
21929
|
+
// Max absolute drawdown across all signals — used as denominator for Calmar and Recovery
|
|
21930
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
21931
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
21932
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
21913
21933
|
return {
|
|
21914
21934
|
signalList: this._signalList,
|
|
21915
21935
|
totalSignals,
|
|
@@ -22638,12 +22658,10 @@ let ReportStorage$9 = class ReportStorage {
|
|
|
22638
22658
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
22639
22659
|
sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
22640
22660
|
}
|
|
22641
|
-
//
|
|
22642
|
-
const
|
|
22643
|
-
|
|
22644
|
-
|
|
22645
|
-
const calmarRatio = avgAbsFall > 0 ? expectedYearlyReturns / avgAbsFall : 0;
|
|
22646
|
-
const recoveryFactor = avgAbsFall > 0 ? totalPnl / avgAbsFall : 0;
|
|
22661
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
22662
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
22663
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
22664
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
22647
22665
|
return {
|
|
22648
22666
|
eventList: this._eventList,
|
|
22649
22667
|
totalEvents: this._eventList.length,
|
|
@@ -24637,15 +24655,13 @@ class HeatmapStorage {
|
|
|
24637
24655
|
sortinoRatio = avgPnl / fallDeviation;
|
|
24638
24656
|
}
|
|
24639
24657
|
}
|
|
24640
|
-
//
|
|
24641
|
-
const
|
|
24642
|
-
? fallReturns.reduce((acc, r) => acc + Math.abs(r), 0) / signals.length
|
|
24643
|
-
: 0;
|
|
24658
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
24659
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
24644
24660
|
let calmarRatio = null;
|
|
24645
24661
|
let recoveryFactor = null;
|
|
24646
|
-
if (
|
|
24647
|
-
calmarRatio = totalPnl /
|
|
24648
|
-
recoveryFactor = totalPnl /
|
|
24662
|
+
if (maxAbsFall > 0 && totalPnl !== null) {
|
|
24663
|
+
calmarRatio = totalPnl / maxAbsFall;
|
|
24664
|
+
recoveryFactor = totalPnl / maxAbsFall;
|
|
24649
24665
|
}
|
|
24650
24666
|
// Apply safe math checks
|
|
24651
24667
|
if (isUnsafe(winRate))
|
|
@@ -50883,7 +50899,8 @@ class DumpAdapter {
|
|
|
50883
50899
|
const unClose = signalEmitter
|
|
50884
50900
|
.filter(({ action }) => action === "closed")
|
|
50885
50901
|
.connect(({ signal }) => handleDispose(signal.id));
|
|
50886
|
-
|
|
50902
|
+
const unEnable = () => this.enable.clear();
|
|
50903
|
+
return functoolsKit.compose(() => unCancel(), () => unClose(), () => unEnable());
|
|
50887
50904
|
});
|
|
50888
50905
|
/**
|
|
50889
50906
|
* Deactivates the adapter by unsubscribing from signal lifecycle events.
|
|
@@ -51570,7 +51587,7 @@ class ReportUtils {
|
|
|
51570
51587
|
*
|
|
51571
51588
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
51572
51589
|
*/
|
|
51573
|
-
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$2) => {
|
|
51590
|
+
this.enable = functoolsKit.singleshot(({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$2) => {
|
|
51574
51591
|
LOGGER_SERVICE$2.debug(REPORT_UTILS_METHOD_NAME_ENABLE, {
|
|
51575
51592
|
backtest: bt,
|
|
51576
51593
|
breakeven,
|
|
@@ -51624,8 +51641,11 @@ class ReportUtils {
|
|
|
51624
51641
|
if (max_drawdown) {
|
|
51625
51642
|
unList.push(backtest.maxDrawdownReportService.subscribe());
|
|
51626
51643
|
}
|
|
51644
|
+
{
|
|
51645
|
+
unList.push(() => this.enable.clear());
|
|
51646
|
+
}
|
|
51627
51647
|
return functoolsKit.compose(...unList.map((un) => () => void un()));
|
|
51628
|
-
};
|
|
51648
|
+
});
|
|
51629
51649
|
/**
|
|
51630
51650
|
* Disables report services selectively.
|
|
51631
51651
|
*
|
|
@@ -51676,6 +51696,11 @@ class ReportUtils {
|
|
|
51676
51696
|
strategy,
|
|
51677
51697
|
sync,
|
|
51678
51698
|
});
|
|
51699
|
+
if (this.enable.hasValue()) {
|
|
51700
|
+
const lastSubscription = this.enable();
|
|
51701
|
+
lastSubscription();
|
|
51702
|
+
return;
|
|
51703
|
+
}
|
|
51679
51704
|
if (bt) {
|
|
51680
51705
|
backtest.backtestReportService.unsubscribe();
|
|
51681
51706
|
}
|
|
@@ -51837,7 +51862,7 @@ class MarkdownUtils {
|
|
|
51837
51862
|
*
|
|
51838
51863
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
51839
51864
|
*/
|
|
51840
|
-
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, strategy = false, risk = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
51865
|
+
this.enable = functoolsKit.singleshot(({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, strategy = false, risk = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
51841
51866
|
LOGGER_SERVICE$1.debug(MARKDOWN_METHOD_NAME_ENABLE, {
|
|
51842
51867
|
backtest: bt,
|
|
51843
51868
|
breakeven,
|
|
@@ -51892,8 +51917,11 @@ class MarkdownUtils {
|
|
|
51892
51917
|
if (max_drawdown) {
|
|
51893
51918
|
unList.push(backtest.maxDrawdownMarkdownService.subscribe());
|
|
51894
51919
|
}
|
|
51920
|
+
{
|
|
51921
|
+
unList.push(() => this.enable.clear());
|
|
51922
|
+
}
|
|
51895
51923
|
return functoolsKit.compose(...unList.map((un) => () => void un()));
|
|
51896
|
-
};
|
|
51924
|
+
});
|
|
51897
51925
|
/**
|
|
51898
51926
|
* Disables markdown report services selectively.
|
|
51899
51927
|
*
|
|
@@ -51946,6 +51974,11 @@ class MarkdownUtils {
|
|
|
51946
51974
|
sync,
|
|
51947
51975
|
highest_profit,
|
|
51948
51976
|
});
|
|
51977
|
+
if (this.enable.hasValue()) {
|
|
51978
|
+
const lastSubscription = this.enable();
|
|
51979
|
+
lastSubscription();
|
|
51980
|
+
return;
|
|
51981
|
+
}
|
|
51949
51982
|
if (bt) {
|
|
51950
51983
|
backtest.backtestMarkdownService.unsubscribe();
|
|
51951
51984
|
}
|
package/build/index.mjs
CHANGED
|
@@ -570,6 +570,20 @@ const GLOBAL_CONFIG = {
|
|
|
570
570
|
* Default: false (PPPL logic is only applied when it does not break the direction of exits, ensuring clearer profit/loss outcomes)
|
|
571
571
|
*/
|
|
572
572
|
CC_ENABLE_PPPL_EVERYWHERE: false,
|
|
573
|
+
/**
|
|
574
|
+
* Enables long signals in strategies that are primarily designed for short signals.
|
|
575
|
+
* This allows the strategy to generate and manage long signals in addition to short signals, even if the original design was focused on short trading.
|
|
576
|
+
* This can help expand the strategy's applicability and take advantage of bullish market conditions, but may require additional logic to manage long signal behavior effectively.
|
|
577
|
+
*
|
|
578
|
+
* Default: false (long signals are only enabled in strategies that are designed for them, ensuring strategy logic is aligned with signal types)
|
|
579
|
+
*/
|
|
580
|
+
CC_ENABLE_LONG_SIGNAL: true,
|
|
581
|
+
/**
|
|
582
|
+
* Enables short signals in strategies that are primarily designed for long signals.
|
|
583
|
+
* This allows the strategy to generate and manage short signals in addition to long signals, even if the original design was focused on long trading.
|
|
584
|
+
* This can help expand the strategy's applicability and take advantage of bearish market conditions, but may require additional logic to manage short signal behavior effectively.
|
|
585
|
+
*/
|
|
586
|
+
CC_ENABLE_SHORT_SIGNAL: true,
|
|
573
587
|
/**
|
|
574
588
|
* Enables trailing logic (Trailing Take / Trailing Stop) without requiring absorption conditions.
|
|
575
589
|
* Allows trailing mechanisms to be activated regardless of whether absorption has been detected.
|
|
@@ -4690,6 +4704,12 @@ const validateCommonSignal = (signal) => {
|
|
|
4690
4704
|
if (signal.position !== "long" && signal.position !== "short") {
|
|
4691
4705
|
errors.push(`position must be "long" or "short", got "${signal.position}"`);
|
|
4692
4706
|
}
|
|
4707
|
+
if (signal.position === "long" && !GLOBAL_CONFIG.CC_ENABLE_LONG_SIGNAL) {
|
|
4708
|
+
errors.push(`Long signals are disabled (CC_ENABLE_LONG_SIGNAL=false)`);
|
|
4709
|
+
}
|
|
4710
|
+
if (signal.position === "short" && !GLOBAL_CONFIG.CC_ENABLE_SHORT_SIGNAL) {
|
|
4711
|
+
errors.push(`Short signals are disabled (CC_ENABLE_SHORT_SIGNAL=false)`);
|
|
4712
|
+
}
|
|
4693
4713
|
}
|
|
4694
4714
|
// ЗАЩИТА ОТ NaN/Infinity: все цены должны быть конечными числами
|
|
4695
4715
|
{
|
|
@@ -21886,10 +21906,10 @@ let ReportStorage$a = class ReportStorage {
|
|
|
21886
21906
|
const fallVariance = fallReturns.reduce((sum, r) => sum + Math.pow(r, 2), 0) / totalSignals;
|
|
21887
21907
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
21888
21908
|
const sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
21889
|
-
//
|
|
21890
|
-
const
|
|
21891
|
-
const calmarRatio =
|
|
21892
|
-
const recoveryFactor =
|
|
21909
|
+
// Max absolute drawdown across all signals — used as denominator for Calmar and Recovery
|
|
21910
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
21911
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
21912
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
21893
21913
|
return {
|
|
21894
21914
|
signalList: this._signalList,
|
|
21895
21915
|
totalSignals,
|
|
@@ -22618,12 +22638,10 @@ let ReportStorage$9 = class ReportStorage {
|
|
|
22618
22638
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
22619
22639
|
sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
22620
22640
|
}
|
|
22621
|
-
//
|
|
22622
|
-
const
|
|
22623
|
-
|
|
22624
|
-
|
|
22625
|
-
const calmarRatio = avgAbsFall > 0 ? expectedYearlyReturns / avgAbsFall : 0;
|
|
22626
|
-
const recoveryFactor = avgAbsFall > 0 ? totalPnl / avgAbsFall : 0;
|
|
22641
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
22642
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
22643
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
22644
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
22627
22645
|
return {
|
|
22628
22646
|
eventList: this._eventList,
|
|
22629
22647
|
totalEvents: this._eventList.length,
|
|
@@ -24617,15 +24635,13 @@ class HeatmapStorage {
|
|
|
24617
24635
|
sortinoRatio = avgPnl / fallDeviation;
|
|
24618
24636
|
}
|
|
24619
24637
|
}
|
|
24620
|
-
//
|
|
24621
|
-
const
|
|
24622
|
-
? fallReturns.reduce((acc, r) => acc + Math.abs(r), 0) / signals.length
|
|
24623
|
-
: 0;
|
|
24638
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
24639
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
24624
24640
|
let calmarRatio = null;
|
|
24625
24641
|
let recoveryFactor = null;
|
|
24626
|
-
if (
|
|
24627
|
-
calmarRatio = totalPnl /
|
|
24628
|
-
recoveryFactor = totalPnl /
|
|
24642
|
+
if (maxAbsFall > 0 && totalPnl !== null) {
|
|
24643
|
+
calmarRatio = totalPnl / maxAbsFall;
|
|
24644
|
+
recoveryFactor = totalPnl / maxAbsFall;
|
|
24629
24645
|
}
|
|
24630
24646
|
// Apply safe math checks
|
|
24631
24647
|
if (isUnsafe(winRate))
|
|
@@ -50863,7 +50879,8 @@ class DumpAdapter {
|
|
|
50863
50879
|
const unClose = signalEmitter
|
|
50864
50880
|
.filter(({ action }) => action === "closed")
|
|
50865
50881
|
.connect(({ signal }) => handleDispose(signal.id));
|
|
50866
|
-
|
|
50882
|
+
const unEnable = () => this.enable.clear();
|
|
50883
|
+
return compose(() => unCancel(), () => unClose(), () => unEnable());
|
|
50867
50884
|
});
|
|
50868
50885
|
/**
|
|
50869
50886
|
* Deactivates the adapter by unsubscribing from signal lifecycle events.
|
|
@@ -51550,7 +51567,7 @@ class ReportUtils {
|
|
|
51550
51567
|
*
|
|
51551
51568
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
51552
51569
|
*/
|
|
51553
|
-
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$2) => {
|
|
51570
|
+
this.enable = singleshot(({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$2) => {
|
|
51554
51571
|
LOGGER_SERVICE$2.debug(REPORT_UTILS_METHOD_NAME_ENABLE, {
|
|
51555
51572
|
backtest: bt,
|
|
51556
51573
|
breakeven,
|
|
@@ -51604,8 +51621,11 @@ class ReportUtils {
|
|
|
51604
51621
|
if (max_drawdown) {
|
|
51605
51622
|
unList.push(backtest.maxDrawdownReportService.subscribe());
|
|
51606
51623
|
}
|
|
51624
|
+
{
|
|
51625
|
+
unList.push(() => this.enable.clear());
|
|
51626
|
+
}
|
|
51607
51627
|
return compose(...unList.map((un) => () => void un()));
|
|
51608
|
-
};
|
|
51628
|
+
});
|
|
51609
51629
|
/**
|
|
51610
51630
|
* Disables report services selectively.
|
|
51611
51631
|
*
|
|
@@ -51656,6 +51676,11 @@ class ReportUtils {
|
|
|
51656
51676
|
strategy,
|
|
51657
51677
|
sync,
|
|
51658
51678
|
});
|
|
51679
|
+
if (this.enable.hasValue()) {
|
|
51680
|
+
const lastSubscription = this.enable();
|
|
51681
|
+
lastSubscription();
|
|
51682
|
+
return;
|
|
51683
|
+
}
|
|
51659
51684
|
if (bt) {
|
|
51660
51685
|
backtest.backtestReportService.unsubscribe();
|
|
51661
51686
|
}
|
|
@@ -51817,7 +51842,7 @@ class MarkdownUtils {
|
|
|
51817
51842
|
*
|
|
51818
51843
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
51819
51844
|
*/
|
|
51820
|
-
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, strategy = false, risk = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
51845
|
+
this.enable = singleshot(({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, strategy = false, risk = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
51821
51846
|
LOGGER_SERVICE$1.debug(MARKDOWN_METHOD_NAME_ENABLE, {
|
|
51822
51847
|
backtest: bt,
|
|
51823
51848
|
breakeven,
|
|
@@ -51872,8 +51897,11 @@ class MarkdownUtils {
|
|
|
51872
51897
|
if (max_drawdown) {
|
|
51873
51898
|
unList.push(backtest.maxDrawdownMarkdownService.subscribe());
|
|
51874
51899
|
}
|
|
51900
|
+
{
|
|
51901
|
+
unList.push(() => this.enable.clear());
|
|
51902
|
+
}
|
|
51875
51903
|
return compose(...unList.map((un) => () => void un()));
|
|
51876
|
-
};
|
|
51904
|
+
});
|
|
51877
51905
|
/**
|
|
51878
51906
|
* Disables markdown report services selectively.
|
|
51879
51907
|
*
|
|
@@ -51926,6 +51954,11 @@ class MarkdownUtils {
|
|
|
51926
51954
|
sync,
|
|
51927
51955
|
highest_profit,
|
|
51928
51956
|
});
|
|
51957
|
+
if (this.enable.hasValue()) {
|
|
51958
|
+
const lastSubscription = this.enable();
|
|
51959
|
+
lastSubscription();
|
|
51960
|
+
return;
|
|
51961
|
+
}
|
|
51929
51962
|
if (bt) {
|
|
51930
51963
|
backtest.backtestMarkdownService.unsubscribe();
|
|
51931
51964
|
}
|
package/package.json
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "backtest-kit",
|
|
3
|
-
"version": "8.
|
|
4
|
-
"description": "A TypeScript library for trading system backtest",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Petr Tripolsky",
|
|
7
|
-
"email": "tripolskypetr@gmail.com",
|
|
8
|
-
"url": "https://github.com/tripolskypetr"
|
|
9
|
-
},
|
|
10
|
-
"funding": {
|
|
11
|
-
"type": "individual",
|
|
12
|
-
"url": "http://paypal.me/tripolskypetr"
|
|
13
|
-
},
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"homepage": "https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html",
|
|
16
|
-
"keywords": [
|
|
17
|
-
"backtesting",
|
|
18
|
-
"backtest",
|
|
19
|
-
"finance",
|
|
20
|
-
"trading",
|
|
21
|
-
"candles",
|
|
22
|
-
"indicators",
|
|
23
|
-
"multi value",
|
|
24
|
-
"multi symbol",
|
|
25
|
-
"framework"
|
|
26
|
-
],
|
|
27
|
-
"files": [
|
|
28
|
-
"build",
|
|
29
|
-
"types.d.ts",
|
|
30
|
-
"README.md"
|
|
31
|
-
],
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "https://github.com/tripolskypetr/backtest-kit",
|
|
35
|
-
"documentation": "https://github.com/tripolskypetr/backtest-kit/tree/master/docs"
|
|
36
|
-
},
|
|
37
|
-
"bugs": {
|
|
38
|
-
"url": "https://github.com/tripolskypetr/backtest-kit/issues"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "rollup -c",
|
|
42
|
-
"test": "npm run build && node ./test/index.mjs",
|
|
43
|
-
"build:docs": "rimraf docs && mkdir docs && node ./scripts/dts-docs.cjs ./types.d.ts ./docs",
|
|
44
|
-
"docs:gpt": "npm run build && node ./tools/gpt-docs/index.mjs",
|
|
45
|
-
"docs:uml": "npm run build && node ./scripts/uml.mjs",
|
|
46
|
-
"docs:www": "rimraf docs/wwwroot && node ./tools/typedoc-packages-docs/index.mjs && typedoc && node ./tools/typedoc-yandex-metrica/index.mjs",
|
|
47
|
-
"repl": "dotenv -e .env -- npm run build && node -e \"import('./scripts/repl.mjs')\" --interactive"
|
|
48
|
-
},
|
|
49
|
-
"main": "build/index.cjs",
|
|
50
|
-
"module": "build/index.mjs",
|
|
51
|
-
"source": "src/index.ts",
|
|
52
|
-
"types": "./types.d.ts",
|
|
53
|
-
"exports": {
|
|
54
|
-
"require": "./build/index.cjs",
|
|
55
|
-
"types": "./types.d.ts",
|
|
56
|
-
"import": "./build/index.mjs",
|
|
57
|
-
"default": "./build/index.cjs"
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@rollup/plugin-typescript": "11.1.6",
|
|
61
|
-
"@types/node": "22.9.0",
|
|
62
|
-
"glob": "11.0.1",
|
|
63
|
-
"plantuml": "0.0.2",
|
|
64
|
-
"rimraf": "6.0.1",
|
|
65
|
-
"rollup": "3.29.5",
|
|
66
|
-
"rollup-plugin-dts": "6.1.1",
|
|
67
|
-
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
68
|
-
"ts-morph": "27.0.2",
|
|
69
|
-
"tslib": "2.7.0",
|
|
70
|
-
"typedoc": "0.27.9",
|
|
71
|
-
"worker-testbed": "2.0.0"
|
|
72
|
-
},
|
|
73
|
-
"peerDependencies": {
|
|
74
|
-
"typescript": "^5.0.0"
|
|
75
|
-
},
|
|
76
|
-
"dependencies": {
|
|
77
|
-
"di-kit": "^1.1.1",
|
|
78
|
-
"di-scoped": "^1.0.21",
|
|
79
|
-
"di-singleton": "^1.0.5",
|
|
80
|
-
"functools-kit": "^2.3.0",
|
|
81
|
-
"get-moment-stamp": "^1.1.2"
|
|
82
|
-
},
|
|
83
|
-
"publishConfig": {
|
|
84
|
-
"access": "public"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "backtest-kit",
|
|
3
|
+
"version": "8.1.1",
|
|
4
|
+
"description": "A TypeScript library for trading system backtest",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Petr Tripolsky",
|
|
7
|
+
"email": "tripolskypetr@gmail.com",
|
|
8
|
+
"url": "https://github.com/tripolskypetr"
|
|
9
|
+
},
|
|
10
|
+
"funding": {
|
|
11
|
+
"type": "individual",
|
|
12
|
+
"url": "http://paypal.me/tripolskypetr"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://backtest-kit.github.io/documents/article_07_ai_news_trading_signals.html",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"backtesting",
|
|
18
|
+
"backtest",
|
|
19
|
+
"finance",
|
|
20
|
+
"trading",
|
|
21
|
+
"candles",
|
|
22
|
+
"indicators",
|
|
23
|
+
"multi value",
|
|
24
|
+
"multi symbol",
|
|
25
|
+
"framework"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"build",
|
|
29
|
+
"types.d.ts",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/tripolskypetr/backtest-kit",
|
|
35
|
+
"documentation": "https://github.com/tripolskypetr/backtest-kit/tree/master/docs"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/tripolskypetr/backtest-kit/issues"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "rollup -c",
|
|
42
|
+
"test": "npm run build && node ./test/index.mjs",
|
|
43
|
+
"build:docs": "rimraf docs && mkdir docs && node ./scripts/dts-docs.cjs ./types.d.ts ./docs",
|
|
44
|
+
"docs:gpt": "npm run build && node ./tools/gpt-docs/index.mjs",
|
|
45
|
+
"docs:uml": "npm run build && node ./scripts/uml.mjs",
|
|
46
|
+
"docs:www": "rimraf docs/wwwroot && node ./tools/typedoc-packages-docs/index.mjs && typedoc && node ./tools/typedoc-yandex-metrica/index.mjs",
|
|
47
|
+
"repl": "dotenv -e .env -- npm run build && node -e \"import('./scripts/repl.mjs')\" --interactive"
|
|
48
|
+
},
|
|
49
|
+
"main": "build/index.cjs",
|
|
50
|
+
"module": "build/index.mjs",
|
|
51
|
+
"source": "src/index.ts",
|
|
52
|
+
"types": "./types.d.ts",
|
|
53
|
+
"exports": {
|
|
54
|
+
"require": "./build/index.cjs",
|
|
55
|
+
"types": "./types.d.ts",
|
|
56
|
+
"import": "./build/index.mjs",
|
|
57
|
+
"default": "./build/index.cjs"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@rollup/plugin-typescript": "11.1.6",
|
|
61
|
+
"@types/node": "22.9.0",
|
|
62
|
+
"glob": "11.0.1",
|
|
63
|
+
"plantuml": "0.0.2",
|
|
64
|
+
"rimraf": "6.0.1",
|
|
65
|
+
"rollup": "3.29.5",
|
|
66
|
+
"rollup-plugin-dts": "6.1.1",
|
|
67
|
+
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
68
|
+
"ts-morph": "27.0.2",
|
|
69
|
+
"tslib": "2.7.0",
|
|
70
|
+
"typedoc": "0.27.9",
|
|
71
|
+
"worker-testbed": "2.0.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"typescript": "^5.0.0"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"di-kit": "^1.1.1",
|
|
78
|
+
"di-scoped": "^1.0.21",
|
|
79
|
+
"di-singleton": "^1.0.5",
|
|
80
|
+
"functools-kit": "^2.3.0",
|
|
81
|
+
"get-moment-stamp": "^1.1.2"
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -6484,6 +6484,20 @@ declare const GLOBAL_CONFIG: {
|
|
|
6484
6484
|
* Default: false (PPPL logic is only applied when it does not break the direction of exits, ensuring clearer profit/loss outcomes)
|
|
6485
6485
|
*/
|
|
6486
6486
|
CC_ENABLE_PPPL_EVERYWHERE: boolean;
|
|
6487
|
+
/**
|
|
6488
|
+
* Enables long signals in strategies that are primarily designed for short signals.
|
|
6489
|
+
* This allows the strategy to generate and manage long signals in addition to short signals, even if the original design was focused on short trading.
|
|
6490
|
+
* This can help expand the strategy's applicability and take advantage of bullish market conditions, but may require additional logic to manage long signal behavior effectively.
|
|
6491
|
+
*
|
|
6492
|
+
* Default: false (long signals are only enabled in strategies that are designed for them, ensuring strategy logic is aligned with signal types)
|
|
6493
|
+
*/
|
|
6494
|
+
CC_ENABLE_LONG_SIGNAL: boolean;
|
|
6495
|
+
/**
|
|
6496
|
+
* Enables short signals in strategies that are primarily designed for long signals.
|
|
6497
|
+
* This allows the strategy to generate and manage short signals in addition to long signals, even if the original design was focused on long trading.
|
|
6498
|
+
* This can help expand the strategy's applicability and take advantage of bearish market conditions, but may require additional logic to manage short signal behavior effectively.
|
|
6499
|
+
*/
|
|
6500
|
+
CC_ENABLE_SHORT_SIGNAL: boolean;
|
|
6487
6501
|
/**
|
|
6488
6502
|
* Enables trailing logic (Trailing Take / Trailing Stop) without requiring absorption conditions.
|
|
6489
6503
|
* Allows trailing mechanisms to be activated regardless of whether absorption has been detected.
|
|
@@ -6632,6 +6646,8 @@ declare function getConfig(): {
|
|
|
6632
6646
|
CC_ENABLE_CANDLE_FETCH_MUTEX: boolean;
|
|
6633
6647
|
CC_ENABLE_DCA_EVERYWHERE: boolean;
|
|
6634
6648
|
CC_ENABLE_PPPL_EVERYWHERE: boolean;
|
|
6649
|
+
CC_ENABLE_LONG_SIGNAL: boolean;
|
|
6650
|
+
CC_ENABLE_SHORT_SIGNAL: boolean;
|
|
6635
6651
|
CC_ENABLE_TRAILING_EVERYWHERE: boolean;
|
|
6636
6652
|
CC_POSITION_ENTRY_COST: number;
|
|
6637
6653
|
};
|
|
@@ -6688,6 +6704,8 @@ declare function getDefaultConfig(): Readonly<{
|
|
|
6688
6704
|
CC_ENABLE_CANDLE_FETCH_MUTEX: boolean;
|
|
6689
6705
|
CC_ENABLE_DCA_EVERYWHERE: boolean;
|
|
6690
6706
|
CC_ENABLE_PPPL_EVERYWHERE: boolean;
|
|
6707
|
+
CC_ENABLE_LONG_SIGNAL: boolean;
|
|
6708
|
+
CC_ENABLE_SHORT_SIGNAL: boolean;
|
|
6691
6709
|
CC_ENABLE_TRAILING_EVERYWHERE: boolean;
|
|
6692
6710
|
CC_POSITION_ENTRY_COST: number;
|
|
6693
6711
|
}>;
|
|
@@ -14735,7 +14753,7 @@ declare class ReportUtils {
|
|
|
14735
14753
|
*
|
|
14736
14754
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
14737
14755
|
*/
|
|
14738
|
-
enable: ({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, strategy, sync, highest_profit, max_drawdown, }?: Partial<IReportTarget>) => (...args: any[]) => any
|
|
14756
|
+
enable: (({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, strategy, sync, highest_profit, max_drawdown, }?: Partial<IReportTarget>) => (...args: any[]) => any) & functools_kit.ISingleshotClearable<({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, strategy, sync, highest_profit, max_drawdown, }?: Partial<IReportTarget>) => (...args: any[]) => any>;
|
|
14739
14757
|
/**
|
|
14740
14758
|
* Disables report services selectively.
|
|
14741
14759
|
*
|
|
@@ -14852,7 +14870,7 @@ declare class MarkdownUtils {
|
|
|
14852
14870
|
*
|
|
14853
14871
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
14854
14872
|
*/
|
|
14855
|
-
enable: ({ backtest: bt, breakeven, heat, live, partial, performance, strategy, risk, schedule, walker, sync, highest_profit, max_drawdown, }?: Partial<IMarkdownTarget>) => (...args: any[]) => any
|
|
14873
|
+
enable: (({ backtest: bt, breakeven, heat, live, partial, performance, strategy, risk, schedule, walker, sync, highest_profit, max_drawdown, }?: Partial<IMarkdownTarget>) => (...args: any[]) => any) & functools_kit.ISingleshotClearable<({ backtest: bt, breakeven, heat, live, partial, performance, strategy, risk, schedule, walker, sync, highest_profit, max_drawdown, }?: Partial<IMarkdownTarget>) => (...args: any[]) => any>;
|
|
14856
14874
|
/**
|
|
14857
14875
|
* Disables markdown report services selectively.
|
|
14858
14876
|
*
|