Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 2.18 KB

README.md

File metadata and controls

44 lines (27 loc) · 2.18 KB

Relayer-Python-SDK CC BY-NC-SA 4.0

Relayer-Go-SDK by Yggdrasil-Protocol is licensed under CC BY-NC-SA 4.0

Example

Here is an example of how to use the Relayer-Python-SDK:

import asyncio
from relayer_python_sdk.ws import RelayerWS
from relayer_python_sdk import events

feedIDs = ["SPOT:BTC_USDT", "SPOT:ETH_USDT"]
ws = RelayerWS(feedIDs)


@ws.on_data_event
async def on_data_event(event: events.DataFeed):
    print("Data Feed Event:", event)


@ws.on_info_event
async def on_info_event(event: events.SubscriptionMsg):
    print("Info event:", event)


async def main():
    sub_task = asyncio.create_task(ws.connect())

    await asyncio.sleep(10)
    await ws.close()

    await sub_task


if __name__ == "__main__":
    asyncio.run(main())

This code will subscribe to the data feeds SPOT:BTC_USDT and SPOT:ETH_USDT and print the price events and info events.