@backtest-kit/pinets 3.0.6 → 3.0.8
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 +8 -0
- package/build/index.mjs +9 -1
- package/package.json +2 -2
package/build/index.cjs
CHANGED
|
@@ -658,6 +658,11 @@ const GET_SOURCE_FN$1 = async (source) => {
|
|
|
658
658
|
throw new Error("Source must be a File or Code instance");
|
|
659
659
|
};
|
|
660
660
|
const BASE_RUNNER_FN = async (script, symbol, timeframe, limit) => await pine.pineJobService.run(script, symbol, timeframe, limit);
|
|
661
|
+
const VALIDATE_NO_TRADING_FN = async () => {
|
|
662
|
+
if (backtestKit.ExecutionContextService.hasContext()) {
|
|
663
|
+
throw new Error(functoolsKit.str.newline("Time overrides are not allowed when running scripts in a trading context.", "Please remove the 'when' parameter from the run function call."));
|
|
664
|
+
}
|
|
665
|
+
};
|
|
661
666
|
const CREATE_INFERENCE_FN = (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
662
667
|
let fn = () => BASE_RUNNER_FN(script, symbol, timeframe, limit);
|
|
663
668
|
if (exchangeName) {
|
|
@@ -673,6 +678,9 @@ const CREATE_INFERENCE_FN = (script, symbol, timeframe, limit, exchangeName, whe
|
|
|
673
678
|
return fn;
|
|
674
679
|
};
|
|
675
680
|
const RUN_INFERENCE_FN = async (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
681
|
+
if (when) {
|
|
682
|
+
VALIDATE_NO_TRADING_FN();
|
|
683
|
+
}
|
|
676
684
|
const inference = CREATE_INFERENCE_FN(script, symbol, timeframe, limit, exchangeName, when);
|
|
677
685
|
return await inference();
|
|
678
686
|
};
|
package/build/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { join } from 'path';
|
|
|
2
2
|
import { getDate, Exchange, MethodContextService, ExecutionContextService, getRawCandles, Markdown, lib } from 'backtest-kit';
|
|
3
3
|
import { createActivator } from 'di-kit';
|
|
4
4
|
import { scoped } from 'di-scoped';
|
|
5
|
-
import { singleshot, memoize, randomString } from 'functools-kit';
|
|
5
|
+
import { singleshot, memoize, str, randomString } from 'functools-kit';
|
|
6
6
|
import fs from 'fs/promises';
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
8
|
|
|
@@ -655,6 +655,11 @@ const GET_SOURCE_FN$1 = async (source) => {
|
|
|
655
655
|
throw new Error("Source must be a File or Code instance");
|
|
656
656
|
};
|
|
657
657
|
const BASE_RUNNER_FN = async (script, symbol, timeframe, limit) => await pine.pineJobService.run(script, symbol, timeframe, limit);
|
|
658
|
+
const VALIDATE_NO_TRADING_FN = async () => {
|
|
659
|
+
if (ExecutionContextService.hasContext()) {
|
|
660
|
+
throw new Error(str.newline("Time overrides are not allowed when running scripts in a trading context.", "Please remove the 'when' parameter from the run function call."));
|
|
661
|
+
}
|
|
662
|
+
};
|
|
658
663
|
const CREATE_INFERENCE_FN = (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
659
664
|
let fn = () => BASE_RUNNER_FN(script, symbol, timeframe, limit);
|
|
660
665
|
if (exchangeName) {
|
|
@@ -670,6 +675,9 @@ const CREATE_INFERENCE_FN = (script, symbol, timeframe, limit, exchangeName, whe
|
|
|
670
675
|
return fn;
|
|
671
676
|
};
|
|
672
677
|
const RUN_INFERENCE_FN = async (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
678
|
+
if (when) {
|
|
679
|
+
VALIDATE_NO_TRADING_FN();
|
|
680
|
+
}
|
|
673
681
|
const inference = CREATE_INFERENCE_FN(script, symbol, timeframe, limit, exchangeName, when);
|
|
674
682
|
return await inference();
|
|
675
683
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backtest-kit/pinets",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"description": "Run TradingView Pine Script strategies in Node.js self hosted environment. Execute existing Pine Script indicators and generate trading signals with 1:1 syntax compatibility via PineTS runtime.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Petr Tripolsky",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"worker-testbed": "1.0.12"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"backtest-kit": "^3.0.
|
|
75
|
+
"backtest-kit": "^3.0.10",
|
|
76
76
|
"pinets": "^0.8.6",
|
|
77
77
|
"typescript": "^5.0.0"
|
|
78
78
|
},
|