@backtest-kit/pinets 3.0.4 → 3.0.6
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 +12 -11
- package/build/index.mjs +12 -11
- package/package.json +1 -1
- package/types.d.ts +3 -3
package/build/index.cjs
CHANGED
|
@@ -514,7 +514,7 @@ function generateMarkdownTable(rows, keys, signalId) {
|
|
|
514
514
|
class PineMarkdownService {
|
|
515
515
|
constructor() {
|
|
516
516
|
this.loggerService = inject(TYPES.loggerService);
|
|
517
|
-
this.getData = (plots, mapping) => {
|
|
517
|
+
this.getData = (plots, mapping, limit = TABLE_ROWS_LIMIT) => {
|
|
518
518
|
this.loggerService.log("pineMarkdownService getData", {
|
|
519
519
|
plotCount: Object.keys(plots).length,
|
|
520
520
|
});
|
|
@@ -543,15 +543,15 @@ class PineMarkdownService {
|
|
|
543
543
|
rows.push(row);
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
return rows.slice(-
|
|
546
|
+
return rows.slice(-limit);
|
|
547
547
|
};
|
|
548
|
-
this.getReport = (signalId, plots, mapping) => {
|
|
548
|
+
this.getReport = (signalId, plots, mapping, limit = TABLE_ROWS_LIMIT) => {
|
|
549
549
|
this.loggerService.log("pineMarkdownService getReport", {
|
|
550
550
|
signalId,
|
|
551
551
|
plotCount: Object.keys(plots).length,
|
|
552
552
|
});
|
|
553
553
|
const keys = Object.keys(mapping);
|
|
554
|
-
const rows = this.getData(plots, mapping);
|
|
554
|
+
const rows = this.getData(plots, mapping, limit);
|
|
555
555
|
return generateMarkdownTable(rows, keys, signalId);
|
|
556
556
|
};
|
|
557
557
|
this.dump = async (signalId, plots, mapping, taName, outputDir = `./dump/ta/${taName}`) => {
|
|
@@ -658,8 +658,8 @@ 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 CREATE_INFERENCE_FN = (symbol, exchangeName, when) => {
|
|
662
|
-
let fn = () => BASE_RUNNER_FN;
|
|
661
|
+
const CREATE_INFERENCE_FN = (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
662
|
+
let fn = () => BASE_RUNNER_FN(script, symbol, timeframe, limit);
|
|
663
663
|
if (exchangeName) {
|
|
664
664
|
fn = ExchangeContextService.runWithContext(fn, { exchangeName });
|
|
665
665
|
}
|
|
@@ -670,11 +670,11 @@ const CREATE_INFERENCE_FN = (symbol, exchangeName, when) => {
|
|
|
670
670
|
backtest: true,
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
|
-
return fn
|
|
673
|
+
return fn;
|
|
674
674
|
};
|
|
675
675
|
const RUN_INFERENCE_FN = async (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
676
|
-
const inference = CREATE_INFERENCE_FN(symbol, exchangeName, when);
|
|
677
|
-
return await inference(
|
|
676
|
+
const inference = CREATE_INFERENCE_FN(script, symbol, timeframe, limit, exchangeName, when);
|
|
677
|
+
return await inference();
|
|
678
678
|
};
|
|
679
679
|
async function run(source, { symbol, timeframe, limit }, exchangeName, when) {
|
|
680
680
|
pine.loggerService.info(METHOD_NAME_RUN$2, {
|
|
@@ -777,13 +777,14 @@ async function dumpPlotData(signalId, plots, mapping, taName, outputDir = "./dum
|
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
const TO_MARKDOWN_METHOD_NAME = "markdown.toMarkdown";
|
|
780
|
-
async function toMarkdown(signalId, plots, mapping) {
|
|
780
|
+
async function toMarkdown(signalId, plots, mapping, limit = Number.POSITIVE_INFINITY) {
|
|
781
781
|
pine.loggerService.log(TO_MARKDOWN_METHOD_NAME, {
|
|
782
782
|
signalId,
|
|
783
783
|
plotCount: Object.keys(plots).length,
|
|
784
784
|
mapping,
|
|
785
|
+
limit,
|
|
785
786
|
});
|
|
786
|
-
return await pine.pineMarkdownService.getReport(signalId, plots, mapping);
|
|
787
|
+
return await pine.pineMarkdownService.getReport(signalId, plots, mapping, limit);
|
|
787
788
|
}
|
|
788
789
|
|
|
789
790
|
exports.AXIS_SYMBOL = AXIS_SYMBOL;
|
package/build/index.mjs
CHANGED
|
@@ -511,7 +511,7 @@ function generateMarkdownTable(rows, keys, signalId) {
|
|
|
511
511
|
class PineMarkdownService {
|
|
512
512
|
constructor() {
|
|
513
513
|
this.loggerService = inject(TYPES.loggerService);
|
|
514
|
-
this.getData = (plots, mapping) => {
|
|
514
|
+
this.getData = (plots, mapping, limit = TABLE_ROWS_LIMIT) => {
|
|
515
515
|
this.loggerService.log("pineMarkdownService getData", {
|
|
516
516
|
plotCount: Object.keys(plots).length,
|
|
517
517
|
});
|
|
@@ -540,15 +540,15 @@ class PineMarkdownService {
|
|
|
540
540
|
rows.push(row);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
return rows.slice(-
|
|
543
|
+
return rows.slice(-limit);
|
|
544
544
|
};
|
|
545
|
-
this.getReport = (signalId, plots, mapping) => {
|
|
545
|
+
this.getReport = (signalId, plots, mapping, limit = TABLE_ROWS_LIMIT) => {
|
|
546
546
|
this.loggerService.log("pineMarkdownService getReport", {
|
|
547
547
|
signalId,
|
|
548
548
|
plotCount: Object.keys(plots).length,
|
|
549
549
|
});
|
|
550
550
|
const keys = Object.keys(mapping);
|
|
551
|
-
const rows = this.getData(plots, mapping);
|
|
551
|
+
const rows = this.getData(plots, mapping, limit);
|
|
552
552
|
return generateMarkdownTable(rows, keys, signalId);
|
|
553
553
|
};
|
|
554
554
|
this.dump = async (signalId, plots, mapping, taName, outputDir = `./dump/ta/${taName}`) => {
|
|
@@ -655,8 +655,8 @@ 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 CREATE_INFERENCE_FN = (symbol, exchangeName, when) => {
|
|
659
|
-
let fn = () => BASE_RUNNER_FN;
|
|
658
|
+
const CREATE_INFERENCE_FN = (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
659
|
+
let fn = () => BASE_RUNNER_FN(script, symbol, timeframe, limit);
|
|
660
660
|
if (exchangeName) {
|
|
661
661
|
fn = ExchangeContextService.runWithContext(fn, { exchangeName });
|
|
662
662
|
}
|
|
@@ -667,11 +667,11 @@ const CREATE_INFERENCE_FN = (symbol, exchangeName, when) => {
|
|
|
667
667
|
backtest: true,
|
|
668
668
|
});
|
|
669
669
|
}
|
|
670
|
-
return fn
|
|
670
|
+
return fn;
|
|
671
671
|
};
|
|
672
672
|
const RUN_INFERENCE_FN = async (script, symbol, timeframe, limit, exchangeName, when) => {
|
|
673
|
-
const inference = CREATE_INFERENCE_FN(symbol, exchangeName, when);
|
|
674
|
-
return await inference(
|
|
673
|
+
const inference = CREATE_INFERENCE_FN(script, symbol, timeframe, limit, exchangeName, when);
|
|
674
|
+
return await inference();
|
|
675
675
|
};
|
|
676
676
|
async function run(source, { symbol, timeframe, limit }, exchangeName, when) {
|
|
677
677
|
pine.loggerService.info(METHOD_NAME_RUN$2, {
|
|
@@ -774,13 +774,14 @@ async function dumpPlotData(signalId, plots, mapping, taName, outputDir = "./dum
|
|
|
774
774
|
}
|
|
775
775
|
|
|
776
776
|
const TO_MARKDOWN_METHOD_NAME = "markdown.toMarkdown";
|
|
777
|
-
async function toMarkdown(signalId, plots, mapping) {
|
|
777
|
+
async function toMarkdown(signalId, plots, mapping, limit = Number.POSITIVE_INFINITY) {
|
|
778
778
|
pine.loggerService.log(TO_MARKDOWN_METHOD_NAME, {
|
|
779
779
|
signalId,
|
|
780
780
|
plotCount: Object.keys(plots).length,
|
|
781
781
|
mapping,
|
|
782
|
+
limit,
|
|
782
783
|
});
|
|
783
|
-
return await pine.pineMarkdownService.getReport(signalId, plots, mapping);
|
|
784
|
+
return await pine.pineMarkdownService.getReport(signalId, plots, mapping, limit);
|
|
784
785
|
}
|
|
785
786
|
|
|
786
787
|
export { AXIS_SYMBOL, Code, File, dumpPlotData, extract, getSignal, pine as lib, run, setLogger, toMarkdown, toSignalDto, usePine };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backtest-kit/pinets",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
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",
|
package/types.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ type ResultId$3 = string | number;
|
|
|
92
92
|
declare function dumpPlotData<M extends PlotMapping>(signalId: ResultId$3, plots: PlotModel, mapping: M, taName: string, outputDir?: string): Promise<void>;
|
|
93
93
|
|
|
94
94
|
type ResultId$2 = string | number;
|
|
95
|
-
declare function toMarkdown<M extends PlotMapping>(signalId: ResultId$2, plots: PlotModel, mapping: M): Promise<string>;
|
|
95
|
+
declare function toMarkdown<M extends PlotMapping>(signalId: ResultId$2, plots: PlotModel, mapping: M, limit?: number): Promise<string>;
|
|
96
96
|
|
|
97
97
|
type ResultId$1 = string | number;
|
|
98
98
|
interface SignalData {
|
|
@@ -180,8 +180,8 @@ interface IPlotRow {
|
|
|
180
180
|
}
|
|
181
181
|
declare class PineMarkdownService {
|
|
182
182
|
private readonly loggerService;
|
|
183
|
-
getData: <M extends PlotMapping>(plots: PlotModel, mapping: M) => IPlotRow[];
|
|
184
|
-
getReport: <M extends PlotMapping>(signalId: ResultId, plots: PlotModel, mapping: M) => string;
|
|
183
|
+
getData: <M extends PlotMapping>(plots: PlotModel, mapping: M, limit?: number) => IPlotRow[];
|
|
184
|
+
getReport: <M extends PlotMapping>(signalId: ResultId, plots: PlotModel, mapping: M, limit?: number) => string;
|
|
185
185
|
dump: <M extends PlotMapping>(signalId: ResultId, plots: PlotModel, mapping: M, taName: string, outputDir?: string) => Promise<void>;
|
|
186
186
|
}
|
|
187
187
|
|