Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

futures websocket private channel empty #7

Open
Rilin opened this issue Feb 17, 2024 · 0 comments
Open

futures websocket private channel empty #7

Rilin opened this issue Feb 17, 2024 · 0 comments

Comments

@Rilin
Copy link

Rilin commented Feb 17, 2024

Tell me how to get balance and pos, order data through a private channel using websocket. I place orders manually in the app, deals appear, but the callbacks are empty.
What am I doing wrong?

from pymexc import futures

def onOrder(message):
    # handle websocket message
    print('onOrder')
    print(message)
def onPosition(message):
    # handle websocket message
    print('onPosition')
    print(message)
def onAsset(message):
    # handle websocket message
    print('onAsset')
    print(message)

SYM = "ETH_USDT"
    futures_client = futures.HTTP(api_key = my_secret_var.mexc_api_key, api_secret = my_secret_var.mexc_api_secret)
    ws_futures_client = futures.WebSocket(api_key = my_secret_var.mexc_api_key, api_secret = my_secret_var.mexc_api_secret, restart_on_error=True, trace_logging=True)
    ws_futures_client.order_stream(onOrder)
    ws_futures_client.asset_stream(onAsset)
    ws_futures_client.position_stream(onPosition)
    while True:
        # lastPrice = getLastPrice(SYM)
        # secho(f"{Now()} {SYM} price:{lastPrice['indexPrice']} time:{lastPrice['timestamp']} check sqltask", fg='magenta')
        sleep(1000)

my API key:
scr1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant