Open Rightshooter opened 6 months ago
min_notional_filter = next((x for x in symbol_info['filters'] if x['filterType'] == 'MIN_NOTIONAL'), None)
min_notional = float(min_notional_filter['notional']) if min_notional_filter else None
# Get LOT_SIZE filter information for Min Trade Amount
lot_size_filter = next((x for x in symbol_info['filters'] if x['filterType'] == 'LOT_SIZE'), None)
min_trade_amount = float(lot_size_filter['minQty']) if lot_size_filter else None
# Get current ticker price
ticker_response = client.futures_symbol_ticker(symbol=symbol)
if 'price' in ticker_response:
ticker_price = float(ticker_response['price'])
else:
print(f"Symbol: {symbol}, 'price' not found in ticker response.")
continue
# Calculate the equivalent BTC quantity for the minimum notional value
quantity = min_notional / ticker_price
# Append symbol, min notional, min trade amount, and ticker price information to the list
symbol_info_list.append({
'Symbol': symbol,
'Min Notional': min_notional,
'Min Trade Amount': min_trade_amount,
'Ticker Price': ticker_price,
'Calculated Quantity': quantity
})
Here's a breakdown of what each part of the code is doing:
MIN_NOTIONAL filter:
It searches for the filter with the type 'MIN_NOTIONAL' in the list of filters for a particular trading symbol. Extracts the 'notional' value from the filter, converting it to a float. If the filter is not found, sets min_notional to None. LOT_SIZE filter:
Similar to MIN_NOTIONAL, it searches for the filter with the type 'LOT_SIZE'. Extracts the 'minQty' (minimum quantity) value from the filter, converting it to a float. If the filter is not found, sets min_trade_amount to None. Ticker Price:
Retrieves the current ticker price for the given trading symbol using the futures_symbol_ticker method from the Binance API. If the 'price' is present in the ticker response, converts it to a float. If 'price' is not found, prints a message and continues to the next symbol. Calculating Equivalent BTC Quantity:
Calculates the equivalent BTC quantity for the minimum notional value using the formula quantity = min_notional / ticker_price. Appending Information to List:
Appends a dictionary containing symbol information (symbol, min_notional, min_trade_amount, ticker_price, and calculated quantity) to the symbol_info_list.
Binance future get minimum position size fetch or calculate in python
how to fetch or get or calculate Minimum Qnt.. anyone help me out ..
thank you ...