Skip to content
This repository was archived by the owner on Sep 9, 2023. It is now read-only.
This repository was archived by the owner on Sep 9, 2023. It is now read-only.

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

@ym-b2

Description

@ym-b2
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!

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