Wrong length of list in 'to_list' method
k-d-l opened this issue · 1 comments
k-d-l commented
Two methods 'to_list' and 'to_dict' give different results when calling on the same object. I'm using cryptofeed but it seems to me that issue is from orderbook.
Steps to reproduce the behavior:
from cryptofeed import FeedHandler
from cryptofeed.defines import L2_BOOK
from cryptofeed.exchanges import Binance
from cryptofeed.backends.aggregate import Throttle
async def book(update, receipt_timestamp):
print(f'dict sz: {len(update.book.bids)}')
print(f'to dict: {len(update.book.bids.to_dict())}')
print(f'to list: {len(update.book.bids.to_list())}\n')
def main():
f = FeedHandler()
f.add_feed(Binance(max_depth=5000, symbols=['BTC-USDT'],
channels=[L2_BOOK], callbacks={L2_BOOK:Throttle(book, 1)}))
f.run()
if __name__ == '__main__':
main()
bmoscon commented
the method works as coded - to_dict will always return up to the max_depth items, whereas to_list requires you to specify as an argument, the max length you want. I think this is incorrect behavior, so I have modified it to match what do_dict does.