@backtest-kit/cli 5.1.0 โ†’ 5.3.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/build/index.cjs CHANGED
@@ -106,6 +106,10 @@ BacktestKit.setConfig({
106
106
  CC_MAX_NOTIFICATIONS: 5000,
107
107
  CC_MAX_SIGNALS: 750,
108
108
  });
109
+ BacktestKit.setConfig({
110
+ CC_ENABLE_DCA_EVERYWHERE: true,
111
+ CC_ENABLE_PPPL_EVERYWHERE: true,
112
+ });
109
113
  BacktestKit.Log.useJsonl();
110
114
 
111
115
  const ERROR_HANDLER_INSTALLED = Symbol.for("error-handler-installed");
@@ -249,10 +253,10 @@ const entrySubject = new functoolsKit.BehaviorSubject();
249
253
 
250
254
  const __filename$2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
251
255
  const __dirname$2 = path.dirname(__filename$2);
252
- const require$3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
256
+ const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
253
257
  const REQUIRE_ENTRY_FACTORY = (filePath) => {
254
258
  try {
255
- require$3(filePath);
259
+ require$2(filePath);
256
260
  return true;
257
261
  }
258
262
  catch {
@@ -660,7 +664,7 @@ class BacktestMainService {
660
664
  });
661
665
  notifyVerbose();
662
666
  }
663
- await this.moduleConnectionService.loadModule("./backtest.module");
667
+ await this.moduleConnectionService.loadModule("./backtest");
664
668
  BacktestKit.Backtest.background(symbol, {
665
669
  strategyName,
666
670
  frameName,
@@ -740,7 +744,7 @@ class LiveMainService {
740
744
  });
741
745
  notifyVerbose();
742
746
  }
743
- await this.moduleConnectionService.loadModule("./live.module");
747
+ await this.moduleConnectionService.loadModule("./live");
744
748
  BacktestKit.Live.background(symbol, {
745
749
  strategyName,
746
750
  exchangeName,
@@ -813,7 +817,7 @@ class PaperMainService {
813
817
  });
814
818
  notifyVerbose();
815
819
  }
816
- await this.moduleConnectionService.loadModule("./paper.module");
820
+ await this.moduleConnectionService.loadModule("./paper");
817
821
  BacktestKit.Live.background(symbol, {
818
822
  strategyName,
819
823
  exchangeName,
@@ -1536,6 +1540,26 @@ class TelegramLogicService {
1536
1540
  markdown,
1537
1541
  });
1538
1542
  });
1543
+ this.notifyCancelScheduled = async (event) => {
1544
+ this.loggerService.log("telegramLogicService notifyCancelScheduled", {
1545
+ event,
1546
+ });
1547
+ const markdown = await this.telegramTemplateService.getCancelScheduledMarkdown(event);
1548
+ await this.telegramWebService.publishNotify({
1549
+ symbol: event.symbol,
1550
+ markdown,
1551
+ });
1552
+ };
1553
+ this.notifyClosePending = async (event) => {
1554
+ this.loggerService.log("telegramLogicService notifyClosePending", {
1555
+ event,
1556
+ });
1557
+ const markdown = await this.telegramTemplateService.getClosePendingMarkdown(event);
1558
+ await this.telegramWebService.publishNotify({
1559
+ symbol: event.symbol,
1560
+ markdown,
1561
+ });
1562
+ };
1539
1563
  this.connect = functoolsKit.singleshot(() => {
1540
1564
  this.loggerService.log("telegramLogicService connect");
1541
1565
  const unRisk = BacktestKit.listenRisk(async (event) => {
@@ -1584,6 +1608,14 @@ class TelegramLogicService {
1584
1608
  await this.notifyAverageBuy(event);
1585
1609
  return;
1586
1610
  }
1611
+ if (event.action === "cancel-scheduled") {
1612
+ await this.notifyCancelScheduled(event);
1613
+ return;
1614
+ }
1615
+ if (event.action === "close-pending") {
1616
+ await this.notifyClosePending(event);
1617
+ return;
1618
+ }
1587
1619
  });
1588
1620
  const unSync = BacktestKit.listenSync(async (event) => {
1589
1621
  if (event.action === "signal-open") {
@@ -1703,10 +1735,22 @@ class TelegramTemplateService {
1703
1735
  });
1704
1736
  return await RENDER_TEMPLATE_FN("signal-close.mustache", event, this);
1705
1737
  };
1738
+ this.getCancelScheduledMarkdown = async (event) => {
1739
+ this.loggerService.log("telegramTemplateService getCancelScheduledMarkdown", {
1740
+ event,
1741
+ });
1742
+ return await RENDER_TEMPLATE_FN("cancel-scheduled.mustache", event, this);
1743
+ };
1744
+ this.getClosePendingMarkdown = async (event) => {
1745
+ this.loggerService.log("telegramTemplateService getClosePendingMarkdown", {
1746
+ event,
1747
+ });
1748
+ return await RENDER_TEMPLATE_FN("close-pending.mustache", event, this);
1749
+ };
1706
1750
  }
1707
1751
  }
1708
1752
 
1709
- const require$2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1753
+ const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1710
1754
  const getExtVariants = (fileName) => {
1711
1755
  const ext = path.extname(fileName);
1712
1756
  const base = ext ? fileName.slice(0, -ext.length) : fileName;
@@ -1722,7 +1766,7 @@ const getExtVariants = (fileName) => {
1722
1766
  const REQUIRE_MODULE_FACTORY = (fileName) => {
1723
1767
  for (const variant of getExtVariants(fileName)) {
1724
1768
  try {
1725
- require$2(variant);
1769
+ require$1(variant);
1726
1770
  return true;
1727
1771
  }
1728
1772
  catch {
@@ -1785,26 +1829,28 @@ class ModuleConnectionService {
1785
1829
  }
1786
1830
 
1787
1831
  standalone.registerPlugin("plugin-transform-modules-umd", pluginUMD);
1788
- const baseRequire = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1789
- const require$1 = new Proxy(baseRequire, {
1790
- apply(_target, _this, args) {
1791
- const id = args[0];
1792
- if (id === "backtest-kit")
1793
- return globalThis.BacktestKit;
1794
- if (id === "@backtest-kit/cli")
1795
- return globalThis.BacktestKitCli;
1796
- if (id === "@backtest-kit/ui")
1797
- return globalThis.BacktestKitUi;
1798
- if (id === "@backtest-kit/graph")
1799
- return globalThis.BacktestKitGraph;
1800
- if (id === "@backtest-kit/ollama")
1801
- return globalThis.BacktestKitOllama;
1802
- if (id === "@backtest-kit/pinets")
1803
- return globalThis.BacktestKitPinets;
1804
- if (id === "@backtest-kit/signals")
1805
- return globalThis.BacktestKitSignals;
1806
- return baseRequire(id);
1807
- },
1832
+ const getBaseRequire = functoolsKit.singleshot(() => {
1833
+ const baseRequire = module$1.createRequire(path.join(process.cwd(), "index.cjs"));
1834
+ return new Proxy(baseRequire, {
1835
+ apply(_target, _this, args) {
1836
+ const id = args[0];
1837
+ if (id === "backtest-kit")
1838
+ return globalThis.BacktestKit;
1839
+ if (id === "@backtest-kit/cli")
1840
+ return globalThis.BacktestKitCli;
1841
+ if (id === "@backtest-kit/ui")
1842
+ return globalThis.BacktestKitUi;
1843
+ if (id === "@backtest-kit/graph")
1844
+ return globalThis.BacktestKitGraph;
1845
+ if (id === "@backtest-kit/ollama")
1846
+ return globalThis.BacktestKitOllama;
1847
+ if (id === "@backtest-kit/pinets")
1848
+ return globalThis.BacktestKitPinets;
1849
+ if (id === "@backtest-kit/signals")
1850
+ return globalThis.BacktestKitSignals;
1851
+ return baseRequire(id);
1852
+ },
1853
+ });
1808
1854
  });
1809
1855
  const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1810
1856
  const __dirname$1 = path.dirname(__filename$1);
@@ -1852,11 +1898,12 @@ class BabelService {
1852
1898
  this.loggerService.log("babelService transpileAndRun", {
1853
1899
  codeLen: code.length,
1854
1900
  });
1901
+ const require = getBaseRequire();
1855
1902
  const module = { exports: {} };
1856
1903
  const exports = module.exports;
1857
1904
  eval(this.transpile(code));
1858
1905
  return {
1859
- require: require$1,
1906
+ require,
1860
1907
  __filename: __filename$1,
1861
1908
  __dirname: __dirname$1,
1862
1909
  exports,
package/build/index.mjs CHANGED
@@ -80,6 +80,10 @@ setConfig({
80
80
  CC_MAX_NOTIFICATIONS: 5000,
81
81
  CC_MAX_SIGNALS: 750,
82
82
  });
83
+ setConfig({
84
+ CC_ENABLE_DCA_EVERYWHERE: true,
85
+ CC_ENABLE_PPPL_EVERYWHERE: true,
86
+ });
83
87
  Log.useJsonl();
84
88
 
85
89
  const ERROR_HANDLER_INSTALLED = Symbol.for("error-handler-installed");
@@ -634,7 +638,7 @@ class BacktestMainService {
634
638
  });
635
639
  notifyVerbose();
636
640
  }
637
- await this.moduleConnectionService.loadModule("./backtest.module");
641
+ await this.moduleConnectionService.loadModule("./backtest");
638
642
  Backtest.background(symbol, {
639
643
  strategyName,
640
644
  frameName,
@@ -714,7 +718,7 @@ class LiveMainService {
714
718
  });
715
719
  notifyVerbose();
716
720
  }
717
- await this.moduleConnectionService.loadModule("./live.module");
721
+ await this.moduleConnectionService.loadModule("./live");
718
722
  Live.background(symbol, {
719
723
  strategyName,
720
724
  exchangeName,
@@ -787,7 +791,7 @@ class PaperMainService {
787
791
  });
788
792
  notifyVerbose();
789
793
  }
790
- await this.moduleConnectionService.loadModule("./paper.module");
794
+ await this.moduleConnectionService.loadModule("./paper");
791
795
  Live.background(symbol, {
792
796
  strategyName,
793
797
  exchangeName,
@@ -1510,6 +1514,26 @@ class TelegramLogicService {
1510
1514
  markdown,
1511
1515
  });
1512
1516
  });
1517
+ this.notifyCancelScheduled = async (event) => {
1518
+ this.loggerService.log("telegramLogicService notifyCancelScheduled", {
1519
+ event,
1520
+ });
1521
+ const markdown = await this.telegramTemplateService.getCancelScheduledMarkdown(event);
1522
+ await this.telegramWebService.publishNotify({
1523
+ symbol: event.symbol,
1524
+ markdown,
1525
+ });
1526
+ };
1527
+ this.notifyClosePending = async (event) => {
1528
+ this.loggerService.log("telegramLogicService notifyClosePending", {
1529
+ event,
1530
+ });
1531
+ const markdown = await this.telegramTemplateService.getClosePendingMarkdown(event);
1532
+ await this.telegramWebService.publishNotify({
1533
+ symbol: event.symbol,
1534
+ markdown,
1535
+ });
1536
+ };
1513
1537
  this.connect = singleshot(() => {
1514
1538
  this.loggerService.log("telegramLogicService connect");
1515
1539
  const unRisk = listenRisk(async (event) => {
@@ -1558,6 +1582,14 @@ class TelegramLogicService {
1558
1582
  await this.notifyAverageBuy(event);
1559
1583
  return;
1560
1584
  }
1585
+ if (event.action === "cancel-scheduled") {
1586
+ await this.notifyCancelScheduled(event);
1587
+ return;
1588
+ }
1589
+ if (event.action === "close-pending") {
1590
+ await this.notifyClosePending(event);
1591
+ return;
1592
+ }
1561
1593
  });
1562
1594
  const unSync = listenSync(async (event) => {
1563
1595
  if (event.action === "signal-open") {
@@ -1677,6 +1709,18 @@ class TelegramTemplateService {
1677
1709
  });
1678
1710
  return await RENDER_TEMPLATE_FN("signal-close.mustache", event, this);
1679
1711
  };
1712
+ this.getCancelScheduledMarkdown = async (event) => {
1713
+ this.loggerService.log("telegramTemplateService getCancelScheduledMarkdown", {
1714
+ event,
1715
+ });
1716
+ return await RENDER_TEMPLATE_FN("cancel-scheduled.mustache", event, this);
1717
+ };
1718
+ this.getClosePendingMarkdown = async (event) => {
1719
+ this.loggerService.log("telegramTemplateService getClosePendingMarkdown", {
1720
+ event,
1721
+ });
1722
+ return await RENDER_TEMPLATE_FN("close-pending.mustache", event, this);
1723
+ };
1680
1724
  }
1681
1725
  }
1682
1726
 
@@ -1759,26 +1803,28 @@ class ModuleConnectionService {
1759
1803
  }
1760
1804
 
1761
1805
  registerPlugin("plugin-transform-modules-umd", pluginUMD);
1762
- const baseRequire = createRequire(import.meta.url);
1763
- const require = new Proxy(baseRequire, {
1764
- apply(_target, _this, args) {
1765
- const id = args[0];
1766
- if (id === "backtest-kit")
1767
- return globalThis.BacktestKit;
1768
- if (id === "@backtest-kit/cli")
1769
- return globalThis.BacktestKitCli;
1770
- if (id === "@backtest-kit/ui")
1771
- return globalThis.BacktestKitUi;
1772
- if (id === "@backtest-kit/graph")
1773
- return globalThis.BacktestKitGraph;
1774
- if (id === "@backtest-kit/ollama")
1775
- return globalThis.BacktestKitOllama;
1776
- if (id === "@backtest-kit/pinets")
1777
- return globalThis.BacktestKitPinets;
1778
- if (id === "@backtest-kit/signals")
1779
- return globalThis.BacktestKitSignals;
1780
- return baseRequire(id);
1781
- },
1806
+ const getBaseRequire = singleshot(() => {
1807
+ const baseRequire = createRequire(path.join(process.cwd(), "index.cjs"));
1808
+ return new Proxy(baseRequire, {
1809
+ apply(_target, _this, args) {
1810
+ const id = args[0];
1811
+ if (id === "backtest-kit")
1812
+ return globalThis.BacktestKit;
1813
+ if (id === "@backtest-kit/cli")
1814
+ return globalThis.BacktestKitCli;
1815
+ if (id === "@backtest-kit/ui")
1816
+ return globalThis.BacktestKitUi;
1817
+ if (id === "@backtest-kit/graph")
1818
+ return globalThis.BacktestKitGraph;
1819
+ if (id === "@backtest-kit/ollama")
1820
+ return globalThis.BacktestKitOllama;
1821
+ if (id === "@backtest-kit/pinets")
1822
+ return globalThis.BacktestKitPinets;
1823
+ if (id === "@backtest-kit/signals")
1824
+ return globalThis.BacktestKitSignals;
1825
+ return baseRequire(id);
1826
+ },
1827
+ });
1782
1828
  });
1783
1829
  const __filename = fileURLToPath(import.meta.url);
1784
1830
  const __dirname = path.dirname(__filename);
@@ -1826,6 +1872,7 @@ class BabelService {
1826
1872
  this.loggerService.log("babelService transpileAndRun", {
1827
1873
  codeLen: code.length,
1828
1874
  });
1875
+ const require = getBaseRequire();
1829
1876
  const module = { exports: {} };
1830
1877
  const exports = module.exports;
1831
1878
  eval(this.transpile(code));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/cli",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Zero-boilerplate CLI runner for backtest-kit strategies. Run backtests, paper trading, and live bots with candle cache warming, web dashboard, and Telegram notifications โ€” no setup code required.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -60,11 +60,11 @@
60
60
  "devDependencies": {
61
61
  "@babel/plugin-transform-modules-umd": "7.27.1",
62
62
  "@babel/standalone": "7.29.1",
63
- "@backtest-kit/ui": "5.1.0",
64
- "@backtest-kit/graph": "5.1.0",
65
- "@backtest-kit/ollama": "5.1.0",
66
- "@backtest-kit/pinets": "5.1.0",
67
- "@backtest-kit/signals": "5.1.0",
63
+ "@backtest-kit/ui": "5.3.0",
64
+ "@backtest-kit/graph": "5.3.0",
65
+ "@backtest-kit/ollama": "5.3.0",
66
+ "@backtest-kit/pinets": "5.3.0",
67
+ "@backtest-kit/signals": "5.3.0",
68
68
  "@rollup/plugin-replace": "6.0.3",
69
69
  "@rollup/plugin-typescript": "11.1.6",
70
70
  "@types/image-size": "0.7.0",
@@ -72,7 +72,7 @@
72
72
  "@types/mustache": "4.2.6",
73
73
  "@types/node": "22.9.0",
74
74
  "@types/stack-trace": "0.0.33",
75
- "backtest-kit": "5.1.0",
75
+ "backtest-kit": "5.3.0",
76
76
  "glob": "11.0.1",
77
77
  "markdown-it": "14.1.1",
78
78
  "rimraf": "6.0.1",
@@ -87,12 +87,12 @@
87
87
  "peerDependencies": {
88
88
  "@babel/plugin-transform-modules-umd": "^7.27.1",
89
89
  "@babel/standalone": "^7.29.1",
90
- "@backtest-kit/ui": "^5.1.0",
91
- "@backtest-kit/graph": "^5.1.0",
92
- "@backtest-kit/ollama": "^5.1.0",
93
- "@backtest-kit/pinets": "^5.1.0",
94
- "@backtest-kit/signals": "^5.1.0",
95
- "backtest-kit": "^5.1.0",
90
+ "@backtest-kit/ui": "^5.3.0",
91
+ "@backtest-kit/graph": "^5.3.0",
92
+ "@backtest-kit/ollama": "^5.3.0",
93
+ "@backtest-kit/pinets": "^5.3.0",
94
+ "@backtest-kit/signals": "^5.3.0",
95
+ "backtest-kit": "^5.3.0",
96
96
  "markdown-it": "^14.1.1",
97
97
  "typescript": "^5.0.0"
98
98
  },
@@ -0,0 +1,15 @@
1
+ **๐Ÿšซ Cancel Scheduled**
2
+
3
+ **Symbol:** `{{symbol}}`
4
+
5
+ **Orig Entry:** `{{originalPriceOpen}}`
6
+ **DCA Entries:** `{{totalEntries}}`
7
+ **Partials Done:** `{{totalPartials}}`
8
+ {{#cancelId}}**Cancel ID:** `{{cancelId}}`
9
+ {{/cancelId}}**PnL:** {{pnl.pnlPercentage}}% ({{pnl.pnlCost}} / {{pnl.pnlEntries}})
10
+ **Signal ID:** `{{signalId}}`
11
+ **Time:** `{{timestamp}}`
12
+
13
+ {{#backtest}}
14
+ _๐Ÿงช Backtest_
15
+ {{/backtest}}
@@ -0,0 +1,15 @@
1
+ **๐Ÿ”’ Close Pending**
2
+
3
+ **Symbol:** `{{symbol}}`
4
+
5
+ **Orig Entry:** `{{originalPriceOpen}}`
6
+ **DCA Entries:** `{{totalEntries}}`
7
+ **Partials Done:** `{{totalPartials}}`
8
+ {{#closeId}}**Close ID:** `{{closeId}}`
9
+ {{/closeId}}**PnL:** {{pnl.pnlPercentage}}% ({{pnl.pnlCost}} / {{pnl.pnlEntries}})
10
+ **Signal ID:** `{{signalId}}`
11
+ **Time:** `{{timestamp}}`
12
+
13
+ {{#backtest}}
14
+ _๐Ÿงช Backtest_
15
+ {{/backtest}}
package/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as functools_kit from 'functools-kit';
2
2
  import * as BacktestKit from 'backtest-kit';
3
- import { CandleInterval, TrailingTakeCommit, TrailingStopCommit, BreakevenCommit, PartialProfitCommit, PartialLossCommit, IStrategyTickResultScheduled, IStrategyTickResultCancelled, IStrategyTickResultOpened, IStrategyTickResultClosed, RiskContract, AverageBuyCommit, SignalOpenContract, SignalCloseContract } from 'backtest-kit';
3
+ import { CandleInterval, TrailingTakeCommit, TrailingStopCommit, BreakevenCommit, PartialProfitCommit, PartialLossCommit, IStrategyTickResultScheduled, IStrategyTickResultCancelled, IStrategyTickResultOpened, IStrategyTickResultClosed, RiskContract, AverageBuyCommit, SignalOpenContract, SignalCloseContract, CancelScheduledCommit, ClosePendingCommit } from 'backtest-kit';
4
4
  import * as BacktestKitUi from '@backtest-kit/ui';
5
5
  import * as BacktestKitGraph from '@backtest-kit/graph';
6
6
  import * as BacktestKitOllama from '@backtest-kit/ollama';
@@ -201,6 +201,8 @@ declare class TelegramLogicService {
201
201
  private notifyAverageBuy;
202
202
  private notifySignalOpen;
203
203
  private notifySignalClose;
204
+ private notifyCancelScheduled;
205
+ private notifyClosePending;
204
206
  connect: (() => () => void) & functools_kit.ISingleshotClearable;
205
207
  }
206
208
 
@@ -220,6 +222,8 @@ declare class TelegramTemplateService {
220
222
  getAverageBuyMarkdown: (event: AverageBuyCommit) => Promise<string>;
221
223
  getSignalOpenMarkdown: (event: SignalOpenContract) => Promise<string>;
222
224
  getSignalCloseMarkdown: (event: SignalCloseContract) => Promise<string>;
225
+ getCancelScheduledMarkdown: (event: CancelScheduledCommit) => Promise<string>;
226
+ getClosePendingMarkdown: (event: ClosePendingCommit) => Promise<string>;
223
227
  }
224
228
 
225
229
  declare class ModuleConnectionService {