@invinite-org/chartlang-compiler 1.0.1
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/CHANGELOG.md +683 -0
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/analysis/extractAlertConditions.d.ts +33 -0
- package/dist/analysis/extractAlertConditions.d.ts.map +1 -0
- package/dist/analysis/extractAlertConditions.js +118 -0
- package/dist/analysis/extractAlertConditions.js.map +1 -0
- package/dist/analysis/extractCapabilities.d.ts +22 -0
- package/dist/analysis/extractCapabilities.d.ts.map +1 -0
- package/dist/analysis/extractCapabilities.js +44 -0
- package/dist/analysis/extractCapabilities.js.map +1 -0
- package/dist/analysis/extractInputs.d.ts +44 -0
- package/dist/analysis/extractInputs.d.ts.map +1 -0
- package/dist/analysis/extractInputs.js +306 -0
- package/dist/analysis/extractInputs.js.map +1 -0
- package/dist/analysis/extractMaxLookback.d.ts +37 -0
- package/dist/analysis/extractMaxLookback.d.ts.map +1 -0
- package/dist/analysis/extractMaxLookback.js +90 -0
- package/dist/analysis/extractMaxLookback.js.map +1 -0
- package/dist/analysis/extractRequestedIntervals.d.ts +19 -0
- package/dist/analysis/extractRequestedIntervals.d.ts.map +1 -0
- package/dist/analysis/extractRequestedIntervals.js +85 -0
- package/dist/analysis/extractRequestedIntervals.js.map +1 -0
- package/dist/analysis/extractRequiresIntervals.d.ts +16 -0
- package/dist/analysis/extractRequiresIntervals.d.ts.map +1 -0
- package/dist/analysis/extractRequiresIntervals.js +71 -0
- package/dist/analysis/extractRequiresIntervals.js.map +1 -0
- package/dist/analysis/forbiddenConstructs.d.ts +22 -0
- package/dist/analysis/forbiddenConstructs.d.ts.map +1 -0
- package/dist/analysis/forbiddenConstructs.js +214 -0
- package/dist/analysis/forbiddenConstructs.js.map +1 -0
- package/dist/analysis/index.d.ts +15 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +13 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/statefulCallInLoop.d.ts +26 -0
- package/dist/analysis/statefulCallInLoop.d.ts.map +1 -0
- package/dist/analysis/statefulCallInLoop.js +64 -0
- package/dist/analysis/statefulCallInLoop.js.map +1 -0
- package/dist/analysis/structuralChecks.d.ts +73 -0
- package/dist/analysis/structuralChecks.d.ts.map +1 -0
- package/dist/analysis/structuralChecks.js +243 -0
- package/dist/analysis/structuralChecks.js.map +1 -0
- package/dist/analysis/validateLowerTfIntervals.d.ts +26 -0
- package/dist/analysis/validateLowerTfIntervals.d.ts.map +1 -0
- package/dist/analysis/validateLowerTfIntervals.js +91 -0
- package/dist/analysis/validateLowerTfIntervals.js.map +1 -0
- package/dist/api.d.ts +205 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +354 -0
- package/dist/api.js.map +1 -0
- package/dist/bundle.d.ts +75 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +90 -0
- package/dist/bundle.js.map +1 -0
- package/dist/diagnostics.d.ts +88 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +95 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +40 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +57 -0
- package/dist/manifest.js.map +1 -0
- package/dist/program.d.ts +68 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +1391 -0
- package/dist/program.js.map +1 -0
- package/dist/transformers/callsiteIdInjection.d.ts +48 -0
- package/dist/transformers/callsiteIdInjection.d.ts.map +1 -0
- package/dist/transformers/callsiteIdInjection.js +91 -0
- package/dist/transformers/callsiteIdInjection.js.map +1 -0
- package/dist/transformers/index.d.ts +4 -0
- package/dist/transformers/index.d.ts.map +1 -0
- package/dist/transformers/index.js +5 -0
- package/dist/transformers/index.js.map +1 -0
- package/dist/transformers/resolveCallee.d.ts +39 -0
- package/dist/transformers/resolveCallee.d.ts.map +1 -0
- package/dist/transformers/resolveCallee.js +136 -0
- package/dist/transformers/resolveCallee.js.map +1 -0
- package/dist/typesEmit.d.ts +35 -0
- package/dist/typesEmit.d.ts.map +1 -0
- package/dist/typesEmit.js +27 -0
- package/dist/typesEmit.js.map +1 -0
- package/package.json +48 -0
package/dist/program.js
ADDED
|
@@ -0,0 +1,1391 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
/**
|
|
5
|
+
* Virtual on-disk path the in-memory `@invinite-org/chartlang-core` ambient
|
|
6
|
+
* declaration file is served from. Kept stable so the analysis passes can
|
|
7
|
+
* detect callee declarations coming from core (vs. user-shadowed names).
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1
|
|
10
|
+
* @example
|
|
11
|
+
* import { CORE_MODULE_PATH } from "@invinite-org/chartlang-compiler/program";
|
|
12
|
+
* void CORE_MODULE_PATH;
|
|
13
|
+
*/
|
|
14
|
+
export const CORE_MODULE_PATH = "/__chartlang__/core.d.ts";
|
|
15
|
+
/**
|
|
16
|
+
* Ambient `.d.ts` shim covering the exact `@invinite-org/chartlang-core`
|
|
17
|
+
* surface the compiler needs for symbol resolution. Lives in-memory so the
|
|
18
|
+
* compiler is deterministic and host-machine independent — no on-disk
|
|
19
|
+
* resolution of `workspace:*` packages required.
|
|
20
|
+
*
|
|
21
|
+
* The shim mirrors the runtime types; it does NOT carry the throw-sentinel
|
|
22
|
+
* bodies the real callable holes ship. That doesn't matter — the compiler
|
|
23
|
+
* only does static analysis; it never executes script source.
|
|
24
|
+
*/
|
|
25
|
+
const CORE_AMBIENT_SHIM = `
|
|
26
|
+
declare module "@invinite-org/chartlang-core" {
|
|
27
|
+
export type Time = number;
|
|
28
|
+
export type Price = number;
|
|
29
|
+
export type Volume = number;
|
|
30
|
+
export type Color = string;
|
|
31
|
+
export type GradientStop = Readonly<{ at: number; color: Color }>;
|
|
32
|
+
export type LineStyle = "solid" | "dashed" | "dotted";
|
|
33
|
+
export type AlertSeverity = "info" | "warning" | "critical";
|
|
34
|
+
export type CapabilityId = "indicators" | "drawings" | "alerts" | "alertConditions";
|
|
35
|
+
export type IntervalDescriptor = Readonly<{
|
|
36
|
+
readonly value: string;
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly group: string;
|
|
39
|
+
readonly intervalSeconds?: number;
|
|
40
|
+
}>;
|
|
41
|
+
export type ValueFormat = "price" | "volume" | "percent" | "compact";
|
|
42
|
+
export type ScaleAxis = "price" | "left" | "right" | "new";
|
|
43
|
+
export type DrawingCounts = {
|
|
44
|
+
readonly lines: number;
|
|
45
|
+
readonly labels: number;
|
|
46
|
+
readonly boxes: number;
|
|
47
|
+
readonly polylines: number;
|
|
48
|
+
readonly other: number;
|
|
49
|
+
};
|
|
50
|
+
export type ScriptOverrides = Readonly<{
|
|
51
|
+
maxBarsBack?: number;
|
|
52
|
+
format?: ValueFormat;
|
|
53
|
+
precision?: number;
|
|
54
|
+
scale?: ScaleAxis;
|
|
55
|
+
requiresIntervals?: ReadonlyArray<string>;
|
|
56
|
+
shortName?: string;
|
|
57
|
+
}>;
|
|
58
|
+
export type BarViewport = Readonly<{
|
|
59
|
+
readonly fromTime: Time;
|
|
60
|
+
readonly toTime: Time;
|
|
61
|
+
}>;
|
|
62
|
+
export type Bar = {
|
|
63
|
+
readonly time: Time;
|
|
64
|
+
readonly open: Price;
|
|
65
|
+
readonly high: Price;
|
|
66
|
+
readonly low: Price;
|
|
67
|
+
readonly close: Price;
|
|
68
|
+
readonly volume: Volume;
|
|
69
|
+
readonly symbol: string;
|
|
70
|
+
readonly interval: string;
|
|
71
|
+
readonly hl2: Price;
|
|
72
|
+
readonly hlc3: Price;
|
|
73
|
+
readonly ohlc4: Price;
|
|
74
|
+
readonly hlcc4: Price;
|
|
75
|
+
readonly viewport?: BarViewport;
|
|
76
|
+
};
|
|
77
|
+
export type Series<T> = {
|
|
78
|
+
readonly current: T;
|
|
79
|
+
readonly [n: number]: T;
|
|
80
|
+
readonly length: number;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A \`ta.*\` source-position argument. The runtime
|
|
84
|
+
* (\`packages/runtime/src/ta/lib/sourceValue.ts\`) accepts either a
|
|
85
|
+
* series reference or a scalar; the script-author surface mirrors
|
|
86
|
+
* that contract so \`ta.ema(bar.close, 12)\` (scalar) and
|
|
87
|
+
* \`ta.ema(other, 12)\` (series) both typecheck.
|
|
88
|
+
*/
|
|
89
|
+
export type ScalarOrSeries = Series<number> | number;
|
|
90
|
+
export type SmaOpts = Readonly<{ offset?: number }>;
|
|
91
|
+
export type EmaOpts = Readonly<{ offset?: number }>;
|
|
92
|
+
export type StdevOpts = Readonly<{ biased?: boolean; offset?: number }>;
|
|
93
|
+
export type BbOpts = Readonly<{ multiplier?: number; offset?: number }>;
|
|
94
|
+
export type RsiOpts = Readonly<{ offset?: number }>;
|
|
95
|
+
export type MacdOpts = Readonly<{
|
|
96
|
+
fastLength?: number;
|
|
97
|
+
slowLength?: number;
|
|
98
|
+
signalLength?: number;
|
|
99
|
+
offset?: number;
|
|
100
|
+
}>;
|
|
101
|
+
export type AtrOpts = Readonly<{ offset?: number }>;
|
|
102
|
+
export type CrossoverOpts = Readonly<{ offset?: number }>;
|
|
103
|
+
export type CrossunderOpts = Readonly<{ offset?: number }>;
|
|
104
|
+
export type HighestOpts = Readonly<{ offset?: number }>;
|
|
105
|
+
export type LowestOpts = Readonly<{ offset?: number }>;
|
|
106
|
+
export type ChangeOpts = Readonly<{ length?: number; offset?: number }>;
|
|
107
|
+
export type PlotLineStyle = "line" | "step" | "dashed" | "circles" | "cross";
|
|
108
|
+
export type WmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
109
|
+
export type VwmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
110
|
+
export type HmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
111
|
+
export type SmmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
112
|
+
export type DemaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
113
|
+
export type TemaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
114
|
+
export type KamaOpts = Readonly<{
|
|
115
|
+
length?: number;
|
|
116
|
+
fastLength?: number;
|
|
117
|
+
slowLength?: number;
|
|
118
|
+
offset?: number;
|
|
119
|
+
lineStyle?: PlotLineStyle;
|
|
120
|
+
}>;
|
|
121
|
+
export type AlmaOpts = Readonly<{
|
|
122
|
+
offset?: number;
|
|
123
|
+
sigma?: number;
|
|
124
|
+
barShift?: number;
|
|
125
|
+
lineStyle?: PlotLineStyle;
|
|
126
|
+
}>;
|
|
127
|
+
export type LsmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
128
|
+
export type McginleyOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
129
|
+
export type MaTypeNoVolume = "sma" | "ema" | "wma" | "smma";
|
|
130
|
+
export type MaRibbonOpts = Readonly<{
|
|
131
|
+
lengths?: ReadonlyArray<number>;
|
|
132
|
+
maType?: MaTypeNoVolume;
|
|
133
|
+
offset?: number;
|
|
134
|
+
outputs?: Readonly<Record<string, { lineStyle?: PlotLineStyle }>>;
|
|
135
|
+
}>;
|
|
136
|
+
export type MaRibbonResult = Readonly<Record<string, Series<number>>>;
|
|
137
|
+
export type AoOpts = Readonly<{
|
|
138
|
+
fastLength?: number;
|
|
139
|
+
slowLength?: number;
|
|
140
|
+
offset?: number;
|
|
141
|
+
lineStyle?: PlotLineStyle;
|
|
142
|
+
}>;
|
|
143
|
+
export type CmoOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
144
|
+
export type MomentumOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
145
|
+
export type RocOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
146
|
+
export type CciOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
147
|
+
export type StochOpts = Readonly<{
|
|
148
|
+
kLength?: number;
|
|
149
|
+
kSmoothing?: number;
|
|
150
|
+
dLength?: number;
|
|
151
|
+
offset?: number;
|
|
152
|
+
}>;
|
|
153
|
+
export type WilliamsROpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
154
|
+
export type StochResult = Readonly<{
|
|
155
|
+
k: Series<number>;
|
|
156
|
+
d: Series<number>;
|
|
157
|
+
}>;
|
|
158
|
+
export type StochRsiOpts = Readonly<{
|
|
159
|
+
rsiLength?: number;
|
|
160
|
+
stochLength?: number;
|
|
161
|
+
kSmoothing?: number;
|
|
162
|
+
dSmoothing?: number;
|
|
163
|
+
offset?: number;
|
|
164
|
+
}>;
|
|
165
|
+
export type StochRsiResult = Readonly<{
|
|
166
|
+
k: Series<number>;
|
|
167
|
+
d: Series<number>;
|
|
168
|
+
}>;
|
|
169
|
+
export type UltimateOscOpts = Readonly<{
|
|
170
|
+
shortLength?: number;
|
|
171
|
+
mediumLength?: number;
|
|
172
|
+
longLength?: number;
|
|
173
|
+
offset?: number;
|
|
174
|
+
lineStyle?: PlotLineStyle;
|
|
175
|
+
}>;
|
|
176
|
+
export type CoppockOpts = Readonly<{
|
|
177
|
+
roc1Length?: number;
|
|
178
|
+
roc2Length?: number;
|
|
179
|
+
wmaLength?: number;
|
|
180
|
+
offset?: number;
|
|
181
|
+
lineStyle?: PlotLineStyle;
|
|
182
|
+
}>;
|
|
183
|
+
export type PpoOpts = Readonly<{
|
|
184
|
+
fastLength?: number;
|
|
185
|
+
slowLength?: number;
|
|
186
|
+
signalLength?: number;
|
|
187
|
+
offset?: number;
|
|
188
|
+
}>;
|
|
189
|
+
export type PpoResult = Readonly<{
|
|
190
|
+
ppo: Series<number>;
|
|
191
|
+
signal: Series<number>;
|
|
192
|
+
hist: Series<number>;
|
|
193
|
+
}>;
|
|
194
|
+
export type DpoOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
195
|
+
export type ConnorsRsiOpts = Readonly<{
|
|
196
|
+
rsiLength?: number;
|
|
197
|
+
streakLength?: number;
|
|
198
|
+
rocLength?: number;
|
|
199
|
+
offset?: number;
|
|
200
|
+
}>;
|
|
201
|
+
export type KstOpts = Readonly<{
|
|
202
|
+
roc1Length?: number;
|
|
203
|
+
roc2Length?: number;
|
|
204
|
+
roc3Length?: number;
|
|
205
|
+
roc4Length?: number;
|
|
206
|
+
roc1Smooth?: number;
|
|
207
|
+
roc2Smooth?: number;
|
|
208
|
+
roc3Smooth?: number;
|
|
209
|
+
roc4Smooth?: number;
|
|
210
|
+
signalLength?: number;
|
|
211
|
+
offset?: number;
|
|
212
|
+
}>;
|
|
213
|
+
export type KstResult = Readonly<{
|
|
214
|
+
kst: Series<number>;
|
|
215
|
+
signal: Series<number>;
|
|
216
|
+
}>;
|
|
217
|
+
export type FisherOpts = Readonly<{ offset?: number }>;
|
|
218
|
+
export type FisherResult = Readonly<{
|
|
219
|
+
fisher: Series<number>;
|
|
220
|
+
trigger: Series<number>;
|
|
221
|
+
}>;
|
|
222
|
+
export type KlingerOpts = Readonly<{
|
|
223
|
+
fastLength?: number;
|
|
224
|
+
slowLength?: number;
|
|
225
|
+
signalLength?: number;
|
|
226
|
+
offset?: number;
|
|
227
|
+
}>;
|
|
228
|
+
export type KlingerResult = Readonly<{
|
|
229
|
+
klinger: Series<number>;
|
|
230
|
+
signal: Series<number>;
|
|
231
|
+
}>;
|
|
232
|
+
export type RvgiOpts = Readonly<{
|
|
233
|
+
length?: number;
|
|
234
|
+
offset?: number;
|
|
235
|
+
}>;
|
|
236
|
+
export type RvgiResult = Readonly<{
|
|
237
|
+
rvgi: Series<number>;
|
|
238
|
+
signal: Series<number>;
|
|
239
|
+
}>;
|
|
240
|
+
export type AroonOpts = Readonly<{
|
|
241
|
+
offset?: number;
|
|
242
|
+
outputs?: Readonly<Record<"up" | "down", { lineStyle?: PlotLineStyle }>>;
|
|
243
|
+
}>;
|
|
244
|
+
export type AroonOscOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
245
|
+
export type VolOpts = Readonly<{ offset?: number }>;
|
|
246
|
+
export type VwapOpts = Readonly<{
|
|
247
|
+
source?: "hlc3" | "close" | "hl2" | "ohlc4" | "hlcc4";
|
|
248
|
+
offset?: number;
|
|
249
|
+
}>;
|
|
250
|
+
export type AnchoredVwapOpts = Readonly<{
|
|
251
|
+
source?: "hlc3" | "close" | "hl2" | "ohlc4" | "hlcc4";
|
|
252
|
+
offset?: number;
|
|
253
|
+
}>;
|
|
254
|
+
export type VisibleRangeVolumeProfileOpts = Readonly<{
|
|
255
|
+
rowSize?: number;
|
|
256
|
+
valueAreaPct?: number;
|
|
257
|
+
offset?: number;
|
|
258
|
+
bucketColor?: string;
|
|
259
|
+
}>;
|
|
260
|
+
export type VisibleRangeVolumeProfileResult = Readonly<{
|
|
261
|
+
poc: Series<number>;
|
|
262
|
+
valHigh: Series<number>;
|
|
263
|
+
valLow: Series<number>;
|
|
264
|
+
}>;
|
|
265
|
+
export type AnchoredVolumeProfileOpts = Readonly<{
|
|
266
|
+
anchor: Time;
|
|
267
|
+
rowSize?: number;
|
|
268
|
+
valueAreaPct?: number;
|
|
269
|
+
offset?: number;
|
|
270
|
+
bucketColor?: string;
|
|
271
|
+
}>;
|
|
272
|
+
export type SessionVolumeProfileOpts = Readonly<{
|
|
273
|
+
rowSize?: number;
|
|
274
|
+
valueAreaPct?: number;
|
|
275
|
+
offset?: number;
|
|
276
|
+
bucketColor?: string;
|
|
277
|
+
sessionStart?: Time;
|
|
278
|
+
}>;
|
|
279
|
+
export type SessionVolumeProfileResult = Readonly<{
|
|
280
|
+
poc: Series<number>;
|
|
281
|
+
valHigh: Series<number>;
|
|
282
|
+
valLow: Series<number>;
|
|
283
|
+
buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;
|
|
284
|
+
}>;
|
|
285
|
+
export type FixedRangeVolumeProfileOpts = Readonly<{
|
|
286
|
+
from: Time;
|
|
287
|
+
to: Time;
|
|
288
|
+
rowSize?: number;
|
|
289
|
+
valueAreaPct?: number;
|
|
290
|
+
offset?: number;
|
|
291
|
+
bucketColor?: string;
|
|
292
|
+
}>;
|
|
293
|
+
export type FixedRangeVolumeProfileResult = Readonly<{
|
|
294
|
+
poc: Series<number>;
|
|
295
|
+
valHigh: Series<number>;
|
|
296
|
+
valLow: Series<number>;
|
|
297
|
+
buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;
|
|
298
|
+
}>;
|
|
299
|
+
export type AnchoredVolumeProfileResult = Readonly<{
|
|
300
|
+
poc: Series<number>;
|
|
301
|
+
valHigh: Series<number>;
|
|
302
|
+
valLow: Series<number>;
|
|
303
|
+
buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;
|
|
304
|
+
}>;
|
|
305
|
+
export type ObvOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
306
|
+
export type AdlOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
307
|
+
export type BopOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
308
|
+
export type CmfOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
309
|
+
export type ChaikinOscOpts = Readonly<{
|
|
310
|
+
fastLength?: number;
|
|
311
|
+
slowLength?: number;
|
|
312
|
+
offset?: number;
|
|
313
|
+
}>;
|
|
314
|
+
export type MfiOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
315
|
+
export type NetVolumeOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
316
|
+
export type PvoOpts = Readonly<{
|
|
317
|
+
fastLength?: number;
|
|
318
|
+
slowLength?: number;
|
|
319
|
+
signalLength?: number;
|
|
320
|
+
offset?: number;
|
|
321
|
+
}>;
|
|
322
|
+
export type PvoResult = Readonly<{
|
|
323
|
+
pvo: Series<number>;
|
|
324
|
+
signal: Series<number>;
|
|
325
|
+
hist: Series<number>;
|
|
326
|
+
}>;
|
|
327
|
+
export type PvtOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
328
|
+
export type EomOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
329
|
+
export type NviOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
330
|
+
export type PviOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
331
|
+
export type PsarOpts = Readonly<{
|
|
332
|
+
accelerationStart?: number;
|
|
333
|
+
accelerationStep?: number;
|
|
334
|
+
accelerationMax?: number;
|
|
335
|
+
offset?: number;
|
|
336
|
+
}>;
|
|
337
|
+
export type PsarResult = Readonly<{
|
|
338
|
+
sar: Series<number>;
|
|
339
|
+
direction: Series<number>;
|
|
340
|
+
}>;
|
|
341
|
+
export type SupertrendOpts = Readonly<{
|
|
342
|
+
length?: number;
|
|
343
|
+
multiplier?: number;
|
|
344
|
+
offset?: number;
|
|
345
|
+
}>;
|
|
346
|
+
export type SupertrendResult = Readonly<{
|
|
347
|
+
line: Series<number>;
|
|
348
|
+
direction: Series<number>;
|
|
349
|
+
}>;
|
|
350
|
+
export type ChandelierOpts = Readonly<{
|
|
351
|
+
length?: number;
|
|
352
|
+
multiplier?: number;
|
|
353
|
+
offset?: number;
|
|
354
|
+
}>;
|
|
355
|
+
export type ChandelierResult = Readonly<{
|
|
356
|
+
long: Series<number>;
|
|
357
|
+
short: Series<number>;
|
|
358
|
+
}>;
|
|
359
|
+
export type ChandeKrollStopOpts = Readonly<{
|
|
360
|
+
length?: number;
|
|
361
|
+
multiplier?: number;
|
|
362
|
+
smoothingLength?: number;
|
|
363
|
+
offset?: number;
|
|
364
|
+
}>;
|
|
365
|
+
export type ChandeKrollStopResult = Readonly<{
|
|
366
|
+
long: Series<number>;
|
|
367
|
+
short: Series<number>;
|
|
368
|
+
}>;
|
|
369
|
+
export type WilliamsFractalOpts = Readonly<{
|
|
370
|
+
length?: number;
|
|
371
|
+
offset?: number;
|
|
372
|
+
}>;
|
|
373
|
+
export type WilliamsFractalResult = Readonly<{
|
|
374
|
+
up: Series<number>;
|
|
375
|
+
down: Series<number>;
|
|
376
|
+
}>;
|
|
377
|
+
export type ZigZagOpts = Readonly<{
|
|
378
|
+
deviation?: number;
|
|
379
|
+
depth?: number;
|
|
380
|
+
offset?: number;
|
|
381
|
+
}>;
|
|
382
|
+
export type ZigZagResult = Readonly<{
|
|
383
|
+
value: Series<number>;
|
|
384
|
+
direction: Series<number>;
|
|
385
|
+
}>;
|
|
386
|
+
export type PivotsHighLowOpts = Readonly<{
|
|
387
|
+
leftLength?: number;
|
|
388
|
+
rightLength?: number;
|
|
389
|
+
offset?: number;
|
|
390
|
+
}>;
|
|
391
|
+
export type PivotsHighLowResult = Readonly<{
|
|
392
|
+
high: Series<number>;
|
|
393
|
+
low: Series<number>;
|
|
394
|
+
}>;
|
|
395
|
+
export type PivotsStandardSystem = "classic" | "fibonacci" | "camarilla" | "woodie";
|
|
396
|
+
export type PivotsStandardOpts = Readonly<{
|
|
397
|
+
system?: PivotsStandardSystem;
|
|
398
|
+
offset?: number;
|
|
399
|
+
}>;
|
|
400
|
+
export type PivotsStandardResult = Readonly<{
|
|
401
|
+
pp: Series<number>;
|
|
402
|
+
r1: Series<number>;
|
|
403
|
+
s1: Series<number>;
|
|
404
|
+
r2: Series<number>;
|
|
405
|
+
s2: Series<number>;
|
|
406
|
+
r3: Series<number>;
|
|
407
|
+
s3: Series<number>;
|
|
408
|
+
}>;
|
|
409
|
+
export type VolatilityStopOpts = Readonly<{
|
|
410
|
+
length?: number;
|
|
411
|
+
multiplier?: number;
|
|
412
|
+
offset?: number;
|
|
413
|
+
}>;
|
|
414
|
+
export type VolatilityStopResult = Readonly<{
|
|
415
|
+
value: Series<number>;
|
|
416
|
+
direction: Series<number>;
|
|
417
|
+
}>;
|
|
418
|
+
export type BbPercentBOpts = Readonly<{
|
|
419
|
+
multiplier?: number;
|
|
420
|
+
offset?: number;
|
|
421
|
+
lineStyle?: PlotLineStyle;
|
|
422
|
+
}>;
|
|
423
|
+
export type BbwOpts = Readonly<{
|
|
424
|
+
multiplier?: number;
|
|
425
|
+
offset?: number;
|
|
426
|
+
lineStyle?: PlotLineStyle;
|
|
427
|
+
}>;
|
|
428
|
+
export type DonchianOpts = Readonly<{
|
|
429
|
+
offset?: number;
|
|
430
|
+
outputs?: Readonly<
|
|
431
|
+
Record<"upper" | "middle" | "lower", { lineStyle?: PlotLineStyle }>
|
|
432
|
+
>;
|
|
433
|
+
}>;
|
|
434
|
+
export type DonchianResult = Readonly<{
|
|
435
|
+
upper: Series<number>;
|
|
436
|
+
middle: Series<number>;
|
|
437
|
+
lower: Series<number>;
|
|
438
|
+
}>;
|
|
439
|
+
export type KeltnerOpts = Readonly<{
|
|
440
|
+
length?: number;
|
|
441
|
+
multiplier?: number;
|
|
442
|
+
maType?: MaTypeNoVolume;
|
|
443
|
+
offset?: number;
|
|
444
|
+
outputs?: Readonly<
|
|
445
|
+
Record<"upper" | "middle" | "lower", { lineStyle?: PlotLineStyle }>
|
|
446
|
+
>;
|
|
447
|
+
}>;
|
|
448
|
+
export type KeltnerResult = Readonly<{
|
|
449
|
+
upper: Series<number>;
|
|
450
|
+
middle: Series<number>;
|
|
451
|
+
lower: Series<number>;
|
|
452
|
+
}>;
|
|
453
|
+
export type EnvelopeOpts = Readonly<{
|
|
454
|
+
length?: number;
|
|
455
|
+
percent?: number;
|
|
456
|
+
maType?: MaTypeNoVolume;
|
|
457
|
+
offset?: number;
|
|
458
|
+
}>;
|
|
459
|
+
export type EnvelopeResult = Readonly<{
|
|
460
|
+
upper: Series<number>;
|
|
461
|
+
middle: Series<number>;
|
|
462
|
+
lower: Series<number>;
|
|
463
|
+
}>;
|
|
464
|
+
export type ChopOpts = Readonly<{
|
|
465
|
+
offset?: number;
|
|
466
|
+
lineStyle?: PlotLineStyle;
|
|
467
|
+
}>;
|
|
468
|
+
export type HvOpts = Readonly<{
|
|
469
|
+
annualisationFactor?: number;
|
|
470
|
+
offset?: number;
|
|
471
|
+
lineStyle?: PlotLineStyle;
|
|
472
|
+
}>;
|
|
473
|
+
export type RviOpts = Readonly<{
|
|
474
|
+
offset?: number;
|
|
475
|
+
lineStyle?: PlotLineStyle;
|
|
476
|
+
}>;
|
|
477
|
+
export type MassIndexOpts = Readonly<{
|
|
478
|
+
emaLength?: number;
|
|
479
|
+
sumLength?: number;
|
|
480
|
+
offset?: number;
|
|
481
|
+
lineStyle?: PlotLineStyle;
|
|
482
|
+
}>;
|
|
483
|
+
export type AroonResult = Readonly<{
|
|
484
|
+
up: Series<number>;
|
|
485
|
+
down: Series<number>;
|
|
486
|
+
}>;
|
|
487
|
+
export type BbResult = Readonly<{
|
|
488
|
+
upper: Series<number>;
|
|
489
|
+
middle: Series<number>;
|
|
490
|
+
lower: Series<number>;
|
|
491
|
+
}>;
|
|
492
|
+
export type MacdResult = Readonly<{
|
|
493
|
+
macd: Series<number>;
|
|
494
|
+
signal: Series<number>;
|
|
495
|
+
hist: Series<number>;
|
|
496
|
+
}>;
|
|
497
|
+
export type AdxOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
498
|
+
export type DmiOpts = Readonly<{
|
|
499
|
+
offset?: number;
|
|
500
|
+
outputs?: Readonly<
|
|
501
|
+
Record<"plusDi" | "minusDi", { lineStyle?: PlotLineStyle }>
|
|
502
|
+
>;
|
|
503
|
+
}>;
|
|
504
|
+
export type DmiResult = Readonly<{
|
|
505
|
+
plusDi: Series<number>;
|
|
506
|
+
minusDi: Series<number>;
|
|
507
|
+
}>;
|
|
508
|
+
export type TrixOpts = Readonly<{ offset?: number; signalLength?: number }>;
|
|
509
|
+
export type TrixResult = Readonly<{
|
|
510
|
+
trix: Series<number>;
|
|
511
|
+
signal: Series<number>;
|
|
512
|
+
}>;
|
|
513
|
+
export type VortexOpts = Readonly<{ offset?: number }>;
|
|
514
|
+
export type VortexResult = Readonly<{
|
|
515
|
+
plus: Series<number>;
|
|
516
|
+
minus: Series<number>;
|
|
517
|
+
}>;
|
|
518
|
+
export type TrendStrengthIndexOpts = Readonly<{
|
|
519
|
+
offset?: number;
|
|
520
|
+
lineStyle?: PlotLineStyle;
|
|
521
|
+
}>;
|
|
522
|
+
export type IchimokuOpts = Readonly<{
|
|
523
|
+
conversionLength?: number;
|
|
524
|
+
baseLength?: number;
|
|
525
|
+
leadingSpanBLength?: number;
|
|
526
|
+
displacement?: number;
|
|
527
|
+
offset?: number;
|
|
528
|
+
outputs?: Readonly<
|
|
529
|
+
Record<
|
|
530
|
+
"tenkan" | "kijun" | "senkouA" | "senkouB" | "chikou",
|
|
531
|
+
{ lineStyle?: PlotLineStyle }
|
|
532
|
+
>
|
|
533
|
+
>;
|
|
534
|
+
}>;
|
|
535
|
+
export type IchimokuResult = Readonly<{
|
|
536
|
+
tenkan: Series<number>;
|
|
537
|
+
kijun: Series<number>;
|
|
538
|
+
senkouA: Series<number>;
|
|
539
|
+
senkouB: Series<number>;
|
|
540
|
+
chikou: Series<number>;
|
|
541
|
+
}>;
|
|
542
|
+
export type MedianOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
543
|
+
export type AdrOpts = Readonly<{
|
|
544
|
+
length?: number;
|
|
545
|
+
offset?: number;
|
|
546
|
+
lineStyle?: PlotLineStyle;
|
|
547
|
+
}>;
|
|
548
|
+
export type UlcerIndexOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
549
|
+
export type PmoOpts = Readonly<{
|
|
550
|
+
length?: number;
|
|
551
|
+
signalLength?: number;
|
|
552
|
+
offset?: number;
|
|
553
|
+
}>;
|
|
554
|
+
export type PmoResult = Readonly<{
|
|
555
|
+
pmo: Series<number>;
|
|
556
|
+
signal: Series<number>;
|
|
557
|
+
}>;
|
|
558
|
+
export type SmiOpts = Readonly<{
|
|
559
|
+
kLength?: number;
|
|
560
|
+
dLength?: number;
|
|
561
|
+
smoothLength?: number;
|
|
562
|
+
offset?: number;
|
|
563
|
+
}>;
|
|
564
|
+
export type SmiResult = Readonly<{
|
|
565
|
+
smi: Series<number>;
|
|
566
|
+
signal: Series<number>;
|
|
567
|
+
}>;
|
|
568
|
+
export type TsiOpts = Readonly<{
|
|
569
|
+
shortLength?: number;
|
|
570
|
+
longLength?: number;
|
|
571
|
+
signalLength?: number;
|
|
572
|
+
offset?: number;
|
|
573
|
+
}>;
|
|
574
|
+
export type TsiResult = Readonly<{
|
|
575
|
+
tsi: Series<number>;
|
|
576
|
+
signal: Series<number>;
|
|
577
|
+
}>;
|
|
578
|
+
export type ValuewhenOpts = Readonly<{ offset?: number }>;
|
|
579
|
+
export type BarssinceOpts = Readonly<{ offset?: number }>;
|
|
580
|
+
export type TaNamespace = {
|
|
581
|
+
sma(source: ScalarOrSeries, length: number, opts?: SmaOpts): Series<number>;
|
|
582
|
+
ema(source: ScalarOrSeries, length: number, opts?: EmaOpts): Series<number>;
|
|
583
|
+
stdev(source: ScalarOrSeries, length: number, opts?: StdevOpts): Series<number>;
|
|
584
|
+
bb(source: ScalarOrSeries, length: number, opts?: BbOpts): BbResult;
|
|
585
|
+
rsi(source: ScalarOrSeries, length: number, opts?: RsiOpts): Series<number>;
|
|
586
|
+
macd(source: ScalarOrSeries, opts?: MacdOpts): MacdResult;
|
|
587
|
+
atr(length: number, opts?: AtrOpts): Series<number>;
|
|
588
|
+
crossover(
|
|
589
|
+
a: ScalarOrSeries,
|
|
590
|
+
b: ScalarOrSeries,
|
|
591
|
+
opts?: CrossoverOpts,
|
|
592
|
+
): Series<boolean>;
|
|
593
|
+
crossunder(
|
|
594
|
+
a: ScalarOrSeries,
|
|
595
|
+
b: ScalarOrSeries,
|
|
596
|
+
opts?: CrossunderOpts,
|
|
597
|
+
): Series<boolean>;
|
|
598
|
+
nz(value: number, replacement?: number): number;
|
|
599
|
+
highest(source: ScalarOrSeries, length: number, opts?: HighestOpts): Series<number>;
|
|
600
|
+
lowest(source: ScalarOrSeries, length: number, opts?: LowestOpts): Series<number>;
|
|
601
|
+
change(source: ScalarOrSeries, opts?: ChangeOpts): Series<number>;
|
|
602
|
+
valuewhen(
|
|
603
|
+
condition: Series<boolean>,
|
|
604
|
+
source: ScalarOrSeries,
|
|
605
|
+
occurrence?: number,
|
|
606
|
+
opts?: ValuewhenOpts,
|
|
607
|
+
): Series<number>;
|
|
608
|
+
barssince(condition: Series<boolean>, opts?: BarssinceOpts): Series<number>;
|
|
609
|
+
wma(source: ScalarOrSeries, length: number, opts?: WmaOpts): Series<number>;
|
|
610
|
+
vwma(source: ScalarOrSeries, length: number, opts?: VwmaOpts): Series<number>;
|
|
611
|
+
hma(source: ScalarOrSeries, length: number, opts?: HmaOpts): Series<number>;
|
|
612
|
+
smma(source: ScalarOrSeries, length: number, opts?: SmmaOpts): Series<number>;
|
|
613
|
+
dema(source: ScalarOrSeries, length: number, opts?: DemaOpts): Series<number>;
|
|
614
|
+
tema(source: ScalarOrSeries, length: number, opts?: TemaOpts): Series<number>;
|
|
615
|
+
kama(source: ScalarOrSeries, opts?: KamaOpts): Series<number>;
|
|
616
|
+
alma(source: ScalarOrSeries, length: number, opts?: AlmaOpts): Series<number>;
|
|
617
|
+
lsma(source: ScalarOrSeries, length: number, opts?: LsmaOpts): Series<number>;
|
|
618
|
+
mcginley(source: ScalarOrSeries, length: number, opts?: McginleyOpts): Series<number>;
|
|
619
|
+
maRibbon(source: ScalarOrSeries, opts?: MaRibbonOpts): MaRibbonResult;
|
|
620
|
+
ao(opts?: AoOpts): Series<number>;
|
|
621
|
+
cmo(source: ScalarOrSeries, length: number, opts?: CmoOpts): Series<number>;
|
|
622
|
+
momentum(source: ScalarOrSeries, length: number, opts?: MomentumOpts): Series<number>;
|
|
623
|
+
roc(source: ScalarOrSeries, length: number, opts?: RocOpts): Series<number>;
|
|
624
|
+
cci(source: ScalarOrSeries, length: number, opts?: CciOpts): Series<number>;
|
|
625
|
+
stoch(opts?: StochOpts): StochResult;
|
|
626
|
+
stochRsi(source: ScalarOrSeries, opts?: StochRsiOpts): StochRsiResult;
|
|
627
|
+
ultimateOsc(opts?: UltimateOscOpts): Series<number>;
|
|
628
|
+
coppock(source: ScalarOrSeries, opts?: CoppockOpts): Series<number>;
|
|
629
|
+
williamsR(length: number, opts?: WilliamsROpts): Series<number>;
|
|
630
|
+
aroon(length: number, opts?: AroonOpts): AroonResult;
|
|
631
|
+
aroonOsc(length: number, opts?: AroonOscOpts): Series<number>;
|
|
632
|
+
median(source: ScalarOrSeries, length: number, opts?: MedianOpts): Series<number>;
|
|
633
|
+
adr(opts?: AdrOpts): Series<number>;
|
|
634
|
+
ulcerIndex(
|
|
635
|
+
source: ScalarOrSeries,
|
|
636
|
+
length: number,
|
|
637
|
+
opts?: UlcerIndexOpts,
|
|
638
|
+
): Series<number>;
|
|
639
|
+
pmo(source: ScalarOrSeries, opts?: PmoOpts): PmoResult;
|
|
640
|
+
smi(opts?: SmiOpts): SmiResult;
|
|
641
|
+
tsi(source: ScalarOrSeries, opts?: TsiOpts): TsiResult;
|
|
642
|
+
vol(opts?: VolOpts): Series<number>;
|
|
643
|
+
vwap(opts?: VwapOpts): Series<number>;
|
|
644
|
+
anchoredVwap(anchorTime: number, opts?: AnchoredVwapOpts): Series<number>;
|
|
645
|
+
anchoredVolumeProfile(opts: AnchoredVolumeProfileOpts): AnchoredVolumeProfileResult;
|
|
646
|
+
fixedRangeVolumeProfile(opts: FixedRangeVolumeProfileOpts): FixedRangeVolumeProfileResult;
|
|
647
|
+
sessionVolumeProfile(opts?: SessionVolumeProfileOpts): SessionVolumeProfileResult;
|
|
648
|
+
visibleRangeVolumeProfile(
|
|
649
|
+
opts?: VisibleRangeVolumeProfileOpts,
|
|
650
|
+
): VisibleRangeVolumeProfileResult;
|
|
651
|
+
obv(opts?: ObvOpts): Series<number>;
|
|
652
|
+
adl(opts?: AdlOpts): Series<number>;
|
|
653
|
+
bop(opts?: BopOpts): Series<number>;
|
|
654
|
+
cmf(length: number, opts?: CmfOpts): Series<number>;
|
|
655
|
+
chaikinOsc(opts?: ChaikinOscOpts): Series<number>;
|
|
656
|
+
mfi(length: number, opts?: MfiOpts): Series<number>;
|
|
657
|
+
netVolume(opts?: NetVolumeOpts): Series<number>;
|
|
658
|
+
pvo(opts?: PvoOpts): PvoResult;
|
|
659
|
+
pvt(opts?: PvtOpts): Series<number>;
|
|
660
|
+
eom(length: number, opts?: EomOpts): Series<number>;
|
|
661
|
+
nvi(opts?: NviOpts): Series<number>;
|
|
662
|
+
pvi(opts?: PviOpts): Series<number>;
|
|
663
|
+
psar(opts?: PsarOpts): PsarResult;
|
|
664
|
+
supertrend(opts?: SupertrendOpts): SupertrendResult;
|
|
665
|
+
chandelier(opts?: ChandelierOpts): ChandelierResult;
|
|
666
|
+
chandeKrollStop(opts?: ChandeKrollStopOpts): ChandeKrollStopResult;
|
|
667
|
+
williamsFractal(opts?: WilliamsFractalOpts): WilliamsFractalResult;
|
|
668
|
+
zigZag(opts?: ZigZagOpts): ZigZagResult;
|
|
669
|
+
pivotsHighLow(opts?: PivotsHighLowOpts): PivotsHighLowResult;
|
|
670
|
+
pivotsStandard(opts?: PivotsStandardOpts): PivotsStandardResult;
|
|
671
|
+
volatilityStop(opts?: VolatilityStopOpts): VolatilityStopResult;
|
|
672
|
+
bbPercentB(
|
|
673
|
+
source: ScalarOrSeries,
|
|
674
|
+
length: number,
|
|
675
|
+
opts?: BbPercentBOpts,
|
|
676
|
+
): Series<number>;
|
|
677
|
+
bbw(source: ScalarOrSeries, length: number, opts?: BbwOpts): Series<number>;
|
|
678
|
+
donchian(length: number, opts?: DonchianOpts): DonchianResult;
|
|
679
|
+
keltner(opts?: KeltnerOpts): KeltnerResult;
|
|
680
|
+
envelope(source: ScalarOrSeries, opts?: EnvelopeOpts): EnvelopeResult;
|
|
681
|
+
chop(length: number, opts?: ChopOpts): Series<number>;
|
|
682
|
+
historicalVolatility(
|
|
683
|
+
source: ScalarOrSeries,
|
|
684
|
+
length: number,
|
|
685
|
+
opts?: HvOpts,
|
|
686
|
+
): Series<number>;
|
|
687
|
+
rvi(source: ScalarOrSeries, length: number, opts?: RviOpts): Series<number>;
|
|
688
|
+
massIndex(opts?: MassIndexOpts): Series<number>;
|
|
689
|
+
ppo(source: ScalarOrSeries, opts?: PpoOpts): PpoResult;
|
|
690
|
+
dpo(source: ScalarOrSeries, length: number, opts?: DpoOpts): Series<number>;
|
|
691
|
+
connorsRsi(source: ScalarOrSeries, opts?: ConnorsRsiOpts): Series<number>;
|
|
692
|
+
kst(source: ScalarOrSeries, opts?: KstOpts): KstResult;
|
|
693
|
+
fisher(length: number, opts?: FisherOpts): FisherResult;
|
|
694
|
+
klinger(opts?: KlingerOpts): KlingerResult;
|
|
695
|
+
rvgi(opts?: RvgiOpts): RvgiResult;
|
|
696
|
+
adx(length: number, opts?: AdxOpts): Series<number>;
|
|
697
|
+
dmi(length: number, opts?: DmiOpts): DmiResult;
|
|
698
|
+
trix(source: ScalarOrSeries, length: number, opts?: TrixOpts): TrixResult;
|
|
699
|
+
vortex(length: number, opts?: VortexOpts): VortexResult;
|
|
700
|
+
trendStrengthIndex(
|
|
701
|
+
source: ScalarOrSeries,
|
|
702
|
+
length: number,
|
|
703
|
+
opts?: TrendStrengthIndexOpts,
|
|
704
|
+
): Series<number>;
|
|
705
|
+
ichimoku(opts?: IchimokuOpts): IchimokuResult;
|
|
706
|
+
};
|
|
707
|
+
export const ta: TaNamespace;
|
|
708
|
+
export type PlotKind =
|
|
709
|
+
| "line"
|
|
710
|
+
| "step-line"
|
|
711
|
+
| "horizontal-line"
|
|
712
|
+
| "histogram"
|
|
713
|
+
| "bars"
|
|
714
|
+
| "area"
|
|
715
|
+
| "filled-band"
|
|
716
|
+
| "label"
|
|
717
|
+
| "marker"
|
|
718
|
+
| "shape"
|
|
719
|
+
| "character"
|
|
720
|
+
| "arrow"
|
|
721
|
+
| "candle-override"
|
|
722
|
+
| "bar-override"
|
|
723
|
+
| "bg-color"
|
|
724
|
+
| "bar-color"
|
|
725
|
+
| "horizontal-histogram";
|
|
726
|
+
export type PlotGlyphShape =
|
|
727
|
+
| "circle"
|
|
728
|
+
| "triangle-up"
|
|
729
|
+
| "triangle-down"
|
|
730
|
+
| "square"
|
|
731
|
+
| "diamond";
|
|
732
|
+
export type PlotShapeGlyph = PlotGlyphShape | "cross" | "xcross" | "flag";
|
|
733
|
+
export type PlotLocation = "above" | "below" | "absolute";
|
|
734
|
+
export type HorizontalHistogramBucket = Readonly<{
|
|
735
|
+
readonly price: number;
|
|
736
|
+
readonly volume: number;
|
|
737
|
+
readonly color?: Color;
|
|
738
|
+
}>;
|
|
739
|
+
export type PlotOptsStyle =
|
|
740
|
+
| { readonly kind: "line" }
|
|
741
|
+
| { readonly kind: "step-line" }
|
|
742
|
+
| { readonly kind: "horizontal-line" }
|
|
743
|
+
| { readonly kind: "histogram"; readonly baseline?: number }
|
|
744
|
+
| {
|
|
745
|
+
readonly kind: "marker";
|
|
746
|
+
readonly shape: PlotGlyphShape;
|
|
747
|
+
readonly size: number;
|
|
748
|
+
}
|
|
749
|
+
| {
|
|
750
|
+
readonly kind: "shape";
|
|
751
|
+
readonly shape: PlotShapeGlyph;
|
|
752
|
+
readonly size: number;
|
|
753
|
+
readonly location?: PlotLocation;
|
|
754
|
+
}
|
|
755
|
+
| {
|
|
756
|
+
readonly kind: "character";
|
|
757
|
+
readonly char: string;
|
|
758
|
+
readonly size: number;
|
|
759
|
+
readonly location?: PlotLocation;
|
|
760
|
+
}
|
|
761
|
+
| { readonly kind: "arrow"; readonly direction: "up" | "down"; readonly size: number }
|
|
762
|
+
| {
|
|
763
|
+
readonly kind: "candle-override";
|
|
764
|
+
readonly bull: Color;
|
|
765
|
+
readonly bear: Color;
|
|
766
|
+
readonly doji?: Color;
|
|
767
|
+
}
|
|
768
|
+
| { readonly kind: "bar-override"; readonly color: Color }
|
|
769
|
+
| { readonly kind: "bg-color"; readonly color: Color; readonly transp?: number }
|
|
770
|
+
| { readonly kind: "bar-color"; readonly color: Color }
|
|
771
|
+
| {
|
|
772
|
+
readonly kind: "horizontal-histogram";
|
|
773
|
+
readonly buckets: ReadonlyArray<HorizontalHistogramBucket>;
|
|
774
|
+
};
|
|
775
|
+
export type PlotOpts = Readonly<{
|
|
776
|
+
color?: Color;
|
|
777
|
+
title?: string;
|
|
778
|
+
lineWidth?: number;
|
|
779
|
+
lineStyle?: LineStyle;
|
|
780
|
+
pane?: "overlay" | "new" | string;
|
|
781
|
+
style?: PlotOptsStyle;
|
|
782
|
+
}>;
|
|
783
|
+
export type HLineOpts = Readonly<{
|
|
784
|
+
color?: Color;
|
|
785
|
+
title?: string;
|
|
786
|
+
lineWidth?: number;
|
|
787
|
+
lineStyle?: LineStyle;
|
|
788
|
+
}>;
|
|
789
|
+
export function plot(value: number | Series<number>, opts?: PlotOpts): void;
|
|
790
|
+
export function hline(price: number, opts?: HLineOpts): void;
|
|
791
|
+
export type JsonValue =
|
|
792
|
+
| null
|
|
793
|
+
| boolean
|
|
794
|
+
| number
|
|
795
|
+
| string
|
|
796
|
+
| ReadonlyArray<JsonValue>
|
|
797
|
+
| { readonly [k: string]: JsonValue };
|
|
798
|
+
export type StreamSnapshot = Readonly<{
|
|
799
|
+
interval: string;
|
|
800
|
+
headIndex: number;
|
|
801
|
+
filled: number;
|
|
802
|
+
buffers: Readonly<{
|
|
803
|
+
time: ReadonlyArray<number | null>;
|
|
804
|
+
open: ReadonlyArray<number | null>;
|
|
805
|
+
high: ReadonlyArray<number | null>;
|
|
806
|
+
low: ReadonlyArray<number | null>;
|
|
807
|
+
close: ReadonlyArray<number | null>;
|
|
808
|
+
volume: ReadonlyArray<number | null>;
|
|
809
|
+
}>;
|
|
810
|
+
}>;
|
|
811
|
+
export type StateSnapshot = Readonly<{
|
|
812
|
+
lastBarTime: number;
|
|
813
|
+
streams: Readonly<Record<string, StreamSnapshot>>;
|
|
814
|
+
slots: Readonly<Record<string, JsonValue>>;
|
|
815
|
+
savedAt: number;
|
|
816
|
+
snapshotVersion: 1;
|
|
817
|
+
}>;
|
|
818
|
+
export type StateStoreKey = Readonly<{
|
|
819
|
+
scriptHash: string;
|
|
820
|
+
compilerVersion: string;
|
|
821
|
+
apiVersion: 1;
|
|
822
|
+
capabilitiesHash: string;
|
|
823
|
+
symbol: string;
|
|
824
|
+
mainInterval: string;
|
|
825
|
+
requestedIntervals: ReadonlyArray<string>;
|
|
826
|
+
}>;
|
|
827
|
+
export type AlertOpts = Readonly<{
|
|
828
|
+
severity?: AlertSeverity;
|
|
829
|
+
meta?: Readonly<Record<string, JsonValue>>;
|
|
830
|
+
}>;
|
|
831
|
+
export function alert(message: string, opts?: AlertOpts): void;
|
|
832
|
+
export type LogLevel = "info" | "warn" | "error";
|
|
833
|
+
export type RuntimeNamespace = Readonly<{
|
|
834
|
+
log: Readonly<{
|
|
835
|
+
info(message: string, meta?: Readonly<Record<string, JsonValue>>): void;
|
|
836
|
+
warn(message: string, meta?: Readonly<Record<string, JsonValue>>): void;
|
|
837
|
+
error(message: string, meta?: Readonly<Record<string, JsonValue>>): void;
|
|
838
|
+
}>;
|
|
839
|
+
error(message: string): never;
|
|
840
|
+
}>;
|
|
841
|
+
export const runtime: RuntimeNamespace;
|
|
842
|
+
export function fromGradient(t: number, stops: ReadonlyArray<GradientStop>): Color;
|
|
843
|
+
export function withAlpha(c: Color, alpha: number): Color;
|
|
844
|
+
export function rgb(r: number, g: number, b: number, alpha?: number): Color;
|
|
845
|
+
export function hsl(h: number, s: number, l: number, alpha?: number): Color;
|
|
846
|
+
export const color: Readonly<{
|
|
847
|
+
aqua: Color;
|
|
848
|
+
black: Color;
|
|
849
|
+
blue: Color;
|
|
850
|
+
fuchsia: Color;
|
|
851
|
+
gray: Color;
|
|
852
|
+
green: Color;
|
|
853
|
+
lime: Color;
|
|
854
|
+
maroon: Color;
|
|
855
|
+
navy: Color;
|
|
856
|
+
olive: Color;
|
|
857
|
+
orange: Color;
|
|
858
|
+
purple: Color;
|
|
859
|
+
red: Color;
|
|
860
|
+
silver: Color;
|
|
861
|
+
teal: Color;
|
|
862
|
+
white: Color;
|
|
863
|
+
yellow: Color;
|
|
864
|
+
fromGradient: typeof fromGradient;
|
|
865
|
+
withAlpha: typeof withAlpha;
|
|
866
|
+
rgb: typeof rgb;
|
|
867
|
+
hsl: typeof hsl;
|
|
868
|
+
}>;
|
|
869
|
+
export type InputKind =
|
|
870
|
+
| "int"
|
|
871
|
+
| "float"
|
|
872
|
+
| "bool"
|
|
873
|
+
| "string"
|
|
874
|
+
| "enum"
|
|
875
|
+
| "color"
|
|
876
|
+
| "source"
|
|
877
|
+
| "time"
|
|
878
|
+
| "price"
|
|
879
|
+
| "symbol"
|
|
880
|
+
| "interval"
|
|
881
|
+
| "external-series";
|
|
882
|
+
export type SourceField =
|
|
883
|
+
| "open"
|
|
884
|
+
| "high"
|
|
885
|
+
| "low"
|
|
886
|
+
| "close"
|
|
887
|
+
| "hl2"
|
|
888
|
+
| "hlc3"
|
|
889
|
+
| "ohlc4"
|
|
890
|
+
| "hlcc4";
|
|
891
|
+
export type Schema<T> = Readonly<{ kind: "external-series-schema"; __brand?: T }>;
|
|
892
|
+
type NumericInputOpts = Readonly<{ min?: number; max?: number; step?: number }>;
|
|
893
|
+
type CommonInputDescriptor<K extends InputKind, T> = Readonly<{
|
|
894
|
+
kind: K;
|
|
895
|
+
defaultValue: T;
|
|
896
|
+
title?: string;
|
|
897
|
+
}>;
|
|
898
|
+
export type IntDescriptor = CommonInputDescriptor<"int", number> & NumericInputOpts;
|
|
899
|
+
export type FloatDescriptor = CommonInputDescriptor<"float", number> & NumericInputOpts;
|
|
900
|
+
export type BoolDescriptor = CommonInputDescriptor<"bool", boolean>;
|
|
901
|
+
export type StringDescriptor = CommonInputDescriptor<"string", string> & Readonly<{ multiline?: boolean }>;
|
|
902
|
+
export type EnumDescriptor<T extends string> = CommonInputDescriptor<"enum", T> & Readonly<{ options: ReadonlyArray<T> }>;
|
|
903
|
+
export type ColorDescriptor = CommonInputDescriptor<"color", Color>;
|
|
904
|
+
export type SourceDescriptor = CommonInputDescriptor<"source", SourceField>;
|
|
905
|
+
export type TimeDescriptor = CommonInputDescriptor<"time", number> & Readonly<{ pickFromChart?: boolean }>;
|
|
906
|
+
export type PriceDescriptor = CommonInputDescriptor<"price", number>;
|
|
907
|
+
export type SymbolDescriptor = CommonInputDescriptor<"symbol", string>;
|
|
908
|
+
export type IntervalDescriptorInput = CommonInputDescriptor<"interval", string>;
|
|
909
|
+
export type ExternalSeriesDescriptor<T> = Readonly<{
|
|
910
|
+
kind: "external-series";
|
|
911
|
+
name: string;
|
|
912
|
+
schema: Schema<T>;
|
|
913
|
+
title?: string;
|
|
914
|
+
}>;
|
|
915
|
+
export type InputDescriptor<T> =
|
|
916
|
+
| IntDescriptor
|
|
917
|
+
| FloatDescriptor
|
|
918
|
+
| BoolDescriptor
|
|
919
|
+
| StringDescriptor
|
|
920
|
+
| EnumDescriptor<string>
|
|
921
|
+
| ColorDescriptor
|
|
922
|
+
| SourceDescriptor
|
|
923
|
+
| TimeDescriptor
|
|
924
|
+
| PriceDescriptor
|
|
925
|
+
| SymbolDescriptor
|
|
926
|
+
| IntervalDescriptorInput
|
|
927
|
+
| ExternalSeriesDescriptor<T>;
|
|
928
|
+
export const input: Readonly<{
|
|
929
|
+
int(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): IntDescriptor;
|
|
930
|
+
float(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): FloatDescriptor;
|
|
931
|
+
bool(defaultValue: boolean, opts?: Readonly<{ title?: string }>): BoolDescriptor;
|
|
932
|
+
string(defaultValue: string, opts?: Readonly<{ title?: string; multiline?: boolean }>): StringDescriptor;
|
|
933
|
+
enum<T extends string>(
|
|
934
|
+
defaultValue: T,
|
|
935
|
+
options: ReadonlyArray<T>,
|
|
936
|
+
opts?: Readonly<{ title?: string }>,
|
|
937
|
+
): EnumDescriptor<T>;
|
|
938
|
+
color(defaultValue: Color, opts?: Readonly<{ title?: string }>): ColorDescriptor;
|
|
939
|
+
source(defaultValue: SourceField, opts?: Readonly<{ title?: string }>): SourceDescriptor;
|
|
940
|
+
time(defaultValue: Time, opts?: Readonly<{ title?: string; pickFromChart?: boolean }>): TimeDescriptor;
|
|
941
|
+
price(defaultValue: Price, opts?: Readonly<{ title?: string }>): PriceDescriptor;
|
|
942
|
+
symbol(defaultValue: string, opts?: Readonly<{ title?: string }>): SymbolDescriptor;
|
|
943
|
+
interval(defaultValue: string, opts?: Readonly<{ title?: string }>): IntervalDescriptorInput;
|
|
944
|
+
externalSeries<T>(args: Readonly<{ name: string; schema: Schema<T>; title?: string }>): ExternalSeriesDescriptor<T>;
|
|
945
|
+
}>;
|
|
946
|
+
export type InputSchema = Readonly<Record<string, InputDescriptor<unknown>>>;
|
|
947
|
+
export type MutableSlot<T> = {
|
|
948
|
+
value: T;
|
|
949
|
+
};
|
|
950
|
+
export type StateNamespace = Readonly<{
|
|
951
|
+
float(init: number): MutableSlot<number>;
|
|
952
|
+
int(init: number): MutableSlot<number>;
|
|
953
|
+
bool(init: boolean): MutableSlot<boolean>;
|
|
954
|
+
string(init: string): MutableSlot<string>;
|
|
955
|
+
tick: Readonly<{
|
|
956
|
+
float(init: number): MutableSlot<number>;
|
|
957
|
+
int(init: number): MutableSlot<number>;
|
|
958
|
+
bool(init: boolean): MutableSlot<boolean>;
|
|
959
|
+
string(init: string): MutableSlot<string>;
|
|
960
|
+
}>;
|
|
961
|
+
}>;
|
|
962
|
+
export const state: StateNamespace;
|
|
963
|
+
export type BarStateView = {
|
|
964
|
+
readonly isfirst: boolean;
|
|
965
|
+
readonly islast: boolean;
|
|
966
|
+
readonly isnew: boolean;
|
|
967
|
+
readonly ishistory: boolean;
|
|
968
|
+
readonly isrealtime: boolean;
|
|
969
|
+
readonly isconfirmed: boolean;
|
|
970
|
+
};
|
|
971
|
+
export const barstate: BarStateView;
|
|
972
|
+
export type SymbolType =
|
|
973
|
+
| "equity"
|
|
974
|
+
| "futures"
|
|
975
|
+
| "forex"
|
|
976
|
+
| "crypto"
|
|
977
|
+
| "index"
|
|
978
|
+
| "fund"
|
|
979
|
+
| "bond"
|
|
980
|
+
| "commodity"
|
|
981
|
+
| "custom";
|
|
982
|
+
export type SymInfoView = {
|
|
983
|
+
readonly ticker: string;
|
|
984
|
+
readonly type: SymbolType;
|
|
985
|
+
readonly mintick: number;
|
|
986
|
+
readonly currency: string;
|
|
987
|
+
readonly basecurrency: string;
|
|
988
|
+
readonly exchange: string;
|
|
989
|
+
readonly timezone: string;
|
|
990
|
+
readonly session: string;
|
|
991
|
+
readonly meta: Readonly<Record<string, JsonValue>>;
|
|
992
|
+
};
|
|
993
|
+
export const syminfo: SymInfoView;
|
|
994
|
+
export type TimeframeView = {
|
|
995
|
+
readonly period: string;
|
|
996
|
+
readonly isintraday: boolean;
|
|
997
|
+
readonly isdaily: boolean;
|
|
998
|
+
readonly isweekly: boolean;
|
|
999
|
+
readonly ismonthly: boolean;
|
|
1000
|
+
readonly inSeconds: number;
|
|
1001
|
+
};
|
|
1002
|
+
export const timeframe: TimeframeView;
|
|
1003
|
+
export type RequestSecurityOpts = Readonly<{ interval: string }>;
|
|
1004
|
+
export type RequestLowerTfOpts = Readonly<{ interval: string }>;
|
|
1005
|
+
export type SecurityBar = Readonly<{
|
|
1006
|
+
readonly time: Series<Time>;
|
|
1007
|
+
readonly open: Series<Price>;
|
|
1008
|
+
readonly high: Series<Price>;
|
|
1009
|
+
readonly low: Series<Price>;
|
|
1010
|
+
readonly close: Series<Price>;
|
|
1011
|
+
readonly volume: Series<Volume>;
|
|
1012
|
+
readonly hl2: Series<Price>;
|
|
1013
|
+
readonly hlc3: Series<Price>;
|
|
1014
|
+
readonly ohlc4: Series<Price>;
|
|
1015
|
+
readonly hlcc4: Series<Price>;
|
|
1016
|
+
readonly symbol: Series<string>;
|
|
1017
|
+
readonly interval: Series<string>;
|
|
1018
|
+
}>;
|
|
1019
|
+
export type RequestNamespace = Readonly<{
|
|
1020
|
+
security(opts: RequestSecurityOpts): SecurityBar;
|
|
1021
|
+
lowerTf(opts: RequestLowerTfOpts): Series<ReadonlyArray<Bar>>;
|
|
1022
|
+
}>;
|
|
1023
|
+
export const request: RequestNamespace;
|
|
1024
|
+
export function intervalToSeconds(d: IntervalDescriptor): number;
|
|
1025
|
+
export type ScriptManifest = {
|
|
1026
|
+
readonly apiVersion: 1;
|
|
1027
|
+
readonly kind: "indicator" | "drawing" | "alert" | "alertCondition";
|
|
1028
|
+
readonly name: string;
|
|
1029
|
+
readonly inputs: InputSchema;
|
|
1030
|
+
readonly capabilities: ReadonlyArray<CapabilityId>;
|
|
1031
|
+
readonly requestedIntervals: ReadonlyArray<string>;
|
|
1032
|
+
readonly userPickableInterval: boolean;
|
|
1033
|
+
readonly seriesCapacities: Readonly<Record<string, number>>;
|
|
1034
|
+
readonly maxLookback: number;
|
|
1035
|
+
readonly maxDrawings?: DrawingCounts;
|
|
1036
|
+
readonly maxBarsBack?: number;
|
|
1037
|
+
readonly format?: ValueFormat;
|
|
1038
|
+
readonly precision?: number;
|
|
1039
|
+
readonly scale?: ScaleAxis;
|
|
1040
|
+
readonly shortName?: string;
|
|
1041
|
+
readonly requiresIntervals?: ReadonlyArray<string>;
|
|
1042
|
+
readonly alertConditions?: ReadonlyArray<AlertConditionDefinition>;
|
|
1043
|
+
};
|
|
1044
|
+
export type AlertConditionDescriptor = Readonly<{
|
|
1045
|
+
title: string;
|
|
1046
|
+
description: string;
|
|
1047
|
+
defaultMessage: string;
|
|
1048
|
+
}>;
|
|
1049
|
+
export type AlertConditionDefinition = AlertConditionDescriptor & Readonly<{ id: string }>;
|
|
1050
|
+
export type Time = number;
|
|
1051
|
+
export type Price = number;
|
|
1052
|
+
export type WorldPoint = { readonly time: Time; readonly price: Price };
|
|
1053
|
+
export type AnchorPair = readonly [WorldPoint, WorldPoint];
|
|
1054
|
+
export type AnchorTriple = readonly [WorldPoint, WorldPoint, WorldPoint];
|
|
1055
|
+
export type AnchorQuad = readonly [WorldPoint, WorldPoint, WorldPoint, WorldPoint];
|
|
1056
|
+
export type AnchorQuint = readonly [
|
|
1057
|
+
WorldPoint,
|
|
1058
|
+
WorldPoint,
|
|
1059
|
+
WorldPoint,
|
|
1060
|
+
WorldPoint,
|
|
1061
|
+
WorldPoint,
|
|
1062
|
+
];
|
|
1063
|
+
export type AnchorHept = readonly [
|
|
1064
|
+
WorldPoint,
|
|
1065
|
+
WorldPoint,
|
|
1066
|
+
WorldPoint,
|
|
1067
|
+
WorldPoint,
|
|
1068
|
+
WorldPoint,
|
|
1069
|
+
WorldPoint,
|
|
1070
|
+
WorldPoint,
|
|
1071
|
+
];
|
|
1072
|
+
export type LineDrawStyle = Readonly<{
|
|
1073
|
+
color?: Color;
|
|
1074
|
+
lineWidth?: number;
|
|
1075
|
+
lineStyle?: LineStyle;
|
|
1076
|
+
extendLeft?: boolean;
|
|
1077
|
+
extendRight?: boolean;
|
|
1078
|
+
}>;
|
|
1079
|
+
export type ShapeStyle = Readonly<{
|
|
1080
|
+
stroke?: Color;
|
|
1081
|
+
fill?: Color;
|
|
1082
|
+
lineWidth?: number;
|
|
1083
|
+
lineStyle?: LineStyle;
|
|
1084
|
+
fillAlpha?: number;
|
|
1085
|
+
}>;
|
|
1086
|
+
export type HighlighterStyle = Readonly<{
|
|
1087
|
+
color: Color;
|
|
1088
|
+
alpha: number;
|
|
1089
|
+
}>;
|
|
1090
|
+
export type BrushStyle = Readonly<{
|
|
1091
|
+
stroke: Color;
|
|
1092
|
+
fill: Color;
|
|
1093
|
+
}>;
|
|
1094
|
+
export type TextOpts = Readonly<{
|
|
1095
|
+
color?: Color;
|
|
1096
|
+
size?: "tiny" | "small" | "normal" | "large" | "huge";
|
|
1097
|
+
halign?: "left" | "center" | "right";
|
|
1098
|
+
valign?: "top" | "middle" | "bottom";
|
|
1099
|
+
bgColor?: Color;
|
|
1100
|
+
}>;
|
|
1101
|
+
export type ArrowOpts = LineDrawStyle & Readonly<{ label?: string }>;
|
|
1102
|
+
export type ArrowMarkerOpts = Readonly<{
|
|
1103
|
+
color?: Color;
|
|
1104
|
+
text?: string;
|
|
1105
|
+
}>;
|
|
1106
|
+
export type PathOpts = LineDrawStyle & Readonly<{ closed?: boolean }>;
|
|
1107
|
+
export type FibOpts = Readonly<{
|
|
1108
|
+
levels?: ReadonlyArray<number>;
|
|
1109
|
+
showLabels?: boolean;
|
|
1110
|
+
color?: Color;
|
|
1111
|
+
extendLeft?: boolean;
|
|
1112
|
+
extendRight?: boolean;
|
|
1113
|
+
}>;
|
|
1114
|
+
export type RegressionTrendOpts = Readonly<{
|
|
1115
|
+
source?: "close" | "open" | "high" | "low" | "hl2" | "hlc3" | "ohlc4" | "hlcc4";
|
|
1116
|
+
stdevMultiplier?: number;
|
|
1117
|
+
showUpperBand?: boolean;
|
|
1118
|
+
showLowerBand?: boolean;
|
|
1119
|
+
color?: Color;
|
|
1120
|
+
}>;
|
|
1121
|
+
export type FrameOpts = Readonly<{
|
|
1122
|
+
label?: string;
|
|
1123
|
+
bgColor?: Color;
|
|
1124
|
+
}>;
|
|
1125
|
+
export type TablePosition =
|
|
1126
|
+
| "top-left" | "top-center" | "top-right"
|
|
1127
|
+
| "middle-left" | "middle-center" | "middle-right"
|
|
1128
|
+
| "bottom-left" | "bottom-center" | "bottom-right";
|
|
1129
|
+
export type TableCell = Readonly<{
|
|
1130
|
+
text: string;
|
|
1131
|
+
bgColor?: Color;
|
|
1132
|
+
textColor?: Color;
|
|
1133
|
+
textHalign?: "left" | "center" | "right";
|
|
1134
|
+
textValign?: "top" | "middle" | "bottom";
|
|
1135
|
+
textSize?: "tiny" | "small" | "normal" | "large" | "huge";
|
|
1136
|
+
}>;
|
|
1137
|
+
export type TableOpts = Readonly<{
|
|
1138
|
+
position: TablePosition;
|
|
1139
|
+
cells: ReadonlyArray<ReadonlyArray<TableCell>>;
|
|
1140
|
+
borderColor?: Color;
|
|
1141
|
+
borderWidth?: number;
|
|
1142
|
+
frame?: Readonly<{ color: Color; width: number }>;
|
|
1143
|
+
}>;
|
|
1144
|
+
export type DrawingHandle = Readonly<{
|
|
1145
|
+
readonly id: string;
|
|
1146
|
+
update(patch: Readonly<Record<string, unknown>>): void;
|
|
1147
|
+
remove(): void;
|
|
1148
|
+
}>;
|
|
1149
|
+
// Phase-3 draw surface — every kind listed in
|
|
1150
|
+
// \`packages/core/src/draw/draw.ts:DrawNamespace\`. The shim must
|
|
1151
|
+
// stay in lockstep; missing methods make valid scripts fail the
|
|
1152
|
+
// semantic-typecheck gate added in PLAN §5.2 step 1.
|
|
1153
|
+
export type DrawNamespace = {
|
|
1154
|
+
// Lines / Rays
|
|
1155
|
+
line(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1156
|
+
horizontalLine(price: Price, opts?: LineDrawStyle): DrawingHandle;
|
|
1157
|
+
horizontalRay(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1158
|
+
verticalLine(time: Time, opts?: LineDrawStyle): DrawingHandle;
|
|
1159
|
+
crossLine(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1160
|
+
trendAngle(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1161
|
+
// Boxes A
|
|
1162
|
+
rectangle(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1163
|
+
rotatedRectangle(anchors: AnchorQuad, opts?: ShapeStyle): DrawingHandle;
|
|
1164
|
+
triangle(anchors: AnchorTriple, opts?: ShapeStyle): DrawingHandle;
|
|
1165
|
+
polyline(anchors: ReadonlyArray<WorldPoint>, opts?: LineDrawStyle): DrawingHandle;
|
|
1166
|
+
// Boxes B
|
|
1167
|
+
circle(centre: WorldPoint, radiusAnchor: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1168
|
+
ellipse(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1169
|
+
path(anchors: ReadonlyArray<WorldPoint>, opts?: PathOpts): DrawingHandle;
|
|
1170
|
+
marker(
|
|
1171
|
+
anchor: WorldPoint,
|
|
1172
|
+
opts?: TextOpts & Readonly<{ text?: string; value?: number }>,
|
|
1173
|
+
): DrawingHandle;
|
|
1174
|
+
// Curves
|
|
1175
|
+
arc(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1176
|
+
curve(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1177
|
+
doubleCurve(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;
|
|
1178
|
+
// Freehand
|
|
1179
|
+
pen(anchors: ReadonlyArray<WorldPoint>, opts?: LineDrawStyle): DrawingHandle;
|
|
1180
|
+
highlighter(anchors: ReadonlyArray<WorldPoint>, opts: HighlighterStyle): DrawingHandle;
|
|
1181
|
+
brush(anchors: ReadonlyArray<WorldPoint>, opts: BrushStyle): DrawingHandle;
|
|
1182
|
+
// Annotations
|
|
1183
|
+
text(anchor: WorldPoint, body: string, opts?: TextOpts): DrawingHandle;
|
|
1184
|
+
arrow(a: WorldPoint, b: WorldPoint, opts?: ArrowOpts): DrawingHandle;
|
|
1185
|
+
arrowMarker(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;
|
|
1186
|
+
arrowMarkUp(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;
|
|
1187
|
+
arrowMarkDown(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;
|
|
1188
|
+
// Channels
|
|
1189
|
+
trendChannel(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1190
|
+
flatTopBottom(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1191
|
+
disjointChannel(anchors: AnchorQuad, opts?: LineDrawStyle): DrawingHandle;
|
|
1192
|
+
regressionTrend(a: WorldPoint, b: WorldPoint, opts?: RegressionTrendOpts): DrawingHandle;
|
|
1193
|
+
// Fibonacci A
|
|
1194
|
+
fibRetracement(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;
|
|
1195
|
+
fibTrendExtension(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;
|
|
1196
|
+
fibChannel(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;
|
|
1197
|
+
fibTimeZone(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;
|
|
1198
|
+
fibWedge(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;
|
|
1199
|
+
// Fibonacci B
|
|
1200
|
+
fibSpeedFan(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;
|
|
1201
|
+
fibSpeedArcs(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;
|
|
1202
|
+
fibSpiral(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;
|
|
1203
|
+
fibCircles(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;
|
|
1204
|
+
fibTrendTime(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;
|
|
1205
|
+
// Gann
|
|
1206
|
+
gannBox(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1207
|
+
gannSquareFixed(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1208
|
+
gannSquare(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1209
|
+
gannFan(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1210
|
+
// Pitchforks
|
|
1211
|
+
pitchfork(
|
|
1212
|
+
anchors: AnchorTriple,
|
|
1213
|
+
opts?: LineDrawStyle & Readonly<{
|
|
1214
|
+
variant?: "standard" | "schiff" | "modifiedSchiff" | "inside";
|
|
1215
|
+
}>,
|
|
1216
|
+
): DrawingHandle;
|
|
1217
|
+
pitchfan(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1218
|
+
// Harmonic Patterns
|
|
1219
|
+
xabcdPattern(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;
|
|
1220
|
+
cypherPattern(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;
|
|
1221
|
+
headAndShoulders(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;
|
|
1222
|
+
abcdPattern(anchors: AnchorQuad, opts?: LineDrawStyle): DrawingHandle;
|
|
1223
|
+
trianglePattern(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1224
|
+
threeDrivesPattern(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;
|
|
1225
|
+
// Elliott Waves
|
|
1226
|
+
elliottImpulseWave(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;
|
|
1227
|
+
elliottCorrectionWave(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;
|
|
1228
|
+
elliottTriangleWave(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;
|
|
1229
|
+
elliottDoubleCombo(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;
|
|
1230
|
+
elliottTripleCombo(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;
|
|
1231
|
+
// Cycles
|
|
1232
|
+
cyclicLines(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1233
|
+
timeCycles(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1234
|
+
sineLine(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;
|
|
1235
|
+
// Containers
|
|
1236
|
+
group(childHandleIds: ReadonlyArray<string>): DrawingHandle;
|
|
1237
|
+
frame(a: WorldPoint, b: WorldPoint, opts?: FrameOpts): DrawingHandle;
|
|
1238
|
+
// Viewport overlays
|
|
1239
|
+
table(opts: TableOpts): DrawingHandle;
|
|
1240
|
+
};
|
|
1241
|
+
export const draw: DrawNamespace;
|
|
1242
|
+
export type ComputeContext = {
|
|
1243
|
+
readonly bar: Bar;
|
|
1244
|
+
readonly inputs: Readonly<Record<string, unknown>>;
|
|
1245
|
+
readonly ta: TaNamespace;
|
|
1246
|
+
readonly plot: typeof plot;
|
|
1247
|
+
readonly hline: typeof hline;
|
|
1248
|
+
readonly alert: typeof alert;
|
|
1249
|
+
readonly draw: DrawNamespace;
|
|
1250
|
+
readonly state: StateNamespace;
|
|
1251
|
+
readonly barstate: BarStateView;
|
|
1252
|
+
readonly syminfo: SymInfoView;
|
|
1253
|
+
readonly timeframe: TimeframeView;
|
|
1254
|
+
readonly request: RequestNamespace;
|
|
1255
|
+
readonly runtime: RuntimeNamespace;
|
|
1256
|
+
readonly signal?: (conditionId: string, fired: boolean) => void;
|
|
1257
|
+
};
|
|
1258
|
+
export type ComputeFn = (ctx: ComputeContext) => void;
|
|
1259
|
+
export type CompiledScriptObject = {
|
|
1260
|
+
readonly manifest: ScriptManifest;
|
|
1261
|
+
readonly compute: ComputeFn;
|
|
1262
|
+
};
|
|
1263
|
+
export type DefineIndicatorOpts = Readonly<{
|
|
1264
|
+
name: string;
|
|
1265
|
+
apiVersion: 1;
|
|
1266
|
+
overlay?: boolean;
|
|
1267
|
+
inputs?: InputSchema;
|
|
1268
|
+
compute: ComputeFn;
|
|
1269
|
+
maxDrawings?: DrawingCounts;
|
|
1270
|
+
}> & ScriptOverrides;
|
|
1271
|
+
export type DefineAlertOpts = Readonly<{
|
|
1272
|
+
name: string;
|
|
1273
|
+
apiVersion: 1;
|
|
1274
|
+
inputs?: InputSchema;
|
|
1275
|
+
compute: ComputeFn;
|
|
1276
|
+
}> & Omit<ScriptOverrides, "scale" | "format" | "precision">;
|
|
1277
|
+
export type DefineAlertConditionOpts = Readonly<{
|
|
1278
|
+
name: string;
|
|
1279
|
+
apiVersion: 1;
|
|
1280
|
+
inputs?: InputSchema;
|
|
1281
|
+
conditions: Readonly<Record<string, AlertConditionDescriptor>>;
|
|
1282
|
+
compute: ComputeFn;
|
|
1283
|
+
}>;
|
|
1284
|
+
export type DefineDrawingOpts = Readonly<{
|
|
1285
|
+
name: string;
|
|
1286
|
+
apiVersion: 1;
|
|
1287
|
+
inputs?: InputSchema;
|
|
1288
|
+
compute: ComputeFn;
|
|
1289
|
+
maxDrawings?: DrawingCounts;
|
|
1290
|
+
}> & Omit<ScriptOverrides, "maxBarsBack" | "scale">;
|
|
1291
|
+
export function defineIndicator(opts: DefineIndicatorOpts): CompiledScriptObject;
|
|
1292
|
+
export function defineAlert(opts: DefineAlertOpts): CompiledScriptObject;
|
|
1293
|
+
export function defineAlertCondition(opts: DefineAlertConditionOpts): CompiledScriptObject;
|
|
1294
|
+
export function defineDrawing(opts: DefineDrawingOpts): CompiledScriptObject;
|
|
1295
|
+
export type StatefulPrimitiveEntry = Readonly<{ name: string; slot: boolean }>;
|
|
1296
|
+
export const STATEFUL_PRIMITIVES: ReadonlySet<StatefulPrimitiveEntry>;
|
|
1297
|
+
export const STATEFUL_PRIMITIVES_BY_NAME: ReadonlyMap<string, StatefulPrimitiveEntry>;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
declare module "@invinite-org/chartlang-core/time" {
|
|
1301
|
+
import type { Time } from "@invinite-org/chartlang-core";
|
|
1302
|
+
export type SessionType = "regular" | "extended";
|
|
1303
|
+
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
1304
|
+
export type SessionBounds = Readonly<{ startMs: number; endMs: number }>;
|
|
1305
|
+
export const session: Readonly<{
|
|
1306
|
+
regular(tz: string, t: Time): SessionBounds | null;
|
|
1307
|
+
extended(tz: string, t: Time): SessionBounds | null;
|
|
1308
|
+
isOpen(tz: string, t: Time, type: SessionType): boolean;
|
|
1309
|
+
}>;
|
|
1310
|
+
export function weekday(tz: string, t: Time): Weekday;
|
|
1311
|
+
export function nyDayKey(t: Time): string;
|
|
1312
|
+
export function nySessionBounds(t: Time): SessionBounds;
|
|
1313
|
+
export function weekKey(tz: string, t: Time): string;
|
|
1314
|
+
}
|
|
1315
|
+
`;
|
|
1316
|
+
/**
|
|
1317
|
+
* The compiler options the compiler pins for every script. ES2022 target,
|
|
1318
|
+
* Bundler module resolution, strict mode, no DOM. Scripts that depend on
|
|
1319
|
+
* browser globals fail the `forbiddenConstructs` pass on the global access
|
|
1320
|
+
* itself; the `lib` setting keeps the typechecker from accepting them in the
|
|
1321
|
+
* first place.
|
|
1322
|
+
*
|
|
1323
|
+
* @since 0.1
|
|
1324
|
+
* @example
|
|
1325
|
+
* import { COMPILER_OPTIONS } from "@invinite-org/chartlang-compiler/program";
|
|
1326
|
+
* void COMPILER_OPTIONS;
|
|
1327
|
+
*/
|
|
1328
|
+
export const COMPILER_OPTIONS = {
|
|
1329
|
+
target: ts.ScriptTarget.ES2022,
|
|
1330
|
+
module: ts.ModuleKind.ESNext,
|
|
1331
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
1332
|
+
strict: true,
|
|
1333
|
+
noEmit: true,
|
|
1334
|
+
lib: ["lib.es2022.d.ts"],
|
|
1335
|
+
skipLibCheck: true,
|
|
1336
|
+
esModuleInterop: true,
|
|
1337
|
+
isolatedModules: true,
|
|
1338
|
+
verbatimModuleSyntax: false,
|
|
1339
|
+
allowJs: false,
|
|
1340
|
+
};
|
|
1341
|
+
/**
|
|
1342
|
+
* Build a single-file TypeScript program for an in-memory `.chart.ts`
|
|
1343
|
+
* source. The synthetic file lives at `sourcePath` (POSIX, as the user
|
|
1344
|
+
* would write it); imports of `@invinite-org/chartlang-core` resolve
|
|
1345
|
+
* against the in-memory ambient shim. Returns the source file and a
|
|
1346
|
+
* configured type checker — the caller never sees the underlying compiler
|
|
1347
|
+
* host plumbing.
|
|
1348
|
+
*
|
|
1349
|
+
* @since 0.1
|
|
1350
|
+
* @example
|
|
1351
|
+
* // const { sourceFile, checker } = createProgramForSource(
|
|
1352
|
+
* // 'export default defineIndicator({ name: "x", apiVersion: 1, compute: () => {} });',
|
|
1353
|
+
* // { sourcePath: "demo.chart.ts" },
|
|
1354
|
+
* // );
|
|
1355
|
+
* const fn: typeof createProgramForSource = createProgramForSource;
|
|
1356
|
+
* void fn;
|
|
1357
|
+
*/
|
|
1358
|
+
export function createProgramForSource(source, opts) {
|
|
1359
|
+
const sourcePath = normalisePath(opts.sourcePath);
|
|
1360
|
+
const VIRTUAL_FILE_SET = new Set([sourcePath, CORE_MODULE_PATH]);
|
|
1361
|
+
const sourceFile = ts.createSourceFile(sourcePath, source, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
|
|
1362
|
+
const shimFile = ts.createSourceFile(CORE_MODULE_PATH, CORE_AMBIENT_SHIM, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
|
|
1363
|
+
const fallbackHost = ts.createCompilerHost(COMPILER_OPTIONS, true);
|
|
1364
|
+
const host = {
|
|
1365
|
+
...fallbackHost,
|
|
1366
|
+
getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
|
|
1367
|
+
if (fileName === sourcePath)
|
|
1368
|
+
return sourceFile;
|
|
1369
|
+
if (fileName === CORE_MODULE_PATH)
|
|
1370
|
+
return shimFile;
|
|
1371
|
+
return fallbackHost.getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
1372
|
+
},
|
|
1373
|
+
fileExists(fileName) {
|
|
1374
|
+
return VIRTUAL_FILE_SET.has(fileName) || fallbackHost.fileExists(fileName);
|
|
1375
|
+
},
|
|
1376
|
+
};
|
|
1377
|
+
const program = ts.createProgram({
|
|
1378
|
+
rootNames: [sourcePath, CORE_MODULE_PATH],
|
|
1379
|
+
options: COMPILER_OPTIONS,
|
|
1380
|
+
host,
|
|
1381
|
+
});
|
|
1382
|
+
return Object.freeze({
|
|
1383
|
+
program,
|
|
1384
|
+
sourceFile,
|
|
1385
|
+
checker: program.getTypeChecker(),
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
function normalisePath(p) {
|
|
1389
|
+
return p.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
1390
|
+
}
|
|
1391
|
+
//# sourceMappingURL=program.js.map
|