Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Binance Testnet user_socket() problem.

Aperta
#1,388 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api

Direzione di ricerca

Start by reproducing the example with Python 3.10, Binance Python 1.0.10, AsyncClient, and BinanceSocketManager.user_socket() against the testnet API URL. Trace the user_socket task alongside order_market_buy() and get_my_trades(); done means identifying why no balance response is received and documenting a verified correction or limitation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Binance Python: 1.0.10
Python: 3.10

Hello,

I have published this issue also on Binance Developer., but didn't get answer.

My issue:

I don't get response from user_socket and do not know if my code is right.

I use Python Binance and asyncIO for parallel processing.

I’m expecting from my program:

  • sending an order via order_market_buy() (ok and tested via get_my_trades())
    
  • response from user_socket() after change in balance. (that's not running, I receive nothing)
    

What's wrong with my code? Do you have any suggestions for my following code?

import asyncio
from binance import AsyncClient, BinanceSocketManager
import os
import datetime

api_key = os.environ.get('binance_api_key_test')
api_secret = os.environ.get('binance_api_secret_test')


async def user_socket(client):
    bm = BinanceSocketManager(client)
    ts = bm.user_socket()
    async with ts as tscm:
        while True:
            res = await tscm.recv()
            print("user socket: ", res)


async def set_order_market_buy(symbol, quantity, client):
    await asyncio.sleep(5)  # waiting user_socket
    await client.order_market_buy(
        symbol=symbol,
        quantity=quantity)
    result = await client.get_my_trades(symbol=symbol, limit=1)
    print("last order: ", datetime.datetime.fromtimestamp(result[0]['time']/1000))  # converts trade time in normal date

    await client.close_connection()


async def aux():
    client = await AsyncClient.create(api_key, api_secret)
    client.API_URL = 'https://testnet.binance.vision/api'
    user_socket2 = asyncio.create_task(user_socket(client=client))
    task_order = asyncio.create_task(set_order_market_buy(symbol='BTCUSDT', quantity=0.001, client=client))

    await user_socket2
    await task_order


if __name__ == "__main__":
    asyncio.run(aux())
Lingua principale
Python
Stelle
7.2k
Fork
2.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sammchardy/python-binance

Tutte le issue di sammchardy/python-binance

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.