question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python - aggregate function issues

See original GitHub issue
  1. Bitfinex v2 API returns book items in [price, volume, timestamp] format, while aggregate function expects [price, volume] format.

order_book = ccxt.bitfinex2().fetch_l2_order_book('BTC/USD')

Traceback (most recent call last): … order_book = ccxt.bitfinex2().fetch_l2_order_book(‘BTC/USD’) File “D:\Python\Python36-32\lib\site-packages\ccxt\exchange.py”, line 787, in fetch_l2_order_book ‘bids’: self.sort_by(self.aggregate(orderbook[‘bids’]), 0, True), File “D:\Python\Python36-32\lib\site-packages\ccxt\exchange.py”, line 511, in aggregate for [price, volume] in bidasks: ValueError: too many values to unpack (expected 2)


  1. ordered.iteritems() should be changed to ordered.items(), as iteritems() has been removed in Python 3.

order_book = ccxt.cex().fetch_l2_order_book('BTC/USD')

Traceback (most recent call last): … order_book = ccxt.cex().fetch_l2_order_book(‘BTC/USD’) File “D:\Python\Python36-32\lib\site-packages\ccxt\exchange.py”, line 787, in fetch_l2_order_book ‘bids’: self.sort_by(self.aggregate(orderbook[‘bids’]), 0, True), File “D:\Python\Python36-32\lib\site-packages\ccxt\exchange.py”, line 514, in aggregate for price, volume in ordered.iteritems(): AttributeError: ‘collections.OrderedDict’ object has no attribute ‘iteritems’

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Nitrooocommented, Oct 11, 2017

fetch_order_book() doesn’t work anymore with Bitfinex v2 on ccxt v.1.9.107+. It works fine on v.1.9.106. I have not much time to investigate right now, but you get the timestamp in place of the price, for example.

1reaction
kroitorcommented, Oct 11, 2017

@Nitrooo that is not critical in our case, because:

  1. efficiency matters, if you are going to aggregate tons of order books every second, which isn’t the case for most of trading applications
  2. this is only done once upon fetching the orderbook
  3. you can’t possibly fetch so many orderbooks in a limited amount of time so that the efficiency of converting list(...items()) becomes critical
  4. Python 2 is going to die soon
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Aggregate function in pandas dataframe not working ...
Aggregate function in pandas dataframe not working appropriately ... I'm trying to sum a certain column based on a groupby of another column ......
Read more >
Comprehensive Guide to Grouping and Aggregating with ...
The most common built in aggregation functions are basic math functions including sum, mean, median, minimum, maximum, standard deviation, ...
Read more >
Stop Using Python to Aggregate Data - Use SQL Instead
Are you using Python to extract raw data from the database? It could be a huge bottleneck in your apps. Use SQL instead....
Read more >
Python | Pandas dataframe.aggregate() - GeeksforGeeks
Dataframe.aggregate() function is used to apply some aggregation across one or more column. Aggregate using callable, string, dict, ...
Read more >
Data Grouping in Python - Towards Data Science
Explanation: Pandas agg() function can be used to handle this type of computing tasks. Relevant columns and the involved aggregate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found