backtest-kit 10.1.0 → 10.2.0

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/package.json CHANGED
@@ -1,86 +1,86 @@
1
- {
2
- "name": "backtest-kit",
3
- "version": "10.1.0",
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": "^2.0.0"
82
- },
83
- "publishConfig": {
84
- "access": "public"
85
- }
86
- }
1
+ {
2
+ "name": "backtest-kit",
3
+ "version": "10.2.0",
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": "^2.0.0"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ }
86
+ }
package/types.d.ts CHANGED
@@ -4618,7 +4618,7 @@ interface BacktestStatisticsModel {
4618
4618
  stdDev: number | null;
4619
4619
  /** Sharpe Ratio (risk-adjusted return = avgPnl / stdDev), null if unsafe. Higher is better. */
4620
4620
  sharpeRatio: number | null;
4621
- /** Annualized Sharpe Ratio (sharpeRatio × √365), null if unsafe. Higher is better. */
4621
+ /** Annualized Sharpe Ratio (sharpeRatio × √tradesPerYear), null if unsafe. Higher is better. */
4622
4622
  annualizedSharpeRatio: number | null;
4623
4623
  /** Certainty Ratio (avgWin / |avgLoss|), null if unsafe. Higher is better. */
4624
4624
  certaintyRatio: number | null;
@@ -4628,7 +4628,7 @@ interface BacktestStatisticsModel {
4628
4628
  avgPeakPnl: number | null;
4629
4629
  /** Average fall PNL percentage across all signals (_fall.pnlPercentage), null if unsafe. Lower (more negative) means deeper drawdowns. */
4630
4630
  avgFallPnl: number | null;
4631
- /** Sortino Ratio (avgPnl / downside deviation — stdDev of losses only), null if unsafe. Higher is better. */
4631
+ /** Sortino Ratio (avgPnl / downside deviation — RMS of losing trades only), null if unsafe. Higher is better. */
4632
4632
  sortinoRatio: number | null;
4633
4633
  /** Calmar Ratio (annualized expected return / max drawdown), null if unsafe. Higher is better. */
4634
4634
  calmarRatio: number | null;
@@ -10693,7 +10693,7 @@ interface IHeatmapRow {
10693
10693
  symbol: string;
10694
10694
  /** Total profit/loss percentage across all closed trades */
10695
10695
  totalPnl: number | null;
10696
- /** Risk-adjusted return (Sharpe Ratio) */
10696
+ /** Risk-adjusted return per trade (Sharpe Ratio = avgPnl / stdDev) */
10697
10697
  sharpeRatio: number | null;
10698
10698
  /** Maximum drawdown percentage (largest peak-to-trough decline) */
10699
10699
  maxDrawdown: number | null;
@@ -10725,7 +10725,7 @@ interface IHeatmapRow {
10725
10725
  avgPeakPnl: number | null;
10726
10726
  /** Average fall PNL percentage across all trades (_fall.pnlPercentage). Closer to 0 is better. */
10727
10727
  avgFallPnl: number | null;
10728
- /** Sortino Ratio (avgPnl / downside deviation — stdDev of losses only). Higher is better. */
10728
+ /** Sortino Ratio (avgPnl / downside deviation — RMS of losing trades only). Higher is better. */
10729
10729
  sortinoRatio: number | null;
10730
10730
  /** Calmar Ratio (totalPnl / maxDrawdown). Higher is better. */
10731
10731
  calmarRatio: number | null;
@@ -12593,7 +12593,7 @@ interface LiveStatisticsModel {
12593
12593
  stdDev: number | null;
12594
12594
  /** Sharpe Ratio (risk-adjusted return = avgPnl / stdDev), null if unsafe. Higher is better. */
12595
12595
  sharpeRatio: number | null;
12596
- /** Annualized Sharpe Ratio (sharpeRatio × √365), null if unsafe. Higher is better. */
12596
+ /** Annualized Sharpe Ratio (sharpeRatio × √tradesPerYear), null if unsafe. Higher is better. */
12597
12597
  annualizedSharpeRatio: number | null;
12598
12598
  /** Certainty Ratio (avgWin / |avgLoss|), null if unsafe. Higher is better. */
12599
12599
  certaintyRatio: number | null;
@@ -12603,7 +12603,7 @@ interface LiveStatisticsModel {
12603
12603
  avgPeakPnl: number | null;
12604
12604
  /** Average fall PNL percentage across all closed signals (_fall.pnlPercentage), null if unsafe. Closer to 0 is better. */
12605
12605
  avgFallPnl: number | null;
12606
- /** Sortino Ratio (avgPnl / downside deviation — stdDev of losses only), null if unsafe. Higher is better. */
12606
+ /** Sortino Ratio (avgPnl / downside deviation — RMS of losing trades only), null if unsafe. Higher is better. */
12607
12607
  sortinoRatio: number | null;
12608
12608
  /** Calmar Ratio (annualized expected return / max drawdown), null if unsafe. Higher is better. */
12609
12609
  calmarRatio: number | null;
@@ -21480,7 +21480,7 @@ declare class HeatMarkdownService {
21480
21480
  * console.log(markdown);
21481
21481
  * // # Portfolio Heatmap: my-strategy
21482
21482
  * //
21483
- * // **Total Symbols:** 5 | **Portfolio PNL:** +45.3% | **Portfolio Sharpe:** 1.85 | **Total Trades:** 120
21483
+ * // **Total Symbols:** 5 | **Portfolio PNL:** +45.3% | **Pooled Sharpe:** 1.85 | **Total Trades:** 120
21484
21484
  * //
21485
21485
  * // | Symbol | Total PNL | Sharpe | Max DD | Trades |
21486
21486
  * // | --- | --- | --- | --- | --- |
@@ -26529,6 +26529,33 @@ declare class CronUtils {
26529
26529
  * `clear()` for those).
26530
26530
  */
26531
26531
  disable: () => void;
26532
+ /**
26533
+ * Hard-reset the entire `Cron` state.
26534
+ *
26535
+ * Performs in order:
26536
+ * 1. {@link disable} — tears down lifecycle subscriptions and resets the
26537
+ * `enable` singleshot so a future `enable()` re-subscribes cleanly.
26538
+ * 2. Wipes `_entries` — every {@link register}'ed entry is forgotten.
26539
+ * Disposers returned by previous `register()` calls become no-ops
26540
+ * (their `unregister(name)` will not find anything to remove).
26541
+ * 3. Wipes `_firedOnce` — all fire-once marks are dropped, so any future
26542
+ * re-registration of the same `name` fires again on the next matching
26543
+ * tick.
26544
+ * 4. Does **not** touch `_inFlight` — in-flight handlers continue to
26545
+ * settle in the background and clear their own slots via `.finally()`.
26546
+ * Their final `_firedOnce.add(firedKey)` writes carry old-generation
26547
+ * keys and are harmless (lookup uses the post-dispose generation).
26548
+ *
26549
+ * Use from a CLI/session teardown when you want to throw away every
26550
+ * registration along with the lifecycle wiring — e.g. between two
26551
+ * independent runner scopes. For "just snap the subscriptions but keep
26552
+ * registrations" use {@link disable} instead; for "just re-arm fire-once
26553
+ * marks" use {@link clear}.
26554
+ *
26555
+ * Idempotent. Safe to call multiple times and safe to call before
26556
+ * `enable()` / without any registrations.
26557
+ */
26558
+ dispose: () => void;
26532
26559
  }
26533
26560
  /**
26534
26561
  * Singleton instance of {@link CronUtils} for registering periodic tasks