I am not able to format coins with really low values like VIB/BTC ( value 1.08e-06 ).
This is my format function.
In such coins, format_value returns 0.
Please help
MJW
February 14, 2021, 8:00am
2
Not API-related question. Please find a python dev forum.
I got it, had to use this repo to see how to properly handle the precision.
import math
from binance.client import Client
class BinanceHelper(object):
def __init__(self, api_key, api_secret, base_currency, coin_currency):
self.client = Client(api_key, api_secret)
self.base_currency = base_currency
self.coin_currency = coin_currency
self.symbol = coin_currency + base_currency
def float_precision(self, f, n):
n = int(math.log10(1 / float(n)))
f = math.floor(float(f) * 10 ** n) / 10 ** n
f = "{:0.0{}f}".format(float(f), n)
return str(int(f)) if int(n) == 0 else f
def get_price(self):
price = None
tickers = self.client.get_all_tickers()
for ticker in tickers:
This file has been truncated. show original
This precision thing is not well documented by the API