Skip to content

Websocket proposal #2

Description

@singlesly

Supports websocket functionality

Market data

const marketStream = new BingxWebSocketMarketStream();

// Heartbeat
marketStream.hearbeat$.subscribe();

// Market Depth data
marketStream.subscribeMarketDepthData({
  symbol: 'BTC-USDT',
  level: 5,
});

marketStream.marketDepthData$.subscribe((data) => {
  console.log(data);
});

// Latest Trade Detail
marketStream.subscribeLatestTradeDetail({
  symbol: 'BTC-USDT'
});

marketStream.latestTradeDetail$.subscribe((data) => {
  console.log(data);
});

// Subscribe K-Line Data
marketStream.subscribeKLineData({
  symbol: 'BTC-USDT',
  interval: '1m'
});

marketStream.kLineData$.subscribe(data => {
  console.log(data);
});

Account stream

  • think about how to support exchange listen key with custom requests
const account = new ApiAccount('x', 'x')
const accountStream = new BingxWebSocketAccountStream(account);

accountStream.hearbeat$.subscribe();

// Listen key expired
accountStream.listenKeyExpired$.subscribe();

// Account balance and position update push
accountStream.accountUpdate$.subscribe();

// Order update push
accountStream.orderTradeUpdate$.subscribe();

// Configuration updates
accountStream.accountConfigUpdate$.subscribe();

Account stream pool

Supports multiple account stream

const accountStreamPool = new BingxWebSocketAccountStreamPool(accounts);

//
accountStreamPool.hearbeat$.subscribe(account => {});

// Add user
accountStreamPool.addAccount(account);

// Remove user
accountStreamPoll.removeAccount(account);

// Listen key expired
accountStreamPool.listenKeyExpired$.subscribe((data, account) => {});

// Account balance and position update push
accountStreamPool.accountUpdate$.subscribe((data, account) => {});

// Order update push
accountStreamPool.orderTradeUpdate$.subscribe((data, account) => {});

// Configuration updates
accountStreamPool.accountConfigUpdate$.subscribe((data, account) => {});

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions