Fetch data from Futures API (client.futures_exchange_info()) - Fetch pricePrecision for every coin

Hello.
I need to get the pricePrecision indicator in futures coins.
However I am getting this much info from ticker size from spot market API with no troubles, I dont seem to find a way to get it in the same way as I do for SPOT.

For Spot I do the following:

How can i get the same info for futures?

Thanks.

def trade():
 #Place Buy market orders for each volatile coin found’’’
  volume, lowest_price = convert_volume()
  orders = {}
  for coin in volume:
# only buy if the there are no active trades on the coin
    if coin not in coins_bought or coins_bought[coin] == None:
      print(f" preparing to buy {volume[coin]} {coin}") 
      info = client.futures_symbol_info(coin)
      step_size = info["filters"][0]["tickSize"]
      lot_size = step_size.index("1") - 1
      # try to create a real order if the test orders did not raise an exception
      try:
        buy_limit = client.futures_create_order(
        symbol=coin,
        side="BUY",
        type="LIMIT",
        price =round(float(lowest_price[coin]["lastPrice"])*0.985,lot_size),
        timeInForce="GTC",
        quantity=round(volume[coin],lot_size)
 )
# error handling here in case position cannot be placed
      except Exception as e:
       print(e)

    else:
      print(f"Signal detected, but there is already an active trade on {coin}")
  return orders, lowest_price, volume`enter code here`

The following is an incorrect way to obtain the PRICE_FILTER filter.

info["filters"][0]

Assuming you are using python, you should apply something similar

tick_size = next((filter["tickSize"] for filter in info["filters"] if filter["filterType"] == "PRICE_FILTER"), None)

if tick_size is None:
    raise Exception("PRICE_FILTER tick size not found")

If you still have issues, please contact the owner of the library you are using.

1 Like