@backtest-kit/cli 3.4.0 → 3.4.2
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 +35 -9
- package/build/index.mjs +30 -4
- package/package.json +1 -1
- package/types.d.ts +2 -1
package/build/index.cjs
CHANGED
|
@@ -240,10 +240,10 @@ const entrySubject = new functoolsKit.BehaviorSubject();
|
|
|
240
240
|
|
|
241
241
|
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)));
|
|
242
242
|
const __dirname$2 = path.dirname(__filename$2);
|
|
243
|
-
const require$
|
|
243
|
+
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)));
|
|
244
244
|
const REQUIRE_ENTRY_FACTORY = (filePath) => {
|
|
245
245
|
try {
|
|
246
|
-
require$
|
|
246
|
+
require$2(filePath);
|
|
247
247
|
return true;
|
|
248
248
|
}
|
|
249
249
|
catch {
|
|
@@ -430,6 +430,10 @@ const getArgs = functoolsKit.singleshot(() => {
|
|
|
430
430
|
type: "boolean",
|
|
431
431
|
default: false,
|
|
432
432
|
},
|
|
433
|
+
debug: {
|
|
434
|
+
type: "boolean",
|
|
435
|
+
default: false,
|
|
436
|
+
},
|
|
433
437
|
ui: {
|
|
434
438
|
type: "boolean",
|
|
435
439
|
default: false,
|
|
@@ -1630,16 +1634,23 @@ class TelegramTemplateService {
|
|
|
1630
1634
|
}
|
|
1631
1635
|
}
|
|
1632
1636
|
|
|
1633
|
-
const require$
|
|
1637
|
+
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)));
|
|
1634
1638
|
const getExtVariants = (fileName) => {
|
|
1635
1639
|
const ext = path.extname(fileName);
|
|
1636
1640
|
const base = ext ? fileName.slice(0, -ext.length) : fileName;
|
|
1637
|
-
return [
|
|
1641
|
+
return [
|
|
1642
|
+
fileName,
|
|
1643
|
+
`${base}.cjs`,
|
|
1644
|
+
`${base}.mjs`,
|
|
1645
|
+
`${base}.ts`,
|
|
1646
|
+
`${base}.tsx`,
|
|
1647
|
+
`${base}.js`,
|
|
1648
|
+
];
|
|
1638
1649
|
};
|
|
1639
1650
|
const REQUIRE_MODULE_FACTORY = (fileName) => {
|
|
1640
1651
|
for (const variant of getExtVariants(fileName)) {
|
|
1641
1652
|
try {
|
|
1642
|
-
return require$
|
|
1653
|
+
return require$1(variant);
|
|
1643
1654
|
}
|
|
1644
1655
|
catch {
|
|
1645
1656
|
continue;
|
|
@@ -1657,7 +1668,10 @@ const BABEL_MODULE_FACTORY = async (fileName, self) => {
|
|
|
1657
1668
|
try {
|
|
1658
1669
|
const code = await fs$1.readFile(variant, "utf-8");
|
|
1659
1670
|
const { exports } = self.babelService.transpileAndRun(code);
|
|
1660
|
-
|
|
1671
|
+
if (exports.default) {
|
|
1672
|
+
return exports.default;
|
|
1673
|
+
}
|
|
1674
|
+
return exports;
|
|
1661
1675
|
}
|
|
1662
1676
|
catch (error) {
|
|
1663
1677
|
console.log(functoolsKit.getErrorMessage(error));
|
|
@@ -1885,7 +1899,6 @@ class LiveProviderService {
|
|
|
1885
1899
|
}
|
|
1886
1900
|
|
|
1887
1901
|
standalone.registerPlugin("plugin-transform-modules-umd", pluginUMD);
|
|
1888
|
-
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)));
|
|
1889
1902
|
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)));
|
|
1890
1903
|
const __dirname$1 = path.dirname(__filename$1);
|
|
1891
1904
|
const BacktestKitCli = new Proxy({}, {
|
|
@@ -1896,8 +1909,10 @@ const BacktestKitCli = new Proxy({}, {
|
|
|
1896
1909
|
class BabelService {
|
|
1897
1910
|
constructor() {
|
|
1898
1911
|
this.loggerService = inject(TYPES.loggerService);
|
|
1912
|
+
this._require = 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)));
|
|
1899
1913
|
this.transpile = (code) => {
|
|
1900
1914
|
this.loggerService.log("babelService transpile", { codeLen: code.length });
|
|
1915
|
+
const { values } = getArgs();
|
|
1901
1916
|
const result = standalone.transform(code, {
|
|
1902
1917
|
filename: "index.ts",
|
|
1903
1918
|
presets: ["env", "typescript"],
|
|
@@ -1907,7 +1922,6 @@ class BabelService {
|
|
|
1907
1922
|
{
|
|
1908
1923
|
globals: {
|
|
1909
1924
|
"backtest-kit": "BacktestKit",
|
|
1910
|
-
"@backtest-kit/cli": "BacktestKitCli",
|
|
1911
1925
|
},
|
|
1912
1926
|
moduleId: "Executor",
|
|
1913
1927
|
},
|
|
@@ -1918,6 +1932,9 @@ class BabelService {
|
|
|
1918
1932
|
if (!result.code) {
|
|
1919
1933
|
throw new Error("BabelService transpile failed");
|
|
1920
1934
|
}
|
|
1935
|
+
if (values.debug) {
|
|
1936
|
+
fs.writeFileSync("./debug.js", result.code);
|
|
1937
|
+
}
|
|
1921
1938
|
return result.code;
|
|
1922
1939
|
};
|
|
1923
1940
|
this.transpileAndRun = (code) => {
|
|
@@ -1926,9 +1943,18 @@ class BabelService {
|
|
|
1926
1943
|
});
|
|
1927
1944
|
const module = { exports: {} };
|
|
1928
1945
|
const exports = module.exports;
|
|
1946
|
+
const require = (id) => {
|
|
1947
|
+
if (id === "backtest-kit") {
|
|
1948
|
+
return globalThis.BacktestKit;
|
|
1949
|
+
}
|
|
1950
|
+
if (id === "@backtest-kit/cli") {
|
|
1951
|
+
return globalThis.BacktestKitCli;
|
|
1952
|
+
}
|
|
1953
|
+
return this._require(id);
|
|
1954
|
+
};
|
|
1929
1955
|
eval(this.transpile(code));
|
|
1930
1956
|
return {
|
|
1931
|
-
require
|
|
1957
|
+
require,
|
|
1932
1958
|
__filename: __filename$1,
|
|
1933
1959
|
__dirname: __dirname$1,
|
|
1934
1960
|
exports,
|
package/build/index.mjs
CHANGED
|
@@ -408,6 +408,10 @@ const getArgs = singleshot(() => {
|
|
|
408
408
|
type: "boolean",
|
|
409
409
|
default: false,
|
|
410
410
|
},
|
|
411
|
+
debug: {
|
|
412
|
+
type: "boolean",
|
|
413
|
+
default: false,
|
|
414
|
+
},
|
|
411
415
|
ui: {
|
|
412
416
|
type: "boolean",
|
|
413
417
|
default: false,
|
|
@@ -1612,7 +1616,14 @@ createRequire(import.meta.url);
|
|
|
1612
1616
|
const getExtVariants = (fileName) => {
|
|
1613
1617
|
const ext = path.extname(fileName);
|
|
1614
1618
|
const base = ext ? fileName.slice(0, -ext.length) : fileName;
|
|
1615
|
-
return [
|
|
1619
|
+
return [
|
|
1620
|
+
fileName,
|
|
1621
|
+
`${base}.cjs`,
|
|
1622
|
+
`${base}.mjs`,
|
|
1623
|
+
`${base}.ts`,
|
|
1624
|
+
`${base}.tsx`,
|
|
1625
|
+
`${base}.js`,
|
|
1626
|
+
];
|
|
1616
1627
|
};
|
|
1617
1628
|
const REQUIRE_MODULE_FACTORY = (fileName) => {
|
|
1618
1629
|
{
|
|
@@ -1635,7 +1646,10 @@ const BABEL_MODULE_FACTORY = async (fileName, self) => {
|
|
|
1635
1646
|
try {
|
|
1636
1647
|
const code = await fs$1.readFile(variant, "utf-8");
|
|
1637
1648
|
const { exports } = self.babelService.transpileAndRun(code);
|
|
1638
|
-
|
|
1649
|
+
if (exports.default) {
|
|
1650
|
+
return exports.default;
|
|
1651
|
+
}
|
|
1652
|
+
return exports;
|
|
1639
1653
|
}
|
|
1640
1654
|
catch (error) {
|
|
1641
1655
|
console.log(getErrorMessage(error));
|
|
@@ -1863,7 +1877,6 @@ class LiveProviderService {
|
|
|
1863
1877
|
}
|
|
1864
1878
|
|
|
1865
1879
|
registerPlugin("plugin-transform-modules-umd", pluginUMD);
|
|
1866
|
-
const require = createRequire(import.meta.url);
|
|
1867
1880
|
const __filename = fileURLToPath(import.meta.url);
|
|
1868
1881
|
const __dirname = path.dirname(__filename);
|
|
1869
1882
|
const BacktestKitCli = new Proxy({}, {
|
|
@@ -1874,8 +1887,10 @@ const BacktestKitCli = new Proxy({}, {
|
|
|
1874
1887
|
class BabelService {
|
|
1875
1888
|
constructor() {
|
|
1876
1889
|
this.loggerService = inject(TYPES.loggerService);
|
|
1890
|
+
this._require = createRequire(import.meta.url);
|
|
1877
1891
|
this.transpile = (code) => {
|
|
1878
1892
|
this.loggerService.log("babelService transpile", { codeLen: code.length });
|
|
1893
|
+
const { values } = getArgs();
|
|
1879
1894
|
const result = transform(code, {
|
|
1880
1895
|
filename: "index.ts",
|
|
1881
1896
|
presets: ["env", "typescript"],
|
|
@@ -1885,7 +1900,6 @@ class BabelService {
|
|
|
1885
1900
|
{
|
|
1886
1901
|
globals: {
|
|
1887
1902
|
"backtest-kit": "BacktestKit",
|
|
1888
|
-
"@backtest-kit/cli": "BacktestKitCli",
|
|
1889
1903
|
},
|
|
1890
1904
|
moduleId: "Executor",
|
|
1891
1905
|
},
|
|
@@ -1896,6 +1910,9 @@ class BabelService {
|
|
|
1896
1910
|
if (!result.code) {
|
|
1897
1911
|
throw new Error("BabelService transpile failed");
|
|
1898
1912
|
}
|
|
1913
|
+
if (values.debug) {
|
|
1914
|
+
fs.writeFileSync("./debug.js", result.code);
|
|
1915
|
+
}
|
|
1899
1916
|
return result.code;
|
|
1900
1917
|
};
|
|
1901
1918
|
this.transpileAndRun = (code) => {
|
|
@@ -1904,6 +1921,15 @@ class BabelService {
|
|
|
1904
1921
|
});
|
|
1905
1922
|
const module = { exports: {} };
|
|
1906
1923
|
const exports = module.exports;
|
|
1924
|
+
const require = (id) => {
|
|
1925
|
+
if (id === "backtest-kit") {
|
|
1926
|
+
return globalThis.BacktestKit;
|
|
1927
|
+
}
|
|
1928
|
+
if (id === "@backtest-kit/cli") {
|
|
1929
|
+
return globalThis.BacktestKitCli;
|
|
1930
|
+
}
|
|
1931
|
+
return this._require(id);
|
|
1932
|
+
};
|
|
1907
1933
|
eval(this.transpile(code));
|
|
1908
1934
|
return {
|
|
1909
1935
|
require,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backtest-kit/cli",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
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",
|
package/types.d.ts
CHANGED
|
@@ -95,9 +95,10 @@ declare global {
|
|
|
95
95
|
}
|
|
96
96
|
declare class BabelService {
|
|
97
97
|
readonly loggerService: LoggerService;
|
|
98
|
+
readonly _require: NodeRequire;
|
|
98
99
|
transpile: (code: string) => any;
|
|
99
100
|
transpileAndRun: (code: string) => {
|
|
100
|
-
require:
|
|
101
|
+
require: (id: string) => any;
|
|
101
102
|
__filename: string;
|
|
102
103
|
__dirname: string;
|
|
103
104
|
exports: Record<string, unknown>;
|