Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView
1.47k stars 332 forks source link

Premium account doesn't return 20000 bars for server='prodata' #223

Open somethingbloodyfunky opened 10 months ago

somethingbloodyfunky commented 10 months ago
const TradingView = require('@mathieuc/tradingview');

server = 'prodata';

var authToken;
var session;
var signature;
var sessionHash;
var privateChannel;

session: 'xxx';
signature: 'xxx';
sessionHash: 'xxx';
privateChannel: 'xxx';
authToken: 'xxx';

const client = new TradingView.Client({
    server: server,
    authToken: authToken,
    signature: signature,
    session: session,
    sessionHash: sessionHash,
    privateChannel: privateChannel
});

const chart = new client.Session.Chart();
const exchange = process.argv[2];
const symbol = process.argv[3];
const timeframe = process.argv[4];
const range = 100000;
const ticker = exchange + ':' + symbol;

chart.setTimezone('UTC');

chart.setMarket(ticker, {
    timeframe: timeframe,
    range: range
});

chart.onSymbolLoaded(() => {
    console.log(chart.infos.name, 'loaded !');
});

(async () => {
    chart.onUpdate(() => {
        console.log('OK', chart.periods);
        client.end();
    });
})();
e.g., node script.js BATS SPY 15

Despite the 'Premium' account of TradingView allowing for the download of 20000 historical bars, my login credentials (authToken, session, sessionHash etc) allow for only 10000 bars from the prodata server. I get 10000 bars even without logging-in so long as use the prodata server.

How can I get 20000 bars as I normally do if I manually export data from within the TradingView desktop app using my Premium account?