OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to get value of asset (coin) in USD using the python wrapper for Binance API?

  • Thread starter Thread starter thecpaptain
  • Start date Start date
T

thecpaptain

Guest
Using the python-binance v1.0.15, how do I get the price of an asset in USD? For example getting the price of BTC in USD. (The reason I want this is to exploit price differences in the prices of stablecoins, such as the prices of USDT and USDC).

I was expecting to be able to do so using price = client.get_symbol_ticker(symbol='BTCUSD') but that gives me an Invalid symbol error.

Checking (what I believe to be) a list of all symbols, I only find trading pairs involving stablecoins (such as USDT), but no prices given in actual USD (fiat). As an example, here are all the symbols I find containing the strings 'USD' and 'BTC':

['BTCUSDT', 'BTCTUSD', 'TUSDBTC', 'BTCUSDC', 'BTCUSDS', 'BTCBUSD', 'BTCUPUSDT', 'BTCDOWNUSDT', 'SUSDBTC', 'BTCSTBUSD', 'BTCSTUSDT', 'BTCUSDP'] (ref #)

produced using the following code

Code:
info = client.get_all_tickers()
symbols = []
for i in range(0, len(info)):
    symbol = info[i]['symbol']
    if 'BTC' in symbol and 'USD' in symbol:
        symbols.append(symbol)

I have a hunch that it might have something to do with using binance.com rather than binance.us. Unclear why this would be the case however.

Any ideas?

EDIT: clarification - the underlying problem is that the trading tickers I'm looking for don't exist. I find no trading tickers that specify the price of a coin in USD, such as 'BTCUSD'. This is what the above list of symbols (ref#) is supposed to demonstrate.
<p>Using the python-binance v1.0.15, how do I get the price of an asset in USD? For example getting the price of BTC in USD. (The reason I want this is to exploit price differences in the prices of stablecoins, such as the prices of USDT and USDC).</p>
<p>I was expecting to be able to do so using <code>price = client.get_symbol_ticker(symbol='BTCUSD')</code> but that gives me an <code>Invalid symbol</code> error.</p>
<p>Checking (what I believe to be) a list of all symbols, I only find trading pairs involving stablecoins (such as USDT), but no prices given in actual USD (fiat). As an example, here are all the symbols I find containing the strings <code>'USD'</code> and <code>'BTC'</code>:</p>
<p>['BTCUSDT', 'BTCTUSD', 'TUSDBTC', 'BTCUSDC', 'BTCUSDS', 'BTCBUSD', 'BTCUPUSDT', 'BTCDOWNUSDT', 'SUSDBTC', 'BTCSTBUSD', 'BTCSTUSDT', 'BTCUSDP'] (ref #)</p>
<p>produced using the following code</p>
<pre><code>info = client.get_all_tickers()
symbols = []
for i in range(0, len(info)):
symbol = info['symbol']
if 'BTC' in symbol and 'USD' in symbol:
symbols.append(symbol)
</code></pre>
<p>I have a hunch that it might have something to do with using binance.com rather than binance.us. Unclear why this would be the case however.</p>
<p>Any ideas?</p>
<p><strong>EDIT:</strong> clarification - the underlying problem is that the trading tickers I'm looking for don't exist. I find no trading tickers that specify the price of a coin in USD, such as 'BTCUSD'. This is what the above list of symbols (ref#) is supposed to demonstrate.</p>
 

Latest posts

M
Replies
0
Views
1
MusicLovingIndianGirl
M
Q
Replies
0
Views
1
quora question
Q
Top