@types/mathieuc__tradingview 3.5.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.
- mathieuc__tradingview/LICENSE +21 -0
- mathieuc__tradingview/README.md +15 -0
- mathieuc__tradingview/index.d.ts +936 -0
- mathieuc__tradingview/package.json +26 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
> `npm install --save @types/mathieuc__tradingview`
|
|
3
|
+
|
|
4
|
+
# Summary
|
|
5
|
+
This package contains type definitions for @mathieuc/tradingview (https://github.com/Mathieu2301/TradingView-API).
|
|
6
|
+
|
|
7
|
+
# Details
|
|
8
|
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mathieuc__tradingview.
|
|
9
|
+
|
|
10
|
+
### Additional Details
|
|
11
|
+
* Last updated: Tue, 01 Jul 2025 21:34:50 GMT
|
|
12
|
+
* Dependencies: none
|
|
13
|
+
|
|
14
|
+
# Credits
|
|
15
|
+
These definitions were written by [Fırat Özden](https://github.com/fir4tozden).
|
|
@@ -0,0 +1,936 @@
|
|
|
1
|
+
export type AnyFunction = (value: number) => void;
|
|
2
|
+
|
|
3
|
+
/** Market symbol (like: 'BTCEUR' or 'KRAKEN:BTCEUR') */
|
|
4
|
+
export type MarketSymbol = string;
|
|
5
|
+
|
|
6
|
+
/** Timezone for chart operations */
|
|
7
|
+
export type Timezone =
|
|
8
|
+
| "Etc/UTC"
|
|
9
|
+
| "exchange"
|
|
10
|
+
| "Pacific/Honolulu"
|
|
11
|
+
| "America/Juneau"
|
|
12
|
+
| "America/Los_Angeles"
|
|
13
|
+
| "America/Phoenix"
|
|
14
|
+
| "America/Vancouver"
|
|
15
|
+
| "US/Mountain"
|
|
16
|
+
| "America/El_Salvador"
|
|
17
|
+
| "America/Bogota"
|
|
18
|
+
| "America/Chicago"
|
|
19
|
+
| "America/Lima"
|
|
20
|
+
| "America/Mexico_City"
|
|
21
|
+
| "America/Caracas"
|
|
22
|
+
| "America/New_York"
|
|
23
|
+
| "America/Toronto"
|
|
24
|
+
| "America/Argentina/Buenos_Aires"
|
|
25
|
+
| "America/Santiago"
|
|
26
|
+
| "America/Sao_Paulo"
|
|
27
|
+
| "Atlantic/Reykjavik"
|
|
28
|
+
| "Europe/Dublin"
|
|
29
|
+
| "Africa/Lagos"
|
|
30
|
+
| "Europe/Lisbon"
|
|
31
|
+
| "Europe/London"
|
|
32
|
+
| "Europe/Amsterdam"
|
|
33
|
+
| "Europe/Belgrade"
|
|
34
|
+
| "Europe/Berlin"
|
|
35
|
+
| "Europe/Brussels"
|
|
36
|
+
| "Europe/Copenhagen"
|
|
37
|
+
| "Africa/Johannesburg"
|
|
38
|
+
| "Africa/Cairo"
|
|
39
|
+
| "Europe/Luxembourg"
|
|
40
|
+
| "Europe/Madrid"
|
|
41
|
+
| "Europe/Malta"
|
|
42
|
+
| "Europe/Oslo"
|
|
43
|
+
| "Europe/Paris"
|
|
44
|
+
| "Europe/Rome"
|
|
45
|
+
| "Europe/Stockholm"
|
|
46
|
+
| "Europe/Warsaw"
|
|
47
|
+
| "Europe/Zurich"
|
|
48
|
+
| "Europe/Athens"
|
|
49
|
+
| "Asia/Bahrain"
|
|
50
|
+
| "Europe/Helsinki"
|
|
51
|
+
| "Europe/Istanbul"
|
|
52
|
+
| "Asia/Jerusalem"
|
|
53
|
+
| "Asia/Kuwait"
|
|
54
|
+
| "Europe/Moscow"
|
|
55
|
+
| "Asia/Qatar"
|
|
56
|
+
| "Europe/Riga"
|
|
57
|
+
| "Asia/Riyadh"
|
|
58
|
+
| "Europe/Tallinn"
|
|
59
|
+
| "Europe/Vilnius"
|
|
60
|
+
| "Asia/Tehran"
|
|
61
|
+
| "Asia/Dubai"
|
|
62
|
+
| "Asia/Muscat"
|
|
63
|
+
| "Asia/Ashkhabad"
|
|
64
|
+
| "Asia/Kolkata"
|
|
65
|
+
| "Asia/Almaty"
|
|
66
|
+
| "Asia/Bangkok"
|
|
67
|
+
| "Asia/Jakarta"
|
|
68
|
+
| "Asia/Ho_Chi_Minh"
|
|
69
|
+
| "Asia/Chongqing"
|
|
70
|
+
| "Asia/Hong_Kong"
|
|
71
|
+
| "Australia/Perth"
|
|
72
|
+
| "Asia/Shanghai"
|
|
73
|
+
| "Asia/Singapore"
|
|
74
|
+
| "Asia/Taipei"
|
|
75
|
+
| "Asia/Seoul"
|
|
76
|
+
| "Asia/Tokyo"
|
|
77
|
+
| "Australia/Brisbane"
|
|
78
|
+
| "Australia/Adelaide"
|
|
79
|
+
| "Australia/Sydney"
|
|
80
|
+
| "Pacific/Norfolk"
|
|
81
|
+
| "Pacific/Auckland"
|
|
82
|
+
| "Pacific/Fakaofo"
|
|
83
|
+
| "Pacific/Chatham";
|
|
84
|
+
|
|
85
|
+
/** Time frame for chart data */
|
|
86
|
+
export type TimeFrame =
|
|
87
|
+
| "1"
|
|
88
|
+
| "3"
|
|
89
|
+
| "5"
|
|
90
|
+
| "15"
|
|
91
|
+
| "30"
|
|
92
|
+
| "45"
|
|
93
|
+
| "60"
|
|
94
|
+
| "120"
|
|
95
|
+
| "180"
|
|
96
|
+
| "240"
|
|
97
|
+
| "1D"
|
|
98
|
+
| "1W"
|
|
99
|
+
| "1M"
|
|
100
|
+
| "D"
|
|
101
|
+
| "W"
|
|
102
|
+
| "M";
|
|
103
|
+
|
|
104
|
+
/** Market type filter */
|
|
105
|
+
export type MarketType = "stock" | "futures" | "forex" | "cfd" | "crypto" | "index" | "economic";
|
|
106
|
+
|
|
107
|
+
/** Server type for client connection */
|
|
108
|
+
export type ServerType = "data" | "prodata" | "widgetdata";
|
|
109
|
+
|
|
110
|
+
/** Client event types */
|
|
111
|
+
export type ClientEvent = "connected" | "disconnected" | "logged" | "ping" | "data" | "error" | "event";
|
|
112
|
+
|
|
113
|
+
/** Chart event types */
|
|
114
|
+
export type ChartEvent = "seriesLoaded" | "symbolLoaded" | "update" | "error";
|
|
115
|
+
|
|
116
|
+
/** Quote fields for data subscription */
|
|
117
|
+
export type QuoteField =
|
|
118
|
+
| "base-currency-logoid"
|
|
119
|
+
| "ch"
|
|
120
|
+
| "chp"
|
|
121
|
+
| "currency-logoid"
|
|
122
|
+
| "provider_id"
|
|
123
|
+
| "currency_code"
|
|
124
|
+
| "current_session"
|
|
125
|
+
| "description"
|
|
126
|
+
| "exchange"
|
|
127
|
+
| "format"
|
|
128
|
+
| "fractional"
|
|
129
|
+
| "is_tradable"
|
|
130
|
+
| "language"
|
|
131
|
+
| "local_description"
|
|
132
|
+
| "logoid"
|
|
133
|
+
| "lp"
|
|
134
|
+
| "lp_time"
|
|
135
|
+
| "minmov"
|
|
136
|
+
| "minmove2"
|
|
137
|
+
| "original_name"
|
|
138
|
+
| "pricescale"
|
|
139
|
+
| "pro_name"
|
|
140
|
+
| "short_name"
|
|
141
|
+
| "type"
|
|
142
|
+
| "update_mode"
|
|
143
|
+
| "volume"
|
|
144
|
+
| "ask"
|
|
145
|
+
| "bid"
|
|
146
|
+
| "fundamentals"
|
|
147
|
+
| "high_price"
|
|
148
|
+
| "low_price"
|
|
149
|
+
| "open_price"
|
|
150
|
+
| "prev_close_price"
|
|
151
|
+
| "rch"
|
|
152
|
+
| "rchp"
|
|
153
|
+
| "rtc"
|
|
154
|
+
| "rtc_time"
|
|
155
|
+
| "status"
|
|
156
|
+
| "industry"
|
|
157
|
+
| "basic_eps_net_income"
|
|
158
|
+
| "beta_1_year"
|
|
159
|
+
| "market_cap_basic"
|
|
160
|
+
| "earnings_per_share_basic_ttm"
|
|
161
|
+
| "price_earnings_ttm"
|
|
162
|
+
| "sector"
|
|
163
|
+
| "dividends_yield"
|
|
164
|
+
| "timezone"
|
|
165
|
+
| "country_code";
|
|
166
|
+
|
|
167
|
+
/** Built-in indicator types */
|
|
168
|
+
export type BuiltInIndicatorType =
|
|
169
|
+
| "Volume@tv-basicstudies-241"
|
|
170
|
+
| "VbPFixed@tv-basicstudies-241"
|
|
171
|
+
| "VbPFixed@tv-basicstudies-241!"
|
|
172
|
+
| "VbPFixed@tv-volumebyprice-53!"
|
|
173
|
+
| "VbPSessions@tv-volumebyprice-53"
|
|
174
|
+
| "VbPSessionsRough@tv-volumebyprice-53!"
|
|
175
|
+
| "VbPSessionsDetailed@tv-volumebyprice-53!"
|
|
176
|
+
| "VbPVisible@tv-volumebyprice-53";
|
|
177
|
+
|
|
178
|
+
/** Built-in indicator options */
|
|
179
|
+
export type BuiltInIndicatorOption =
|
|
180
|
+
| "rowsLayout"
|
|
181
|
+
| "rows"
|
|
182
|
+
| "volume"
|
|
183
|
+
| "vaVolume"
|
|
184
|
+
| "subscribeRealtime"
|
|
185
|
+
| "first_bar_time"
|
|
186
|
+
| "first_visible_bar_time"
|
|
187
|
+
| "last_bar_time"
|
|
188
|
+
| "last_visible_bar_time"
|
|
189
|
+
| "extendPocRight";
|
|
190
|
+
|
|
191
|
+
/** Indicator input types */
|
|
192
|
+
export type IndicatorInputType = "text" | "source" | "integer" | "float" | "resolution" | "bool" | "color";
|
|
193
|
+
|
|
194
|
+
/** Indicator types */
|
|
195
|
+
export type IndicatorType = "Script@tv-scripting-101!" | "StrategyScript@tv-scripting-101!";
|
|
196
|
+
|
|
197
|
+
/** Custom chart types */
|
|
198
|
+
export type ChartType = "HeikinAshi" | "Renko" | "LineBreak" | "Kagi" | "PointAndFigure" | "Range";
|
|
199
|
+
|
|
200
|
+
/** Chart input sources */
|
|
201
|
+
export type ChartInputSource = "open" | "high" | "low" | "close" | "hl2" | "hlc3" | "ohlc4";
|
|
202
|
+
|
|
203
|
+
/** Chart input styles */
|
|
204
|
+
export type ChartInputStyle = "ATR" | string;
|
|
205
|
+
|
|
206
|
+
/** Chart input sources for specific types */
|
|
207
|
+
export type ChartInputSources = "Close";
|
|
208
|
+
|
|
209
|
+
// ============================================================================
|
|
210
|
+
// INTERFACE DEFINITIONS
|
|
211
|
+
// ============================================================================
|
|
212
|
+
|
|
213
|
+
/** Technical analysis advice value */
|
|
214
|
+
export type Advice = number;
|
|
215
|
+
|
|
216
|
+
/** Technical analysis period data */
|
|
217
|
+
export interface Period {
|
|
218
|
+
Other: Advice;
|
|
219
|
+
All: Advice;
|
|
220
|
+
MA: Advice;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Technical analysis periods for different timeframes */
|
|
224
|
+
export interface Periods {
|
|
225
|
+
"1": Period;
|
|
226
|
+
"5": Period;
|
|
227
|
+
"15": Period;
|
|
228
|
+
"60": Period;
|
|
229
|
+
"240": Period;
|
|
230
|
+
"1D": Period;
|
|
231
|
+
"1W": Period;
|
|
232
|
+
"1M": Period;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Search market result */
|
|
236
|
+
export interface SearchMarketResult {
|
|
237
|
+
id: string;
|
|
238
|
+
exchange: string;
|
|
239
|
+
fullExchange: string;
|
|
240
|
+
symbol: string;
|
|
241
|
+
description: string;
|
|
242
|
+
type: string;
|
|
243
|
+
getTA(): Promise<Periods>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Search indicator result */
|
|
247
|
+
export interface SearchIndicatorResult {
|
|
248
|
+
id: string;
|
|
249
|
+
version: string;
|
|
250
|
+
name: string;
|
|
251
|
+
author: { id: number; username: string };
|
|
252
|
+
image: string;
|
|
253
|
+
source: string | "";
|
|
254
|
+
type: "study" | "strategy";
|
|
255
|
+
access: "open_source" | "closed_source" | "invite_only" | "private" | "other";
|
|
256
|
+
get(): Promise<PineIndicator>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Indicator input definition */
|
|
260
|
+
export interface IndicatorInput {
|
|
261
|
+
name: string;
|
|
262
|
+
inline: string;
|
|
263
|
+
internalID?: string;
|
|
264
|
+
tooltip?: string;
|
|
265
|
+
type: IndicatorInputType;
|
|
266
|
+
value: string | number | boolean;
|
|
267
|
+
isHidden: boolean;
|
|
268
|
+
isFake: boolean;
|
|
269
|
+
options?: string[];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Indicator definition */
|
|
273
|
+
export interface Indicator {
|
|
274
|
+
pineId: string;
|
|
275
|
+
pineVersion: string;
|
|
276
|
+
description: string;
|
|
277
|
+
shortDescription: string;
|
|
278
|
+
inputs: Record<string, IndicatorInput>;
|
|
279
|
+
plots: Record<string, string>;
|
|
280
|
+
script: string;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Socket session information */
|
|
284
|
+
export interface SocketSession {
|
|
285
|
+
session_id: string;
|
|
286
|
+
timestamp: number;
|
|
287
|
+
timestampMs: number;
|
|
288
|
+
release: string;
|
|
289
|
+
studies_metadata_hash: string;
|
|
290
|
+
protocol: "json" | string;
|
|
291
|
+
javastudies: string;
|
|
292
|
+
auth_scheme_vsn: number;
|
|
293
|
+
via: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Client options */
|
|
297
|
+
export interface ClientOptions {
|
|
298
|
+
token?: string;
|
|
299
|
+
signature?: string;
|
|
300
|
+
DEBUG?: boolean;
|
|
301
|
+
server?: ServerType;
|
|
302
|
+
location?: string;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Session definition */
|
|
306
|
+
export interface Session {
|
|
307
|
+
type: "quote" | "chart" | "replay";
|
|
308
|
+
onData: (data: any) => null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Session list */
|
|
312
|
+
export interface SessionList {
|
|
313
|
+
[key: string]: Session;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Send packet function */
|
|
317
|
+
export type SendPacket = (t: string, p?: string[]) => void;
|
|
318
|
+
|
|
319
|
+
/** Client bridge interface */
|
|
320
|
+
export interface ClientBridge {
|
|
321
|
+
sessions: SessionList;
|
|
322
|
+
send: SendPacket;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** Quote session options */
|
|
326
|
+
export interface QuoteSessionOptions {
|
|
327
|
+
fields?: "all" | "price";
|
|
328
|
+
customFields?: QuoteField[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Chart session options */
|
|
332
|
+
export interface ChartSessionOptions {
|
|
333
|
+
symbol?: MarketSymbol;
|
|
334
|
+
timeframe?: TimeFrame;
|
|
335
|
+
range?: number;
|
|
336
|
+
to?: number;
|
|
337
|
+
from?: number;
|
|
338
|
+
countback?: number;
|
|
339
|
+
adjustment?: "splits" | "dividends" | "earnings" | "none";
|
|
340
|
+
session?: string;
|
|
341
|
+
timezone?: Timezone;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Chart inputs for custom chart types */
|
|
345
|
+
export interface ChartInputs {
|
|
346
|
+
atrLength?: number;
|
|
347
|
+
source?: ChartInputSource;
|
|
348
|
+
style?: ChartInputStyle;
|
|
349
|
+
boxSize?: number;
|
|
350
|
+
reversalAmount?: number;
|
|
351
|
+
sources?: ChartInputSources;
|
|
352
|
+
wicks?: boolean;
|
|
353
|
+
lb?: number;
|
|
354
|
+
oneStepBackBuilding?: boolean;
|
|
355
|
+
phantomBars?: boolean;
|
|
356
|
+
range?: number;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Price period data */
|
|
360
|
+
export interface PricePeriod {
|
|
361
|
+
time: number;
|
|
362
|
+
open: number;
|
|
363
|
+
close: number;
|
|
364
|
+
max: number;
|
|
365
|
+
min: number;
|
|
366
|
+
volume: number;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Subsession information */
|
|
370
|
+
export interface Subsession {
|
|
371
|
+
id: string;
|
|
372
|
+
description: string;
|
|
373
|
+
private: boolean;
|
|
374
|
+
session: string;
|
|
375
|
+
"session-correction": string;
|
|
376
|
+
"session-display": string;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Market information */
|
|
380
|
+
export interface MarketInfos {
|
|
381
|
+
series_id: string;
|
|
382
|
+
base_currency: string;
|
|
383
|
+
base_currency_id: string;
|
|
384
|
+
name: string;
|
|
385
|
+
full_name: string;
|
|
386
|
+
pro_name: string;
|
|
387
|
+
description: string;
|
|
388
|
+
short_description: string;
|
|
389
|
+
exchange: string;
|
|
390
|
+
listed_exchange: string;
|
|
391
|
+
provider_id: string;
|
|
392
|
+
currency_id: string;
|
|
393
|
+
currency_code: string;
|
|
394
|
+
variable_tick_size: string;
|
|
395
|
+
pricescale: number;
|
|
396
|
+
pointvalue: number;
|
|
397
|
+
session: string;
|
|
398
|
+
session_display: string;
|
|
399
|
+
type: string;
|
|
400
|
+
has_intraday: boolean;
|
|
401
|
+
fractional: boolean;
|
|
402
|
+
is_tradable: boolean;
|
|
403
|
+
minmov: number;
|
|
404
|
+
minmove2: number;
|
|
405
|
+
timezone: string;
|
|
406
|
+
is_replayable: boolean;
|
|
407
|
+
has_adjustment: boolean;
|
|
408
|
+
has_extended_hours: boolean;
|
|
409
|
+
bar_source: string;
|
|
410
|
+
bar_transform: string;
|
|
411
|
+
bar_fillgaps: boolean;
|
|
412
|
+
allowed_adjustment: string;
|
|
413
|
+
subsession_id: string;
|
|
414
|
+
pro_perm: string;
|
|
415
|
+
base_name: string[];
|
|
416
|
+
legs: string[];
|
|
417
|
+
subsessions: Subsession[];
|
|
418
|
+
typespecs: any[];
|
|
419
|
+
resolutions: any[];
|
|
420
|
+
aliases: any[];
|
|
421
|
+
alternatives: any[];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** Authorization user information */
|
|
425
|
+
export interface AuthorizationUser {
|
|
426
|
+
id: number;
|
|
427
|
+
username: string;
|
|
428
|
+
userpic: string;
|
|
429
|
+
expiration: string;
|
|
430
|
+
created: string;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Quote session bridge */
|
|
434
|
+
export interface QuoteSessionBridge {
|
|
435
|
+
sessionID: string;
|
|
436
|
+
symbolListeners: Record<string, AnyFunction[]>;
|
|
437
|
+
send: SendPacket;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Chart session bridge */
|
|
441
|
+
export interface ChartSessionBridge {
|
|
442
|
+
sessionID: string;
|
|
443
|
+
studyListeners: Record<string, AnyFunction[]>;
|
|
444
|
+
indexes: Record<number, number>;
|
|
445
|
+
send: SendPacket;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Symbol listeners */
|
|
449
|
+
export interface SymbolListeners {
|
|
450
|
+
[key: string]: AnyFunction[];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Study listeners */
|
|
454
|
+
export interface StudyListeners {
|
|
455
|
+
[key: string]: AnyFunction[];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ============================================================================
|
|
459
|
+
// CLASS DEFINITIONS
|
|
460
|
+
// ============================================================================
|
|
461
|
+
|
|
462
|
+
/** TradingView Client class */
|
|
463
|
+
export class Client {
|
|
464
|
+
/** If the client is logged in */
|
|
465
|
+
readonly isLogged: boolean;
|
|
466
|
+
|
|
467
|
+
/** If the client was closed */
|
|
468
|
+
readonly isOpen: boolean;
|
|
469
|
+
|
|
470
|
+
/** Session namespace */
|
|
471
|
+
readonly Session: {
|
|
472
|
+
Quote: new(options?: QuoteSessionOptions) => QuoteSession;
|
|
473
|
+
Chart: new() => ChartSession;
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Create a new TradingView client
|
|
478
|
+
* @param clientOptions TradingView client options
|
|
479
|
+
*/
|
|
480
|
+
constructor(clientOptions?: ClientOptions);
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* When client is connected
|
|
484
|
+
* @param cb Callback
|
|
485
|
+
*/
|
|
486
|
+
onConnected(cb: () => void): void;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* When client is disconnected
|
|
490
|
+
* @param cb Callback
|
|
491
|
+
*/
|
|
492
|
+
onDisconnected(cb: () => void): void;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* When client is logged
|
|
496
|
+
* @param cb Callback
|
|
497
|
+
*/
|
|
498
|
+
onLogged(cb: (session: SocketSession) => void): void;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* When server is pinging the client
|
|
502
|
+
* @param cb Callback
|
|
503
|
+
*/
|
|
504
|
+
onPing(cb: (i: number) => void): void;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* When unparsed data is received
|
|
508
|
+
* @param cb Callback
|
|
509
|
+
*/
|
|
510
|
+
onData(cb: (...data: any[]) => void): void;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* When a client error happens
|
|
514
|
+
* @param cb Callback
|
|
515
|
+
*/
|
|
516
|
+
onError(cb: (...data: any[]) => void): void;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* When a client event happens
|
|
520
|
+
* @param cb Callback
|
|
521
|
+
*/
|
|
522
|
+
onEvent(cb: (...data: any[]) => void): void;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Send a custom packet
|
|
526
|
+
* @param t Packet type
|
|
527
|
+
* @param p Packet data
|
|
528
|
+
*/
|
|
529
|
+
send(t: string, p?: string[]): void;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Send all waiting packets
|
|
533
|
+
*/
|
|
534
|
+
sendQueue(): void;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Close the websocket connection
|
|
538
|
+
* @returns Promise that resolves when websocket is closed
|
|
539
|
+
*/
|
|
540
|
+
end(): Promise<void>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** Built-in indicator class */
|
|
544
|
+
export class BuiltInIndicator {
|
|
545
|
+
/** Indicator script type */
|
|
546
|
+
readonly type: BuiltInIndicatorType;
|
|
547
|
+
|
|
548
|
+
/** Indicator script options */
|
|
549
|
+
readonly options: Record<string, any>;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Create a new built-in indicator
|
|
553
|
+
* @param type Built-in indicator raw type
|
|
554
|
+
*/
|
|
555
|
+
constructor(type: BuiltInIndicatorType);
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Set an option
|
|
559
|
+
* @param key The option you want to change
|
|
560
|
+
* @param value The new value of the property
|
|
561
|
+
* @param FORCE Ignore type and key verifications
|
|
562
|
+
*/
|
|
563
|
+
setOption(key: BuiltInIndicatorOption, value: any, FORCE?: boolean): void;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Pine indicator class */
|
|
567
|
+
export class PineIndicator {
|
|
568
|
+
/** Indicator ID */
|
|
569
|
+
readonly pineId: string;
|
|
570
|
+
|
|
571
|
+
/** Indicator version */
|
|
572
|
+
readonly pineVersion: string;
|
|
573
|
+
|
|
574
|
+
/** Indicator description */
|
|
575
|
+
readonly description: string;
|
|
576
|
+
|
|
577
|
+
/** Indicator short description */
|
|
578
|
+
readonly shortDescription: string;
|
|
579
|
+
|
|
580
|
+
/** Indicator inputs */
|
|
581
|
+
readonly inputs: Record<string, IndicatorInput>;
|
|
582
|
+
|
|
583
|
+
/** Indicator plots */
|
|
584
|
+
readonly plots: Record<string, string>;
|
|
585
|
+
|
|
586
|
+
/** Indicator script type */
|
|
587
|
+
readonly type: IndicatorType;
|
|
588
|
+
|
|
589
|
+
/** Indicator script */
|
|
590
|
+
readonly script: string;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Create a new Pine indicator
|
|
594
|
+
* @param options Indicator options
|
|
595
|
+
*/
|
|
596
|
+
constructor(options: Indicator);
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Set the indicator type
|
|
600
|
+
* @param type Indicator type
|
|
601
|
+
*/
|
|
602
|
+
setType(type?: IndicatorType): void;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Set an option
|
|
606
|
+
* @param key The key can be ID of the property (`in_{ID}`), the inline name or the internalID
|
|
607
|
+
* @param value The new value of the property
|
|
608
|
+
*/
|
|
609
|
+
setOption(key: number | string, value: any): void;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** Pine permission manager class */
|
|
613
|
+
export class PinePermManager {
|
|
614
|
+
sessionId: string;
|
|
615
|
+
pineId: string;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Create a Pine permission manager
|
|
619
|
+
* @param sessionId Token from `sessionid` cookie
|
|
620
|
+
* @param signature Signature cookie
|
|
621
|
+
* @param pineId Indicator ID (Like: PUB;XXXXXXXXXXXXXXXXXXXXX)
|
|
622
|
+
*/
|
|
623
|
+
constructor(sessionId: string, signature: string, pineId: string);
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Get list of authorized users
|
|
627
|
+
* @param limit Fetching limit
|
|
628
|
+
* @param order Fetching order
|
|
629
|
+
* @returns Promise with authorization users
|
|
630
|
+
*/
|
|
631
|
+
getUsers(
|
|
632
|
+
limit?: number,
|
|
633
|
+
order?:
|
|
634
|
+
| "user__username"
|
|
635
|
+
| "-user__username"
|
|
636
|
+
| "created"
|
|
637
|
+
| "-created"
|
|
638
|
+
| "expiration,user__username"
|
|
639
|
+
| "-expiration,user__username",
|
|
640
|
+
): Promise<AuthorizationUser[]>;
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Adds an user to the authorized list
|
|
644
|
+
* @param username User's username
|
|
645
|
+
* @param expiration Expiration date
|
|
646
|
+
* @returns Promise with status
|
|
647
|
+
*/
|
|
648
|
+
addUser(username: string, expiration?: Date | null): Promise<"ok" | "exists" | null>;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Modify an authorization expiration date
|
|
652
|
+
* @param username User's username
|
|
653
|
+
* @param expiration New expiration date
|
|
654
|
+
* @returns Promise with status
|
|
655
|
+
*/
|
|
656
|
+
modifyExpiration(username: string, expiration?: Date | null): Promise<"ok" | null>;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Removes an user to the authorized list
|
|
660
|
+
* @param username User's username
|
|
661
|
+
* @returns Promise with status
|
|
662
|
+
*/
|
|
663
|
+
removeUser(username: string): Promise<"ok" | null>;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** Quote session class */
|
|
667
|
+
export class QuoteSession {
|
|
668
|
+
/** Market constructor */
|
|
669
|
+
readonly Market: new(symbol: MarketSymbol) => QuoteMarket;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Create a new quote session
|
|
673
|
+
* @param options Quote session options
|
|
674
|
+
*/
|
|
675
|
+
constructor(options?: QuoteSessionOptions);
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Delete the quote session
|
|
679
|
+
*/
|
|
680
|
+
delete(): void;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/** Quote market class */
|
|
684
|
+
export class QuoteMarket {
|
|
685
|
+
/**
|
|
686
|
+
* Create a new quote market
|
|
687
|
+
* @param symbol Market symbol
|
|
688
|
+
*/
|
|
689
|
+
constructor(symbol: MarketSymbol);
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Subscribe to market data
|
|
693
|
+
* @param callback Data callback
|
|
694
|
+
*/
|
|
695
|
+
onData(callback: (data: any) => void): void;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Unsubscribe from market data
|
|
699
|
+
*/
|
|
700
|
+
unsubscribe(): void;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/** Chart session class */
|
|
704
|
+
export class ChartSession {
|
|
705
|
+
/** List of periods values */
|
|
706
|
+
readonly periods: PricePeriod[];
|
|
707
|
+
|
|
708
|
+
/** Current market infos */
|
|
709
|
+
readonly infos: MarketInfos;
|
|
710
|
+
|
|
711
|
+
/** Study constructor */
|
|
712
|
+
readonly Study: new(type: BuiltInIndicatorType | PineIndicator, options?: any) => Study;
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Create a new chart session
|
|
716
|
+
*/
|
|
717
|
+
constructor();
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Set series parameters
|
|
721
|
+
* @param timeframe Time frame
|
|
722
|
+
* @param range Range
|
|
723
|
+
* @param reference Reference
|
|
724
|
+
*/
|
|
725
|
+
setSeries(timeframe?: TimeFrame, range?: number, reference?: number | null): void;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Set market symbol
|
|
729
|
+
* @param symbol Market symbol
|
|
730
|
+
* @param options Chart session options
|
|
731
|
+
*/
|
|
732
|
+
setMarket(symbol: MarketSymbol, options?: ChartSessionOptions): void;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Set timezone
|
|
736
|
+
* @param timezone Timezone
|
|
737
|
+
*/
|
|
738
|
+
setTimezone(timezone: Timezone): void;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Fetch more data
|
|
742
|
+
* @param number Number of bars
|
|
743
|
+
*/
|
|
744
|
+
fetchMore(number?: number): void;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Replay step
|
|
748
|
+
* @param number Step number
|
|
749
|
+
*/
|
|
750
|
+
replayStep(number?: number): void;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Start replay mode
|
|
754
|
+
* @param interval Interval in milliseconds
|
|
755
|
+
*/
|
|
756
|
+
replayStart(interval?: number): void;
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Stop replay mode
|
|
760
|
+
*/
|
|
761
|
+
replayStop(): void;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* When symbol is loaded
|
|
765
|
+
* @param cb Callback
|
|
766
|
+
*/
|
|
767
|
+
onSymbolLoaded(cb: () => void): void;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* When data is updated
|
|
771
|
+
* @param cb Callback
|
|
772
|
+
*/
|
|
773
|
+
onUpdate(cb: (periods: PricePeriod[]) => void): void;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* When replay is loaded
|
|
777
|
+
* @param cb Callback
|
|
778
|
+
*/
|
|
779
|
+
onReplayLoaded(cb: () => void): void;
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* When replay resolution changes
|
|
783
|
+
* @param cb Callback
|
|
784
|
+
*/
|
|
785
|
+
onReplayResolution(cb: (resolution: TimeFrame) => void): void;
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* When replay ends
|
|
789
|
+
* @param cb Callback
|
|
790
|
+
*/
|
|
791
|
+
onReplayEnd(cb: () => void): void;
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* When replay point changes
|
|
795
|
+
* @param cb Callback
|
|
796
|
+
*/
|
|
797
|
+
onReplayPoint(cb: (point: number) => void): void;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* When error occurs
|
|
801
|
+
* @param cb Callback
|
|
802
|
+
*/
|
|
803
|
+
onError(cb: (...data: any[]) => void): void;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Delete the chart session
|
|
807
|
+
*/
|
|
808
|
+
delete(): void;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/** Study class */
|
|
812
|
+
export class Study {
|
|
813
|
+
/**
|
|
814
|
+
* Create a new study
|
|
815
|
+
* @param type Study type
|
|
816
|
+
* @param options Study options
|
|
817
|
+
*/
|
|
818
|
+
constructor(type: BuiltInIndicatorType | PineIndicator, options?: any);
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Set study option
|
|
822
|
+
* @param key Option key
|
|
823
|
+
* @param value Option value
|
|
824
|
+
*/
|
|
825
|
+
setOption(key: string, value: any): void;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Delete the study
|
|
829
|
+
*/
|
|
830
|
+
delete(): void;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// ============================================================================
|
|
834
|
+
// FUNCTION EXPORTS
|
|
835
|
+
// ============================================================================
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Get technical analysis
|
|
839
|
+
* @param id Full market id (Example: COINBASE:BTCEUR)
|
|
840
|
+
* @returns Promise with technical analysis results
|
|
841
|
+
*/
|
|
842
|
+
export function getTA(id: string): Promise<Periods>;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Find a symbol (deprecated)
|
|
846
|
+
* @param search Keywords
|
|
847
|
+
* @param filter Category filter
|
|
848
|
+
* @returns Promise with search results
|
|
849
|
+
* @deprecated Use searchMarketV3 instead
|
|
850
|
+
*/
|
|
851
|
+
export function searchMarket(search: string, filter?: MarketType): Promise<SearchMarketResult[]>;
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Find a symbol
|
|
855
|
+
* @param search Keywords
|
|
856
|
+
* @param filter Category filter
|
|
857
|
+
* @returns Promise with search results
|
|
858
|
+
*/
|
|
859
|
+
export function searchMarketV3(search: string, filter?: MarketType): Promise<SearchMarketResult[]>;
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* Find an indicator
|
|
863
|
+
* @param search Keywords
|
|
864
|
+
* @returns Promise with search results
|
|
865
|
+
*/
|
|
866
|
+
export function searchIndicator(search?: string): Promise<SearchIndicatorResult[]>;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Get indicator by ID
|
|
870
|
+
* @param id Indicator ID
|
|
871
|
+
* @param version Indicator version
|
|
872
|
+
* @param session Session token
|
|
873
|
+
* @param signature Session signature
|
|
874
|
+
* @returns Promise with indicator
|
|
875
|
+
*/
|
|
876
|
+
export function getIndicator(
|
|
877
|
+
id: string,
|
|
878
|
+
version?: string,
|
|
879
|
+
session?: string,
|
|
880
|
+
signature?: string,
|
|
881
|
+
): Promise<PineIndicator>;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Login user
|
|
885
|
+
* @param username Username
|
|
886
|
+
* @param password Password
|
|
887
|
+
* @param remember Remember login
|
|
888
|
+
* @param UA User agent
|
|
889
|
+
* @returns Promise with login result
|
|
890
|
+
*/
|
|
891
|
+
export function loginUser(
|
|
892
|
+
username: string,
|
|
893
|
+
password: string,
|
|
894
|
+
remember?: boolean,
|
|
895
|
+
UA?: string,
|
|
896
|
+
): Promise<{ session: string; signature: string }>;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Get user information
|
|
900
|
+
* @param session Session token
|
|
901
|
+
* @param signature Session signature
|
|
902
|
+
* @param location Auth page location
|
|
903
|
+
* @returns Promise with user information
|
|
904
|
+
*/
|
|
905
|
+
export function getUser(session: string, signature?: string, location?: string): Promise<{ authToken: string }>;
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Get private indicators
|
|
909
|
+
* @param session Session token
|
|
910
|
+
* @param signature Session signature
|
|
911
|
+
* @returns Promise with private indicators
|
|
912
|
+
*/
|
|
913
|
+
export function getPrivateIndicators(session: string, signature?: string): Promise<SearchIndicatorResult[]>;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Get chart token
|
|
917
|
+
* @param layout Chart layout
|
|
918
|
+
* @param credentials User credentials
|
|
919
|
+
* @returns Promise with chart token
|
|
920
|
+
*/
|
|
921
|
+
export function getChartToken(layout: string, credentials?: { session?: string; signature?: string }): Promise<string>;
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Get drawings
|
|
925
|
+
* @param layout Chart layout
|
|
926
|
+
* @param symbol Chart symbol
|
|
927
|
+
* @param credentials User credentials
|
|
928
|
+
* @param chartID Chart ID
|
|
929
|
+
* @returns Promise with drawings
|
|
930
|
+
*/
|
|
931
|
+
export function getDrawings(
|
|
932
|
+
layout: string,
|
|
933
|
+
symbol?: string,
|
|
934
|
+
credentials?: { session?: string; signature?: string },
|
|
935
|
+
chartID?: string,
|
|
936
|
+
): Promise<any[]>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@types/mathieuc__tradingview",
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "TypeScript definitions for @mathieuc/tradingview",
|
|
5
|
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mathieuc__tradingview",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"name": "Fırat Özden",
|
|
10
|
+
"githubUsername": "fir4tozden",
|
|
11
|
+
"url": "https://github.com/fir4tozden"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"main": "",
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
|
19
|
+
"directory": "types/mathieuc__tradingview"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {},
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"peerDependencies": {},
|
|
24
|
+
"typesPublisherContentHash": "d7a05c790df53e678f3a85acadfd2427ea8977a4c57a9cbb2101a0703663a3cf",
|
|
25
|
+
"typeScriptVersion": "5.1"
|
|
26
|
+
}
|