I want to know is this the correct way to calculate lot size and is the fees correct??
def lot_sizing(self, price, amount, btc=False, last=False):
precision_oco = int(markets[self.symbol][‘info’][‘quotePrecision’])
price_str_buy = ‘{:0.0{}f}’.format(price, precision_oco)
btc_per_trade = float(amount)
filters = markets[self.symbol]['info']['filters']
step_size = None
for f in filters:
if f['filterType'] == 'LOT_SIZE':
step_size = float(f['stepSize'])
break
precision = int(round(-math.log(step_size, 10), 0))
if btc:
quantity_buy = (btc_per_trade / price) * 0.995 # calculating the quantity of per coin too buy
else:
quantity_buy = float(amount) * 0.995 # calculating the quantity of per coin too buy
final_quantity_buy = round(quantity_buy, precision) # rounding of the quantity
if last:
final_quantity_buy = final_quantity_buy-step_size # Total tradeable balance
return final_quantity_buy