I know lately I’m asking to much questions but I’m trying to understand api correctly so thank u all for Answering my questions
so this time I try to get same minutes trades with future websocket aggerated trades and futures aggregated trades they started working same time and gave me different results
for websocket I used this code
import websocket,json,ssl,threading,datetime
def takeInfo(symbol):
negatif_data = []
pozitif_data = []
#oran = float(tp)*100/float(hacim)
def on_message(ws, message):
if datetime.datetime.now() <=m:
json_message = json.loads(message)
quantity = json_message["q"]
price = json_message["p"]
isBuyerTrue = json_message["m"]
usdt = float(quantity)*float(price)
if isBuyerTrue:
usdt = -usdt
negatif_data.append(usdt)
yon = "sell"
else:
pozitif_data.append(usdt)
yon = "buy"
f = open("data.txt","a+")
f.write(message)
f.close()
# print(f"fiyat : {price}, miktar : {quantity}, usdt : {usdt}, symbol : {symbol}")
else:
print(f"Last one minutes volume : {sum(negatif_data)+sum(pozitif_data)}")
ws.close()
def on_close(ws, close_status_code, close_msg)
print("### closed ###")
while True:
m = datetime.datetime.now() + datetime.timedelta(minutes = 1)
print(m)
ws = websocket.WebSocketApp(f"wss://fstream.binance.com/ws/{symbol}@aggTrade",on_message=on_message,on_close=on_close)
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
takeInfo("btcusdt")
and I used this code for futures aggregated trades
from config import Connect
import time
client = Connect().make_connection()
print("logged in")
pozitif_data = []
negatif_data = []
a = client.futures_aggregate_trades(symbol="BTCUSDT")[-1]["a"]
time.sleep(60)
trades = client.futures_aggregate_trades(symbol="BTCUSDT",fromid=a)
data = [(trades[x]['q'], trades[x]['m']) for x in range(len(trades))]
for q,isBuyerMaker in data:
if isBuyerMaker == True:
usdt = float(q)
usdt = -usdt
negatif_data.append(usdt)
else:
usdt =float(q)
pozitif_data.append(usdt)
toplam = sum(negatif_data)+sum(pozitif_data)
print("Last 1 minutes volume :", toplam )
and first one gave me -1034107.9589800024
and second one gave me -4.356999999999971
and for that moments candlestick trading view volume indicator says 126 so why is this happening what am I doing wrong its clear I have a mistake somewhere thank you for helping me already