@mathieuc/tradingview 3.4.3 → 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/package.json +1 -1
- package/src/miscRequests.js +15 -3
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) {
|
|
@@ -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
|
},
|