Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong length of list in 'to_list' method #26

Closed
k-d-l opened this issue Apr 14, 2023 · 1 comment
Closed

Wrong length of list in 'to_list' method #26

k-d-l opened this issue Apr 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@k-d-l
Copy link

k-d-l commented Apr 14, 2023

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()

bug_report

@k-d-l k-d-l added the bug Something isn't working label Apr 14, 2023
@bmoscon
Copy link
Owner

bmoscon commented May 28, 2023

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.

@bmoscon bmoscon closed this as completed May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants