python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

There is an error in quantity calculation, but where I could not solve it. Can you help me?

Open kuratkull opened this issue 5 years ago • 0 comments

code


@space_it
def get_ticker_info(client, tick):
	info = client.get_ticker(symbol=tick+"BTC")
	precision = client.get_symbol_info(symbol=tick+"BTC")['quoteAssetPrecision']
	price = client.get_symbol_ticker(symbol=tick+"BTC")
	price = float(price['price'])

	t = ['symbol', 'priceChangePercent', 'lastPrice', 'volume']
	print_table(t, [info[i] for i in t])
	return price, precision


@space_it
def get_max_quantity(client, balance, value, tick, precision):
	print("[{}] calculating order quantity...".format(get_time()))
	qty = balance/value

	s = client.get_symbol_info('{}BTC'.format(tick))['filters'][2]['stepSize']
	qty = round(step(float(s), qty), precision)

	print(
		"[{}] calculated purchasing power: {} x {}".format(
			get_time(),
			qty,
			tick
			)
		)

	return qty

kuratkull avatar Apr 04 '21 19:04 kuratkull