pinets 0.8.12 → 0.9.0

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.
@@ -5,6 +5,7 @@ import PineMath from './namespaces/math/math.index';
5
5
  import { PineRequest } from './namespaces/request/request.index';
6
6
  import TechnicalAnalysis from './namespaces/ta/ta.index';
7
7
  import { Series } from './Series';
8
+ import type { IndicatorOptions } from './types/PineTypes';
8
9
  export declare class Context {
9
10
  data: any;
10
11
  indicator: IndicatorOptions;
@@ -1,4 +1,5 @@
1
1
  import { PineTypeObject } from './PineTypeObject';
2
+ import type { IndicatorOptions } from '../types/PineTypes';
2
3
  export declare function parseIndicatorOptions(args: any[]): Partial<IndicatorOptions>;
3
4
  /**
4
5
  * NAHelper implements the dual-use `na` identifier.
@@ -15,7 +16,8 @@ export declare class Core {
15
16
  color: {
16
17
  param: (source: any, index?: number) => any;
17
18
  rgb: (r: number, g: number, b: number, a?: number) => string;
18
- new: (color: string, a?: number) => string;
19
+ new: (color: any, a?: number) => any;
20
+ from_gradient: (value: any, bottom_value: any, top_value: any, bottom_color: any, top_color: any) => string;
19
21
  aqua: "#00BCD4";
20
22
  black: "#363A45";
21
23
  blue: "#2196F3";
@@ -78,25 +78,25 @@ export declare enum display {
78
78
  status_line = "status_line"
79
79
  }
80
80
  export declare enum shape {
81
- flag = "flag",
82
- arrowdown = "arrowdown",
83
- arrowup = "arrowup",
84
- circle = "circle",
85
- cross = "cross",
86
- diamond = "diamond",
87
- labeldown = "labeldown",
88
- labelup = "labelup",
89
- square = "square",
90
- triangledown = "triangledown",
91
- triangleup = "triangleup",
92
- xcross = "xcross"
81
+ flag = "shape_flag",
82
+ arrowdown = "shape_arrow_down",
83
+ arrowup = "shape_arrow_up",
84
+ circle = "shape_circle",
85
+ cross = "shape_cross",
86
+ diamond = "shape_diamond",
87
+ labeldown = "shape_label_down",
88
+ labelup = "shape_label_up",
89
+ square = "shape_square",
90
+ triangledown = "shape_triangle_down",
91
+ triangleup = "shape_triangle_up",
92
+ xcross = "shape_xcross"
93
93
  }
94
94
  export declare enum location {
95
- abovebar = "abovebar",
96
- belowbar = "belowbar",
97
- absolute = "absolute",
98
- bottom = "bottom",
99
- top = "top"
95
+ abovebar = "AboveBar",
96
+ belowbar = "BelowBar",
97
+ absolute = "Absolute",
98
+ bottom = "Bottom",
99
+ top = "Top"
100
100
  }
101
101
  export declare enum size {
102
102
  auto = "auto",
@@ -136,24 +136,71 @@ export declare enum barmerge {
136
136
  lookahead_off = "lookahead_off"
137
137
  }
138
138
  export declare enum xloc {
139
- bar_index = "bar_index",
140
- bar_time = "bar_time"
139
+ bar_index = "bi",
140
+ bar_time = "bt"
141
141
  }
142
142
  export declare enum yloc {
143
- price = "price",
144
- abovebar = "abovebar",
145
- belowbar = "belowbar"
143
+ price = "pr",
144
+ abovebar = "ab",
145
+ belowbar = "bl"
146
+ }
147
+ export declare enum extend {
148
+ left = "l",
149
+ right = "r",
150
+ both = "b",
151
+ none = "n"
146
152
  }
147
153
  export declare enum text {
148
- align_left = "align_left",
149
- align_center = "align_center",
150
- align_right = "align_right",
151
- wrap_auto = "wrap_auto",
152
- wrap_none = "wrap_none"
154
+ align_left = "left",
155
+ align_center = "center",
156
+ align_right = "right",
157
+ wrap_auto = "auto",
158
+ wrap_none = "none"
153
159
  }
154
160
  export declare enum font {
155
- family_default = "family_default",
156
- family_monospace = "family_monospace"
161
+ family_default = "default",
162
+ family_monospace = "monospace"
163
+ }
164
+ export declare enum adjustment {
165
+ none = "none",
166
+ splits = "splits",
167
+ dividends = "dividends"
168
+ }
169
+ export declare enum backadjustment {
170
+ inherit = "inherit",
171
+ off = "off",
172
+ on = "on"
173
+ }
174
+ export declare enum earnings {
175
+ actual = "earnings_actual",
176
+ estimate = "earnings_estimate",
177
+ standardized = "earnings_standardized",
178
+ future_eps = "earnings_future_eps",
179
+ future_period_end_time = "earnings_future_period_end_time",
180
+ future_revenue = "earnings_future_revenue",
181
+ future_time = "earnings_future_time"
182
+ }
183
+ export declare enum dividends {
184
+ gross = "dividends_gross",
185
+ net = "dividends_net",
186
+ future_amount = "dividends_future_amount",
187
+ future_ex_date = "dividends_future_ex_date",
188
+ future_pay_date = "dividends_future_pay_date"
189
+ }
190
+ export declare enum splits {
191
+ denominator = "splits_denominator",
192
+ numerator = "splits_numerator"
193
+ }
194
+ export declare enum position {
195
+ top_left = "top_left",
196
+ top_center = "top_center",
197
+ top_right = "top_right",
198
+ middle_left = "middle_left",
199
+ middle_center = "middle_center",
200
+ middle_right = "middle_right",
201
+ bottom_left = "bottom_left",
202
+ bottom_center = "bottom_center",
203
+ bottom_right = "bottom_right"
157
204
  }
158
205
  declare const types: {
159
206
  order: typeof order;
@@ -167,7 +214,14 @@ declare const types: {
167
214
  barmerge: typeof barmerge;
168
215
  xloc: typeof xloc;
169
216
  yloc: typeof yloc;
217
+ extend: typeof extend;
170
218
  text: typeof text;
171
219
  font: typeof font;
220
+ adjustment: typeof adjustment;
221
+ backadjustment: typeof backadjustment;
222
+ earnings: typeof earnings;
223
+ dividends: typeof dividends;
224
+ splits: typeof splits;
225
+ position: typeof position;
172
226
  };
173
227
  export default types;
@@ -0,0 +1,44 @@
1
+ import { BoxObject } from './BoxObject';
2
+ import { ChartPointObject } from '../chart/ChartPointObject';
3
+ export declare class BoxHelper {
4
+ private context;
5
+ private _boxes;
6
+ constructor(context: any);
7
+ param(source: any, index?: number, name?: string): any;
8
+ private _ensurePlotsEntry;
9
+ private _syncToPlot;
10
+ private _resolvePoint;
11
+ private _resolve;
12
+ private _createBox;
13
+ new(...args: any[]): BoxObject;
14
+ any(...args: any[]): BoxObject;
15
+ set_left(id: BoxObject, left: number): void;
16
+ set_right(id: BoxObject, right: number): void;
17
+ set_top(id: BoxObject, top: number): void;
18
+ set_bottom(id: BoxObject, bottom: number): void;
19
+ set_lefttop(id: BoxObject, left: number, top: number): void;
20
+ set_rightbottom(id: BoxObject, right: number, bottom: number): void;
21
+ set_top_left_point(id: BoxObject, point: ChartPointObject): void;
22
+ set_bottom_right_point(id: BoxObject, point: ChartPointObject): void;
23
+ set_xloc(id: BoxObject, left: number, right: number, xloc: string): void;
24
+ set_bgcolor(id: BoxObject, color: string): void;
25
+ set_border_color(id: BoxObject, color: string): void;
26
+ set_border_width(id: BoxObject, width: number): void;
27
+ set_border_style(id: BoxObject, style: string): void;
28
+ set_extend(id: BoxObject, extend: string): void;
29
+ set_text(id: BoxObject, text: string): void;
30
+ set_text_color(id: BoxObject, color: string): void;
31
+ set_text_size(id: BoxObject, size: string): void;
32
+ set_text_halign(id: BoxObject, align: string): void;
33
+ set_text_valign(id: BoxObject, align: string): void;
34
+ set_text_wrap(id: BoxObject, wrap: string): void;
35
+ set_text_font_family(id: BoxObject, family: string): void;
36
+ set_text_formatting(id: BoxObject, formatting: string): void;
37
+ get_left(id: BoxObject): number;
38
+ get_right(id: BoxObject): number;
39
+ get_top(id: BoxObject): number;
40
+ get_bottom(id: BoxObject): number;
41
+ copy(id: BoxObject): BoxObject | undefined;
42
+ delete(id: BoxObject): void;
43
+ get all(): BoxObject[];
44
+ }
@@ -0,0 +1,27 @@
1
+ export declare function resetBoxIdCounter(): void;
2
+ export declare class BoxObject {
3
+ id: number;
4
+ left: number;
5
+ top: number;
6
+ right: number;
7
+ bottom: number;
8
+ xloc: string;
9
+ extend: string;
10
+ border_color: string;
11
+ border_style: string;
12
+ border_width: number;
13
+ bgcolor: string;
14
+ text: string;
15
+ text_color: string;
16
+ text_size: string;
17
+ text_halign: string;
18
+ text_valign: string;
19
+ text_wrap: string;
20
+ text_font_family: string;
21
+ text_formatting: string;
22
+ force_overlay: boolean;
23
+ _deleted: boolean;
24
+ constructor(left: number, top: number, right: number, bottom: number, xloc?: string, extend?: string, border_color?: string, border_style?: string, border_width?: number, bgcolor?: string, text?: string, text_color?: string, text_size?: string, text_halign?: string, text_valign?: string, text_wrap?: string, text_font_family?: string, text_formatting?: string, force_overlay?: boolean);
25
+ delete(): void;
26
+ copy(): BoxObject;
27
+ }
@@ -16,6 +16,7 @@ export declare class LabelObject {
16
16
  force_overlay: boolean;
17
17
  _deleted: boolean;
18
18
  constructor(x: number, y: number, text?: string, xloc?: string, yloc?: string, color?: string, style?: string, textcolor?: string, size?: string, textalign?: string, tooltip?: string, text_font_family?: string, force_overlay?: boolean);
19
+ delete(): void;
19
20
  copy(): LabelObject;
20
21
  toPlotData(): any;
21
22
  }
@@ -13,6 +13,7 @@ export declare class LineObject {
13
13
  force_overlay: boolean;
14
14
  _deleted: boolean;
15
15
  constructor(x1: number, y1: number, x2: number, y2: number, xloc?: string, extend?: string, color?: string, style?: string, width?: number, force_overlay?: boolean);
16
+ delete(): void;
16
17
  copy(): LineObject;
17
18
  toPlotData(): any;
18
19
  }
@@ -7,4 +7,5 @@ export declare class LinefillObject {
7
7
  color: string;
8
8
  _deleted: boolean;
9
9
  constructor(line1: LineObject, line2: LineObject, color: string);
10
+ delete(): void;
10
11
  }
@@ -0,0 +1,21 @@
1
+ import { PolylineObject } from './PolylineObject';
2
+ export declare class PolylineHelper {
3
+ private context;
4
+ private _polylines;
5
+ constructor(context: any);
6
+ param(source: any, index?: number, name?: string): any;
7
+ private _ensurePlotsEntry;
8
+ private _syncToPlot;
9
+ /**
10
+ * Resolve a value that may be a Series, a bound function, or a plain scalar.
11
+ */
12
+ private _resolve;
13
+ /**
14
+ * Extract raw ChartPointObject array from a PineArrayObject or plain array.
15
+ */
16
+ private _extractPoints;
17
+ new(...args: any[]): PolylineObject;
18
+ any(...args: any[]): PolylineObject;
19
+ delete(id: PolylineObject): void;
20
+ get all(): PolylineObject[];
21
+ }
@@ -0,0 +1,17 @@
1
+ import { ChartPointObject } from '../chart/ChartPointObject';
2
+ export declare function resetPolylineIdCounter(): void;
3
+ export declare class PolylineObject {
4
+ id: number;
5
+ points: ChartPointObject[];
6
+ curved: boolean;
7
+ closed: boolean;
8
+ xloc: string;
9
+ line_color: string;
10
+ fill_color: string;
11
+ line_style: string;
12
+ line_width: number;
13
+ force_overlay: boolean;
14
+ _deleted: boolean;
15
+ constructor(points: ChartPointObject[], curved?: boolean, closed?: boolean, xloc?: string, line_color?: string, fill_color?: string, line_style?: string, line_width?: number, force_overlay?: boolean);
16
+ delete(): void;
17
+ }
@@ -0,0 +1,35 @@
1
+ import { TableObject } from './TableObject';
2
+ export declare class TableHelper {
3
+ private context;
4
+ private _tables;
5
+ constructor(context: any);
6
+ param(source: any, index?: number, name?: string): any;
7
+ private _ensurePlotsEntry;
8
+ private _syncToPlot;
9
+ private _resolve;
10
+ new(...args: any[]): TableObject;
11
+ any(...args: any[]): TableObject;
12
+ cell(...args: any[]): void;
13
+ delete(id: TableObject): void;
14
+ clear(...args: any[]): void;
15
+ merge_cells(...args: any[]): void;
16
+ cell_set_text(table_id: any, column: any, row: any, text: any): void;
17
+ cell_set_bgcolor(table_id: any, column: any, row: any, bgcolor: any): void;
18
+ cell_set_text_color(table_id: any, column: any, row: any, text_color: any): void;
19
+ cell_set_text_size(table_id: any, column: any, row: any, text_size: any): void;
20
+ cell_set_height(table_id: any, column: any, row: any, height: any): void;
21
+ cell_set_width(table_id: any, column: any, row: any, width: any): void;
22
+ cell_set_tooltip(table_id: any, column: any, row: any, tooltip: any): void;
23
+ cell_set_text_halign(table_id: any, column: any, row: any, text_halign: any): void;
24
+ cell_set_text_valign(table_id: any, column: any, row: any, text_valign: any): void;
25
+ cell_set_text_font_family(table_id: any, column: any, row: any, text_font_family: any): void;
26
+ set_position(table_id: any, position: any): void;
27
+ set_bgcolor(table_id: any, bgcolor: any): void;
28
+ set_border_color(table_id: any, border_color: any): void;
29
+ set_border_width(table_id: any, border_width: any): void;
30
+ set_frame_color(table_id: any, frame_color: any): void;
31
+ set_frame_width(table_id: any, frame_width: any): void;
32
+ get all(): TableObject[];
33
+ private _setCellProp;
34
+ private _resolveText;
35
+ }
@@ -0,0 +1,42 @@
1
+ export declare function resetTableIdCounter(): void;
2
+ export interface TableCell {
3
+ text: string;
4
+ width: number;
5
+ height: number;
6
+ text_color: string;
7
+ text_halign: string;
8
+ text_valign: string;
9
+ text_size: string | number;
10
+ bgcolor: string;
11
+ tooltip: string;
12
+ text_font_family: string;
13
+ _merged: boolean;
14
+ _merge_parent: [number, number] | null;
15
+ }
16
+ export interface MergeRegion {
17
+ startCol: number;
18
+ startRow: number;
19
+ endCol: number;
20
+ endRow: number;
21
+ }
22
+ export declare class TableObject {
23
+ id: number;
24
+ position: string;
25
+ columns: number;
26
+ rows: number;
27
+ bgcolor: string;
28
+ frame_color: string;
29
+ frame_width: number;
30
+ border_color: string;
31
+ border_width: number;
32
+ force_overlay: boolean;
33
+ _deleted: boolean;
34
+ cells: (TableCell | null)[][];
35
+ merges: MergeRegion[];
36
+ constructor(position?: string, columns?: number, rows?: number, bgcolor?: string, frame_color?: string, frame_width?: number, border_color?: string, border_width?: number, force_overlay?: boolean);
37
+ delete(): void;
38
+ setCell(column: number, row: number, props: Partial<TableCell>): void;
39
+ getCell(column: number, row: number): TableCell | null;
40
+ clearCell(column: number, row: number): void;
41
+ private _defaultCell;
42
+ }
@@ -50,6 +50,17 @@ export declare class ScopeManager {
50
50
  enterHoistingScope(): void;
51
51
  exitHoistingScope(): any[];
52
52
  addHoistedStatement(stmt: any): void;
53
+ /**
54
+ * Hoist a statement to the script body scope (inside the async IIFE).
55
+ * Used for TA built-in variable auto-calls (e.g. ta.obv) that must run
56
+ * every bar, even when referenced inside conditional blocks.
57
+ *
58
+ * hoistingStack layout for PineTS:
59
+ * [0] = Program level (outside IIFE — variables not in scope)
60
+ * [1] = IIFE body level (script's top-level — correct target)
61
+ * [2+] = inner scopes (if-blocks, loops, etc.)
62
+ */
63
+ addOuterHoistedStatement(stmt: any): void;
53
64
  getCurrentHoistingScope(): any[] | null;
54
65
  setSuppressHoisting(suppress: boolean): void;
55
66
  shouldSuppressHoisting(): boolean;
@@ -48,7 +48,9 @@ export declare class CodeGenerator {
48
48
  generateArrayExpression(node: any): void;
49
49
  generateObjectExpression(node: any): void;
50
50
  generateSwitchExpression(node: any): void;
51
+ generateSwitchAsIfElseIIFE(node: any): void;
51
52
  generateSwitchAsIfElse(node: any): void;
53
+ generateLoopAsExpression(node: any, loopType: any): void;
52
54
  generateSequenceExpression(node: any): void;
53
55
  getPrecedence(node: any): 0 | 10 | 1 | 2 | 3 | 4 | 5 | 9 | 12 | 13 | 15 | 20 | 19;
54
56
  }
@@ -10,11 +10,13 @@ export declare class Parser {
10
10
  match(type: any, value?: any): boolean;
11
11
  expect(type: any, value?: any): Token;
12
12
  matchEx(type: any, value?: any, allowLineContinuation?: boolean): boolean;
13
+ peekOperatorEx(validOps: string[]): any;
13
14
  skipNewlines(allowIndent?: boolean): void;
14
15
  parse(): Program;
15
16
  parseStatement(handleCommas?: boolean): any;
16
17
  isFunctionDeclaration(): boolean;
17
18
  parseTypeExpression(): any;
19
+ parseEnumDefinition(): VariableDeclaration;
18
20
  parseTypeDefinition(): TypeDefinition;
19
21
  parseVarDeclaration(): VariableDeclaration;
20
22
  isTypedVarDeclaration(): boolean;
@@ -45,5 +47,7 @@ export declare class Parser {
45
47
  parseIfExpression(): any;
46
48
  needsIIFE(consequentStmts: any, alternateStmts: any): any;
47
49
  parseSwitchExpression(): SwitchExpression;
50
+ parseForExpression(): ForStatement;
51
+ parseWhileExpression(): WhileStatement;
48
52
  getBlockValue(statements: any): any;
49
53
  }
@@ -1,4 +1,4 @@
1
- type PlotCharOptions = {
1
+ export type PlotCharOptions = {
2
2
  title?: string;
3
3
  char?: string;
4
4
  location?: string;
@@ -14,7 +14,7 @@ type PlotCharOptions = {
14
14
  precision?: number;
15
15
  force_overlay?: boolean;
16
16
  };
17
- type PlotOptions = {
17
+ export type PlotOptions = {
18
18
  series?: number;
19
19
  title?: string;
20
20
  color?: string;
@@ -31,7 +31,7 @@ type PlotOptions = {
31
31
  precision?: number;
32
32
  force_overlay?: boolean;
33
33
  };
34
- type PlotShapeOptions = {
34
+ export type PlotShapeOptions = {
35
35
  series?: number;
36
36
  title?: string;
37
37
  style?: string;
@@ -48,7 +48,7 @@ type PlotShapeOptions = {
48
48
  precision?: number;
49
49
  force_overlay?: boolean;
50
50
  };
51
- type PlotArrowOptions = {
51
+ export type PlotArrowOptions = {
52
52
  series?: number;
53
53
  title?: string;
54
54
  colorup?: string;
@@ -63,7 +63,7 @@ type PlotArrowOptions = {
63
63
  precision?: number;
64
64
  force_overlay?: boolean;
65
65
  };
66
- type PlotBarOptions = {
66
+ export type PlotBarOptions = {
67
67
  open: number;
68
68
  high: number;
69
69
  low: number;
@@ -77,7 +77,7 @@ type PlotBarOptions = {
77
77
  precision?: number;
78
78
  force_overlay?: boolean;
79
79
  };
80
- type BackgroundColorOptions = {
80
+ export type BackgroundColorOptions = {
81
81
  color?: string;
82
82
  offset?: number;
83
83
  editable?: boolean;
@@ -86,7 +86,7 @@ type BackgroundColorOptions = {
86
86
  display?: string;
87
87
  force_overlay?: boolean;
88
88
  };
89
- type BarColorOptions = {
89
+ export type BarColorOptions = {
90
90
  color?: string;
91
91
  offset?: number;
92
92
  editable?: boolean;
@@ -94,7 +94,7 @@ type BarColorOptions = {
94
94
  title?: string;
95
95
  display?: string;
96
96
  };
97
- type PlotCandleOptions = {
97
+ export type PlotCandleOptions = {
98
98
  open: number;
99
99
  high: number;
100
100
  low: number;
@@ -110,7 +110,7 @@ type PlotCandleOptions = {
110
110
  precision?: number;
111
111
  force_overlay?: boolean;
112
112
  };
113
- type IndicatorOptions = {
113
+ export type IndicatorOptions = {
114
114
  title: string;
115
115
  shorttitle: string;
116
116
  overlay: boolean;
@@ -129,7 +129,16 @@ type IndicatorOptions = {
129
129
  dynamic_requests: boolean;
130
130
  behind_chart: boolean;
131
131
  };
132
- type FillOptions = {
132
+ export type HlineOptions = {
133
+ price: number;
134
+ title: string;
135
+ color: string;
136
+ linestyle: string;
137
+ linewidth: number;
138
+ editable: boolean;
139
+ display: string;
140
+ };
141
+ export type FillOptions = {
133
142
  plot1: Record<string, any>;
134
143
  plot2: Record<string, any>;
135
144
  color: string;
@@ -139,7 +148,7 @@ type FillOptions = {
139
148
  fillgaps: boolean;
140
149
  display: string;
141
150
  };
142
- type TSessionInfo = {
151
+ export type TSessionInfo = {
143
152
  isfirstbar: boolean;
144
153
  isfirstbar_regular: boolean;
145
154
  islastbar: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinets",
3
- "version": "0.8.12",
3
+ "version": "0.9.0",
4
4
  "description": "Run Pine Script anywhere. PineTS is an open-source transpiler and runtime that brings Pine Script logic to Node.js and the browser with 1:1 syntax compatibility. Reliably write, port, and run indicators or strategies on your own infrastructure.",
5
5
  "keywords": [
6
6
  "Pine Script",
@@ -81,6 +81,7 @@
81
81
  "astring": "^1.9.0"
82
82
  },
83
83
  "devDependencies": {
84
+ "typescript": "~5.9.3",
84
85
  "@rollup/plugin-commonjs": "^29.0.0",
85
86
  "@rollup/plugin-json": "^6.1.0",
86
87
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -105,5 +106,6 @@
105
106
  "repository": {
106
107
  "type": "git",
107
108
  "url": "git+https://github.com/QuantForgeOrg/PineTS.git"
108
- }
109
+ },
110
+ "homepage": "https://quantforge.org/pinets/"
109
111
  }