Search code examples
apipython-3.7symbolsbinancebinance-api-client

How to get symbol info in binance socket manager api?


I am actually developing a binance api bot and I am trying to get the symbol info for the following currency pairs:

BTCAUD

BTCEUR

BTCGBP

And I tried following code to do it:

import time
import matplotlib.pyplot as plt
from binance.client import Client
from binance.websockets import BinanceSocketManager
from binance.enums import *
from binance.exceptions import BinanceAPIException, BinanceOrderException
from twisted.internet import reactor
import os
import pandas as pd

from time import sleep

api_key='your api key'
api_secret='your secret key'
client = Client(api_key, api_secret)



#One:
btc_price = client.get_symbol_ticker(symbol="BTC_AUD")
# print full output (dictionary)
print(btc_price)


#Two:
btc_price = client.get_symbol_ticker(symbol="BTCAUD")
# print full output (dictionary)
print(btc_price)

#Three:
btc_price = client.get_symbol_ticker(symbol="BTC_AUDT")
# print full output (dictionary)
print(btc_price)

#Four:    
btc_price = client.get_symbol_ticker(symbol="BTCAUDT")
# print full output (dictionary)
print(btc_price)

But I am unable to get the ticker and info of these currency pairs and getting this error on above all four methods.

OUTPUT:
    raise BinanceAPIException(self.response)
binance.exceptions.BinanceAPIException: APIError(code=-1121): Invalid symbol.

Would anyone like to help me?

Thanks in advance.


Solution

  • I found myself what was wrong, actually binance test api only has BTCUSDT and ETHUSDT for testing purpose, so I changed my test api and secret key with the original ones and checked it this way:

    btc_price = client.get_symbol_ticker(symbol="BTCAUD")
    print(btc_price)
    
    OUTPUT:
    
    {'symbol': 'BTCAUD', 'price': '51341.55000000'}
    

    It worked without any error.