@backtest-kit/pinets 0.0.4 → 0.0.5
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 +25 -23
- package/build/index.mjs +25 -24
- package/package.json +1 -1
- package/types.d.ts +13 -1
package/build/index.cjs
CHANGED
|
@@ -501,7 +501,7 @@ function extractRowAtIndex(plots, keys, index) {
|
|
|
501
501
|
}
|
|
502
502
|
function isRowWarmedUp(row, keys) {
|
|
503
503
|
for (const key of keys) {
|
|
504
|
-
if (
|
|
504
|
+
if (isUnsafe(row[key])) {
|
|
505
505
|
return false;
|
|
506
506
|
}
|
|
507
507
|
}
|
|
@@ -690,28 +690,6 @@ function setLogger(logger) {
|
|
|
690
690
|
pine.loggerService.setLogger(logger);
|
|
691
691
|
}
|
|
692
692
|
|
|
693
|
-
const METHOD_NAME_RUN = "strategy.getSignal";
|
|
694
|
-
const DEFAULT_ESTIMATED_TIME = 240;
|
|
695
|
-
const GET_SOURCE_FN = async (source) => {
|
|
696
|
-
if (File.isFile(source)) {
|
|
697
|
-
const code = await pine.pineCacheService.readFile(source.path, source.baseDir);
|
|
698
|
-
return Code.fromString(code);
|
|
699
|
-
}
|
|
700
|
-
if (Code.isCode(source)) {
|
|
701
|
-
return source;
|
|
702
|
-
}
|
|
703
|
-
throw new Error("Source must be a File or Code instance");
|
|
704
|
-
};
|
|
705
|
-
const SIGNAL_SCHEMA = {
|
|
706
|
-
position: "Signal",
|
|
707
|
-
priceOpen: "Close",
|
|
708
|
-
priceTakeProfit: "TakeProfit",
|
|
709
|
-
priceStopLoss: "StopLoss",
|
|
710
|
-
minuteEstimatedTime: {
|
|
711
|
-
plot: "EstimatedTime",
|
|
712
|
-
transform: (v) => v || DEFAULT_ESTIMATED_TIME,
|
|
713
|
-
},
|
|
714
|
-
};
|
|
715
693
|
function toSignalDto(data) {
|
|
716
694
|
if (data.position === 1) {
|
|
717
695
|
return {
|
|
@@ -735,6 +713,29 @@ function toSignalDto(data) {
|
|
|
735
713
|
}
|
|
736
714
|
return null;
|
|
737
715
|
}
|
|
716
|
+
|
|
717
|
+
const METHOD_NAME_RUN = "strategy.getSignal";
|
|
718
|
+
const DEFAULT_ESTIMATED_TIME = 240;
|
|
719
|
+
const GET_SOURCE_FN = async (source) => {
|
|
720
|
+
if (File.isFile(source)) {
|
|
721
|
+
const code = await pine.pineCacheService.readFile(source.path, source.baseDir);
|
|
722
|
+
return Code.fromString(code);
|
|
723
|
+
}
|
|
724
|
+
if (Code.isCode(source)) {
|
|
725
|
+
return source;
|
|
726
|
+
}
|
|
727
|
+
throw new Error("Source must be a File or Code instance");
|
|
728
|
+
};
|
|
729
|
+
const SIGNAL_SCHEMA = {
|
|
730
|
+
position: "Signal",
|
|
731
|
+
priceOpen: "Close",
|
|
732
|
+
priceTakeProfit: "TakeProfit",
|
|
733
|
+
priceStopLoss: "StopLoss",
|
|
734
|
+
minuteEstimatedTime: {
|
|
735
|
+
plot: "EstimatedTime",
|
|
736
|
+
transform: (v) => v || DEFAULT_ESTIMATED_TIME,
|
|
737
|
+
},
|
|
738
|
+
};
|
|
738
739
|
async function getSignal(source, { symbol, timeframe, limit }) {
|
|
739
740
|
pine.loggerService.info(METHOD_NAME_RUN, {
|
|
740
741
|
source,
|
|
@@ -766,4 +767,5 @@ exports.getSignal = getSignal;
|
|
|
766
767
|
exports.lib = pine;
|
|
767
768
|
exports.run = run;
|
|
768
769
|
exports.setLogger = setLogger;
|
|
770
|
+
exports.toSignalDto = toSignalDto;
|
|
769
771
|
exports.usePine = usePine;
|
package/build/index.mjs
CHANGED
|
@@ -498,7 +498,7 @@ function extractRowAtIndex(plots, keys, index) {
|
|
|
498
498
|
}
|
|
499
499
|
function isRowWarmedUp(row, keys) {
|
|
500
500
|
for (const key of keys) {
|
|
501
|
-
if (
|
|
501
|
+
if (isUnsafe(row[key])) {
|
|
502
502
|
return false;
|
|
503
503
|
}
|
|
504
504
|
}
|
|
@@ -687,28 +687,6 @@ function setLogger(logger) {
|
|
|
687
687
|
pine.loggerService.setLogger(logger);
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
-
const METHOD_NAME_RUN = "strategy.getSignal";
|
|
691
|
-
const DEFAULT_ESTIMATED_TIME = 240;
|
|
692
|
-
const GET_SOURCE_FN = async (source) => {
|
|
693
|
-
if (File.isFile(source)) {
|
|
694
|
-
const code = await pine.pineCacheService.readFile(source.path, source.baseDir);
|
|
695
|
-
return Code.fromString(code);
|
|
696
|
-
}
|
|
697
|
-
if (Code.isCode(source)) {
|
|
698
|
-
return source;
|
|
699
|
-
}
|
|
700
|
-
throw new Error("Source must be a File or Code instance");
|
|
701
|
-
};
|
|
702
|
-
const SIGNAL_SCHEMA = {
|
|
703
|
-
position: "Signal",
|
|
704
|
-
priceOpen: "Close",
|
|
705
|
-
priceTakeProfit: "TakeProfit",
|
|
706
|
-
priceStopLoss: "StopLoss",
|
|
707
|
-
minuteEstimatedTime: {
|
|
708
|
-
plot: "EstimatedTime",
|
|
709
|
-
transform: (v) => v || DEFAULT_ESTIMATED_TIME,
|
|
710
|
-
},
|
|
711
|
-
};
|
|
712
690
|
function toSignalDto(data) {
|
|
713
691
|
if (data.position === 1) {
|
|
714
692
|
return {
|
|
@@ -732,6 +710,29 @@ function toSignalDto(data) {
|
|
|
732
710
|
}
|
|
733
711
|
return null;
|
|
734
712
|
}
|
|
713
|
+
|
|
714
|
+
const METHOD_NAME_RUN = "strategy.getSignal";
|
|
715
|
+
const DEFAULT_ESTIMATED_TIME = 240;
|
|
716
|
+
const GET_SOURCE_FN = async (source) => {
|
|
717
|
+
if (File.isFile(source)) {
|
|
718
|
+
const code = await pine.pineCacheService.readFile(source.path, source.baseDir);
|
|
719
|
+
return Code.fromString(code);
|
|
720
|
+
}
|
|
721
|
+
if (Code.isCode(source)) {
|
|
722
|
+
return source;
|
|
723
|
+
}
|
|
724
|
+
throw new Error("Source must be a File or Code instance");
|
|
725
|
+
};
|
|
726
|
+
const SIGNAL_SCHEMA = {
|
|
727
|
+
position: "Signal",
|
|
728
|
+
priceOpen: "Close",
|
|
729
|
+
priceTakeProfit: "TakeProfit",
|
|
730
|
+
priceStopLoss: "StopLoss",
|
|
731
|
+
minuteEstimatedTime: {
|
|
732
|
+
plot: "EstimatedTime",
|
|
733
|
+
transform: (v) => v || DEFAULT_ESTIMATED_TIME,
|
|
734
|
+
},
|
|
735
|
+
};
|
|
735
736
|
async function getSignal(source, { symbol, timeframe, limit }) {
|
|
736
737
|
pine.loggerService.info(METHOD_NAME_RUN, {
|
|
737
738
|
source,
|
|
@@ -754,4 +755,4 @@ async function dumpPlotData(signalId, plots, taName, outputDir = "./dump/ta") {
|
|
|
754
755
|
return await pine.pineMarkdownService.dump(signalId, plots, taName, outputDir);
|
|
755
756
|
}
|
|
756
757
|
|
|
757
|
-
export { AXIS_SYMBOL, Code, File, dumpPlotData, extract, getSignal, pine as lib, run, setLogger, usePine };
|
|
758
|
+
export { AXIS_SYMBOL, Code, File, dumpPlotData, extract, getSignal, pine as lib, run, setLogger, toSignalDto, usePine };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backtest-kit/pinets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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
|
@@ -86,6 +86,18 @@ declare function getSignal(source: File | Code, { symbol, timeframe, limit }: IP
|
|
|
86
86
|
type ResultId$1 = string | number;
|
|
87
87
|
declare function dumpPlotData(signalId: ResultId$1, plots: PlotModel, taName: string, outputDir?: string): Promise<void>;
|
|
88
88
|
|
|
89
|
+
interface SignalData {
|
|
90
|
+
position: number;
|
|
91
|
+
priceOpen: number;
|
|
92
|
+
priceTakeProfit: number;
|
|
93
|
+
priceStopLoss: number;
|
|
94
|
+
minuteEstimatedTime: number;
|
|
95
|
+
}
|
|
96
|
+
interface Signal extends ISignalDto {
|
|
97
|
+
id: string;
|
|
98
|
+
}
|
|
99
|
+
declare function toSignalDto(data: SignalData): Signal | null;
|
|
100
|
+
|
|
89
101
|
interface CandleModel {
|
|
90
102
|
openTime: number;
|
|
91
103
|
open: number;
|
|
@@ -172,4 +184,4 @@ declare const pine: {
|
|
|
172
184
|
loggerService: LoggerService;
|
|
173
185
|
};
|
|
174
186
|
|
|
175
|
-
export { AXIS_SYMBOL, type CandleModel, Code, File, type ILogger, type IPine, type IProvider, type PlotExtractConfig, type PlotMapping, type PlotModel, type PlotRecord, type SymbolInfoModel, type TPineCtor, dumpPlotData, extract, getSignal, pine as lib, run, setLogger, usePine };
|
|
187
|
+
export { AXIS_SYMBOL, type CandleModel, Code, File, type ILogger, type IPine, type IProvider, type PlotExtractConfig, type PlotMapping, type PlotModel, type PlotRecord, type SymbolInfoModel, type TPineCtor, dumpPlotData, extract, getSignal, pine as lib, run, setLogger, toSignalDto, usePine };
|