4

I want to get the price precision of any futures asset.

What I tried:

client.get_symbol_info(symbol='My Symbol')

But this returns the precision of the Spot and I need the precision of the futures.

So theres this Command:

client.futures_exchange_info()

Which return this:

{'timezone': 'UTC', 'serverTime': 1630437033153, 'futuresType': 'U_MARGINED', 'rateLimits': [{'rateLimitType': 'REQUEST_WEIGHT', 'interval': 'MINUTE', 'intervalNum': 1, 'limit': 2400},

{'rateLimitType': 'ORDERS', 'interval': 'MINUTE', 'intervalNum': 1, 'limit': 1200},

{'rateLimitType': 'ORDERS', 'interval': 'SECOND', 'intervalNum': 10, 'limit': 300}],

'exchangeFilters': [],

'assets': [{'asset': 'USDT', 'marginAvailable': True, 'autoAssetExchange': '-10000'},

{'asset': 'BTC', 'marginAvailable': True, 'autoAssetExchange': '-0.00100000'},

{'asset': 'BNB', 'marginAvailable': True, 'autoAssetExchange': '-10'},

{'asset': 'ETH', 'marginAvailable': True, 'autoAssetExchange': '-5'},

{'asset': 'BUSD', 'marginAvailable': True, 'autoAssetExchange': '-10000'}],

'symbols': [{'symbol': 'BTCUSDT', 'pair': 'BTCUSDT', 'contractType': 'PERPETUAL', 'deliveryDate': 4133404800000, 'onboardDate': 1569398400000, 'status': 'TRADING', 'maintMarginPercent': '2.5000', 'requiredMarginPercent': '5.0000', 'baseAsset': 'BTC', 'quoteAsset': 'USDT', 'marginAsset': 'USDT', 'pricePrecision': 2, 'quantityPrecision': 3, 'baseAssetPrecision': 8, 'quotePrecision': 8, 'underlyingType': 'COIN', 'underlyingSubType': [], 'settlePlan': 0, 'triggerProtect': '0.0500', 'liquidationFee': '0.012000', 'marketTakeBound': '0.05', 'filters': [{'minPrice': '556.72', 'maxPrice': '4529764', 'filterType': 'PRICE_FILTER', 'tickSize': '0.01'}, {'stepSize': '0.001', 'filterType': 'LOT_SIZE', 'maxQty': '1000', 'minQty': '0.001'}, {'stepSize': '0.001', 'filterType': 'MARKET_LOT_SIZE', 'maxQty': '200', 'minQty': '0.001'}, {'limit': 200, 'filterType': 'MAX_NUM_ORDERS'}, {'limit': 10, 'filterType': 'MAX_NUM_ALGO_ORDERS'}, {'notional': '5', 'filterType': 'MIN_NOTIONAL'}, {'multiplierDown': '0.9500', 'multiplierUp': '1.0500', 'multiplierDecimal': '4', 'filterType': 'PERCENT_PRICE'}], 'orderTypes': ['LIMIT', 'MARKET', 'STOP', 'STOP_MARKET', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'TRAILING_STOP_MARKET'], 'timeInForce': ['GTC', 'IOC', 'FOK', 'GTX']},

{'symbol': 'ETHUSDT', 'pair': 'ETHUSDT', 'contractType': 'PERPETUAL', 'deliveryDate': 4133404800000, 'onboardDate': 1569398400000, 'status': 'TRADING', 'maintMarginPercent': '2.5000', 'requiredMarginPercent': '5.0000', 'baseAsset': 'ETH', 'quoteAsset': 'USDT', 'marginAsset': 'USDT', 'pricePrecision': 2, 'quantityPrecision': 3, 'baseAssetPrecision': 8, 'quotePrecision': 8, 'underlyingType': 'COIN', 'underlyingSubType': [], 'settlePlan': 0, 'triggerProtect': '0.0500', 'liquidationFee': '0.005000', 'marketTakeBound': '0.05', 'filters': [{'minPrice': '39.86', 'maxPrice': '306177', 'filterType': 'PRICE_FILTER', 'tickSize': '0.01'}, {'stepSize': '0.001', 'filterType': 'LOT_SIZE', 'maxQty': '10000', 'minQty': '0.001'}, {'stepSize': '0.001', 'filterType': 'MARKET_LOT_SIZE', 'maxQty': '2000', 'minQty': '0.001'}, {'limit': 200, 'filterType': 'MAX_NUM_ORDERS'}, {'limit': 10, 'filterType': 'MAX_NUM_ALGO_ORDERS'}, {'notional': '5', 'filterType': 'MIN_NOTIONAL'}, {'multiplierDown': '0.9500', 'multiplierUp': '1.0500', 'multiplierDecimal': '4', 'filterType': 'PERCENT_PRICE'}], 'orderTypes': ['LIMIT', 'MARKET', 'STOP', 'STOP_MARKET', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'TRAILING_STOP_MARKET'], 'timeInForce': ['GTC', 'IOC', 'FOK', 'GTX']}...

and so on.

I need to access the Value of 'quantityPrecision':.

Is there a way to like filter this list for the symbol value like 'BTCUSDT' and then return the Value of 'quantityPrecision':?

Thanks in Advance for any help.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
avr_dude
  • 41
  • 1
  • 2

2 Answers2

5
info = client.futures_exchange_info()
    
def get_precision(symbol):
   for x in info['symbols']:
    if x['symbol'] == symbol:
        return x['quantityPrecision']

print(get_precision('LTCUSDT'))
  • 3
    This answer was flagged as [Low Quality](https://stackoverflow.com/help/review-low-quality) and could benefit from an explanation. Here are some guidelines for [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Code only answers are **not considered good answers** and are likely to be downvoted and/or deleted because they are **less useful** to a community of learners. It's only obvious to you. Explain what it does, and how it's different / better than existing answers (if there are any). [From Review](https://stackoverflow.com/review/low-quality-posts/29858283) – Trenton McKinney Sep 18 '21 at 19:10
  • 1
    This answer is perfect actually. – August Kimo Sep 22 '21 at 14:43
0
async function getLimits(asset) {
    var filtered = await client.futures_exchange_info()
    return Object.values( filtered.symbols).filter(O => O.symbol===asset)[0]
}

getLimits("BTCUSDT")
Cu di
  • 37
  • 6