@mathieuc/tradingview 3.4.2 → 3.4.4
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/README.md +6 -2
- package/package.json +1 -1
- package/src/miscRequests.js +17 -5
package/README.md
CHANGED
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
Get realtime market prices and indicator values from Tradingview !
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## 🟢 Need help with your project?
|
|
13
|
+
|
|
14
|
+
🚀 Click [here](https://forms.gle/qPp5RKo8L55C5oJE7) for personalized assistance on your project.
|
|
15
|
+
|
|
16
|
+
## 🔵 Telegram group
|
|
13
17
|
|
|
14
18
|
👉 To get help, exchange tips, find collaborators, developers, missions, etc...
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
Join the Telegram group of the TradingView-API Community: [t.me/tradingview_api](https://t.me/tradingview_api)
|
|
17
21
|
|
|
18
22
|
## Features
|
|
19
23
|
|
package/package.json
CHANGED
package/src/miscRequests.js
CHANGED
|
@@ -243,14 +243,21 @@ module.exports = {
|
|
|
243
243
|
* @function getIndicator
|
|
244
244
|
* @param {string} id Indicator ID (Like: PUB;XXXXXXXXXXXXXXXXXXXXX)
|
|
245
245
|
* @param {'last' | string} [version] Wanted version of the indicator
|
|
246
|
+
* @param {string} [session] User 'sessionid' cookie
|
|
247
|
+
* @param {string} [signature] User 'sessionid_sign' cookie
|
|
246
248
|
* @returns {Promise<PineIndicator>} Indicator
|
|
247
249
|
*/
|
|
248
|
-
async getIndicator(id, version = 'last') {
|
|
250
|
+
async getIndicator(id, version = 'last', session = '', signature = '') {
|
|
249
251
|
const indicID = id.replace(/ |%/g, '%25');
|
|
250
252
|
|
|
251
253
|
const { data } = await axios.get(
|
|
252
254
|
`https://pine-facade.tradingview.com/pine-facade/translate/${indicID}/${version}`,
|
|
253
|
-
{
|
|
255
|
+
{
|
|
256
|
+
validateStatus,
|
|
257
|
+
headers: {
|
|
258
|
+
cookie: `${session ? `sessionid=${session};` : ''}${signature ? `sessionid_sign=${signature};` : ''}`,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
254
261
|
);
|
|
255
262
|
|
|
256
263
|
if (!data.success || !data.result.metaInfo || !data.result.metaInfo.inputs) {
|
|
@@ -412,8 +419,8 @@ module.exports = {
|
|
|
412
419
|
following: parseFloat(/,"following":([0-9]*?),/.exec(data)?.[1] || 0),
|
|
413
420
|
followers: parseFloat(/,"followers":([0-9]*?),/.exec(data)?.[1] || 0),
|
|
414
421
|
notifications: {
|
|
415
|
-
following: parseFloat(/"notification_count":\{"following":([0-9]*),/.exec(data)?.[1]
|
|
416
|
-
user: parseFloat(/"notification_count":\{"following":[0-9]*,"user":([0-9]*)/.exec(data)?.[1]
|
|
422
|
+
following: parseFloat(/"notification_count":\{"following":([0-9]*),/.exec(data)?.[1] ?? 0),
|
|
423
|
+
user: parseFloat(/"notification_count":\{"following":[0-9]*,"user":([0-9]*)/.exec(data)?.[1] ?? 0),
|
|
417
424
|
},
|
|
418
425
|
session,
|
|
419
426
|
signature,
|
|
@@ -455,7 +462,12 @@ module.exports = {
|
|
|
455
462
|
source: ind.scriptSource,
|
|
456
463
|
type: (ind.extra && ind.extra.kind) ? ind.extra.kind : 'study',
|
|
457
464
|
get() {
|
|
458
|
-
return module.exports.getIndicator(
|
|
465
|
+
return module.exports.getIndicator(
|
|
466
|
+
ind.scriptIdPart,
|
|
467
|
+
ind.version,
|
|
468
|
+
session,
|
|
469
|
+
signature,
|
|
470
|
+
);
|
|
459
471
|
},
|
|
460
472
|
}));
|
|
461
473
|
},
|