I get a dictionary back from an API call and would like to clean up and split the dictionary into 2 new dictionaries.
ob = ( the whole dictionary from the API )
b_ob = should only have 5 first items where SIDE=BUY and only the price KEY and VAL
s_ob = should only have 5 first items where SIDE=SELL and only the price KEY and VAL
Here is the dictionary from API Call:
{'price': '47296.5', 'side': 'Buy', 'size': 0.002},
{'price': '47296', 'side': 'Buy', 'size': 0.002},
{'price': '47295.5', 'side': 'Buy', 'size': 0.003},
{'price': '47295', 'side': 'Buy', 'size': 0.002},
{'price': '47294.5', 'side': 'Buy', 'size': 0.002},
{'price': '47294', 'side': 'Buy', 'size': 0.002},
{'price': '47293.5', 'side': 'Buy', 'size': 0.002},
{'price': '47293', 'side': 'Buy', 'size': 0.002},
{'price': '47297.5', 'side': 'Sell', 'size': 0.016},
{'price': '47298', 'side': 'Sell', 'size': 0.01},
{'price': '47298.5', 'side': 'Sell', 'size': 0.003},
{'price': '47299.5', 'side': 'Sell', 'size': 0.002},
{'price': '47300', 'side': 'Sell', 'size': 4.39},
{'price': '47300.5', 'side': 'Sell', 'size': 4.365},
{'price': '47301', 'side': 'Sell', 'size': 9.638},
{'price': '47301.5', 'side': 'Sell', 'size': 0.623},
{'price': '47302', 'side': 'Sell', 'size': 1.107},
{'price': '47302.5', 'side': 'Sell', 'size': 2.223} ```