I have such dict:
[{'info': {'symbol': 'GMT', 'contract_code': 'GMT-USDT', 'volume': '4.000000000000000000', 'available': '4.000000000000000000', 'frozen': '0E-18', 'cost_open': '1.425850000000000000', 'cost_hold': '1.425850000000000000', 'profit_unreal': '0.037880000000000000', 'profit_rate': '0.006641652347722411', 'lever_rate': '1', 'position_margin': '5.741280000000000000', 'direction': 'buy', 'profit': '0.037880000000000000', 'last_price': '1.43532', 'margin_asset': 'USDT', 'margin_mode': 'cross', 'margin_account': 'USDT', 'contract_type': 'swap', 'pair': 'GMT-USDT', 'business_type': 'swap', 'trade_partition': 'USDT', 'position_mode': 'dual_side'}, 'symbol': 'GMT/USDT:USDT', 'contracts': 4.0, 'contractSize': 1.0, 'entryPrice': 1.42585, 'collateral': None, 'side': 'long', 'unrealizedProfit': 0.03788, 'leverage': 1.0, 'percentage': 0.6641652347722411, 'marginMode': 'cross', 'marginType': 'cross', 'notional': 5.74128, 'markPrice': None, 'liquidationPrice': None, 'initialMargin': 5.74128, 'initialMarginPercentage': 1.0, 'maintenanceMargin': None, 'maintenanceMarginPercentage': None, 'marginRatio': None, 'timestamp': 1652721082637, 'datetime': '2022-05-16T17:11:22.637Z'}, {'info': {'symbol': 'SHIB', 'contract_code': 'SHIB-USDT', 'volume': '671.000000000000000000', 'available': '671.000000000000000000', 'frozen': '0E-18', 'cost_open': '0.000011800000000000', 'cost_hold': '0.000011800000000000', 'profit_unreal': '0.040260000000000000', 'profit_rate': '0.005084745762711864', 'lever_rate': '1', 'position_margin': '7.958060000000000000', 'direction': 'buy', 'profit': '0.040260000000000000', 'last_price': '0.00001186', 'margin_asset': 'USDT', 'margin_mode': 'cross', 'margin_account': 'USDT', 'contract_type': 'swap', 'pair': 'SHIB-USDT', 'business_type': 'swap', 'trade_partition': 'USDT', 'position_mode': 'dual_side'}, 'symbol': 'SHIB/USDT:USDT', 'contracts': 671.0, 'contractSize': 1000.0, 'entryPrice': 1.18e-05, 'collateral': None, 'side': 'long', 'unrealizedProfit': 0.04026, 'leverage': 1.0, 'percentage': 0.5084745762711864, 'marginMode': 'cross', 'marginType': 'cross', 'notional': 7.95806, 'markPrice': None, 'liquidationPrice': None, 'initialMargin': 7.95806, 'initialMarginPercentage': 1.0, 'maintenanceMargin': None, 'maintenanceMarginPercentage': None, 'marginRatio': None, 'timestamp': 1652721082637, 'datetime': '2022-05-16T17:11:22.637Z'}]
I need somehow get available numbers from symbol "GMT"
CodePudding user response:
If you want only the list of available numbers:
x = [{'info': {'symbol': 'GMT', 'contract_code': 'GMT-USDT', 'volume': '4.000000000000000000', 'available': '4.000000000000000000', 'frozen': '0E-18', 'cost_open': '1.425850000000000000', 'cost_hold': '1.425850000000000000', 'profit_unreal': '0.037880000000000000', 'profit_rate': '0.006641652347722411', 'lever_rate': '1', 'position_margin': '5.741280000000000000', 'direction': 'buy', 'profit': '0.037880000000000000', 'last_price': '1.43532', 'margin_asset': 'USDT', 'margin_mode': 'cross', 'margin_account': 'USDT', 'contract_type': 'swap', 'pair': 'GMT-USDT', 'business_type': 'swap', 'trade_partition': 'USDT', 'position_mode': 'dual_side'}, 'symbol': 'GMT/USDT:USDT', 'contracts': 4.0, 'contractSize': 1.0, 'entryPrice': 1.42585, 'collateral': None, 'side': 'long', 'unrealizedProfit': 0.03788, 'leverage': 1.0, 'percentage': 0.6641652347722411, 'marginMode': 'cross', 'marginType': 'cross', 'notional': 5.74128, 'markPrice': None, 'liquidationPrice': None, 'initialMargin': 5.74128, 'initialMarginPercentage': 1.0, 'maintenanceMargin': None, 'maintenanceMarginPercentage': None, 'marginRatio': None, 'timestamp': 1652721082637, 'datetime': '2022-05-16T17:11:22.637Z'}, {'info': {'symbol': 'SHIB', 'contract_code': 'SHIB-USDT', 'volume': '671.000000000000000000', 'available': '671.000000000000000000', 'frozen': '0E-18', 'cost_open': '0.000011800000000000', 'cost_hold': '0.000011800000000000', 'profit_unreal': '0.040260000000000000', 'profit_rate': '0.005084745762711864', 'lever_rate': '1', 'position_margin': '7.958060000000000000', 'direction': 'buy', 'profit': '0.040260000000000000', 'last_price': '0.00001186', 'margin_asset': 'USDT', 'margin_mode': 'cross', 'margin_account': 'USDT', 'contract_type': 'swap', 'pair': 'SHIB-USDT', 'business_type': 'swap', 'trade_partition': 'USDT', 'position_mode': 'dual_side'}, 'symbol': 'SHIB/USDT:USDT', 'contracts': 671.0, 'contractSize': 1000.0, 'entryPrice': 1.18e-05, 'collateral': None, 'side': 'long', 'unrealizedProfit': 0.04026, 'leverage': 1.0, 'percentage': 0.5084745762711864, 'marginMode': 'cross', 'marginType': 'cross', 'notional': 7.95806, 'markPrice': None, 'liquidationPrice': None, 'initialMargin': 7.95806, 'initialMarginPercentage': 1.0, 'maintenanceMargin': None, 'maintenanceMarginPercentage': None, 'marginRatio': None, 'timestamp': 1652721082637, 'datetime': '2022-05-16T17:11:22.637Z'}]
GMT_available_info = []
for info in x:
if info['info']['symbol'] == 'GMT':
GMT_available_info.append(info['info']['available'])
print(GMT_available_info)