@backtest-kit/cli 5.5.1 → 5.5.3

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
@@ -110,6 +110,9 @@ BacktestKit.setConfig({
110
110
  CC_ENABLE_DCA_EVERYWHERE: true,
111
111
  CC_ENABLE_PPPL_EVERYWHERE: true,
112
112
  });
113
+ BacktestKit.setConfig({
114
+ CC_MAX_SIGNAL_GENERATION_SECONDS: 15 * 60,
115
+ });
113
116
  BacktestKit.Log.useJsonl();
114
117
 
115
118
  const ERROR_HANDLER_INSTALLED = Symbol.for("error-handler-installed");
@@ -627,7 +630,7 @@ class BacktestMainService {
627
630
  });
628
631
  notifyVerbose();
629
632
  }
630
- await this.moduleConnectionService.loadModule("./backtest");
633
+ await this.moduleConnectionService.loadModule("./backtest.module");
631
634
  BacktestKit.Backtest.background(symbol, {
632
635
  strategyName,
633
636
  frameName,
@@ -707,7 +710,7 @@ class LiveMainService {
707
710
  });
708
711
  notifyVerbose();
709
712
  }
710
- await this.moduleConnectionService.loadModule("./live");
713
+ await this.moduleConnectionService.loadModule("./live.module");
711
714
  BacktestKit.Live.background(symbol, {
712
715
  strategyName,
713
716
  exchangeName,
@@ -780,7 +783,7 @@ class PaperMainService {
780
783
  });
781
784
  notifyVerbose();
782
785
  }
783
- await this.moduleConnectionService.loadModule("./paper");
786
+ await this.moduleConnectionService.loadModule("./paper.module");
784
787
  BacktestKit.Live.background(symbol, {
785
788
  strategyName,
786
789
  exchangeName,
@@ -1713,32 +1716,6 @@ class TelegramTemplateService {
1713
1716
  }
1714
1717
  }
1715
1718
 
1716
- const getExtVariants = (fileName) => {
1717
- const ext = path.extname(fileName);
1718
- const base = ext ? fileName.slice(0, -ext.length) : fileName;
1719
- return [
1720
- `${base}.cjs`,
1721
- `${base}.mjs`,
1722
- `${base}.ts`,
1723
- `${base}.tsx`,
1724
- `${base}.js`,
1725
- ];
1726
- };
1727
- const LOADER_FACTORY = async (fileName, self) => {
1728
- for (const variant of getExtVariants(fileName)) {
1729
- try {
1730
- await fs$1.access(variant, fs.constants.F_OK | fs.constants.R_OK);
1731
- self.loaderService.import(variant);
1732
- return true;
1733
- }
1734
- catch (error) {
1735
- const { values } = getArgs();
1736
- values.verbose && console.log(functoolsKit.getErrorMessage(error));
1737
- continue;
1738
- }
1739
- }
1740
- return false;
1741
- };
1742
1719
  const LOAD_MODULE_MODULE_FN = async (fileName, self) => {
1743
1720
  const overridePath = path.join(self.resolveService.OVERRIDE_MODULES_DIR, fileName);
1744
1721
  const targetPath = path.join(process.cwd(), "modules", fileName);
@@ -1747,11 +1724,17 @@ const LOAD_MODULE_MODULE_FN = async (fileName, self) => {
1747
1724
  .then(() => true)
1748
1725
  .catch(() => false);
1749
1726
  const resolvedFile = hasOverride ? overridePath : targetPath;
1750
- if (LOADER_FACTORY(resolvedFile, self)) {
1751
- return true;
1727
+ try {
1728
+ if (self.loaderService.check(resolvedFile)) {
1729
+ self.loaderService.import(resolvedFile);
1730
+ return true;
1731
+ }
1732
+ return false;
1733
+ }
1734
+ catch {
1735
+ console.warn(`Module module import failed for file: ${resolvedFile}`);
1736
+ return false;
1752
1737
  }
1753
- console.warn(`Module module import failed for file: ${resolvedFile}`);
1754
- return false;
1755
1738
  };
1756
1739
  class ModuleConnectionService {
1757
1740
  constructor() {
@@ -1812,7 +1795,13 @@ const TRANSPILE_FN = (code, self) => {
1812
1795
  const __dirname = self.__dirname;
1813
1796
  const module = { exports: {} };
1814
1797
  const exports = module.exports;
1815
- eval(self.params.babel.transpile(code));
1798
+ try {
1799
+ eval(self.params.babel.transpile(code));
1800
+ }
1801
+ catch (error) {
1802
+ console.log(`Error during transpilation error=\`${functoolsKit.getErrorMessage(error)}\` __filename=\`${__filename}\` __dirname=\`${__dirname}\``);
1803
+ process.exit(-1);
1804
+ }
1816
1805
  return {
1817
1806
  require,
1818
1807
  __filename,
@@ -1844,13 +1833,48 @@ const BABEL_ENTRY_FACTORY = (filePath, self) => {
1844
1833
  return null;
1845
1834
  }
1846
1835
  };
1847
- const ENTRY_FACTORY = (filePath, self) => {
1848
- let result = null;
1849
- if (result = REQUIRE_ENTRY_FACTORY(filePath, self)) {
1850
- return result;
1836
+ const GET_EXT_VARIANTS_FN = (fileName) => {
1837
+ const ext = path.extname(fileName);
1838
+ const base = ext ? fileName.slice(0, -ext.length) : fileName;
1839
+ const result = [];
1840
+ {
1841
+ result.push(`${base}`);
1842
+ result.push(`${base}.cjs`);
1843
+ result.push(`${base}.mjs`);
1844
+ result.push(`${base}.ts`);
1845
+ result.push(`${base}.tsx`);
1846
+ result.push(`${base}.js`);
1847
+ result.push(`${base}.json`);
1851
1848
  }
1852
- if (result = BABEL_ENTRY_FACTORY(filePath, self)) {
1853
- return result;
1849
+ {
1850
+ result.push(`${fileName}`);
1851
+ result.push(`${fileName}.cjs`);
1852
+ result.push(`${fileName}.mjs`);
1853
+ result.push(`${fileName}.ts`);
1854
+ result.push(`${fileName}.tsx`);
1855
+ result.push(`${fileName}.js`);
1856
+ result.push(`${fileName}.json`);
1857
+ }
1858
+ return result;
1859
+ };
1860
+ const GET_RESOLVED_EXT_FN = (filePath) => {
1861
+ for (const variant of GET_EXT_VARIANTS_FN(filePath)) {
1862
+ if (fs.existsSync(variant)) {
1863
+ return variant;
1864
+ }
1865
+ }
1866
+ return filePath;
1867
+ };
1868
+ const ENTRY_FACTORY = (filePath, self) => {
1869
+ filePath = GET_RESOLVED_EXT_FN(filePath);
1870
+ {
1871
+ let result = null;
1872
+ if ((result = REQUIRE_ENTRY_FACTORY(filePath, self))) {
1873
+ return result;
1874
+ }
1875
+ if ((result = BABEL_ENTRY_FACTORY(filePath, self))) {
1876
+ return result;
1877
+ }
1854
1878
  }
1855
1879
  throw new Error(`Failed to load module at ${filePath} (basepath: ${self.params.path})`);
1856
1880
  };
@@ -1917,6 +1941,19 @@ class ClientLoader {
1917
1941
  });
1918
1942
  return ENTRY_FACTORY(filePath, this);
1919
1943
  }
1944
+ check(filePath) {
1945
+ this.params.logger.log("ClientLoader check", {
1946
+ filePath,
1947
+ basePath: this.params.path,
1948
+ });
1949
+ const resolved = path.resolve(this.__dirname, filePath);
1950
+ for (const variantPath of GET_EXT_VARIANTS_FN(resolved)) {
1951
+ if (fs.existsSync(variantPath)) {
1952
+ return true;
1953
+ }
1954
+ }
1955
+ return false;
1956
+ }
1920
1957
  }
1921
1958
  globalThis.BacktestKit = BacktestKit__namespace;
1922
1959
  globalThis.BacktestKitCli = BacktestKitCli;
@@ -1935,13 +1972,22 @@ class LoaderService {
1935
1972
  logger: this.loggerService,
1936
1973
  path: basePath,
1937
1974
  }));
1938
- this.import = async (filePath, basePath = process.cwd()) => {
1975
+ this.import = (filePath, basePath = process.cwd()) => {
1939
1976
  this.loggerService.log("loaderService import", {
1940
1977
  filePath,
1978
+ basePath,
1941
1979
  });
1942
1980
  const instance = this.getInstance(basePath);
1943
1981
  return instance.import(filePath);
1944
1982
  };
1983
+ this.check = async (filePath, basePath = process.cwd()) => {
1984
+ this.loggerService.log("loaderService check", {
1985
+ filePath,
1986
+ basePath,
1987
+ });
1988
+ const instance = this.getInstance(basePath);
1989
+ return instance.check(filePath);
1990
+ };
1945
1991
  }
1946
1992
  }
1947
1993
 
package/build/index.mjs CHANGED
@@ -84,6 +84,9 @@ setConfig({
84
84
  CC_ENABLE_DCA_EVERYWHERE: true,
85
85
  CC_ENABLE_PPPL_EVERYWHERE: true,
86
86
  });
87
+ setConfig({
88
+ CC_MAX_SIGNAL_GENERATION_SECONDS: 15 * 60,
89
+ });
87
90
  Log.useJsonl();
88
91
 
89
92
  const ERROR_HANDLER_INSTALLED = Symbol.for("error-handler-installed");
@@ -601,7 +604,7 @@ class BacktestMainService {
601
604
  });
602
605
  notifyVerbose();
603
606
  }
604
- await this.moduleConnectionService.loadModule("./backtest");
607
+ await this.moduleConnectionService.loadModule("./backtest.module");
605
608
  Backtest.background(symbol, {
606
609
  strategyName,
607
610
  frameName,
@@ -681,7 +684,7 @@ class LiveMainService {
681
684
  });
682
685
  notifyVerbose();
683
686
  }
684
- await this.moduleConnectionService.loadModule("./live");
687
+ await this.moduleConnectionService.loadModule("./live.module");
685
688
  Live.background(symbol, {
686
689
  strategyName,
687
690
  exchangeName,
@@ -754,7 +757,7 @@ class PaperMainService {
754
757
  });
755
758
  notifyVerbose();
756
759
  }
757
- await this.moduleConnectionService.loadModule("./paper");
760
+ await this.moduleConnectionService.loadModule("./paper.module");
758
761
  Live.background(symbol, {
759
762
  strategyName,
760
763
  exchangeName,
@@ -1687,32 +1690,6 @@ class TelegramTemplateService {
1687
1690
  }
1688
1691
  }
1689
1692
 
1690
- const getExtVariants = (fileName) => {
1691
- const ext = path.extname(fileName);
1692
- const base = ext ? fileName.slice(0, -ext.length) : fileName;
1693
- return [
1694
- `${base}.cjs`,
1695
- `${base}.mjs`,
1696
- `${base}.ts`,
1697
- `${base}.tsx`,
1698
- `${base}.js`,
1699
- ];
1700
- };
1701
- const LOADER_FACTORY = async (fileName, self) => {
1702
- for (const variant of getExtVariants(fileName)) {
1703
- try {
1704
- await fs$1.access(variant, constants.F_OK | constants.R_OK);
1705
- self.loaderService.import(variant);
1706
- return true;
1707
- }
1708
- catch (error) {
1709
- const { values } = getArgs();
1710
- values.verbose && console.log(getErrorMessage(error));
1711
- continue;
1712
- }
1713
- }
1714
- return false;
1715
- };
1716
1693
  const LOAD_MODULE_MODULE_FN = async (fileName, self) => {
1717
1694
  const overridePath = path.join(self.resolveService.OVERRIDE_MODULES_DIR, fileName);
1718
1695
  const targetPath = path.join(process.cwd(), "modules", fileName);
@@ -1721,11 +1698,17 @@ const LOAD_MODULE_MODULE_FN = async (fileName, self) => {
1721
1698
  .then(() => true)
1722
1699
  .catch(() => false);
1723
1700
  const resolvedFile = hasOverride ? overridePath : targetPath;
1724
- if (LOADER_FACTORY(resolvedFile, self)) {
1725
- return true;
1701
+ try {
1702
+ if (self.loaderService.check(resolvedFile)) {
1703
+ self.loaderService.import(resolvedFile);
1704
+ return true;
1705
+ }
1706
+ return false;
1707
+ }
1708
+ catch {
1709
+ console.warn(`Module module import failed for file: ${resolvedFile}`);
1710
+ return false;
1726
1711
  }
1727
- console.warn(`Module module import failed for file: ${resolvedFile}`);
1728
- return false;
1729
1712
  };
1730
1713
  class ModuleConnectionService {
1731
1714
  constructor() {
@@ -1786,7 +1769,13 @@ const TRANSPILE_FN = (code, self) => {
1786
1769
  const __dirname = self.__dirname;
1787
1770
  const module = { exports: {} };
1788
1771
  const exports = module.exports;
1789
- eval(self.params.babel.transpile(code));
1772
+ try {
1773
+ eval(self.params.babel.transpile(code));
1774
+ }
1775
+ catch (error) {
1776
+ console.log(`Error during transpilation error=\`${getErrorMessage(error)}\` __filename=\`${__filename}\` __dirname=\`${__dirname}\``);
1777
+ process.exit(-1);
1778
+ }
1790
1779
  return {
1791
1780
  require,
1792
1781
  __filename,
@@ -1814,13 +1803,48 @@ const BABEL_ENTRY_FACTORY = (filePath, self) => {
1814
1803
  return null;
1815
1804
  }
1816
1805
  };
1817
- const ENTRY_FACTORY = (filePath, self) => {
1818
- let result = null;
1819
- if (result = REQUIRE_ENTRY_FACTORY()) {
1820
- return result;
1806
+ const GET_EXT_VARIANTS_FN = (fileName) => {
1807
+ const ext = path.extname(fileName);
1808
+ const base = ext ? fileName.slice(0, -ext.length) : fileName;
1809
+ const result = [];
1810
+ {
1811
+ result.push(`${base}`);
1812
+ result.push(`${base}.cjs`);
1813
+ result.push(`${base}.mjs`);
1814
+ result.push(`${base}.ts`);
1815
+ result.push(`${base}.tsx`);
1816
+ result.push(`${base}.js`);
1817
+ result.push(`${base}.json`);
1821
1818
  }
1822
- if (result = BABEL_ENTRY_FACTORY(filePath, self)) {
1823
- return result;
1819
+ {
1820
+ result.push(`${fileName}`);
1821
+ result.push(`${fileName}.cjs`);
1822
+ result.push(`${fileName}.mjs`);
1823
+ result.push(`${fileName}.ts`);
1824
+ result.push(`${fileName}.tsx`);
1825
+ result.push(`${fileName}.js`);
1826
+ result.push(`${fileName}.json`);
1827
+ }
1828
+ return result;
1829
+ };
1830
+ const GET_RESOLVED_EXT_FN = (filePath) => {
1831
+ for (const variant of GET_EXT_VARIANTS_FN(filePath)) {
1832
+ if (fs.existsSync(variant)) {
1833
+ return variant;
1834
+ }
1835
+ }
1836
+ return filePath;
1837
+ };
1838
+ const ENTRY_FACTORY = (filePath, self) => {
1839
+ filePath = GET_RESOLVED_EXT_FN(filePath);
1840
+ {
1841
+ let result = null;
1842
+ if ((result = REQUIRE_ENTRY_FACTORY())) {
1843
+ return result;
1844
+ }
1845
+ if ((result = BABEL_ENTRY_FACTORY(filePath, self))) {
1846
+ return result;
1847
+ }
1824
1848
  }
1825
1849
  throw new Error(`Failed to load module at ${filePath} (basepath: ${self.params.path})`);
1826
1850
  };
@@ -1887,6 +1911,19 @@ class ClientLoader {
1887
1911
  });
1888
1912
  return ENTRY_FACTORY(filePath, this);
1889
1913
  }
1914
+ check(filePath) {
1915
+ this.params.logger.log("ClientLoader check", {
1916
+ filePath,
1917
+ basePath: this.params.path,
1918
+ });
1919
+ const resolved = path.resolve(this.__dirname, filePath);
1920
+ for (const variantPath of GET_EXT_VARIANTS_FN(resolved)) {
1921
+ if (fs.existsSync(variantPath)) {
1922
+ return true;
1923
+ }
1924
+ }
1925
+ return false;
1926
+ }
1890
1927
  }
1891
1928
  globalThis.BacktestKit = BacktestKit;
1892
1929
  globalThis.BacktestKitCli = BacktestKitCli;
@@ -1905,13 +1942,22 @@ class LoaderService {
1905
1942
  logger: this.loggerService,
1906
1943
  path: basePath,
1907
1944
  }));
1908
- this.import = async (filePath, basePath = process.cwd()) => {
1945
+ this.import = (filePath, basePath = process.cwd()) => {
1909
1946
  this.loggerService.log("loaderService import", {
1910
1947
  filePath,
1948
+ basePath,
1911
1949
  });
1912
1950
  const instance = this.getInstance(basePath);
1913
1951
  return instance.import(filePath);
1914
1952
  };
1953
+ this.check = async (filePath, basePath = process.cwd()) => {
1954
+ this.loggerService.log("loaderService check", {
1955
+ filePath,
1956
+ basePath,
1957
+ });
1958
+ const instance = this.getInstance(basePath);
1959
+ return instance.check(filePath);
1960
+ };
1915
1961
  }
1916
1962
  }
1917
1963
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/cli",
3
- "version": "5.5.1",
3
+ "version": "5.5.3",
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.5.1",
64
- "@backtest-kit/graph": "5.5.1",
65
- "@backtest-kit/ollama": "5.5.1",
66
- "@backtest-kit/pinets": "5.5.1",
67
- "@backtest-kit/signals": "5.5.1",
63
+ "@backtest-kit/ui": "5.5.3",
64
+ "@backtest-kit/graph": "5.5.3",
65
+ "@backtest-kit/ollama": "5.5.3",
66
+ "@backtest-kit/pinets": "5.5.3",
67
+ "@backtest-kit/signals": "5.5.3",
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.5.1",
75
+ "backtest-kit": "5.5.3",
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.5.1",
91
- "@backtest-kit/graph": "^5.5.1",
92
- "@backtest-kit/ollama": "^5.5.1",
93
- "@backtest-kit/pinets": "^5.5.1",
94
- "@backtest-kit/signals": "^5.5.1",
95
- "backtest-kit": "^5.5.1",
90
+ "@backtest-kit/ui": "^5.5.3",
91
+ "@backtest-kit/graph": "^5.5.3",
92
+ "@backtest-kit/ollama": "^5.5.3",
93
+ "@backtest-kit/pinets": "^5.5.3",
94
+ "@backtest-kit/signals": "^5.5.3",
95
+ "backtest-kit": "^5.5.3",
96
96
  "markdown-it": "^14.1.1",
97
97
  "typescript": "^5.0.0"
98
98
  },
package/types.d.ts CHANGED
@@ -91,7 +91,8 @@ declare class LoaderService {
91
91
  private readonly babelService;
92
92
  private readonly loggerService;
93
93
  private getInstance;
94
- import: (filePath: string, basePath?: string) => Promise<any>;
94
+ import: (filePath: string, basePath?: string) => any;
95
+ check: (filePath: string, basePath?: string) => Promise<boolean>;
95
96
  }
96
97
 
97
98
  declare class ResolveService {
@@ -242,6 +243,7 @@ declare const cli: {
242
243
 
243
244
  interface ILoader {
244
245
  import(filePath: string): any;
246
+ check(filePath: string): boolean;
245
247
  }
246
248
 
247
249
  declare enum ExchangeName {