tardis-dev / tardis-machine

Locally runnable server with built-in data caching, providing both tick-level historical and consolidated real-time cryptocurrency market data via HTTP and WebSocket APIs
https://docs.tardis.dev/api/tardis-machine
Mozilla Public License 2.0
235 stars 46 forks source link

Bybit linear contract #3

Closed devcon14 closed 3 years ago

devcon14 commented 3 years ago

Hello, I was testing the python realtime ws sample and it works great with the bybit BTCUSD inverse contract.

Is the linear BTCUSDT contract supported too? I see it in this list but the sample code below prints no messages.

import asyncio
import aiohttp
import json
import urllib.parse

async def run():
    data_types = ["trade", "book_change", "book_snapshot_10_100ms"]

    stream_options = [
        {
            "exchange": "bybit",
            "symbols": ["BTCUSDT"],
            "dataTypes": data_types,
        },
    ]

    options = urllib.parse.quote_plus(json.dumps(stream_options))

    URL = f"ws://localhost:8001/ws-stream-normalized?options={options}"
    async with aiohttp.ClientSession() as session:
        async with session.ws_connect(URL) as websocket:

            async for msg in websocket:
                print(msg.data)

asyncio.run(run())
thaaddeus commented 3 years ago

Indeed, it wasn't working for real-time data unfortunately, thing is Bybit requires separate WS endpoint for it's linear contracts. It's all covered in v3.2.0 which has just been released. Hope that helps.