cryptofeed
cryptofeed copied to clipboard
new style websocket_endpoint not support address list type , only str
Sorry about the translator. Since version 2.1.2 above, support for new websocket_endpoint has been introduced, but support for list type addresses has been removed. Because of this, an error occurs when adding trading pairs greater than the exchange limit per connection.
from cryptofeed import FeedHandler
from cryptofeed.backends.aggregate import OHLCV
from cryptofeed.defines import TRADES
from cryptofeed.exchanges import Binance
async def ohlcv(data):
print(data)
def main():
f = FeedHandler()
pairs_spot = Binance.symbols()
sorted_pairs_spot = [item for item in pairs_spot if item.endswith(("-USDT", "-BUSD"))]
f.add_feed(Binance(symbols=sorted_pairs_spot, channels=[TRADES], callbacks={TRADES: OHLCV(ohlcv, window=10)}))
f.run()
if __name__ == "__main__":
main()
traceback
File "C:\Python39\lib\site-packages\cryptofeed\feedhandler.py", line 143, in run
feed.start(loop)
File "C:\Python39\lib\site-packages\cryptofeed\feed.py", line 284, in start
for conn, sub, handler, auth in self.connect():
File "C:\Python39\lib\site-packages\cryptofeed\feed.py", line 205, in connect
ret.extend(limit_sub(filtered_sub, limit, auth, endpoint.options))
File "C:\Python39\lib\site-packages\cryptofeed\feed.py", line 174, in limit_sub
ret.append((WSAsyncConn(addr, self.id, authentication=auth, subscription=sub, **options), self.subscribe, self.message_handler, self.authenticate))
File "C:\Python39\lib\site-packages\cryptofeed\connection.py", line 296, in __init__
if not address.startswith("wss://"):
AttributeError: 'list' object has no attribute 'startswith'
Exception ignored in: <function AsyncConnection.__del__ at 0x000002DB407FF5E0>
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\cryptofeed\connection.py", line 91, in __del__
if self.is_open:
File "C:\Python39\lib\site-packages\cryptofeed\connection.py", line 304, in is_open
return self.conn and not self.conn.closed
AttributeError: 'WSAsyncConn' object has no attribute 'conn'
- windows, linux
- pypi version older than 2.1.2 (2.1.2 works)
@xiva-wgt thanks for filing this, I'll try and fix this soon
Hi Bryant,
Any chance that you will have time for this issue?
Thanks!
a temporary solution is to split the list of symbols into multiple add_feed
fixed