@mathieuc/tradingview 3.5.2 → 4.0.0-beta.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.
Files changed (120) hide show
  1. package/README.md +112 -51
  2. package/dist/chart/chart-session.d.ts +114 -0
  3. package/dist/chart/chart-session.js +339 -0
  4. package/dist/chart/graphics.d.ts +129 -0
  5. package/dist/chart/graphics.js +153 -0
  6. package/dist/chart/index.d.ts +11 -0
  7. package/dist/chart/index.js +6 -0
  8. package/dist/chart/strategy.d.ts +100 -0
  9. package/dist/chart/strategy.js +51 -0
  10. package/dist/chart/study.d.ts +60 -0
  11. package/dist/chart/study.js +171 -0
  12. package/dist/chart/timeframes.d.ts +7 -0
  13. package/dist/chart/timeframes.js +22 -0
  14. package/dist/chart/types.d.ts +105 -0
  15. package/dist/chart/types.js +9 -0
  16. package/dist/client/client.d.ts +89 -0
  17. package/dist/client/client.js +254 -0
  18. package/dist/client/index.d.ts +4 -0
  19. package/dist/client/index.js +2 -0
  20. package/dist/client/transport.d.ts +27 -0
  21. package/dist/client/transport.js +38 -0
  22. package/dist/data/candles.d.ts +40 -0
  23. package/dist/data/candles.js +101 -0
  24. package/dist/data/history.d.ts +61 -0
  25. package/dist/data/history.js +101 -0
  26. package/dist/data/index.d.ts +28 -0
  27. package/dist/data/index.js +15 -0
  28. package/dist/data/indicators.d.ts +54 -0
  29. package/dist/data/indicators.js +139 -0
  30. package/dist/data/operation.d.ts +71 -0
  31. package/dist/data/operation.js +205 -0
  32. package/dist/data/provider.d.ts +23 -0
  33. package/dist/data/provider.js +11 -0
  34. package/dist/data/quotes.d.ts +33 -0
  35. package/dist/data/quotes.js +117 -0
  36. package/dist/data/symbols.d.ts +9 -0
  37. package/dist/data/symbols.js +19 -0
  38. package/dist/errors.d.ts +53 -0
  39. package/dist/errors.js +24 -0
  40. package/dist/events.d.ts +36 -0
  41. package/dist/events.js +70 -0
  42. package/dist/http/account.d.ts +47 -0
  43. package/dist/http/account.js +127 -0
  44. package/dist/http/index.d.ts +11 -0
  45. package/dist/http/index.js +5 -0
  46. package/dist/http/indicators.d.ts +37 -0
  47. package/dist/http/indicators.js +144 -0
  48. package/dist/http/layouts.d.ts +36 -0
  49. package/dist/http/layouts.js +24 -0
  50. package/dist/http/market.d.ts +45 -0
  51. package/dist/http/market.js +59 -0
  52. package/dist/http/pine-permissions.d.ts +29 -0
  53. package/dist/http/pine-permissions.js +56 -0
  54. package/dist/http/request.d.ts +44 -0
  55. package/dist/http/request.js +83 -0
  56. package/dist/index.d.ts +21 -0
  57. package/dist/index.js +19 -0
  58. package/dist/indicators/builtin-indicator.d.ts +17 -0
  59. package/dist/indicators/builtin-indicator.js +75 -0
  60. package/dist/indicators/index.d.ts +8 -0
  61. package/dist/indicators/index.js +2 -0
  62. package/dist/indicators/pine-indicator.d.ts +63 -0
  63. package/dist/indicators/pine-indicator.js +101 -0
  64. package/dist/protocol/compression.d.ts +12 -0
  65. package/dist/protocol/compression.js +83 -0
  66. package/dist/protocol/framing.d.ts +59 -0
  67. package/dist/protocol/framing.js +68 -0
  68. package/dist/protocol/ids.d.ts +2 -0
  69. package/dist/protocol/ids.js +10 -0
  70. package/dist/protocol/index.d.ts +4 -0
  71. package/dist/protocol/index.js +3 -0
  72. package/dist/quote/fields.d.ts +35 -0
  73. package/dist/quote/fields.js +21 -0
  74. package/dist/quote/index.d.ts +4 -0
  75. package/dist/quote/index.js +2 -0
  76. package/dist/quote/quote-session.d.ts +73 -0
  77. package/dist/quote/quote-session.js +205 -0
  78. package/docs/README.es.md +58 -0
  79. package/docs/README.fr.md +58 -0
  80. package/docs/README.pt.md +58 -0
  81. package/docs/data-api.md +229 -0
  82. package/docs/low-level-api.md +213 -0
  83. package/docs/migration-v4.md +128 -0
  84. package/docs/v4-coverage.md +192 -0
  85. package/docs/v4-reliability.md +33 -0
  86. package/package.json +55 -20
  87. package/.env.sample +0 -2
  88. package/.eslintrc.js +0 -28
  89. package/.gitattributes +0 -2
  90. package/docs/DOCS.md +0 -3
  91. package/examples/AllPrivateIndicators.js +0 -44
  92. package/examples/BuiltInIndicator.js +0 -51
  93. package/examples/CustomChartType.js +0 -123
  94. package/examples/CustomTimeframe.js +0 -31
  95. package/examples/Errors.js +0 -155
  96. package/examples/FakeReplayMode.js +0 -40
  97. package/examples/FromToData.js +0 -35
  98. package/examples/GetDrawings.js +0 -27
  99. package/examples/GraphicIndicator.js +0 -42
  100. package/examples/MultipleSyncFetch.js +0 -44
  101. package/examples/PinePermManage.js +0 -67
  102. package/examples/ReplayMode.js +0 -103
  103. package/examples/Search.js +0 -14
  104. package/examples/SimpleChart.js +0 -63
  105. package/examples/UserLogin.js +0 -16
  106. package/main.js +0 -11
  107. package/src/chart/graphicParser.js +0 -308
  108. package/src/chart/session.js +0 -553
  109. package/src/chart/study.js +0 -435
  110. package/src/classes/BuiltInIndicator.js +0 -137
  111. package/src/classes/PineIndicator.js +0 -132
  112. package/src/classes/PinePermManager.js +0 -159
  113. package/src/client.js +0 -298
  114. package/src/miscRequests.js +0 -609
  115. package/src/protocol.js +0 -60
  116. package/src/quote/market.js +0 -132
  117. package/src/quote/session.js +0 -125
  118. package/src/types.js +0 -36
  119. package/src/utils.js +0 -20
  120. package/vite.config.js +0 -7
@@ -1,308 +0,0 @@
1
- const TRANSLATOR = {
2
- /** @typedef {'right' | 'left' | 'both' | 'none'} ExtendValue */
3
- extend: {
4
- r: 'right',
5
- l: 'left',
6
- b: 'both',
7
- n: 'none',
8
- },
9
-
10
- /** @typedef {'price' | 'abovebar' | 'belowbar'} yLocValue */
11
- yLoc: {
12
- pr: 'price',
13
- ab: 'abovebar',
14
- bl: 'belowbar',
15
- },
16
-
17
- /**
18
- * @typedef {'none' | 'xcross' | 'cross' | 'triangleup'
19
- * | 'triangledown' | 'flag' | 'circle' | 'arrowup'
20
- * | 'arrowdown' | 'label_up' | 'label_down' | 'label_left'
21
- * | 'label_right' | 'label_lower_left' | 'label_lower_right'
22
- * | 'label_upper_left' | 'label_upper_right' | 'label_center'
23
- * | 'square' | 'diamond'
24
- * } LabelStyleValue
25
- * */
26
- labelStyle: {
27
- n: 'none',
28
- xcr: 'xcross',
29
- cr: 'cross',
30
- tup: 'triangleup',
31
- tdn: 'triangledown',
32
- flg: 'flag',
33
- cir: 'circle',
34
- aup: 'arrowup',
35
- adn: 'arrowdown',
36
- lup: 'label_up',
37
- ldn: 'label_down',
38
- llf: 'label_left',
39
- lrg: 'label_right',
40
- llwlf: 'label_lower_left',
41
- llwrg: 'label_lower_right',
42
- luplf: 'label_upper_left',
43
- luprg: 'label_upper_right',
44
- lcn: 'label_center',
45
- sq: 'square',
46
- dia: 'diamond',
47
- },
48
-
49
- /**
50
- * @typedef {'solid' | 'dotted' | 'dashed'| 'arrow_left'
51
- * | 'arrow_right' | 'arrow_both'} LineStyleValue
52
- */
53
- lineStyle: {
54
- sol: 'solid',
55
- dot: 'dotted',
56
- dsh: 'dashed',
57
- al: 'arrow_left',
58
- ar: 'arrow_right',
59
- ab: 'arrow_both',
60
- },
61
-
62
- /** @typedef {'solid' | 'dotted' | 'dashed'} BoxStyleValue */
63
- boxStyle: {
64
- sol: 'solid',
65
- dot: 'dotted',
66
- dsh: 'dashed',
67
- },
68
- };
69
-
70
- /**
71
- * @typedef {'auto' | 'huge' | 'large'
72
- * | 'normal' | 'small' | 'tiny'} SizeValue
73
- */
74
- /** @typedef {'top' | 'center' | 'bottom'} VAlignValue */
75
- /** @typedef {'left' | 'center' | 'right'} HAlignValue */
76
- /** @typedef {'none' | 'auto'} TextWrapValue */
77
- /**
78
- * @typedef {'top_left' | 'top_center' | 'top_right'
79
- * | 'middle_left' | 'middle_center' | 'middle_right'
80
- * | 'bottom_left' | 'bottom_center' | 'bottom_right'
81
- * } TablePositionValue
82
- */
83
-
84
- /**
85
- * @typedef {Object} GraphicLabel
86
- * @prop {number} id Drawing ID
87
- * @prop {number} x Label x position
88
- * @prop {number} y Label y position
89
- * @prop {yLocValue} yLoc yLoc mode
90
- * @prop {string} text Label text
91
- * @prop {LabelStyleValue} style Label style
92
- * @prop {number} color
93
- * @prop {number} textColor
94
- * @prop {SizeValue} size Label size
95
- * @prop {HAlignValue} textAlign Text horizontal align
96
- * @prop {string} toolTip Tooltip text
97
- */
98
-
99
- /**
100
- * @typedef {Object} GraphicLine
101
- * @prop {number} id Drawing ID
102
- * @prop {number} x1 First x position
103
- * @prop {number} y1 First y position
104
- * @prop {number} x2 Second x position
105
- * @prop {number} y2 Second y position
106
- * @prop {ExtendValue} extend Horizontal extend
107
- * @prop {LineStyleValue} style Line style
108
- * @prop {number} color Line color
109
- * @prop {number} width Line width
110
- */
111
-
112
- /**
113
- * @typedef {Object} GraphicBox
114
- * @prop {number} id Drawing ID
115
- * @prop {number} x1 First x position
116
- * @prop {number} y1 First y position
117
- * @prop {number} x2 Second x position
118
- * @prop {number} y2 Second y position
119
- * @prop {number} color Box color
120
- * @prop {number} bgColor Background color
121
- * @prop {ExtendValue} extend Horizontal extend
122
- * @prop {BoxStyleValue} style Box style
123
- * @prop {number} width Box width
124
- * @prop {string} text Text
125
- * @prop {SizeValue} textSize Text size
126
- * @prop {number} textColor Text color
127
- * @prop {VAlignValue} textVAlign Text vertical align
128
- * @prop {HAlignValue} textHAlign Text horizontal align
129
- * @prop {TextWrapValue} textWrap Text wrap
130
- */
131
-
132
- /**
133
- * @typedef {Object} TableCell
134
- * @prop {number} id Drawing ID
135
- * @prop {string} text Cell text
136
- * @prop {number} width Cell width
137
- * @prop {number} height Cell height
138
- * @prop {number} textColor Text color
139
- * @prop {HAlignValue} textHAlign Text horizontal align
140
- * @prop {VAlignValue} textVAlign Text Vertical align
141
- * @prop {SizeValue} textSize Text size
142
- * @prop {number} bgColor Background color
143
- */
144
-
145
- /**
146
- * @typedef {Object} GraphicTable
147
- * @prop {number} id Drawing ID
148
- * @prop {TablePositionValue} position Table position
149
- * @prop {number} rows Number of rows
150
- * @prop {number} columns Number of columns
151
- * @prop {number} bgColor Background color
152
- * @prop {number} frameColor Frame color
153
- * @prop {number} frameWidth Frame width
154
- * @prop {number} borderColor Border color
155
- * @prop {number} borderWidth Border width
156
- * @prop {() => TableCell[][]} cells Table cells matrix
157
- */
158
-
159
- /**
160
- * @typedef {Object} GraphicHorizline
161
- * @prop {number} id Drawing ID
162
- * @prop {number} level Y position of the line
163
- * @prop {number} startIndex Start index of the line (`chart.periods[line.startIndex]`)
164
- * @prop {number} endIndex End index of the line (`chart.periods[line.endIndex]`)
165
- * @prop {boolean} extendRight Is the line extended to the right
166
- * @prop {boolean} extendLeft Is the line extended to the left
167
- */
168
-
169
- /**
170
- * @typedef {Object} GraphicPoint
171
- * @prop {number} index X position of the point
172
- * @prop {number} level Y position of the point
173
- */
174
-
175
- /**
176
- * @typedef {Object} GraphicPolygon
177
- * @prop {number} id Drawing ID
178
- * @prop {GraphicPoint[]} points List of polygon points
179
- */
180
-
181
- /**
182
- * @typedef {Object} GraphicHorizHist
183
- * @prop {number} id Drawing ID
184
- * @prop {number} priceLow Low Y position
185
- * @prop {number} priceHigh High Y position
186
- * @prop {number} firstBarTime First X position
187
- * @prop {number} lastBarTime Last X position
188
- * @prop {number[]} rate List of values
189
- */
190
-
191
- /**
192
- * @typedef {Object} GraphicData List of drawings indexed by type
193
- * @prop {GraphicLabel[]} labels List of labels drawings
194
- * @prop {GraphicLine[]} lines List of lines drawings
195
- * @prop {GraphicBox[]} boxes List of boxes drawings
196
- * @prop {GraphicTable[]} tables List of tables drawings
197
- * @prop {GraphicPolygon[]} polygons List of polygons drawings
198
- * @prop {GraphicHorizHist[]} horizHists List of horizontal histograms drawings
199
- * @prop {GraphicHorizline[]} horizLines List of horizontal lines drawings
200
- */
201
-
202
- /**
203
- * @param {Object} rawGraphic Raw graphic data
204
- * @param {Object} indexes Drawings xPos indexes
205
- * @returns {GraphicData}
206
- */
207
- module.exports = function graphicParse(rawGraphic = {}, indexes = []) {
208
- // console.log('indexes', indexes);
209
- return {
210
- labels: Object.values(rawGraphic.dwglabels ?? {}).map((l) => ({
211
- id: l.id,
212
- x: indexes[l.x],
213
- y: l.y,
214
- yLoc: TRANSLATOR.yLoc[l.yl] ?? l.yl,
215
- text: l.t,
216
- style: TRANSLATOR.labelStyle[l.st] ?? l.st,
217
- color: l.ci,
218
- textColor: l.tci,
219
- size: l.sz,
220
- textAlign: l.ta,
221
- toolTip: l.tt,
222
- })),
223
-
224
- lines: Object.values(rawGraphic.dwglines ?? {}).map((l) => ({
225
- id: l.id,
226
- x1: indexes[l.x1],
227
- y1: l.y1,
228
- x2: indexes[l.x2],
229
- y2: l.y2,
230
- extend: TRANSLATOR.extend[l.ex] ?? l.ex,
231
- style: TRANSLATOR.lineStyle[l.st] ?? l.st,
232
- color: l.ci,
233
- width: l.w,
234
- })),
235
-
236
- boxes: Object.values(rawGraphic.dwgboxes ?? {}).map((b) => ({
237
- id: b.id,
238
- x1: indexes[b.x1],
239
- y1: b.y1,
240
- x2: indexes[b.x2],
241
- y2: b.y2,
242
- color: b.c,
243
- bgColor: b.bc,
244
- extend: TRANSLATOR.extend[b.ex] ?? b.ex,
245
- style: TRANSLATOR.boxStyle[b.st] ?? b.st,
246
- width: b.w,
247
- text: b.t,
248
- textSize: b.ts,
249
- textColor: b.tc,
250
- textVAlign: b.tva,
251
- textHAlign: b.tha,
252
- textWrap: b.tw,
253
- })),
254
-
255
- tables: Object.values(rawGraphic.dwgtables ?? {}).map((t) => ({
256
- id: t.id,
257
- position: t.pos,
258
- rows: t.rows,
259
- columns: t.cols,
260
- bgColor: t.bgc,
261
- frameColor: t.frmc,
262
- frameWidth: t.frmw,
263
- borderColor: t.brdc,
264
- borderWidth: t.brdw,
265
- cells: () => {
266
- const matrix = [];
267
- Object.values(rawGraphic.dwgtablecells ?? {}).forEach((cell) => {
268
- if (cell.tid !== t.id) return;
269
- if (!matrix[cell.row]) matrix[cell.row] = [];
270
- matrix[cell.row][cell.col] = {
271
- id: cell.id,
272
- text: cell.t,
273
- width: cell.w,
274
- height: cell.h,
275
- textColor: cell.tc,
276
- textHAlign: cell.tha,
277
- textVAlign: cell.tva,
278
- textSize: cell.ts,
279
- bgColor: cell.bgc,
280
- };
281
- });
282
- return matrix;
283
- },
284
- })),
285
-
286
- horizLines: Object.values(rawGraphic.horizlines ?? {}).map((h) => ({
287
- ...h,
288
- startIndex: indexes[h.startIndex],
289
- endIndex: indexes[h.endIndex],
290
- })),
291
-
292
- polygons: Object.values(rawGraphic.polygons ?? {}).map((p) => ({
293
- ...p,
294
- points: p.points.map((pt) => ({
295
- ...pt,
296
- index: indexes[pt.index],
297
- })),
298
- })),
299
-
300
- horizHists: Object.values(rawGraphic.hhists ?? {}).map((h) => ({
301
- ...h,
302
- firstBarTime: indexes[h.firstBarTime],
303
- lastBarTime: indexes[h.lastBarTime],
304
- })),
305
-
306
- raw: () => rawGraphic,
307
- };
308
- };