bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.14k stars 666 forks source link

Bybit Trades do not work for Linear Futures #1010

Closed pavs94 closed 3 months ago

pavs94 commented 5 months ago

Describe the bug When subscribing to BTCUSDT Perpetual Futures, the subscription fails as the websocket connection url is different on bybit

To Reproduce Steps to reproduce the behavior:

from cryptofeed import FeedHandler from cryptofeed.backends.aggregate import Throttle from cryptofeed.defines import TRADES from cryptofeed.exchanges import Bybit

async def trade(t, receipt_timestamp): print(f"Book received at {t} ts: {receipt_timestamp}")

def main(): f = FeedHandler() f.add_feed(Bybit(symbols=['BTC-USDT-PERP'], channels=[TRADES], callbacks={TRADES: trade}))

f.run()

if name == 'main': main()



**Expected behavior**
- Get Trades for Bybit BTCUSDT. Subscribe to the correct websocket
https://bybit-exchange.github.io/docs/v5/ws/connect
- USDT Futures: wss://stream.bybit.com/v5/public/linear
- Inverse Futures: wss://stream.bybit.com/v5/public/inverse
- Upgrade Bybit functions with the upgraded Websockets

**Operating System:**
- macOS

**Cryptofeed Version**
- installed via pip - v2.4.0
gawaboga commented 4 months ago

Hi, I'm getting same errors, Cryptofeed Version 2.4.0, on ubuntu: fh.add_feed(Bybit(symbols=['BTC-USDT-PERP'], channels=[FUNDING, OPEN_INTEREST], callbacks={OPEN_INTEREST: oi, FUNDING: funding}))

output: 2024-03-07 16:26:43,689 : ERROR : BYBIT.ws.1: Error from exchange {'success': False, 'ret_msg': 'error:handler not found,topic:instrument_info.100ms.BTCUSDT', 'conn_id': '26ffa4fb-e6aa-48fb-94b3-91f415ec765c', 'req_id': '', 'op': 'subscribe'}

How is possible to solve in the code? Really appreciate, Thanks Sam