@alphacharts/script 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +161 -2
- package/dist/builtins-BXxWK58s.js +812 -0
- package/dist/builtins-BXxWK58s.js.map +1 -0
- package/dist/editor.js +211 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.js +342 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox-p2HPP8yl.js +2416 -0
- package/dist/sandbox-p2HPP8yl.js.map +1 -0
- package/dist/sandbox-worker.js +8 -0
- package/dist/sandbox-worker.js.map +1 -0
- package/dist/types/ast.d.ts +156 -0
- package/dist/types/builtins.d.ts +67 -0
- package/dist/types/check.d.ts +78 -0
- package/dist/types/codegen.d.ts +14 -0
- package/dist/types/compile.d.ts +52 -0
- package/dist/types/diag.d.ts +45 -0
- package/dist/types/editor/index.d.ts +23 -0
- package/dist/types/feeds.d.ts +33 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/lexer.d.ts +14 -0
- package/dist/types/limits.d.ts +25 -0
- package/dist/types/parser.d.ts +3 -0
- package/dist/types/run.d.ts +69 -0
- package/dist/types/runner.d.ts +54 -0
- package/dist/types/sandbox-worker.d.ts +1 -0
- package/dist/types/sandbox.d.ts +78 -0
- package/dist/types/ui-adapter.d.ts +21 -0
- package/package.json +75 -3
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
import { ALL_STUDIES as e } from "@alphacharts/indicators/all";
|
|
2
|
+
//#region src/lexer.ts
|
|
3
|
+
var t = /* @__PURE__ */ new Set([
|
|
4
|
+
"if",
|
|
5
|
+
"else",
|
|
6
|
+
"for",
|
|
7
|
+
"to",
|
|
8
|
+
"by",
|
|
9
|
+
"var",
|
|
10
|
+
"and",
|
|
11
|
+
"or",
|
|
12
|
+
"not",
|
|
13
|
+
"true",
|
|
14
|
+
"false"
|
|
15
|
+
]), n = Object.assign(Object.create(null), Object.fromEntries(Object.entries({
|
|
16
|
+
while: "'while' is not supported: loops must be bounded, use 'for i = a to b'",
|
|
17
|
+
switch: "'switch' is not supported: use if / else",
|
|
18
|
+
function: "functions are not supported",
|
|
19
|
+
return: "'return' is not supported",
|
|
20
|
+
import: "'import' is not supported",
|
|
21
|
+
export: "'export' is not supported",
|
|
22
|
+
break: "'break' is not supported: loops are bounded",
|
|
23
|
+
continue: "'continue' is not supported",
|
|
24
|
+
class: "'class' is not supported",
|
|
25
|
+
eval: "'eval' is not part of the language",
|
|
26
|
+
this: "'this' is not part of the language",
|
|
27
|
+
null: "there is no 'null'; use na",
|
|
28
|
+
undefined: "there is no 'undefined'; use na",
|
|
29
|
+
constructor: "'constructor' is a reserved name",
|
|
30
|
+
prototype: "'prototype' is a reserved name"
|
|
31
|
+
}).concat([["__proto__", "'__proto__' is a reserved name"]]))), r = /* @__PURE__ */ new Set([
|
|
32
|
+
":=",
|
|
33
|
+
"==",
|
|
34
|
+
"!=",
|
|
35
|
+
"<=",
|
|
36
|
+
">=",
|
|
37
|
+
"+=",
|
|
38
|
+
"-=",
|
|
39
|
+
"*=",
|
|
40
|
+
"/=",
|
|
41
|
+
"%="
|
|
42
|
+
]), i = /* @__PURE__ */ new Set([
|
|
43
|
+
"+",
|
|
44
|
+
"-",
|
|
45
|
+
"*",
|
|
46
|
+
"/",
|
|
47
|
+
"%",
|
|
48
|
+
"<",
|
|
49
|
+
">",
|
|
50
|
+
"=",
|
|
51
|
+
"?",
|
|
52
|
+
":",
|
|
53
|
+
"(",
|
|
54
|
+
")",
|
|
55
|
+
"[",
|
|
56
|
+
"]",
|
|
57
|
+
",",
|
|
58
|
+
"."
|
|
59
|
+
]), a = (e) => e >= 48 && e <= 57, o = (e) => e >= 65 && e <= 90 || e >= 97 && e <= 122 || e === 95, s = (e) => o(e) || a(e), c = (e) => a(e) || e >= 65 && e <= 70 || e >= 97 && e <= 102;
|
|
60
|
+
function l(e, l) {
|
|
61
|
+
let u = [], d = e.length, f = 0, p = 0, m = [0], h = !0, g = (e, t, n, r, i) => {
|
|
62
|
+
u.push(i === void 0 ? {
|
|
63
|
+
kind: e,
|
|
64
|
+
text: t,
|
|
65
|
+
from: n,
|
|
66
|
+
to: r
|
|
67
|
+
} : {
|
|
68
|
+
kind: e,
|
|
69
|
+
text: t,
|
|
70
|
+
from: n,
|
|
71
|
+
to: r,
|
|
72
|
+
value: i
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
for (; f < d;) {
|
|
76
|
+
if (h && p === 0) {
|
|
77
|
+
let t = f;
|
|
78
|
+
for (; t < d && e.charCodeAt(t) === 32;) t++;
|
|
79
|
+
if (t < d && e.charCodeAt(t) === 9) for (l.error("tab characters are not allowed; indent with spaces", {
|
|
80
|
+
from: t,
|
|
81
|
+
to: t + 1
|
|
82
|
+
}); t < d && e.charCodeAt(t) === 9;) t++;
|
|
83
|
+
let n = e.charCodeAt(t);
|
|
84
|
+
if (t >= d || n === 10 || n === 13 || n === 47 && e.charCodeAt(t + 1) === 47) {
|
|
85
|
+
for (; t < d && e.charCodeAt(t) !== 10;) t++;
|
|
86
|
+
f = t < d ? t + 1 : t;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
let r = t - f, i = m[m.length - 1];
|
|
90
|
+
if (r > i) m.push(r), g("indent", "", f, t);
|
|
91
|
+
else if (r < i) {
|
|
92
|
+
for (; m.length > 1 && m[m.length - 1] > r;) m.pop(), g("dedent", "", f, t);
|
|
93
|
+
m[m.length - 1] !== r && (l.error("indentation does not match any outer block", {
|
|
94
|
+
from: f,
|
|
95
|
+
to: t
|
|
96
|
+
}), m.push(r));
|
|
97
|
+
}
|
|
98
|
+
f = t, h = !1;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
let u = e.charCodeAt(f);
|
|
102
|
+
if (u === 10) {
|
|
103
|
+
p === 0 && (g("newline", "\n", f, f + 1), h = !0), f++;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (u === 32 || u === 13) {
|
|
107
|
+
f++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (u === 9) {
|
|
111
|
+
l.error("tab characters are not allowed; indent with spaces", {
|
|
112
|
+
from: f,
|
|
113
|
+
to: f + 1
|
|
114
|
+
}), f++;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (u === 47 && e.charCodeAt(f + 1) === 47) {
|
|
118
|
+
for (; f < d && e.charCodeAt(f) !== 10;) f++;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (a(u) || u === 46 && a(e.charCodeAt(f + 1))) {
|
|
122
|
+
let t = f;
|
|
123
|
+
for (; f < d && a(e.charCodeAt(f));) f++;
|
|
124
|
+
if (e.charCodeAt(f) === 46 && a(e.charCodeAt(f + 1))) for (f++; f < d && a(e.charCodeAt(f));) f++;
|
|
125
|
+
else e.charCodeAt(f) === 46 && !o(e.charCodeAt(f + 1)) && f++;
|
|
126
|
+
if (e.charCodeAt(f) === 101 || e.charCodeAt(f) === 69) {
|
|
127
|
+
let t = f + 1;
|
|
128
|
+
if ((e.charCodeAt(t) === 43 || e.charCodeAt(t) === 45) && t++, a(e.charCodeAt(t))) {
|
|
129
|
+
for (; a(e.charCodeAt(t));) t++;
|
|
130
|
+
f = t;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
let n = e.slice(t, f);
|
|
134
|
+
if (o(e.charCodeAt(f))) {
|
|
135
|
+
let n = f;
|
|
136
|
+
for (; n < d && s(e.charCodeAt(n));) n++;
|
|
137
|
+
l.error(`invalid number "${e.slice(t, n)}"`, {
|
|
138
|
+
from: t,
|
|
139
|
+
to: n
|
|
140
|
+
}), f = n, g("num", "0", t, n, 0);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
let r = Number(n);
|
|
144
|
+
Number.isFinite(r) || l.error(`number "${n}" is out of range`, {
|
|
145
|
+
from: t,
|
|
146
|
+
to: f
|
|
147
|
+
}), g("num", n, t, f, Number.isFinite(r) ? r : 0);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (o(u)) {
|
|
151
|
+
let r = f;
|
|
152
|
+
for (; f < d && s(e.charCodeAt(f));) f++;
|
|
153
|
+
let i = e.slice(r, f);
|
|
154
|
+
i in n ? (l.error(n[i], {
|
|
155
|
+
from: r,
|
|
156
|
+
to: f
|
|
157
|
+
}), g("ident", "_reserved", r, f)) : g(t.has(i) ? "kw" : "ident", i, r, f);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (u === 34 || u === 39) {
|
|
161
|
+
let t = f, n = u;
|
|
162
|
+
f++;
|
|
163
|
+
let r = "", i = !1;
|
|
164
|
+
for (; f < d;) {
|
|
165
|
+
let t = e.charCodeAt(f);
|
|
166
|
+
if (t === 10) break;
|
|
167
|
+
if (t === n) {
|
|
168
|
+
f++, i = !0;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
if (t === 92) {
|
|
172
|
+
let t = e[f + 1];
|
|
173
|
+
t === "n" ? r += "\n" : t === "t" ? r += " " : t === "\\" || t === "\"" || t === "'" ? r += t : l.error(`unknown escape "\\${t ?? ""}"`, {
|
|
174
|
+
from: f,
|
|
175
|
+
to: Math.min(d, f + 2)
|
|
176
|
+
}), f += 2;
|
|
177
|
+
} else r += e[f], f++;
|
|
178
|
+
}
|
|
179
|
+
i || l.error("unterminated string", {
|
|
180
|
+
from: t,
|
|
181
|
+
to: f
|
|
182
|
+
}), g("str", r, t, f);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (u === 35) {
|
|
186
|
+
let t = f;
|
|
187
|
+
for (f++; f < d && c(e.charCodeAt(f));) f++;
|
|
188
|
+
let n = e.slice(t + 1, f);
|
|
189
|
+
n.length !== 6 && n.length !== 8 && l.error(`invalid color "${e.slice(t, f)}": use #RRGGBB or #RRGGBBAA`, {
|
|
190
|
+
from: t,
|
|
191
|
+
to: f
|
|
192
|
+
}), g("color", `#${n}`.toLowerCase(), t, f);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
let _ = e.slice(f, f + 2);
|
|
196
|
+
if (r.has(_)) {
|
|
197
|
+
g("op", _, f, f + 2), f += 2;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
let v = e[f];
|
|
201
|
+
if (i.has(v)) {
|
|
202
|
+
v === "(" || v === "[" ? p++ : (v === ")" || v === "]") && (p = Math.max(0, p - 1)), g("op", v, f, f + 1), f++;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
let y = e.codePointAt(f) > 65535 ? 2 : 1;
|
|
206
|
+
l.error(`unexpected character ${JSON.stringify(e.slice(f, f + y))}`, {
|
|
207
|
+
from: f,
|
|
208
|
+
to: f + y
|
|
209
|
+
}), f += y;
|
|
210
|
+
}
|
|
211
|
+
for (p > 0 && l.error("unclosed bracket", {
|
|
212
|
+
from: d,
|
|
213
|
+
to: d
|
|
214
|
+
}), u.length > 0 && u[u.length - 1].kind !== "newline" && g("newline", "\n", d, d); m.length > 1;) m.pop(), g("dedent", "", d, d);
|
|
215
|
+
return g("eof", "", d, d), u;
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/builtins.ts
|
|
219
|
+
var u = {
|
|
220
|
+
b: "float",
|
|
221
|
+
q: "series"
|
|
222
|
+
}, d = {
|
|
223
|
+
b: "int",
|
|
224
|
+
q: "series"
|
|
225
|
+
}, f = {
|
|
226
|
+
b: "bool",
|
|
227
|
+
q: "series"
|
|
228
|
+
}, p = (e, t = "const") => ({
|
|
229
|
+
b: e,
|
|
230
|
+
q: t
|
|
231
|
+
}), m = (e) => ({
|
|
232
|
+
b: "tuple",
|
|
233
|
+
q: "series",
|
|
234
|
+
elems: e
|
|
235
|
+
});
|
|
236
|
+
function h(e) {
|
|
237
|
+
return Object.assign(Object.create(null), e);
|
|
238
|
+
}
|
|
239
|
+
var g = [
|
|
240
|
+
"open",
|
|
241
|
+
"high",
|
|
242
|
+
"low",
|
|
243
|
+
"close",
|
|
244
|
+
"volume"
|
|
245
|
+
], _ = /* @__PURE__ */ new Set([
|
|
246
|
+
"ta",
|
|
247
|
+
"math",
|
|
248
|
+
"color",
|
|
249
|
+
"input",
|
|
250
|
+
"plot",
|
|
251
|
+
"shape",
|
|
252
|
+
"location",
|
|
253
|
+
"hline",
|
|
254
|
+
"str"
|
|
255
|
+
]), v = h({
|
|
256
|
+
close: {
|
|
257
|
+
ty: u,
|
|
258
|
+
needs: "value"
|
|
259
|
+
},
|
|
260
|
+
open: {
|
|
261
|
+
ty: u,
|
|
262
|
+
needs: "ohlc"
|
|
263
|
+
},
|
|
264
|
+
high: {
|
|
265
|
+
ty: u,
|
|
266
|
+
needs: "ohlc"
|
|
267
|
+
},
|
|
268
|
+
low: {
|
|
269
|
+
ty: u,
|
|
270
|
+
needs: "ohlc"
|
|
271
|
+
},
|
|
272
|
+
hl2: {
|
|
273
|
+
ty: u,
|
|
274
|
+
needs: "ohlc"
|
|
275
|
+
},
|
|
276
|
+
hlc3: {
|
|
277
|
+
ty: u,
|
|
278
|
+
needs: "ohlc"
|
|
279
|
+
},
|
|
280
|
+
ohlc4: {
|
|
281
|
+
ty: u,
|
|
282
|
+
needs: "ohlc"
|
|
283
|
+
},
|
|
284
|
+
hlcc4: {
|
|
285
|
+
ty: u,
|
|
286
|
+
needs: "ohlc"
|
|
287
|
+
},
|
|
288
|
+
volume: {
|
|
289
|
+
ty: u,
|
|
290
|
+
needs: "ohlcv"
|
|
291
|
+
},
|
|
292
|
+
time: {
|
|
293
|
+
ty: u,
|
|
294
|
+
needs: "value"
|
|
295
|
+
},
|
|
296
|
+
bar_index: {
|
|
297
|
+
ty: d,
|
|
298
|
+
needs: "value"
|
|
299
|
+
},
|
|
300
|
+
bars_per_year: {
|
|
301
|
+
ty: u,
|
|
302
|
+
needs: "value"
|
|
303
|
+
}
|
|
304
|
+
}), y = h({
|
|
305
|
+
"math.pi": {
|
|
306
|
+
ty: p("float"),
|
|
307
|
+
value: Math.PI
|
|
308
|
+
},
|
|
309
|
+
"math.e": {
|
|
310
|
+
ty: p("float"),
|
|
311
|
+
value: Math.E
|
|
312
|
+
},
|
|
313
|
+
...Object.fromEntries(Object.entries({
|
|
314
|
+
aqua: "#00bcd4",
|
|
315
|
+
black: "#000000",
|
|
316
|
+
blue: "#2962ff",
|
|
317
|
+
fuchsia: "#e040fb",
|
|
318
|
+
gray: "#787b86",
|
|
319
|
+
green: "#4caf50",
|
|
320
|
+
lime: "#00e676",
|
|
321
|
+
maroon: "#880e4f",
|
|
322
|
+
navy: "#311b92",
|
|
323
|
+
olive: "#808000",
|
|
324
|
+
orange: "#ff9800",
|
|
325
|
+
purple: "#9c27b0",
|
|
326
|
+
red: "#f23645",
|
|
327
|
+
silver: "#b2b5be",
|
|
328
|
+
teal: "#089981",
|
|
329
|
+
white: "#ffffff",
|
|
330
|
+
yellow: "#fdd835"
|
|
331
|
+
}).map(([e, t]) => [`color.${e}`, {
|
|
332
|
+
ty: p("color"),
|
|
333
|
+
value: t
|
|
334
|
+
}])),
|
|
335
|
+
"plot.style_line": {
|
|
336
|
+
ty: p("string"),
|
|
337
|
+
value: "line"
|
|
338
|
+
},
|
|
339
|
+
"plot.style_histogram": {
|
|
340
|
+
ty: p("string"),
|
|
341
|
+
value: "histogram"
|
|
342
|
+
},
|
|
343
|
+
"plot.style_area": {
|
|
344
|
+
ty: p("string"),
|
|
345
|
+
value: "area"
|
|
346
|
+
},
|
|
347
|
+
"hline.style_solid": {
|
|
348
|
+
ty: p("string"),
|
|
349
|
+
value: "solid"
|
|
350
|
+
},
|
|
351
|
+
"hline.style_dashed": {
|
|
352
|
+
ty: p("string"),
|
|
353
|
+
value: "dashed"
|
|
354
|
+
},
|
|
355
|
+
"hline.style_dotted": {
|
|
356
|
+
ty: p("string"),
|
|
357
|
+
value: "dotted"
|
|
358
|
+
},
|
|
359
|
+
"shape.circle": {
|
|
360
|
+
ty: p("string"),
|
|
361
|
+
value: "circle"
|
|
362
|
+
},
|
|
363
|
+
"shape.square": {
|
|
364
|
+
ty: p("string"),
|
|
365
|
+
value: "square"
|
|
366
|
+
},
|
|
367
|
+
"shape.diamond": {
|
|
368
|
+
ty: p("string"),
|
|
369
|
+
value: "diamond"
|
|
370
|
+
},
|
|
371
|
+
"shape.triangleup": {
|
|
372
|
+
ty: p("string"),
|
|
373
|
+
value: "triangleUp"
|
|
374
|
+
},
|
|
375
|
+
"shape.triangledown": {
|
|
376
|
+
ty: p("string"),
|
|
377
|
+
value: "triangleDown"
|
|
378
|
+
},
|
|
379
|
+
"shape.arrowup": {
|
|
380
|
+
ty: p("string"),
|
|
381
|
+
value: "arrowUp"
|
|
382
|
+
},
|
|
383
|
+
"shape.arrowdown": {
|
|
384
|
+
ty: p("string"),
|
|
385
|
+
value: "arrowDown"
|
|
386
|
+
},
|
|
387
|
+
"shape.xcross": {
|
|
388
|
+
ty: p("string"),
|
|
389
|
+
value: "cross"
|
|
390
|
+
},
|
|
391
|
+
"shape.cross": {
|
|
392
|
+
ty: p("string"),
|
|
393
|
+
value: "cross"
|
|
394
|
+
},
|
|
395
|
+
"location.abovebar": {
|
|
396
|
+
ty: p("string"),
|
|
397
|
+
value: "above"
|
|
398
|
+
},
|
|
399
|
+
"location.belowbar": {
|
|
400
|
+
ty: p("string"),
|
|
401
|
+
value: "below"
|
|
402
|
+
},
|
|
403
|
+
"location.absolute": {
|
|
404
|
+
ty: p("string"),
|
|
405
|
+
value: "value"
|
|
406
|
+
}
|
|
407
|
+
}), b = (e) => Object.keys(y).filter((t) => t.startsWith(`${e}.`)).map((e) => y[e].value), x = {
|
|
408
|
+
plotStyle: b("plot"),
|
|
409
|
+
lineStyle: b("hline"),
|
|
410
|
+
shape: b("shape"),
|
|
411
|
+
location: b("location")
|
|
412
|
+
}, S = (e) => ({
|
|
413
|
+
name: e,
|
|
414
|
+
kind: "series"
|
|
415
|
+
}), C = (e, t = {}) => ({
|
|
416
|
+
name: e,
|
|
417
|
+
kind: "num",
|
|
418
|
+
...t
|
|
419
|
+
}), w = (e, t = {}) => ({
|
|
420
|
+
name: e,
|
|
421
|
+
kind: "int",
|
|
422
|
+
...t
|
|
423
|
+
}), T = w("length", {
|
|
424
|
+
min: 1,
|
|
425
|
+
max: 5e3
|
|
426
|
+
}), E = /* @__PURE__ */ new Map(), D = (e, t, n, r, i = {}) => E.set(e, {
|
|
427
|
+
name: e,
|
|
428
|
+
params: t,
|
|
429
|
+
ret: n,
|
|
430
|
+
op: r,
|
|
431
|
+
...i
|
|
432
|
+
}), O = (e) => Number.isFinite(e) ? e : NaN, k = (e, t) => D(`math.${e}`, [S("x")], u, "scalar", { fn: (e) => O(t(e)) });
|
|
433
|
+
for (let [e, t] of Object.entries({
|
|
434
|
+
abs: Math.abs,
|
|
435
|
+
sqrt: Math.sqrt,
|
|
436
|
+
log: Math.log,
|
|
437
|
+
log10: Math.log10,
|
|
438
|
+
exp: Math.exp,
|
|
439
|
+
sin: Math.sin,
|
|
440
|
+
cos: Math.cos,
|
|
441
|
+
tan: Math.tan,
|
|
442
|
+
asin: Math.asin,
|
|
443
|
+
acos: Math.acos,
|
|
444
|
+
atan: Math.atan,
|
|
445
|
+
sinh: Math.sinh,
|
|
446
|
+
cosh: Math.cosh,
|
|
447
|
+
tanh: Math.tanh,
|
|
448
|
+
ceil: Math.ceil,
|
|
449
|
+
floor: Math.floor,
|
|
450
|
+
trunc: Math.trunc,
|
|
451
|
+
sign: Math.sign,
|
|
452
|
+
round: Math.round,
|
|
453
|
+
toradians: (e) => e * Math.PI / 180,
|
|
454
|
+
todegrees: (e) => e * 180 / Math.PI
|
|
455
|
+
})) k(e, t);
|
|
456
|
+
D("math.pow", [S("base"), S("exponent")], u, "scalar", { fn: (e, t) => O(e ** t) }), D("math.max", [S("a"), S("b")], u, "scalar", { fn: (e, t) => e !== e || t !== t ? NaN : e > t ? e : t }), D("math.min", [S("a"), S("b")], u, "scalar", { fn: (e, t) => e !== e || t !== t ? NaN : e < t ? e : t }), D("math.avg", [S("a"), S("b")], u, "scalar", { fn: (e, t) => (e + t) / 2 }), D("nz", [S("x"), {
|
|
457
|
+
name: "replacement",
|
|
458
|
+
kind: "series",
|
|
459
|
+
opt: !0
|
|
460
|
+
}], u, "special"), D("na", [S("x")], f, "special"), D("math.sum", [S("source"), T], u, "kernel");
|
|
461
|
+
for (let e of [
|
|
462
|
+
"sma",
|
|
463
|
+
"ema",
|
|
464
|
+
"wma",
|
|
465
|
+
"rma",
|
|
466
|
+
"highest",
|
|
467
|
+
"lowest",
|
|
468
|
+
"sum"
|
|
469
|
+
]) D(`ta.${e}`, [S("source"), T], u, "kernel");
|
|
470
|
+
for (let e of ["stdev", "variance"]) D(`ta.${e}`, [
|
|
471
|
+
S("source"),
|
|
472
|
+
T,
|
|
473
|
+
{
|
|
474
|
+
name: "sample",
|
|
475
|
+
kind: "bool",
|
|
476
|
+
opt: !0
|
|
477
|
+
}
|
|
478
|
+
], u, "kernel");
|
|
479
|
+
for (let e of ["highestbars", "lowestbars"]) D(`ta.${e}`, [S("source"), T], d, "kernel");
|
|
480
|
+
D("ta.linreg", [S("source"), w("length", {
|
|
481
|
+
min: 2,
|
|
482
|
+
max: 5e3
|
|
483
|
+
})], u, "kernel"), D("ta.atr", [T], u, "kernel", { needs: "ohlc" }), D("ta.change", [S("source"), w("length", {
|
|
484
|
+
opt: !0,
|
|
485
|
+
min: 1,
|
|
486
|
+
max: 5e3
|
|
487
|
+
})], u, "special");
|
|
488
|
+
for (let e of [
|
|
489
|
+
"crossover",
|
|
490
|
+
"crossunder",
|
|
491
|
+
"cross"
|
|
492
|
+
]) D(`ta.${e}`, [S("a"), S("b")], f, "special");
|
|
493
|
+
D("ta.bb", [
|
|
494
|
+
S("source"),
|
|
495
|
+
w("length", {
|
|
496
|
+
min: 1,
|
|
497
|
+
max: 5e3
|
|
498
|
+
}),
|
|
499
|
+
C("mult", {
|
|
500
|
+
min: 0,
|
|
501
|
+
max: 100
|
|
502
|
+
})
|
|
503
|
+
], m([
|
|
504
|
+
u,
|
|
505
|
+
u,
|
|
506
|
+
u
|
|
507
|
+
]), "special");
|
|
508
|
+
var A = u;
|
|
509
|
+
function j(e) {
|
|
510
|
+
switch (e.type) {
|
|
511
|
+
case "int": return {
|
|
512
|
+
name: e.key,
|
|
513
|
+
kind: "int",
|
|
514
|
+
opt: !0,
|
|
515
|
+
...e.min !== void 0 && { min: e.min },
|
|
516
|
+
...e.max !== void 0 && { max: e.max },
|
|
517
|
+
input: e
|
|
518
|
+
};
|
|
519
|
+
case "float": return {
|
|
520
|
+
name: e.key,
|
|
521
|
+
kind: "num",
|
|
522
|
+
opt: !0,
|
|
523
|
+
...e.min !== void 0 && { min: e.min },
|
|
524
|
+
...e.max !== void 0 && { max: e.max },
|
|
525
|
+
input: e
|
|
526
|
+
};
|
|
527
|
+
case "bool": return {
|
|
528
|
+
name: e.key,
|
|
529
|
+
kind: "bool",
|
|
530
|
+
opt: !0,
|
|
531
|
+
input: e
|
|
532
|
+
};
|
|
533
|
+
case "source": return {
|
|
534
|
+
name: e.key,
|
|
535
|
+
kind: "series",
|
|
536
|
+
opt: !0,
|
|
537
|
+
input: e
|
|
538
|
+
};
|
|
539
|
+
case "select": return {
|
|
540
|
+
name: e.key,
|
|
541
|
+
kind: "string",
|
|
542
|
+
opt: !0,
|
|
543
|
+
input: e,
|
|
544
|
+
...e.options && { oneOf: e.options }
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
var M = (e) => `ta.${e.replace(/-/g, "_")}`;
|
|
549
|
+
for (let t of e) {
|
|
550
|
+
if (t.family === "math") continue;
|
|
551
|
+
let e = M(t.id);
|
|
552
|
+
E.has(e) || D(e, [...t.inputs.filter((e) => e.key === "source"), ...t.inputs.filter((e) => e.key !== "source")].map(j), t.columns.length === 1 ? u : m(t.columns.map(() => u)), "study", {
|
|
553
|
+
study: t,
|
|
554
|
+
needs: t.needs
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
D("indicator", [
|
|
558
|
+
{
|
|
559
|
+
name: "title",
|
|
560
|
+
kind: "string"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: "shorttitle",
|
|
564
|
+
kind: "string",
|
|
565
|
+
opt: !0
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "overlay",
|
|
569
|
+
kind: "bool",
|
|
570
|
+
opt: !0
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
name: "scale",
|
|
574
|
+
kind: "string",
|
|
575
|
+
opt: !0,
|
|
576
|
+
oneOf: ["left", "right"]
|
|
577
|
+
}
|
|
578
|
+
], p("void"), "special"), D("plot", [
|
|
579
|
+
S("series"),
|
|
580
|
+
{
|
|
581
|
+
name: "title",
|
|
582
|
+
kind: "string",
|
|
583
|
+
opt: !0
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
name: "color",
|
|
587
|
+
kind: "color",
|
|
588
|
+
opt: !0
|
|
589
|
+
},
|
|
590
|
+
w("linewidth", {
|
|
591
|
+
opt: !0,
|
|
592
|
+
min: 1,
|
|
593
|
+
max: 8
|
|
594
|
+
}),
|
|
595
|
+
{
|
|
596
|
+
name: "style",
|
|
597
|
+
kind: "enum",
|
|
598
|
+
oneOf: x.plotStyle,
|
|
599
|
+
opt: !0
|
|
600
|
+
},
|
|
601
|
+
w("offset", {
|
|
602
|
+
opt: !0,
|
|
603
|
+
min: -5e3,
|
|
604
|
+
max: 5e3
|
|
605
|
+
}),
|
|
606
|
+
{
|
|
607
|
+
name: "color_down",
|
|
608
|
+
kind: "color",
|
|
609
|
+
opt: !0
|
|
610
|
+
}
|
|
611
|
+
], p("plot"), "special"), D("hline", [
|
|
612
|
+
C("price"),
|
|
613
|
+
{
|
|
614
|
+
name: "title",
|
|
615
|
+
kind: "string",
|
|
616
|
+
opt: !0
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "color",
|
|
620
|
+
kind: "color",
|
|
621
|
+
opt: !0
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: "linestyle",
|
|
625
|
+
kind: "enum",
|
|
626
|
+
oneOf: x.lineStyle,
|
|
627
|
+
opt: !0
|
|
628
|
+
}
|
|
629
|
+
], p("void"), "special"), D("fill", [
|
|
630
|
+
{
|
|
631
|
+
name: "plot1",
|
|
632
|
+
kind: "plot"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: "plot2",
|
|
636
|
+
kind: "plot"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
name: "color",
|
|
640
|
+
kind: "color",
|
|
641
|
+
opt: !0
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
name: "title",
|
|
645
|
+
kind: "string",
|
|
646
|
+
opt: !0
|
|
647
|
+
}
|
|
648
|
+
], p("void"), "special"), D("plotshape", [
|
|
649
|
+
{
|
|
650
|
+
name: "series",
|
|
651
|
+
kind: "any"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
name: "title",
|
|
655
|
+
kind: "string",
|
|
656
|
+
opt: !0
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
name: "style",
|
|
660
|
+
kind: "enum",
|
|
661
|
+
oneOf: x.shape,
|
|
662
|
+
opt: !0
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
name: "location",
|
|
666
|
+
kind: "enum",
|
|
667
|
+
oneOf: x.location,
|
|
668
|
+
opt: !0
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: "color",
|
|
672
|
+
kind: "color",
|
|
673
|
+
opt: !0
|
|
674
|
+
},
|
|
675
|
+
w("offset", {
|
|
676
|
+
opt: !0,
|
|
677
|
+
min: -5e3,
|
|
678
|
+
max: 5e3
|
|
679
|
+
}),
|
|
680
|
+
w("last", {
|
|
681
|
+
opt: !0,
|
|
682
|
+
min: 1,
|
|
683
|
+
max: 5e3
|
|
684
|
+
}),
|
|
685
|
+
w("within", {
|
|
686
|
+
opt: !0,
|
|
687
|
+
min: 1,
|
|
688
|
+
max: 5e3
|
|
689
|
+
})
|
|
690
|
+
], p("void"), "special"), D("barcolor", [{
|
|
691
|
+
name: "condition",
|
|
692
|
+
kind: "any"
|
|
693
|
+
}, {
|
|
694
|
+
name: "color",
|
|
695
|
+
kind: "color"
|
|
696
|
+
}], p("void"), "special"), D("bgcolor", [{
|
|
697
|
+
name: "condition",
|
|
698
|
+
kind: "any"
|
|
699
|
+
}, {
|
|
700
|
+
name: "color",
|
|
701
|
+
kind: "color"
|
|
702
|
+
}], p("void"), "special"), D("outside", [
|
|
703
|
+
{
|
|
704
|
+
name: "symbol",
|
|
705
|
+
kind: "any",
|
|
706
|
+
opt: !0
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
name: "field",
|
|
710
|
+
kind: "string",
|
|
711
|
+
opt: !0,
|
|
712
|
+
oneOf: g
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
name: "timeframe",
|
|
716
|
+
kind: "any",
|
|
717
|
+
opt: !0
|
|
718
|
+
}
|
|
719
|
+
], u, "special"), D("color.new", [{
|
|
720
|
+
name: "color",
|
|
721
|
+
kind: "color"
|
|
722
|
+
}, C("transp", {
|
|
723
|
+
min: 0,
|
|
724
|
+
max: 100
|
|
725
|
+
})], p("color"), "special"), D("input.int", [
|
|
726
|
+
w("defval"),
|
|
727
|
+
{
|
|
728
|
+
name: "title",
|
|
729
|
+
kind: "string",
|
|
730
|
+
opt: !0
|
|
731
|
+
},
|
|
732
|
+
w("minval", { opt: !0 }),
|
|
733
|
+
w("maxval", { opt: !0 }),
|
|
734
|
+
w("step", { opt: !0 })
|
|
735
|
+
], p("int", "input"), "special"), D("input.float", [
|
|
736
|
+
C("defval"),
|
|
737
|
+
{
|
|
738
|
+
name: "title",
|
|
739
|
+
kind: "string",
|
|
740
|
+
opt: !0
|
|
741
|
+
},
|
|
742
|
+
C("minval", { opt: !0 }),
|
|
743
|
+
C("maxval", { opt: !0 }),
|
|
744
|
+
C("step", { opt: !0 })
|
|
745
|
+
], p("float", "input"), "special"), D("input.bool", [{
|
|
746
|
+
name: "defval",
|
|
747
|
+
kind: "bool"
|
|
748
|
+
}, {
|
|
749
|
+
name: "title",
|
|
750
|
+
kind: "string",
|
|
751
|
+
opt: !0
|
|
752
|
+
}], p("bool", "input"), "special"), D("input.string", [
|
|
753
|
+
{
|
|
754
|
+
name: "defval",
|
|
755
|
+
kind: "string"
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
name: "title",
|
|
759
|
+
kind: "string",
|
|
760
|
+
opt: !0
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
name: "options",
|
|
764
|
+
kind: "strlist"
|
|
765
|
+
}
|
|
766
|
+
], p("string", "input"), "special"), D("input.source", [{
|
|
767
|
+
name: "defval",
|
|
768
|
+
kind: "any"
|
|
769
|
+
}, {
|
|
770
|
+
name: "title",
|
|
771
|
+
kind: "string",
|
|
772
|
+
opt: !0
|
|
773
|
+
}], u, "special"), D("input.color", [{
|
|
774
|
+
name: "defval",
|
|
775
|
+
kind: "color"
|
|
776
|
+
}, {
|
|
777
|
+
name: "title",
|
|
778
|
+
kind: "string",
|
|
779
|
+
opt: !0
|
|
780
|
+
}], p("color", "input"), "special");
|
|
781
|
+
function N() {
|
|
782
|
+
let e = [];
|
|
783
|
+
for (let t of E.values()) e.push({
|
|
784
|
+
label: t.name,
|
|
785
|
+
kind: "function",
|
|
786
|
+
detail: `(${t.params.map((e) => e.opt ? `${e.name}?` : e.name).join(", ")})`
|
|
787
|
+
});
|
|
788
|
+
for (let t of Object.keys(y)) e.push({
|
|
789
|
+
label: t,
|
|
790
|
+
kind: "constant"
|
|
791
|
+
});
|
|
792
|
+
for (let t of Object.keys(v)) e.push({
|
|
793
|
+
label: t,
|
|
794
|
+
kind: "variable"
|
|
795
|
+
});
|
|
796
|
+
e.push({
|
|
797
|
+
label: "ta.tr",
|
|
798
|
+
kind: "variable"
|
|
799
|
+
}, {
|
|
800
|
+
label: "na",
|
|
801
|
+
kind: "constant"
|
|
802
|
+
});
|
|
803
|
+
for (let t of _) e.push({
|
|
804
|
+
label: t,
|
|
805
|
+
kind: "namespace"
|
|
806
|
+
});
|
|
807
|
+
return e;
|
|
808
|
+
}
|
|
809
|
+
//#endregion
|
|
810
|
+
export { _ as a, N as c, l as d, y as i, p as l, x as n, E as o, u as r, A as s, v as t, t as u };
|
|
811
|
+
|
|
812
|
+
//# sourceMappingURL=builtins-BXxWK58s.js.map
|