Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binance future Minimum Qnt.. get minimum position size fetch or calculate in python #1381

Open
Rightshooter opened this issue Dec 14, 2023 · 1 comment

Comments

@Rightshooter
Copy link

Binance future get minimum position size fetch or calculate in python
Screenshot 2023-12-14 221711
Screenshot 2023-12-14 221807

how to fetch or get or calculate Minimum Qnt..
anyone help me out ..

thank you ...

@Rightshooter
Copy link
Author

Get MIN_NOTIONAL filter information

        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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Rightshooter and others