Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mathieuc/tradingview",
"version": "3.4.3",
"version": "3.4.4",
"description": "Tradingview instant stocks API, indicator alerts, trading bot, and more !",
"main": "main.js",
"scripts": {
Expand Down
18 changes: 15 additions & 3 deletions src/miscRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,21 @@ module.exports = {
* @function getIndicator
* @param {string} id Indicator ID (Like: PUB;XXXXXXXXXXXXXXXXXXXXX)
* @param {'last' | string} [version] Wanted version of the indicator
* @param {string} [session] User 'sessionid' cookie
* @param {string} [signature] User 'sessionid_sign' cookie
* @returns {Promise<PineIndicator>} Indicator
*/
async getIndicator(id, version = 'last') {
async getIndicator(id, version = 'last', session = '', signature = '') {
const indicID = id.replace(/ |%/g, '%25');

const { data } = await axios.get(
`https://pine-facade.tradingview.com/pine-facade/translate/${indicID}/${version}`,
{ validateStatus },
{
validateStatus,
headers: {
cookie: `${session ? `sessionid=${session};` : ''}${signature ? `sessionid_sign=${signature};` : ''}`,
},
},
);

if (!data.success || !data.result.metaInfo || !data.result.metaInfo.inputs) {
Expand Down Expand Up @@ -455,7 +462,12 @@ module.exports = {
source: ind.scriptSource,
type: (ind.extra && ind.extra.kind) ? ind.extra.kind : 'study',
get() {
return module.exports.getIndicator(ind.scriptIdPart, ind.version);
return module.exports.getIndicator(
ind.scriptIdPart,
ind.version,
session,
signature,
);
},
}));
},
Expand Down