Skip to content

public_funding_rate_channel show error #4

Description

@algoqt

2025-07-23 10:26:31.323 | ERROR | nexusbridge.base:OkxWSClient:on_ws_frame:110 - Error processing message: unexpected character: line 1 column 1 (char 0)

the code below has error above, also, ws.public_funding_rate_channel can't subcribe (call ) more than once, because your code:


     if op == "subscribe":
            await self._subscribe(params, channel)
        else:
            await self._unsubscribe(params, channel)

use channel as _subscriptions's key

self._subscriptions[subscription_id] = payload

shoud use self._subscriptions[(chanel,instr_id)] = payload instead ?


async def funding_rate(api:OkxApiClient):
    try:
        res = await api.get_api_v5_public_instruments('SWAP')
        if res["code"] != "0":
            recv_logger.error(res)
            return 
        
        symbol_infos = pd.DataFrame(res["data"])
        symbol_stat = symbol_infos.groupby("state").count().to_dict()
        recv_logger.info(symbol_stat)
        subscribe_symbols = symbol_infos[symbol_infos["state"]=="live"]["instId"].tolist()
            
        ws = OkxWSClient(account_type=OkxAccountType.LIVE
                            ,handler=handler_funding_rate)
        await ws.public_funding_rate_channel("subscribe",subscribe_symbols[0])

        # params = [{ "channel": "funding-rate","instId": symbol} for symbol in subscribe_symbols]
        # payload = {
        #     "op": "subscribe",
        #     "args": params,
        # }
        # await ws._connect()
        # await ws._send(payload)
        await ws.connect()
    finally:
        pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions