binance-exchange / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Agg trades startTime and endTime not working

cecilymiller opened this issue · comments

binance.aggTrades("BTCUSDT", { startTime: 1587704945000, endTime: 1587713502000 }, (error, response) => {
    console.log('response', response); // empty, no results
})

If there is not a bug, that means there weren't any trade actions over 2 hours, which cannot be true.

I have tried several other startTime and endTimecombinations and each time no trades are returned.

  1. use Error Handling or at least reporting for all financial applications
    example:
    binance.aggTrades( "BTCUSDT", { startTime, endTime }, ( error, response ) => {
        if ( error ) return console.warn( error );
        console.log( 'response', response );
    } )
  1. More than 1 hours between startTime and endTime are not allowed.

  2. Binance downtime was during the window you specified: https://binance.zendesk.com/hc/en-us/articles/360042668671

  3. Working example:

    const oneHour = 60 * 60 * 1e3, now = new Date().getTime();
    const startTime = now - oneHour, endTime = now;
    const aggTrades = await binance.aggTrades( "BTCUSDT", { startTime, endTime } );
    console.info( aggTrades );

Thanks for fast reply.

More than 1 hours between startTime and endTime are not allowed.

https://github.com/binance-exchange/binance-api-node#aggtrades - docs says the following:

startTime and endTime must be less than 24 hours.

That is from different API but I assume the both uses the same endpoints to fetch the data under the hood.

Anyway, thanks for your answer, I just wanted to point out that a bit misleading info