This repository has been archived on 2025-01-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
mexc-trade/mexc-socket.py
dongho 9e9cbf3547
All checks were successful
SonarQube Scan / SonarQube Trigger (push) Successful in 1m12s
mexc-websocket added
2024-12-20 20:48:02 +09:00

26 lines
566 B
Python

from pymexc import spot, futures
from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.getenv("API_KEY")
api_secret = os.getenv("API_SECRET")
def handle_message(message):
print(message)
# initialize WebSocket client
ws_spot_client = spot.WebSocket(api_key = api_key, api_secret = api_secret)
# make http request to api
# create websocket connection to public channel (spot@public.deals.v3.api@BTCUSDT)
# all messages will be handled by function `handle_message`
ws_spot_client.deals_stream(handle_message, "BTCUSDT")
while True:
...