cryptofeed icon indicating copy to clipboard operation
cryptofeed copied to clipboard

CustomAggregate doesn't reset the data dict

Open aysuio opened this issue 6 years ago • 1 comments

Currently, the CustomAggregate class doesn't reset the data dict for every window, because self.init doesn't return data to overwrite the last self.data

Below is the code that may work

demo_custom_agg.py


def init(data):

    data = {}
    return data

In aggregate.CustomAggregate

    async def __call__(self, **kwargs):
        now = time.time()
        if now - self.last_update > self.window:
            self.last_update = now
            await self.handler(data=self.data)
            self.data = self.init(self.data)
        
        self.agg(self.data, **kwargs)

aysuio avatar Feb 17 '20 00:02 aysuio

i fixed the example - thanks for raising this issue!

bmoscon avatar Feb 21 '20 00:02 bmoscon