@@ -819,7 +819,7 @@ let api = function Binance() {
819819 */
820820 roundStep : function ( qty , stepSize ) {
821821 const precision = stepSize . toString ( ) . split ( '.' ) [ 1 ] . length || 0 ;
822- return ( ( Math . round ( qty / stepSize ) | 0 ) * stepSize ) . toFixed ( precision ) ;
822+ return ( ( Math . floor ( qty / stepSize ) | 0 ) * stepSize ) . toFixed ( precision ) ;
823823 } ,
824824
825825 /**
@@ -1188,6 +1188,55 @@ let api = function Binance() {
11881188 if ( callback ) return callback . call ( this , error , data , symbol ) ;
11891189 } ) ;
11901190 } ,
1191+
1192+ /**
1193+ * Gets the depth information for a given symbol
1194+ * @param {string } symbol - the symbol
1195+ * @param {function } callback - the callback function
1196+ * @param {int } limit - limit the number of returned orders
1197+ * @return {undefined }
1198+ */
1199+ depth : function ( symbol , callback , limit = 100 ) {
1200+ publicRequest ( base + 'v1/depth' , { symbol : symbol , limit : limit } , function ( error , data ) {
1201+ return callback . call ( this , error , depthData ( data ) , symbol ) ;
1202+ } ) ;
1203+ } ,
1204+
1205+ /**
1206+ * Gets the average prices of a given symbol
1207+ * @param {string } symbol - the symbol
1208+ * @param {function } callback - the callback function
1209+ * @return {undefined }
1210+ */
1211+ avgPrice : function ( symbol , callback = false ) {
1212+ let socksproxy = process . env . socks_proxy || false ;
1213+
1214+ let opt = {
1215+ url : base + 'v3/avgPrice?symbol=' + symbol ,
1216+ timeout : Binance . options . recvWindow
1217+ } ;
1218+
1219+ if ( socksproxy !== false ) {
1220+ socksproxy = proxyReplacewithIp ( socksproxy ) ;
1221+ if ( Binance . options . verbose ) Binance . options . log ( 'using socks proxy server ' + socksproxy ) ;
1222+ opt . agentClass = SocksProxyAgent ;
1223+ opt . agentOptions = {
1224+ protocol : parseProxy ( socksproxy ) [ 0 ] ,
1225+ host : parseProxy ( socksproxy ) [ 1 ] ,
1226+ port : parseProxy ( socksproxy ) [ 2 ]
1227+ }
1228+ }
1229+
1230+ request ( opt , function ( error , response , body ) {
1231+ if ( ! callback ) return ;
1232+
1233+ if ( error ) return callback ( error ) ;
1234+
1235+ if ( response && response . statusCode !== 200 ) return callback ( response ) ;
1236+
1237+ if ( callback ) return callback ( null , priceData ( JSON . parse ( body ) ) ) ;
1238+ } ) ;
1239+ } ,
11911240
11921241 /**
11931242 * Gets the depth information for a given symbol
0 commit comments