Skip to content

Kucoin trade subscription fails since ~10 feb. #1100

@kozy

Description

@kozy

Describe the bug
In cryptofeed v2.4.1, the KuCoin exchange adapter constructs WebSocket subscription topics with a space after the colon delimiter:

/market/match: BTC-USDT

KuCoin’s WebSocket API requires the topic to be formatted without whitespace:

/market/match:BTC-USDT

As a result, KuCoin returns:

{'id': '1', 'type': 'error', 'code': 400, 'data': 'topic /market/match: BTC-USDT is invalid'}

This affects both single-symbol and multi-symbol subscriptions and causes all trade subscriptions to fail.


To Reproduce

Small reproducible example:

from cryptofeed import FeedHandler
from cryptofeed.defines import TRADES
from cryptofeed.exchanges import KuCoin

async def trade(t, receipt_timestamp):
    print(t)

fh = FeedHandler()
fh.add_feed(
    KuCoin(
        symbols=["BTC-USDT"],
        channels=[TRADES],
        callbacks={TRADES: trade},
    )
)
fh.run()

Observed error:

WARNING: KUCOIN: error from exchange {
    'id': '1',
    'type': 'error',
    'code': 400,
    'data': 'topic /market/match: BTC-USDT is invalid'
}

Inspection of cryptofeed/exchanges/kucoin.py (v2.4.1) shows:

'topic': f"{chan}: {','.join(...)}"

The space after : results in an invalid topic string per KuCoin’s API grammar.


Expected behavior
The KuCoin adapter should emit:

/market/match:BTC-USDT

without whitespace after the colon, matching KuCoin’s documented topic format.

Subscriptions should succeed and trades should stream normally.


Screenshots
N/A


Operating System:
Linux (reproduced on x86_64)


Cryptofeed Version
2.4.1 (installed from PyPI via pip)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions