Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView
1.31k stars 307 forks source link

Missing data in examples/FromToData.js - provided date and custom date #231

Open ITOskarWozniak opened 4 months ago

ITOskarWozniak commented 4 months ago

Describe the bug I'm trying to verify functionality in example below https://github.com/Mathieu2301/TradingView-API/blob/main/examples/FromToData.js But getting empty periods for chart and SUPERTREND indicator Tested on "1600000000" and "1705000000" Tickers: "BINANCE:BTCEUR" and "NASDAQ:PLCE"

To Reproduce Run below snipped or from example

    const client = new TradingView.Client();

    const chart = new client.Session.Chart();
    chart.setMarket('NASDAQ:PLCE', {
        timeframe: '1',
        range: 1000, // Can be positive to get before or negative to get after
        to: 1705000000,
    });

// This works with indicators

    TradingView.getIndicator('STD;Supertrend').then(async (indic: any) => {
        console.log(`Loading '${indic.description}' study...`);
        const SUPERTREND = new chart.Study(indic);

        SUPERTREND.onUpdate(() => {
            console.log('Prices periods:', chart.periods);
            console.log('Study periods:', SUPERTREND.periods);
            client.end();
        });
    });

Expected behavior Expecting to get OHLC data + any indicator (VOL is the best) from any ticket at specific data

Screenshots image

Environment: OS: MacOS Node version: v18.17.0 Executing it as chrome extension

Additional context I'm attaching all socket data field logged in "this.#ws.onmessage " in client.js

[
  "~m~348~m~{\"session_id\":\"<0.27096.1970>_lon1-charts-35-webchart-13@lon1-compute-35\",\"timestamp\":1708098173,\"timestampMs\":1708098173995,\"release\":\"registry.xtools.tv/tvbs_release/webchart:release_207-41\",\"studies_metadata_hash\":\"ce6cef671d23dbb90bbf1df3ee17b5dd14933cbf\",\"auth_scheme_vsn\":2,\"protocol\":\"json\",\"via\":\"93.123.102.179:443\",\"javastudies\":[\"3.64\"]}",
  "~m~97~m~{\"m\":\"series_loading\",\"p\":[\"cs_mr6b5ThoAdmH\",\"$prices\",\"s1\"],\"t\":1708098174,\"t_ms\":1708098174268}~m~108~m~{\"m\":\"study_loading\",\"p\":[\"cs_mr6b5ThoAdmH\",\"st_p9clqpmArvHw\",\"s1_st1\"],\"t\":1708098174,\"t_ms\":1708098174268}~m~4311~m~{\"m\":\"symbol_resolved\",\"p\":[\"cs_mr6b5ThoAdmH\",\"ser_1\",{\"source2\":{\"country\":\"US\",\"description\":\"Cboe One\",\"exchange-type\":\"exchange\",\"id\":\"BATS\",\"name\":\"Cboe One\",\"url\":\"markets.cboe.com/us/equities/overview/\"},\"currency_code\":\"USD\",\"source_id\":\"BATS\",\"session_holidays\":\"20000117,20000221,20000421,20000529,20000704,20000904,20001123,20001225,20010101,20010115,20010219,20010413,20010528,20010704,20010903,20011122,20011225,20020101,20020121,20020218,20020329,20020527,20020704,20020902,20021128,20021225,20030101,20030120,20030217,20030418,20030526,20030704,20030901,20031127,20031225,20040101,20040119,20040216,20040409,20040531,20040611,20040705,20040906,20041125,20041224,20050117,20050221,20050325,20050530,20050704,20050905,20051124,20051226,20060102,20060116,20060220,20060414,20060529,20060704,20060904,20061123,20061225,20070101,20070102,20070115,20070219,20070406,20070528,20070704,20070903,20071122,20071225,20080101,20080121,20080218,20080321,20080526,20080704,20080901,20081127,20081225,20090101,20090119,20090216,20090410,20090525,20090703,20090907,20091126,20091225,20100101,20100118,20100215,20100402,20100531,20100705,20100906,20101125,20101224,20110117,20110221,20110422,20110530,20110704,20110905,20111124,20111226,20120102,20120116,20120220,20120406,20120528,20120704,20120903,20121122,20121225,20130101,20130121,20130218,20130329,20130527,20130704,20130902,20131128,20131225,20140101,20140120,20140217,20140418,20140526,20140704,20140901,20141127,20141225,20150101,20150119,20150216,20150403,20150525,20150703,20150907,20151126,20151225,20160101,20160118,20160215,20160325,20160530,20160704,20160905,20161124,20161226,20170102,20170116,20170220,20170414,20170529,20170704,20170904,20171123,20171225,20180101,20180115,20180219,20180330,20180528,20180704,20180903,20181122,20181225,20190101,20190121,20190218,20190419,20190527,20190704,20190902,20191128,20191225,20200101,20200120,20200217,20200410,20200525,20200703,20200907,20201126,20201225,20210101,20210118,20210215,20210402,20210531,20210705,20210906,20211125,20211224,20220117,20220221,20220415,20220530,20220620,20220704,20220905,20221124,20221226,20230102,20230116,20230220,20230407,20230529,20230619,20230704,20230904,20231123,20231225,20240101,20240115,20240219,20240329,20240527,20240619,20240704,20240902,20241128,20241225,20250101,20250120,20250217,20250418,20250526,20250619,20250704,20250901,20251127,20251225\",\"subsession_id\":\"regular\",\"provider_id\":\"ice\",\"currency_id\":\"USD\",\"country\":\"US\",\"pro_perm\":\"nasdaq\",\"allowed_adjustment\":\"any\",\"short_description\":\"Children's Place, Inc. (The)\",\"variable_tick_size\":\"0.0001 1 0.01\",\"sedol\":\"2106791\",\"isin\":\"US1689051076\",\"language\":\"en\",\"local_description\":\"Children's Place, Inc. (The)\",\"name\":\"PLCE\",\"full_name\":\"BATS:PLCE\",\"pro_name\":\"NASDAQ:PLCE\",\"base_name\":[\"NASDAQ:PLCE\"],\"description\":\"Children's Place, Inc. (The)\",\"exchange\":\"Cboe One\",\"pricescale\":100,\"pointvalue\":1.0,\"minmov\":1,\"session\":\"0930-1600\",\"session_display\":\"0930-1600\",\"subsessions\":[{\"description\":\"Regular Trading Hours\",\"id\":\"regular\",\"private\":false,\"session\":\"0930-1600\",\"session-correction\":\"0930-1300:20190703,20191129,20191224,20211126,20221125,20230703,20231124\",\"session-display\":\"0930-1600\"},{\"description\":\"Extended Trading Hours\",\"id\":\"extended\",\"private\":false,\"session\":\"0400-2000\",\"session-correction\":\"0400-2000:20211126,20221125,20230703,20231124;0400-2100:20190703,20191129,20191224\",\"session-display\":\"0400-2000\"},{\"description\":\"Premarket\",\"id\":\"premarket\",\"private\":true,\"session\":\"0400-0930\",\"session-display\":\"0400-0930\"},{\"description\":\"Postmarket\",\"id\":\"postmarket\",\"private\":true,\"session\":\"1600-2000\",\"session-correction\":\"1300-2000:20211126,20221125,20230703,20231124;1300-2100:20190703,20191129,20191224\",\"session-display\":\"1600-2000\"}],\"type\":\"stock\",\"typespecs\":[\"common\"],\"has_intraday\":true,\"fractional\":false,\"listed_exchange\":\"NASDAQ\",\"legs\":[\"BATS:PLCE\"],\"is_tradable\":true,\"minmove2\":0,\"timezone\":\"America/New_York\",\"aliases\":[],\"alternatives\":[\"BATS_DLY:PLCE\"],\"is_replayable\":true,\"has_adjustment\":true,\"has_extended_hours\":true,\"bar_source\":\"trade\",\"bar_transform\":\"none\",\"bar_fillgaps\":false,\"visible_plots_set\":\"ohlcv\",\"is-tickbars-available\":true,\"figi\":{\"country-composite\":\"BBG000JK9DK4\",\"exchange-level\":\"BBG000JK9DK4\"}}],\"t\":1708098174,\"t_ms\":1708098174268}~m~159~m~{\"m\":\"series_completed\",\"p\":[\"cs_mr6b5ThoAdmH\",\"$prices\",\"streaming\",\"s1\",{\"rt_update_period\":5,\"data_completed\":\"limit\"}],\"t\":1708098174,\"t_ms\":1708098174268}",
  "~m~152~m~{\"m\":\"du\",\"p\":[\"cs_mr6b5ThoAdmH\",{\"st_p9clqpmArvHw\":{\"node\":\"lon1-35-studies-charts-free-2-runner-8\",\"st\":[],\"ns\":{\"d\":\"\",\"indexes\":[]},\"t\":\"s1_st1\"}}]}~m~110~m~{\"m\":\"study_completed\",\"p\":[\"cs_mr6b5ThoAdmH\",\"st_p9clqpmArvHw\",\"s1_st1\"],\"t\":1708098174,\"t_ms\":1708098174441}",
  "~m~348~m~{\"session_id\":\"<0.17160.1955>_lon1-charts-35-webchart-16@lon1-compute-35\",\"timestamp\":1708098174,\"timestampMs\":1708098174492,\"release\":\"registry.xtools.tv/tvbs_release/webchart:release_207-41\",\"studies_metadata_hash\":\"ce6cef671d23dbb90bbf1df3ee17b5dd14933cbf\",\"auth_scheme_vsn\":2,\"protocol\":\"json\",\"via\":\"93.123.102.179:443\",\"javastudies\":[\"3.64\"]}",
  "~m~97~m~{\"m\":\"series_loading\",\"p\":[\"cs_m3dcaenwWta5\",\"$prices\",\"s1\"],\"t\":1708098174,\"t_ms\":1708098174622}~m~108~m~{\"m\":\"study_loading\",\"p\":[\"cs_m3dcaenwWta5\",\"st_j2t39OIfMqTo\",\"s1_st1\"],\"t\":1708098174,\"t_ms\":1708098174622}~m~4311~m~{\"m\":\"symbol_resolved\",\"p\":[\"cs_m3dcaenwWta5\",\"ser_1\",{\"source2\":{\"country\":\"US\",\"description\":\"Cboe One\",\"exchange-type\":\"exchange\",\"id\":\"BATS\",\"name\":\"Cboe One\",\"url\":\"markets.cboe.com/us/equities/overview/\"},\"currency_code\":\"USD\",\"source_id\":\"BATS\",\"session_holidays\":\"20000117,20000221,20000421,20000529,20000704,20000904,20001123,20001225,20010101,20010115,20010219,20010413,20010528,20010704,20010903,20011122,20011225,20020101,20020121,20020218,20020329,20020527,20020704,20020902,20021128,20021225,20030101,20030120,20030217,20030418,20030526,20030704,20030901,20031127,20031225,20040101,20040119,20040216,20040409,20040531,20040611,20040705,20040906,20041125,20041224,20050117,20050221,20050325,20050530,20050704,20050905,20051124,20051226,20060102,20060116,20060220,20060414,20060529,20060704,20060904,20061123,20061225,20070101,20070102,20070115,20070219,20070406,20070528,20070704,20070903,20071122,20071225,20080101,20080121,20080218,20080321,20080526,20080704,20080901,20081127,20081225,20090101,20090119,20090216,20090410,20090525,20090703,20090907,20091126,20091225,20100101,20100118,20100215,20100402,20100531,20100705,20100906,20101125,20101224,20110117,20110221,20110422,20110530,20110704,20110905,20111124,20111226,20120102,20120116,20120220,20120406,20120528,20120704,20120903,20121122,20121225,20130101,20130121,20130218,20130329,20130527,20130704,20130902,20131128,20131225,20140101,20140120,20140217,20140418,20140526,20140704,20140901,20141127,20141225,20150101,20150119,20150216,20150403,20150525,20150703,20150907,20151126,20151225,20160101,20160118,20160215,20160325,20160530,20160704,20160905,20161124,20161226,20170102,20170116,20170220,20170414,20170529,20170704,20170904,20171123,20171225,20180101,20180115,20180219,20180330,20180528,20180704,20180903,20181122,20181225,20190101,20190121,20190218,20190419,20190527,20190704,20190902,20191128,20191225,20200101,20200120,20200217,20200410,20200525,20200703,20200907,20201126,20201225,20210101,20210118,20210215,20210402,20210531,20210705,20210906,20211125,20211224,20220117,20220221,20220415,20220530,20220620,20220704,20220905,20221124,20221226,20230102,20230116,20230220,20230407,20230529,20230619,20230704,20230904,20231123,20231225,20240101,20240115,20240219,20240329,20240527,20240619,20240704,20240902,20241128,20241225,20250101,20250120,20250217,20250418,20250526,20250619,20250704,20250901,20251127,20251225\",\"subsession_id\":\"regular\",\"provider_id\":\"ice\",\"currency_id\":\"USD\",\"country\":\"US\",\"pro_perm\":\"nasdaq\",\"allowed_adjustment\":\"any\",\"short_description\":\"Children's Place, Inc. (The)\",\"variable_tick_size\":\"0.0001 1 0.01\",\"sedol\":\"2106791\",\"isin\":\"US1689051076\",\"language\":\"en\",\"local_description\":\"Children's Place, Inc. (The)\",\"name\":\"PLCE\",\"full_name\":\"BATS:PLCE\",\"pro_name\":\"NASDAQ:PLCE\",\"base_name\":[\"NASDAQ:PLCE\"],\"description\":\"Children's Place, Inc. (The)\",\"exchange\":\"Cboe One\",\"pricescale\":100,\"pointvalue\":1.0,\"minmov\":1,\"session\":\"0930-1600\",\"session_display\":\"0930-1600\",\"subsessions\":[{\"description\":\"Regular Trading Hours\",\"id\":\"regular\",\"private\":false,\"session\":\"0930-1600\",\"session-correction\":\"0930-1300:20190703,20191129,20191224,20211126,20221125,20230703,20231124\",\"session-display\":\"0930-1600\"},{\"description\":\"Extended Trading Hours\",\"id\":\"extended\",\"private\":false,\"session\":\"0400-2000\",\"session-correction\":\"0400-2000:20211126,20221125,20230703,20231124;0400-2100:20190703,20191129,20191224\",\"session-display\":\"0400-2000\"},{\"description\":\"Premarket\",\"id\":\"premarket\",\"private\":true,\"session\":\"0400-0930\",\"session-display\":\"0400-0930\"},{\"description\":\"Postmarket\",\"id\":\"postmarket\",\"private\":true,\"session\":\"1600-2000\",\"session-correction\":\"1300-2000:20211126,20221125,20230703,20231124;1300-2100:20190703,20191129,20191224\",\"session-display\":\"1600-2000\"}],\"type\":\"stock\",\"typespecs\":[\"common\"],\"has_intraday\":true,\"fractional\":false,\"listed_exchange\":\"NASDAQ\",\"legs\":[\"BATS:PLCE\"],\"is_tradable\":true,\"minmove2\":0,\"timezone\":\"America/New_York\",\"aliases\":[],\"alternatives\":[\"BATS_DLY:PLCE\"],\"is_replayable\":true,\"has_adjustment\":true,\"has_extended_hours\":true,\"bar_source\":\"trade\",\"bar_transform\":\"none\",\"bar_fillgaps\":false,\"visible_plots_set\":\"ohlcv\",\"is-tickbars-available\":true,\"figi\":{\"country-composite\":\"BBG000JK9DK4\",\"exchange-level\":\"BBG000JK9DK4\"}}],\"t\":1708098174,\"t_ms\":1708098174622}~m~159~m~{\"m\":\"series_completed\",\"p\":[\"cs_m3dcaenwWta5\",\"$prices\",\"streaming\",\"s1\",{\"rt_update_period\":5,\"data_completed\":\"limit\"}],\"t\":1708098174,\"t_ms\":1708098174622}~m~152~m~{\"m\":\"du\",\"p\":[\"cs_m3dcaenwWta5\",{\"st_j2t39OIfMqTo\":{\"node\":\"lon1-35-studies-charts-free-2-runner-8\",\"st\":[],\"ns\":{\"d\":\"\",\"indexes\":[]},\"t\":\"s1_st1\"}}]}~m~110~m~{\"m\":\"study_completed\",\"p\":[\"cs_m3dcaenwWta5\",\"st_j2t39OIfMqTo\",\"s1_st1\"],\"t\":1708098174,\"t_ms\":1708098174622}"
]
TenViki commented 4 months ago

I am currently facing the same problem, it would be nice to have a way to fix this.