Skip to content

(feat) Add BingX spot candles and complete trading rules - #8450

Open
aMoonshine wants to merge 2 commits into
hummingbot:masterfrom
aMoonshine:feat/bingx-spot-candles
Open

aMoonshine wants to merge 2 commits into
hummingbot:masterfrom
aMoonshine:feat/bingx-spot-candles

Conversation

@aMoonshine

Copy link
Copy Markdown

Summary

Adds complete BingX spot market-data support for Hummingbot:

  • registers a BingX spot candles feed in CandlesFactory ("bing_x": BingXSpotCandles)
  • makes BingX trading rules load all active symbols from the exchange response, like other full-market connectors such as KuCoin

Upstream, BingX is listed as "Not built" for the Spot Candles Feed, and its trading-rule formatter previously filtered to already-configured pairs only.

Implementation

  • New feed: hummingbot/data_feed/candles_feed/bing_x_spot_candles/
  • REST: GET https://open-api.bingx.com/openApi/spot/v2/market/kline — dashed trading pair (BTC-USDT), Hummingbot interval names, millisecond startTime/endTime, limit capped at 1440. BingX returns rows newest-first; the parser reverses them into ascending 10-column candles.
  • WS: wss://open-api-ws.bingx.com/market — subscription {"id": <uuid>, "reqType": "sub", "dataType": "<PAIR>@kline_<interval>"} using the BingX dataType vocabulary (1min, 3min, 5min, 15min, 30min, 60min, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 3day, 1week). Frames are gzip-compressed; decompression reuses decompress_ws_message from the existing bing_x connector utils (no new dependency).
  • 1M is intentionally not offered: BingX WS has no monthly kline, so a monthly feed would silently never stream.
  • Rate limits mirror the bing_x connector request pools (GET / GET_BURST / GET_MIXED) so a shared throttler deduplicates when the connector is attached to the feed.
  • Protocol verified live against BingX production (REST intervals list, WS vocabulary rejections for 1hour/1M, push shape {"code":0,"data":{"e":"kline","s":"BTC-USDT","K":{...}}}, gzip framing, no client ping required).

Trading rules

  • Processes every active symbol from BingX data.symbols, rather than filtering by self.trading_pairs.
  • Uses the exchange-provided minQty, maxQty, minNotional, tickSize, and stepSize values.
  • Avoids one last-price request per symbol, so a cold connector can expose the complete market list without a request storm.

Testing

  • BingX connector + candle feed + factory tests: 63 tests pass (including all-symbol trading-rules parsing, REST params, newest-first reversal, WS subscription payload, WS field mapping from data.K, ack/text frames ignored, gzip decompression, and factory registration).
  • Environment note: with aiohttp 3.14.x + aioresponses 0.7.9 (latest published release), test_fetch_candles fails identically for ALL candle feeds (pre-existing ecosystem incompatibility, unrelated to this PR). Tests are green against aiohttp 3.12.15 + aioresponses 0.7.9.

Register BingXSpotCandles in CandlesFactory ("bing_x"), which was
previously missing (official docs list Spot Candles Feed as
"Not built").

REST: GET https://open-api.bingx.com/openApi/spot/v2/market/kline with
dashed symbol (BTC-USDT), HB interval names, ms epoch startTime/endTime,
limit<=1440; rows arrive newest-first and are reversed into ascending
10-column candles.

WS: wss://open-api-ws.bingx.com/market, subscription
{"id": <uuid>, "reqType": "sub", "dataType": "<PAIR>@kline_<interval>"},
BingX interval vocabulary (1min..60min, 2hour..12hour, 1day, 3day,
1week). Frames are gzip-compressed; decompression reuses
decompress_ws_message from the bing_x connector utils. 1M is excluded
(BingX WS has no monthly kline). Rate limits mirror the bing_x
connector pools (GET/GET_BURST/GET_MIXED) for shared-throttler dedup.

Tests cover REST params, newest-first reversal, WS subscription
payload, WS field mapping (data.K), ack/text frame handling and gzip
decompression, plus factory registration.
@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown

Greptile Summary

Adds BingX spot candle support and broadens BingX trading-rule discovery to all active exchange symbols.

  • Registers bing_x with CandlesFactory.
  • Adds REST history normalization and gzip WebSocket candle processing.
  • Uses exchange-provided quantity and notional constraints while eliminating per-symbol last-price requests.

Confidence Score: 5/5

The pull request appears safe to merge, with no concrete blocking or independently actionable non-blocking issue established.

The new candle feed follows the shared factory, historical normalization, live-update, and throttling contracts, while the trading-rule change consistently uses active exchange metadata without an established downstream regression.

Important Files Changed

Filename Overview
hummingbot/connector/exchange/bing_x/bing_x_exchange.py Loads active-symbol rules directly from exchange quantity and notional fields while removing per-symbol ticker requests; no actionable defect was established.
hummingbot/data_feed/candles_feed/bing_x_spot_candles/bing_x_spot_candles.py Implements BingX REST and WebSocket candle normalization in the shared feed contract; reviewed lifecycle paths reveal no concrete failure.
hummingbot/data_feed/candles_feed/bing_x_spot_candles/constants.py Defines endpoint, interval, result-limit, and linked-throttling configuration for the new feed.
hummingbot/data_feed/candles_feed/candles_factory.py Registers the BingX spot candle implementation under the expected connector name.
test/hummingbot/data_feed/candles_feed/bing_x_spot_candles/test_bing_x_spot_candles.py Covers REST parameters and ordering, WebSocket subscription vocabulary, field mapping, ignored frames, and gzip decompression.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[CandlesConfig: bing_x] --> B[CandlesFactory]
    B --> C[BingXSpotCandles]
    D[BingX REST klines] --> C
    E[BingX gzip WebSocket klines] --> C
    C --> F[Ascending ten-column candle series]
    G[BingX exchange info] --> H[BingXExchange]
    H --> I[Active-symbol trading rules]
Loading

Reviews (1): Last reviewed commit: "(fix) load all BingX trading rules from ..." | Re-trigger Greptile

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

Successfully merging this pull request may close these issues.

1 participant