ccxws icon indicating copy to clipboard operation
ccxws copied to clipboard

Is this a correct way of implementing ccws in Node.js?

Open ym-b2 opened this issue 1 year ago • 0 comments

const ccxws = require("ccxws");

const binance = new ccxws.BinanceClient();
const kucoin = new ccxws.KucoinClient();

// select binance markets
const subscribeData1 = {
  id: "ETHUSDT",
  base: "ETH",
  quote: "USDT",
};

// select kucoin markets
const subscribeData2 = {
  id: "LTCBTC",
  base: "LTC",
  quote: "BTC",
};

// handle the trade and order book events from websocket
binance.on("trade", (trade) => console.log(trade));
kucoin.on("l2snapshot", (snapshot) => console.log(snapshot));

// subscribe to the trade and order book events
binance.subscribeTrades(subscribeData1);
kucoin.subscribeLevel2Snapshots(subscribeData2);

I created a client file following a tutorial on Medium.com . I got response from Binance but not from Kucoin.

Output:


....
Trade {
  exchange: 'Binance',
  quote: 'USDT',
  base: 'ETH',
  tradeId: '735481432',
  sequenceId: undefined,
  unix: 1659513082185,
  side: 'sell',
  price: '1627.68000000',
  amount: '0.50510000',
  buyOrderId: undefined,
  sellOrderId: undefined
}
Trade {
  exchange: 'Binance',
  quote: 'USDT',
  base: 'ETH',
  tradeId: '735481433',
  sequenceId: undefined,
  unix: 1659513082224,
  side: 'sell',
  price: '1627.68000000',
  amount: '0.19220000',
  buyOrderId: undefined,
  sellOrderId: undefined
}
Trade {
  exchange: 'Binance',
  quote: 'USDT',
  base: 'ETH',
  tradeId: '735481434',
  sequenceId: undefined,
  unix: 1659513082298,
  side: 'sell',
  price: '1627.69000000',
  amount: '0.15000000',
  buyOrderId: undefined,
  sellOrderId: undefined
}
Trade {
  exchange: 'Binance',
  quote: 'USDT',
  base: 'ETH',
  tradeId: '735481435',
  sequenceId: undefined,
  unix: 1659513082365,
  side: 'sell',
  price: '1627.70000000',
  amount: '0.19220000',
  buyOrderId: undefined,
  sellOrderId: undefined
}
....

After I commented out lines related to Binance, I got nothing in response.

Please let me know the correct way of implementing ccxws in Node.js. Thanks!

ym-b2 avatar Aug 03 '22 07:08 ym-b2