0

I'm trying to pull a value that's nested out, looking get the value at "minPrice" but I don't seem to be able to isolate it.

data = {'symbol': 'MKRUSD', 
        'quoteCommissionPrecision': 4,
        'orderTypes': ['LIMIT', 'LIMIT_MAKER', 'MARKET', 'STOP_LOSS_LIMIT', 'TAKE_PROFIT_LIMIT'], 
        'isSpotTradingAllowed': True,
        'isMarginTradingAllowed': False,
        'filters': 
            [{'filterType': 'PRICE_FILTER', 'minPrice': '0.0001', 'maxPrice': '100000.0000', 'tickSize': '0.0001'}, 
             {'filterType': 'PERCENT_PRICE', 'multiplierUp': '5', 'multiplierDown': '0.2', 'avgPriceMins': 5},
             {'filterType': 'LOT_SIZE', 'minQty': '0.00001000', 'maxQty': '900000.00000000', 'stepSize': '0.00001000'},
             {'filterType': 'MIN_NOTIONAL', 'minNotional': '10.0000', 'applyToMarket': True, 'avgPriceMins': 5},
             {'filterType': 'ICEBERG_PARTS', 'limit': 10},
             {'filterType': 'MAX_NUM_ORDERS', 'maxNumOrders': 200},
             {'filterType': 'MAX_NUM_ALGO_ORDERS', 'maxNumAlgoOrders': 5}],
 'permissions': ['SPOT']}

print(symbol_info["symbol"])
print(symbol_info["filters"]["filterType"]["LOT_SIZE"]["minQty"])

I don't think it's json because, when I do type, it comes back as a python dictionary, and the False/True seem to look that way. But maybe it is, and I need to read it somehow first?

2 Answers 2

1

First of all, you are using the wrong variable to access the data. Assign data to symbol_info variable and then access it or use the data variable directly.

print(data["symbol"])

Second, the filtertype is a dict inside a list. So you have to use index to access it.

print(type(data["filters"])) #<- this is list
print(data["filters"][2]["filterType"])
print(data["filters"][2]["minQty"])
Sign up to request clarification or add additional context in comments.

Comments

0

Hope it helps

data = {'symbol': 'MKRUSD', 
        'quoteCommissionPrecision': 4,
        'orderTypes': ['LIMIT', 'LIMIT_MAKER', 'MARKET', 'STOP_LOSS_LIMIT', 'TAKE_PROFIT_LIMIT'], 
        'isSpotTradingAllowed': True,
        'isMarginTradingAllowed': False,
        'filters': 
            [{'filterType': 'PRICE_FILTER', 'minPrice': '0.0001', 'maxPrice': '100000.0000', 'tickSize': '0.0001'}, 
            {'filterType': 'PERCENT_PRICE', 'multiplierUp': '5', 'multiplierDown': '0.2', 'avgPriceMins': 5},
            {'filterType': 'LOT_SIZE', 'minQty': '0.00001000', 'maxQty': '900000.00000000', 'stepSize': '0.00001000'},
            {'filterType': 'MIN_NOTIONAL', 'minNotional': '10.0000', 'applyToMarket': True, 'avgPriceMins': 5},
            {'filterType': 'ICEBERG_PARTS', 'limit': 10},
            {'filterType': 'MAX_NUM_ORDERS', 'maxNumOrders': 200},
            {'filterType': 'MAX_NUM_ALGO_ORDERS', 'maxNumAlgoOrders': 5}],'permissions': ['SPOT']}
for key,val in data["filters"][0].items():
  if key =="minPrice":
    print(val)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.