1

I am having trouble with getting my trade history via the Binance API.

I am using python binance and this is my script:

import config, time
from binance.client import Client

def getAllTickers(client):

    # Get all available exchange tickers
    exchangeInfo = client.get_exchange_info()

    # Extract the tickers general info
    exchangeSymbols = []

    for i in exchangeInfo['symbols']:
        exchangeSymbols.append(i)

    return exchangeSymbols

            
def getMyTrades(client, strSymbol):
    return client.get_my_trades(symbol=strSymbol, fromId=0)

def getMyTradedTickers(client):
    tickers = getAllTickers(client)
    # Extract every ticker where trade happened
    traded = []
    for i in tickers:
        tickerTransactions = getMyTrades(client, i["symbol"])
        if tickerTransactions :
            traded.append(tickerTransactions)
            print(i["symbol"], " transactions available")
        else :
            print(i["symbol"], " has no transactions")
        time.sleep(0.5)
        
    return traded

client = Client(config.API_KEY, config.API_SECRET)

trades = getMyTradedTickers(client)
print(trades)

This returns "has no transactions" for every symbol and and empty list ("[]") at the end.

I know that the client itself and the authentication with the API keys works fine, because I can e.g. get my account balance without any issues.

Is there anything I'm overlooking or that I don't know about?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Kubix
  • 11
  • 2
  • Please include the code as text in the question – Nicolas Forstner Sep 27 '21 at 09:48
  • sorry, I edited my question accordingly – Kubix Sep 27 '21 at 10:29
  • what is the *client* in `client.get_my_trades` ? – balderman Sep 27 '21 at 11:12
  • a function provided by python-binance https://python-binance.readthedocs.io/en/latest/_modules/binance/client.html – Kubix Sep 27 '21 at 11:36
  • @balderman Sorry, I misread your question. The client is an object that is used by other python-binance functions to connect to the binance API via the API keys. I edited my script to include my imports for more clarity. – Kubix Sep 27 '21 at 13:03
  • 1
    Hello brother, I dropped this into my interpreter and it worked fine. I would suggest checking what type of coin you are trading - if you don't trade spot, then this will return an empty string as these are spot only calls. – Bjorgum Sep 29 '21 at 16:39
  • @Bjorgum Thanks! Knowing that the script itself works fine actually helps out a lot! :) – Kubix Sep 30 '21 at 09:26

0 Answers0