@@ -1865,11 +1865,12 @@ let api = function Binance() {
18651865 * @param {array/string } symbols - an array or string of symbols to query
18661866 * @param {string } interval - the time interval
18671867 * @param {function } callback - callback function
1868+ * @param {int } limit - maximum results, no more than 1000
18681869 * @return {string } the websocket endpoint
18691870 */
1870- chart : function chart ( symbols , interval , callback ) {
1871+ chart : function chart ( symbols , interval , callback , limit = 500 ) {
18711872 let reconnect = function ( ) {
1872- if ( Binance . options . reconnect ) chart ( symbols , interval , callback ) ;
1873+ if ( Binance . options . reconnect ) chart ( symbols , interval , callback , limit ) ;
18731874 } ;
18741875
18751876 let symbolChartInit = function ( symbol ) {
@@ -1897,8 +1898,8 @@ let api = function Binance() {
18971898 }
18981899 } ;
18991900
1900- let getSymbolKlineSnapshot = function ( symbol ) {
1901- publicRequest ( base + 'v1/klines' , { symbol : symbol , interval : interval } , function ( error , data ) {
1901+ let getSymbolKlineSnapshot = function ( symbol , limit = 500 ) {
1902+ publicRequest ( base + 'v1/klines' , { symbol : symbol , interval : interval , limit : limit } , function ( error , data ) {
19021903 klineData ( symbol , interval , data ) ;
19031904 //Binance.options.log('/klines at ' + Binance.info[symbol][interval].timestamp);
19041905 if ( typeof Binance . klineQueue [ symbol ] [ interval ] !== 'undefined' ) {
@@ -1917,12 +1918,12 @@ let api = function Binance() {
19171918 return symbol . toLowerCase ( ) + '@kline_' + interval ;
19181919 } ) ;
19191920 subscription = subscribeCombined ( streams , handleKlineStreamData , reconnect ) ;
1920- symbols . forEach ( getSymbolKlineSnapshot ) ;
1921+ symbols . forEach ( element => getSymbolKlineSnapshot ( element , limit ) ) ;
19211922 } else {
19221923 let symbol = symbols ;
19231924 symbolChartInit ( symbol ) ;
19241925 subscription = subscribe ( symbol . toLowerCase ( ) + '@kline_' + interval , handleKlineStreamData , reconnect ) ;
1925- getSymbolKlineSnapshot ( symbol ) ;
1926+ getSymbolKlineSnapshot ( symbol , limit ) ;
19261927 }
19271928 return subscription . endpoint ;
19281929 } ,
0 commit comments