Skip to content
This repository has been 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

Open
ym-b2 opened this issue Aug 3, 2022 · 0 comments
Open

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

ym-b2 opened this issue Aug 3, 2022 · 0 comments

Comments

@ym-b2
Copy link

ym-b2 commented Aug 3, 2022

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant