Recent Trades is wrong ?

I am using this code to get recent trades for 5 minutes

 negatif_data = []
 pozitif_data = []
 while datetime.datetime.now() < fiveMinutesLater:

        recent_trades = client.futures_recent_trades(symbol=symbol)
        data = [(recent_trades[x]['time'],recent_trades[x]['price'], recent_trades[x]['quoteQty'], recent_trades[x]['isBuyerMaker']) for x in range(len(recent_trades))]
        for time,price,qty,isBuyerMaker in data:

            if isBuyerMaker == True:
                usdt = float(qty)
                usdt = -usdt
                 negatif_data.append(usdt)

            else:
                usdt =float(qty)
                pozitif_data.append(usdt)

and also using this code to get 24h volume

    time_end= datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
    time_ago= datetime.datetime.now()- datetime.timedelta(days=1)
    time_ago = time_ago.strftime("%Y-%m-%d %H:%M")
    volume = client.futures_historical_klines(symbol=symbol,interval='1d',start_str=time_ago,end_str=time_end)[0][5]

but somehow when I sum pozitif_data it gives a bigger value than volume how is that even possible?

Recent Trades is not intended to be used to calculate Market Volume.

You can use Aggregated Trade List to calculate Market Volume.

@tantialex is there a way to use aggregated trade list without giving fromid
cause I don’t know how to find fromid or can u tell me how can I find fromid and use aggregated trade list

Use the startTime and endTime which you are using to retrieve klines.

If the amount of aggTrades received from the endpoint hits the limit, repeat the process and insert the aggTradeId of the last aggTrade. Repeat this process till the endpoint returns less aggTrades than the limit.

@tantialex do i have to use fromid for use aggregated trade list
can’t I use it with just start and end time

Yes, however this may cause issues with the limit if there are multiple aggTrades with the same timestamp.

I suggest using aggTradeId to be safe.

@tantialex sorry for asking to much questions but I couldn’t use aggtrade I tried this code

   client.futures_aggregate_trades(symbol = symbol,startTime = "02-11-2021 17:20",endTime = "02-11-2021 17:21")

but it is not working it gives 6 minutes ago and now’s datas what am I doing wrong

startTime and endTime need to be in epoch milliseconds format (ex: 1635876778000).

Snippet for python

milliseconds_since_epoch = datetime.datetime.now().timestamp() * 1000

@tantialex so this should work right?

        nexts= datetime.datetime(2021,11,2,18,45,00).timestamp() * 1000
        end = datetime.datetime(2021,11,2,18,46,00).timestamp() * 1000
        aggregate = client.futures_aggregate_trades(symbol = symbol,startTime = nexts,endTime = end)

why isn’t this working

@BerkeErtep These are programming questions which are not the focus of this forum. Although as good practice, you should always print/debug your local code to troubleshoot.
In this case, doing print(datetime.datetime(2021,11,2,18,46,00).timestamp() * 1000) gives 1635878760000.0, but timestamps doesn’t have decimals.

thank u for all of your helps u helped me so much @tantialex @aisling