import asyncio MAX_ITEMS = 10 class Depth: def __init__(self): self.bids = [] self.asks = [] self._event = asyncio.Event() async def wait(self): await self._event.wait() def askVolumeUntil(self, price): ret = 0 for i in range(len(self.asks)): if self.asks[i][0] > price: break ret += self.asks[i][1] return ret