Code Monkey home page Code Monkey logo

ccxws's Introduction

CryptoCurrency eXchange WebSockets

CI Coverage

A JavaScript library for connecting to realtime public APIs on all cryptocurrency exchanges.

CCXWS provides a standardized eventing interface for connection to public APIs. Currently CCXWS support ticker, trade and orderbook events.

The CCXWS socket client performs automatic reconnection when there are disconnections. It also has silent reconnection logic to assist when no data has been seen by the client but the socket remains open.

CCXWS uses similar market structures to those generated by the CCXT library. This allows interoperability between the RESTful interfaces provided by CCXT and the realtime interfaces provided by CCXWS.

Check out the FAQS for more inforamtion on common issues you may encounter.

Check out the CONTRIBUTING guide for how to get involved.

Getting Started

Install ccxws

npm install ccxws

Create a new client for an exchange. Subscribe to the events that you want to listen to by supplying a market.

import { BinanceClient } from "ccxws";
const binance = new BinanceClient();

// market could be from CCXT or genearted by the user
const market = {
  id: "BTCUSDT", // remote_id used by the exchange
  base: "BTC", // standardized base symbol for Bitcoin
  quote: "USDT", // standardized quote symbol for Tether
};

// handle trade events
binance.on("trade", trade => console.log(trade));

// handle level2 orderbook snapshots
binance.on("l2snapshot", snapshot => console.log(snapshot));

// subscribe to trades
binance.subscribeTrades(market);

// subscribe to level2 orderbook snapshots
binance.subscribeLevel2Snapshots(market);

Exchanges

Exchange API Class Ticker Trades Candles OB-L2 Snapshot OB-L2 Updates OB-L3 Snapshot OB-L3 Updates
Bibox 1 BiboxClient - -
Binance 1 BinanceClient ✓** - -
Binance Futures Coin-M 1 BinanceFuturesCoinmClient ✓** - -
Binance Futures USDT-M 1 BinanceFuturesUsdtmClient ✓** - -
Binance US 1 BinanceUsClient ✓** - -
Bitfinex 2 BitfinexClient - - ✓* - ✓*
bitFlyer 1 BitflyerClient - - ✓** - -
Bithumb 1 BithumbClient - - ✓** - -
BitMEX 1 BitmexClient - ✓* - -
Bitstamp 2 BitstampClient - - ✓** - -
Bittrex 3 BittrexClient - ✓* - -
Cex.io 1 CexClient - -
Coinbase Pro 1 CoinbaseProClient - - ✓* -
Coinex 1 CoinexClient - ✓* - -
Deribit 2 DeribitClient - ✓* - -
Digifinex 1 DigifinexClient - - ✓* - -
ErisX 3.4 ErisXClient - - - - - ✓*
FTX 1 FtxClient - - ✓* - -
FTX US 1 FtxUsClient - - ✓* - -
Gate.io 3 GateioClient - - ✓* - -
Gemini 1 GeminiClient - - - ✓* - -
HitBTC 2 HitBtcClient - ✓* - -
Huobi Global 1 HuobiClient - - -
Huobi Global Futures 1 HuobiFuturesClient ✓* - -
Huobi Global Swaps 1 HuobiSwapsClient ✓* - -
Huobi Japan 1 HuobiJapanClient - - -
Huobi Korea 1 HuobiKoreaClient - - -
KuCoin 2 KucoinClient - ✓** - ✓*
Kraken 0 KrakenClient - ✓* - -
LedgerX 1 LedgerXClient - - - - - ✓*
Liquid 2 LiquidClient - - - -
OKEx 3 OkexClient ✓* - -
Poloniex 2 PoloniexClient - - ✓* - -
Upbit 1 UpbitClient - - - -
ZB 1 ZbClient - - - -

Notes:

  • ✓* broadcasts a snapshot event at startup
  • ✓** broadcasts a snapshot by using the REST API

Definitions

Trades - A maker/taker match has been made. Broadcast as an aggregated event.

Orderbook level 2 - has aggregated price points for bids/asks that include the price and total volume at that point. Some exchange may include the number of orders making up the volume at that price point.

Orderbook level 3 - this is the most granual order book information. It has raw order information for bids/asks that can be used to build aggregated volume information for the price points.

API

Market

Markets are used as input to many of the client functions. Markets can be generated and stored by you the developer or loaded from the CCXT library.

These properties are required by CCXWS.

  • id: string - the identifier used by the remote exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • type: string - the type of market: spot, futures, option, swap

Client

A websocket client that connects to a specific exchange. There is an implementation of this class for each exchange that governs the specific rules for managing the realtime connections to the exchange. You must instantiate the specific exchanges client to conncet to the exchange.

const binance = new ccxws.Binance();
const coinbase = new ccxws.CoinbasePro();

Clients can be instantiated with an options object that has several properties properties:

  • wssPath: string - allows customization of the web socket path. When this is configured, additional rules surrounding connection may be ignored.
  • watcherMs: number - allows customization of the reconnection watcher. This value is the duration of time that must pass without a message for a reconnection is peroformed. This value can be customized depending on the type and liquidity of markets that you are subscribing to.
  • apiKey: string - any API key needed for the exchange
  • apiSecret: string - any API secret needed for the exchange

Events

Subscribe to events by addding an event handler to the client .on(<event>) method of the client. Multiple event handlers can be added for the same event.

Once an event handler is attached you can start the stream using the subscribe<X> methods.

All events emit the market used to subscribe to the event as a second property of the event handler.

binance.on("error", err => console.error(err));
binance.on("trades", (trade, market) => console.log(trade, market));
binance.on("l2snapshot", (snapshot, market) => console.log(snapshot, market));
error emits Error

You must subscribe to the error event to prevent the process exiting. More information in the Node.js Events Documentation

If an EventEmitter does not have at least one listener registered for the 'error' event, and an 'error' event is emitted, the error is thrown, a stack trace is printed, and the Node.js process exits.

ticker emits Ticker, Market

Fired when a ticker update is received. Returns an instance of Ticker and the Market used to subscribe to the event.

trade emits Trade, Market

Fired when a trade is received. Returns an instance of Trade and the Market used to subscribe to the event.

candle emits Candle, Market

Fired when a candle is received. Returns an instance of Candle and the Market used to subscribe to the event.

l2snapshot emits Level2Snapshot, Market

Fired when a orderbook level 2 snapshot is received. Returns an instance of Level2Snapshot and the Market used to subscribe to the event.

The level of detail will depend on the specific exchange and may include 5/10/20/50/100/1000 bids and asks.

This event is also fired when subscribing to the l2update event on many exchanges.

l2update emits Level2Update, Market

Fired when a orderbook level 2 update is recieved. Returns an instance of Level2Update and the Market used to subscribe to the event.

Subscribing to this event may trigger an initial l2snapshot event for many exchanges.

l3snapshot emits Level3Snapshot, Market

Fired when a orderbook level 3 snapshot is received. Returns an instance of Level3Snapshot and the Market used to subscribe to the event.

l3update emits Level3Update, Market

Fired when a level 3 update is recieved. Returns an instance of Level3Update and the Market used to subscribe to the event.

Connection Events

Clients emit events as their state changes.

   +-------+
   |       |
   | start |
   |       |
   +---+---+
       |
       |
       |
       | subscribe
       |
       |
       |
+------v-------+       initiate
|              |       reconnect
|  connecting  <------------------------+
|              |                        |
+------+-------+                        |
       |                                |
       |                        +-------+-------+
       |                        |               |
       | socket                 | disconnected  |
       | open                   |               |
       |                        +-------^-------+
       |                                |
+------v-------+                        |
|              |                        |
|  connected   +------------------------+
|              |        socket
+------+-------+        closed
       |
       |
       |
       | close
       | requested
       |
       |
       |
+------v-------+                  +--------------+
|              |                  |              |
|   closing    +------------------>    closed    |
|              |     socket       |              |
+--------------+     closed       +--------------+
connecting

Fires prior to a socket initiating the connection. This event also fires when a reconnection starts.

connected

Fires when a socket has connected. This event will also fire for reconnection completed.

disconnected

Fires when a socket prematurely disconnects. Automatic reconnection will be triggered. The expected flow is disconnected -> connecting -> connected.

closing

Fires when the client is preparing to close its connection(s). This event is not fired during reconnections.

closed

Fires when the client has closed its connection(s). This event is not fired during reconnections, it is fired when the close method is called and the connection(s) are successfully closed.

reconnecting

Fires when a socket has initiated the reconnection process due to inactivity. This is fired at the start of the reconnection process reconnecting -> closing -> closed -> connecting -> connected

Methods

subscribeTicker(market): void

Subscribes to a ticker feed for a market. This method will cause the client to emit ticker events that have a payload of the Ticker object.

unsubscribeTicker(market): void

Unsubscribes from a ticker feed for a market.

subscribeTrades(market): void

Subscribes to a trade feed for a market. This method will cause the client to emit trade events that have a payload of the Trade object.

unsubscribeTrades(market): void

Unsubscribes from a trade feed for a market.

*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.

subscribeCandles(market): void

Subscribes to a candle feed for a market. This method will cause the client to emit candle events that have a payload of the Candle object. Set the candlePeriod property of the client to control which candle is returned by the feed.

unsubscribeCandles(market): void

Unsubscribes from a candle feed for a market.

*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.

subscribeLevel2Snapshots(market): void

Subscribes to the orderbook level 2 snapshot feed for a market. This method will cause the client to emit l2snapshot events that have a payload of the Level2Snaphot object.

This method is a no-op for exchanges that do not support level 2 snapshot subscriptions.

unsubscribeLevel2Snapshots(market): void

Unbusbscribes from the orderbook level 2 snapshot for a market.

*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.

subscribeLevel2Updates(market): void

Subscribes to the orderbook level 2 update feed for a market. This method will cause the client to emit l2update events that have a payload of the Level2Update object.

This method is a no-op for exchanges that do not support level 2 snapshot subscriptions.

unsubscribeLevel2Updates(market): void

Unbusbscribes from the orderbook level 2 updates for a market.

*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.

subscribeLevel3Snapshots(market): void

Subscribes to the orderbook level 3 snapshot feed for a market. This method will cause the client to emit l3snapshot events that have a payload of the Level3Snaphot object.

This method is a no-op for exchanges that do not support level 2 snapshot subscriptions.

unsubscribeLevel3Snapshots(market): void

Unbusbscribes from the orderbook level 3 snapshot for a market.

*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.

subscribeLevel3Updates(market): void

Subscribes to the orderbook level 3 update feed for a market. This method will cause the client to emit l3update events that have a payload of the Level3Update object.

This method is a no-op for exchanges that do not support level 3 snapshot subscriptions.

unsubscribeLevel3Updates(market): void

Unbusbscribes from the orderbook level 3 updates for a market.

*For some exchanges, calling unsubscribe may cause a temporary disruption in all feeds.

Ticker

The ticker class is the result of a ticker event.

Properties

  • exchange: string - the name of the exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • timestamp: int - the unix timestamp in milliseconds
  • last: string - the last price of a match that caused a tick
  • open: string - the price 24 hours ago
  • low: string - the highest price in the last 24 hours
  • high: string - the lowest price in the last 24 hours
  • volume: string - the base volume traded in the last 24 hours
  • quoteVolume: string - the quote volume traded in the last 24 hours
  • change: string - the price change (last - open)
  • changePercent: string - the price change in percent (last - open) / open * 100
  • bid: string - the best bid price
  • bidVolume: string - the volume at the best bid price
  • ask: string - the best ask price
  • askVolume: string - the volume at the best ask price

Trade

The trade class is the result of a trade event emitted from a client.

Properties

  • exchange: string - the name of the exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • tradeId: string - the unique trade identifer from the exchanges feed
  • unix: int - the unix timestamp in milliseconds for when the trade executed
  • side: string - whether the buyer buy or seller sell was the maker for the match
  • price: string - the price at which the match executed
  • amount: string - the amount executed in the match
  • buyOrderId: string - the order id of the buy side
  • sellOrderId: string - the order id of the sell side

Candle

The candle class is the result of a candle event emitted from a client.

Properties

  • timestampMs: int - the unix timestamp in milliseconds for the candle
  • open: string - the open price for the period
  • high: string - the high price for the period
  • low: string - the low price for the period
  • close: string - the close price for the period
  • volume: string - the volume exchanged during the period

Level2Point

Represents a price point in a level 2 orderbook

Properties

  • price: string - price
  • size: string - aggregated volume for all orders at this price point
  • count: int - optional number of orders aggregated into the price point

Level2Snapshot

The level 2 snapshot class is the result of a l2snapshot or l2update event emitted from the client.

Properties

  • exchange: string - the name of the exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • timestampMs: int - optional timestamp in milliseconds for the snapshot
  • sequenceId: int - optional sequence identifier for the snapshot
  • asks: [Level2Point] - the ask (seller side) price points
  • bids: [Level2Point] - the bid (buyer side) price points

Level2Update

The level 2 update class is a result of a l2update event emitted from the client. It consists of a collection of bids/asks even exchanges broadcast single events at a time.

Properties

  • exchange: string - the name of the exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • timestampMs: int - optional timestamp in milliseconds for the snapshot
  • sequenceId: int - optional sequence identifier for the snapshot
  • asks: [Level2Point] - the ask (seller side) price points
  • bids: [Level2Point] - the bid (buyer side) price points

Level3Point

Represents a price point in a level 3 orderbook

Properties

  • orderId: string - identifier for the order
  • price: string - price
  • size: string - volume of the order
  • meta: object - optional exchange specific metadata with additional information about the update.

Level3Snapshot

The level 3 snapshot class is the result of a l3snapshot or l3update event emitted from the client.

Properties

  • exchange: string - the name of the exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • timestampMs: int - optional timestamp in milliseconds for the snapshot
  • sequenceId: int - optional sequence identifier for the snapshot
  • asks: [Level3Point] - the ask (seller side) price points
  • bids: [Level3Point] - the bid (buyer side) price points

Level3Update

The level 3 update class is a result of a l3update event emitted from the client. It consists of a collection of bids/asks even exchanges broadcast single events at a time.

Additional metadata is often provided in the meta property that has more detailed information that is often required to propertly manage a level 3 orderbook.

Properties

  • exchange: string - the name of the exchange
  • base: string - the normalized base symbol for the market
  • quote: string - the normalized quote symbol for the market
  • timestampMs: int - optional timestamp in milliseconds for the snapshot
  • sequenceId: int - optional sequence identifier for the snapshot
  • asks: [Level3Point] - the ask (seller side) price points
  • bids: [Level3Point] - the bid (buyer side) price points

Caveats

Snapshots broadcast using the REST API

For exchanges which request the Level2Snapshot or Level3Snapshot over REST, there can be a race condition where messages are missed between the snapshot and the first update, for example the snapshot sequenceId is 100 and the first update's sequenceId is 105.

For a not-so-reliable fix you can monkey-patch a delay so that the snapshot is requested after subscribing to updates to better ensure the snapshot arrives with a sequenceId >= the first update that arrives. See example below:

const REST_DELAY_MS = 500;
client._originalRequestLevel2Snapshot = client._requestLevel2Snapshot;
client._requestLevel2Snapshot = market =>
  setTimeout(() => client._originalRequestLevel2Snapshot(market), REST_DELAY_MS);

Otherwise you should be prepared to manually verify the sequenceId if possible, and request the snapshot again if there is a gap between the snapshot and the first update by calling client.requestLevel2Snapshot(market) again.

ccxws's People

Contributors

abogical avatar aurecchia avatar benoist avatar bmancini55 avatar camray avatar carlos-r-l-rodrigues avatar coretechs avatar dependabot[bot] avatar dwynr avatar ejfrancis avatar evan-coygo avatar gmaf avatar hhagelbe avatar iamthemachine avatar jackson123d avatar jakebrown58 avatar karimhossenbux avatar panevgen avatar pavel-khritonenko avatar polyetilen avatar rejdzu avatar shutch avatar tiptoeeye avatar tominon avatar traderr avatar woonchancho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ccxws's Issues

Trade "fullId" property is missing

v0.26.4

Exchange
Binance, Kraken, Coinbase Pro, Poloniex. This seems to be on every exchange but I haven't tried all of them

Subscription type
trades

Describe the bug
The "fullId" documented Trade event property is not included. This makes it difficult or impossible to know if the trade event is for the specific market you subscribed to if you've subscribed to multiple.

Here are a couple payloads received:

 Trade {
      exchange: 'CoinbasePro',
      quote: 'ETH',
      base: 'BTC',
      tradeId: '8137331',
      unix: 1565828460948,
      side: 'buy',
      price: '0.01861000',
      amount: '0.02361238',
      buyOrderId: '1a8ff9efbf64423a92fa24f8c867ead0',
      sellOrderId: '9437194088d448a3af35aebb11584266' }
{
      exchange: 'Binance',
      quote: 'ETH',
      base: 'BTC',
      tradeId: '126287492',
      unix: 1565828362478,
      side: 'buy',
      price: '0.01861000',
      amount: '0.10600000',
      buyOrderId: undefined,
      sellOrderId: undefined }
 Trade {
      exchange: 'Kraken',
      quote: 'ETH',
      base: 'BTC',
      tradeId: '1565828233337300000',
      unix: 1565828233337,
      side: 'buy',
      price: '0.018590',
      amount: '13.50000000',
      buyOrderId: undefined,
      sellOrderId: undefined,
      rawUnix: '1565828233.337347' }

To Reproduce

 this.ccxws.subscribeTrades(ccwxsMarket);
 this.ccxws.on('trade', (trade) => {
    console.log('---trade=', trade);
 });

Expected behavior
The documented "fullId" property should be on the event payload.

Watcher does not reset on ticker event

Exchange
All exchanges that support tickers

Subscription type
ticker

Describe the bug
The last update time kept internally in the watcher is not updated on ticker events, therefore clients that only subscribe to those are reconnected every 90 seconds.

To Reproduce

  1. Connect to the ticker event with a client that supports that (e.g. the Bittrex one)
  2. Wait for 90 seconds
  3. The watcher logs info: watcher initiating reconnection then disconnects and reconnects the client.

Expected behavior
The client connection should be kept alive by ticker messages as well

Additional context
I'll provide a PR to fix the issue. In case this behaviour was intentional, I'll find a way around the problem :)

Change trade properties to industry standard values

The trade event should be outputting industry standard data:

  • unix time should not be truncating valid unix timestamps to seconds
  • add flag for buy/sell instead of +/- amount
  • amount should always be positive

Bittrex: Error invoking Hub method 'corehub.QueryExchangeState'

Exchange
Bittrex

Subscription type
Trades, Level2 orderbook updates for BTC/LTC

Describe the bug
Received an error in invoking Hub method 'corehub.QueryExchangeState'. Might be a SignalR hub issue.

To Reproduce
Steps to reproduce the behaviour:

  1. Initialise Bittrex Client
  2. Call the function for subscribeLevel2Updates(market) with the specified market.
  3. Receive the following error.

Error:

info: cloudflare connection to https://bittrex.com/
info: subscribing to level2 updates Bittrex BTCLTC
info: connected to wss://socket.bittrex.com/signalr
error: snapshot failed BTCLTC There was an error invoking Hub method 'corehub.QueryExchangeState'.
error: subscribe failed BTCLTC There was an error invoking Hub method 'corehub.SubscribeToExchangeDeltas'.

Here's the code snippet:

async subscribe(intent, uuid, full_instrument){
    this.bittrexClient = new ccxws.bittrex();

    let market = {
      id: "BTC-LTC",
      base: "LTC",
      quote: "BTC",
    };

    this.bittrexClient.subscribeLevel2Updates(market);
    this.bittrexClient.on("l2updates", snapshot => console.log(snapshot));
}

Expected behavior
Expected to receive and print JSON objects of the bids and asks price from Bittrex exchange to the console.

Candlestick charts

Is it in the roadmap and if so when do you plan to release. Thank you for the great work.

Flaky test for change and changePercent

Exchange
No

Subscription type
No

Describe the bug
Flaky tests caused when change/percentChange are negative. This will need to be fixed in all test files.

expect(Math.abs(parseFloat(ticker.change))).toBeGreaterThan(0);
expect(Math.abs(parseFloat(ticker.changePercent))).toBeGreaterThan(0);

To Reproduce
Steps to reproduce the behavior:

  1. Run tests
  2. Observe intermittent failures on down days

Expected behavior
Tests should not be flaky

Screenshots
N/A

Desktop (please complete the following information):
N/A

Add exchange Bitmart

Please provide as much information as possible to make the addition of the exchange easier:

Exchange URL
https://www.bitmart.com/

Exchange API URL
https://github.com/bitmartexchange/api-docs/tree/master/websocket

Additional information about Websocket connection


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Error parsing upbit json

Exchange
Upbit

Subscription type
Trades

Describe the bug
Error parsing upbit json response, process exited on error.
This happened after a few successful days of consuming upbit trades socket.
I think node process should not stop on such kinds of errors?

info: connected to wss://api.upbit.com/websocket/v1
undefined:1
x�e�Mo�0
        ����-JB[5�Cڄh�=���6 !��>[[U}�_��?^���������P��v�۱�w���n(xJ!2ɥL�?�2ړA0.c��<���Ƌ4/8���,eAFW����ZdAx�͝�<g+�;$k�G��o��
                                                                                                                         Nڔ2���ꦟ\wY���
                                                                                                                                      -��Q�!�S�cdN�v��w�QD�N ��խ��^yܜ��S?���b�
^

SyntaxError: Unexpected token x in JSON at position 0
    at JSON.parse (<anonymous>)
    at UpbitClient._onMessage (/usr/src/app/node_modules/ccxws/src/exchanges/upbit-client.js:72:17)
    at emitOne (events.js:116:13)
    at SmartWss.emit (events.js:211:7)
    at WebSocket._wss.on.msg (/usr/src/app/node_modules/ccxws/src/smart-wss.js:70:43)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at Receiver.receiverOnMessage (/usr/src/app/node_modules/ws/lib/websocket.js:720:20)
    at emitOne (events.js:116:13)
    at Receiver.emit (events.js:211:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node ws.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-04-18T03_04_14_107Z-debug.log

To Reproduce
Steps to reproduce the behavior:
No idea, this fixed after restart and happened only once.

Expected behavior
Log error, but do not stop proccess

Add exchange Kraken

Please provide as much information as possible to make the addition of the exchange easier:

Exchange API URL
https://www.kraken.com/features/websocket-api

Additional information about Websocket connection
ws.kraken.com - Once the socket is open you can subscribe to a channel by sending a subscribe request message.

Supports, ticker, ohlcv, trade, l2 orderbook updates (snapshot provided at start).


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Add exchange KuCoin

Please provide as much information as possible to make the addition of the exchange easier:

Exchange API URL
https://docs.kucoin.com/#public-channels

Additional information about Websocket connection
Looks to support tickers, trades, l2 order book, and l3 order books


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Restart method missing

Following exchanges are missing the restart method:

  • bibox
  • bitstamp
  • coinex
  • gemini

This method should exist and restart any connections that exist. This also ensures uniformity of client interface.

Support running in browser

When I try to get data by your lib, I geting warnings like this:

image

And catch this error:
image

This is how I try to fetch data:

const ccxws = require("ccxws");

export default function wsUpdate() {
  const binance = new ccxws.Binance();
  const market = {
    id: "USDT-BTC", // remote_id used by the exchange
    base: "BTC", // standardized base symbol for Cardano
    quote: "USDT" // standardized quote symbol for Bitcoin
  };

  binance.subscribeTrades(market);
  binance.on("trades", trade => console.log(trade));
}

OKEx needs to migrate to v3 websocket API

Exchange
OKEx

Describe the bug
OKEx v1 feeds are no longer available. The new API documentation states

Please note that the current version of this document is v3 and it will be updated regularly. Traders are advised to check this document from time to time for latest updates.

So it looks like the library needs to migrate to the new API since the old one is offline now.

New documentation: https://www.okex.com/docs/en/#spot_ws-general
The V3 API uses the V3 REST API, this corresponds ot the okex3 ccxt client as well.

Better error handling

I've had CCXWS running on multiple exchanges and assets for a while now, and recently noticed that some exchanges (Binance in this case) will throw an error and cause my script to crash, even with a try catch around it. Below is the snippet I receive. I am trying to add logic to my code so I can catch this error and handle it myself and believe this is a bug. If it isn't, please let me know how to handle it as there doesn't appear to be any documentation and what I've tried so far hasn't worked (try catch and websocket.on('error')).

`info: watcher initiating reconnection
info: reconnecting
info: closing connection to wss://stream.binance.com:9443/stream?streams=bnbusdt@aggTrade
info: attempting connection
info: connecting to wss://stream.binance.com:9443/stream?streams=bnbusdt@aggTrade
events.js:183
throw er; // Unhandled 'error' event
^

RangeError: Invalid WebSocket frame: invalid status code 1005
at Receiver.controlMessage (/var/www/html/discord-node/node_modules/ccxws/node_modules/ws/lib/receiver.js:441:18)
at Receiver.getData (/var/www/html/discord-node/node_modules/ccxws/node_modules/ws/lib/receiver.js:329:42)
at Receiver.startLoop (/var/www/html/discord-node/node_modules/ccxws/node_modules/ws/lib/receiver.js:133:22)
at Receiver._write (/var/www/html/discord-node/node_modules/ccxws/node_modules/ws/lib/receiver.js:69:10)
at doWrite (_stream_writable.js:397:12)
at writeOrBuffer (_stream_writable.js:383:5)
at Receiver.Writable.write (_stream_writable.js:290:11)
at TLSSocket.socketOnData (/var/www/html/discord-node/node_modules/ccxws/node_modules/ws/lib/websocket.js:795:35)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:607:20)
error: Forever detected script exited with code: 1
error: Script restart attempt #179`

Add exchange IDEX

Please provide as much information as possible to make the addition of the exchange easier:

Exchange URL
https://idex.market/

Exchange API URL
https://docs.idex.market/

Additional information about Websocket connection


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Poloniex silently drops connection

Poloniex will silently drop the socket connection without triggering reconnection logic. Investigate whether their API supports a ping/pong mechanism.

Support for klines in all exchanges

First of all thank you for the amazing integration across various exchanges.
I looked through the code and see subscribeTicker, subscribeTrade etc but dont find klines anywhere. Do you have any plans of integrating klines from each exchange?

Thannks

Binance ticker has timestamp in microseconds

Exchange
Binance

Subscription type
Ticker

Describe the bug
The timestamp in the ticker message "is in microseconds", but should be in milliseconds according to the documentation. (all other exchanges report it in milliseconds).

To Reproduce

  • Connect to ticker feed for Binance
  • Receive a message?

Expected behavior
The timestamp should be in milliseconds. Looking at the code I can see that the value retrieved from the Binance feed is then multiplied by 1000 (src/exchanges/binance-client.js:239). Was this done on purpose or is it maybe a leftover from a previous version of the Binance API?

I can raise a PR to fix this if you agree that the * 1000 should be removed.

Cheers!

Add exchange Bibox

Please provide as much information as possible to make the addition of the exchange easier:

Exchange URL

Exchange API URL
https://github.com/Biboxcom/API_Docs_en/wiki/WS_API_Reference

Additional information about Websocket connection
Ticker: https://github.com/Biboxcom/API_Docs_en/wiki/WS_API_Reference#subscribe-ticker-bibox_sub_spot_pair_ticker
Trades: https://github.com/Biboxcom/API_Docs_en/wiki/WS_API_Reference#subscribe-deals-bibox_sub_spot_pair_deals
L2 Snapshots: https://github.com/Biboxcom/API_Docs_en/wiki/WS_API_Reference#subscribe-depth-bibox_sub_spot_pair_depth

Does not appear to have L2 updates, only snapshots, but will want to verify this.

Implementation similar to OKEx, will need to run inflate on payload.


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Add exchange UpBit

Please provide as much information as possible to make the addition of the exchange easier:

Exchange API URL
https://docs.upbit.com/docs/upbit-quotation-websocket

Additional information about Websocket connection
Documentation in Korean. WebSocket supports Tickers, Trades, and L2 Orderbooks Updates (snapshot provided on connection).

BasicClient can probably be used, it looks like the socket allows subscribing to more than one feed per connection.


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and smallest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Add exchange Coinex

Exchange Name
Coinex

Exchange URL
https://www.coinex.com/

Exchange API URL
Tickers - https://github.com/coinexcom/coinex_exchange_api/wiki/021ticker
Trades - https://github.com/coinexcom/coinex_exchange_api/wiki/045deals
L2 Snapshot - https://github.com/coinexcom/coinex_exchange_api/wiki/022depth

Describe the technology used by the exchange use for realtime updates?

Does each market require it own connection?
Yes

Describe how subscriptions occur

#Request
{
  "method":"deals.subscribe",
  "params":[
    "BTCBCH"                        #1.market: See<API invocation description·market> 
  ],
  "id":16
}

It is standard JSON RPC subscribe. But it will unsubscribe if you subscribe to more than one feed per connection.

Can you subscribe to tickers?
Yes, each market has its own ticker feed
https://github.com/coinexcom/coinex_exchange_api/wiki/053state

Can you subscribe to candles?
Yes
https://github.com/coinexcom/coinex_exchange_api/wiki/046kline

Are trades and order book updates provided in a unified market feed?
No, it is 2 separate feeds
Market depth / orderbook - https://github.com/coinexcom/coinex_exchange_api/wiki/044depth
Transactions / trades / ticks/ match - https://github.com/coinexcom/coinex_exchange_api/wiki/045deals

Can you subscribe to trades?
Yes
https://github.com/coinexcom/coinex_exchange_api/wiki/045deals

Can you subscribe to level2 snapshots?
Yes, a level2 snapshot can be manually requested (Ex: Bittrex)
https://github.com/coinexcom/coinex_exchange_api/wiki/044depth

Can you subscribe to level2 updates?
Yes, there is a feed for level2 updates (Ex: Bitfinex)
https://github.com/coinexcom/coinex_exchange_api/wiki/044depth

Can you subscribe to level3 snapshots?
No

Can you subscribe to level3 updates?
No

Additional Poloniex markets

Last supported market for Poloniex appears to be 239. Need to add the new markets to the client's MARKET_IDS map. Refer to https://docs.poloniex.com/#currency-pair-ids

240 | USDC_XRP
241 | USDC_XMR
242 | USDC_STR
243 | USDC_DOGE
244 | USDC_LTC
245 | USDC_ZEC
246 | BTC_FOAM
247 | USDC_FOAM
248 | BTC_NMR
249 | BTC_POLY
250 | BTC_LPT
251 | BTC_GRIN
252 | USDC_GRIN

Add exchange CEX.io

Exchange Name
CEX.io

Exchange API URL
https://cex.io/websocket-api-dsl
wss://ws.cex.io/ws

Describe the technology used by the exchange use for realtime updates?

  • Websockets - wss://ws.cex.io/ws
  • Authenticated - requires an API token to access full Orderbook API

Does each market require it own connection?
No

Describe how subscriptions occur
Standard subscription payload as shown below. However, there are two modes for accessing data. You can use the "Old Pair-Room Subscription" to access a partial order book, trades, and ticker. You need to be authenticated to access the full order book subscription.

{
  "e": "subscribe",
  "rooms": [
    "pair-BTC-USD"
  ]
}

Can you subscribe to tickers?
Yes, each market has its own ticker feed

  • It is part of the unified "room feed"

Can you subscribe to candles?
Yes

  • There is a new public api that does not require authentication to access this feed

Are trades and order book updates provided in a unified market feed?
Yes

There is the "Old Pair-Room Subscription" as described here:

This is the oldest subscription, on which Server is sending almost all public data to WebClient.

The data, in fact, represents Order Book, Market Depth, Trade History and History Updates, 1d OHLCV updates. Therefore, the subscription is overlapping with new OHLCV subscriptions, Order Book subscription for authenticated user.

Authenticated user can use either new, old or both.

There is also the authenticated order book feed that allow full depth snapshots and updates.

Can you subscribe to trades?
Yes, trades are broadcast as part of a unified market feed

Can you subscribe to level2 snapshots?
Yes, level2 snapshots are broadcast as part of an unified market feed - however this is only a partial orderbook
Yes, a level2 snapshot is broadcast at the start of level2 update subscription - authentication required

Can you subscribe to level2 updates?
Yes, there is a feed for level2 updates - authentication required

Can you subscribe to level3 snapshots?
No

Can you subscribe to level3 updates?
No

OKEx bad JSON causes process exit

Exchange
OKEx

Subscription type
All

Describe the bug
Reconnection error with bad JSON causes process crash.

2018-10-30T04:39:42.949Z - info: connected to wss://real.okex.com:10441/websocket
undefined:1
-�A
 ^

SyntaxError: Unexpected token � in JSON at position 1
    at JSON.parse (<anonymous>)
    at OKExClient._onMessage (/usr/src/trades/trade-engine/node_modules/ccxws/src/exchanges/okex-client.js:116:21)
    at emitOne (events.js:116:13)
    at SmartWss.emit (events.js:211:7)
    at WebSocket._wss.on.msg (/usr/src/trades/trade-engine/node_modules/ccxws/src/smart-wss.js:70:43)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at Receiver.receiverOnMessage (/usr/src/trades/trade-engine/node_modules/ws/lib/websocket.js:720:20)
    at emitOne (events.js:116:13)
    at Receiver.emit (events.js:211:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node src`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-30T04_39_43_198Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @blocktap/[email protected] engine: `cd trade-engine; npm start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @blocktap/[email protected] engine script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-30T04_39_43_208Z-debug.log

Refactor integration tests

Refactor integration test to be fixture based. We should run consistent tests between exchanges. Fixtures should control what features are allowed and what the expected outputs are for each object type

We should also migrate away from jest in factor of mocha + chai + sinon. The rationale for this change is to remove the massive dependency bloat caused by jest. Migrated fixture tests should be done with mocha.

ccxt market id

Exchange
ALL

Subscription type
AlLL

Describe the bug
ccxt uses [BASE]/[QUOTE] for pair symbols / id, are we able to follow as well?

for Bibox currently, one needs to pass in [BASE]_[QUOTE] to work...

internally, there should be a function to convert from ccxt symbol / id, to the one used by the exchange.

I can do it for bibox and make change if you wish, every public facing function on the exchange with market as input parameter will need to have the conversion if the format is not [BASE]/[QUOTE]

To Reproduce
Steps to reproduce the behavior:
use ETH/BTC as market id

Expected behavior
There will be error similar to "channel not valid" in chinese

Additional context
N.A.

Bitmex -l2snapshot and l2update are missing symbol

Exchange
Bitmex

Subscription type
Level2 orderbook updates

Describe the bug
Bitmex uses the symbol to uniquely identify contracts in the bitmex-client, lines 92 to 131, the symbol is used to set a market variable, but the symbol is ignored when creating the l2snapshot or l2update. This means that the term of the bitmex contract is ignored, as that resides in the symbol as opposed to inside the base and quote identifiers.

We need the symbol to propagate through on the l2update and l2snapshot.

To Reproduce
Steps to reproduce the behavior:
Run the bitmex client
l2Update and l2snapshot do not have symbol

Expected behavior
l2update and l2snapshot should have symbol

Additional context
Add any other context about the problem here.

CCXWS exchange disconnect / reconnect not working..

Notice the following error intermittently - but no auto reconnect after it occurs:

connecting to wss://stream.binance.com:9443/stream?streams=!ticker@arr
events.js:167
throw er; // Unhandled 'error' event
^

RangeError: Invalid WebSocket frame: invalid status code 1005
....
at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

Add exchange Cobinhood

Please provide as much information as possible to make the addition of the exchange easier:

Exchange URL
https://cobinhood.com

Exchange API URL
https://cobinhood.github.io/api-public/


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Add exchange Gate.io

Exchange URL
https://www.gate.io/

Exchange API URL
Tickers - https://www.gate.io/docs/websocket/index.html?javascript#ticker-api
Trades - https://www.gate.io/docs/websocket/index.html?javascript#trade-api
L2 Snapshot - https://www.gate.io/docs/websocket/index.html?javascript#depth-api

Describe the technology used by the exchange use for realtime updates?
Documentation: https://www.gate.io/docs/websocket/index.html?javascript#
Socket URL: wss://ws.gate.io/v3/
Uses JSON RPC
Uses Websockets

Simple WebSocket test

function socket_send_cmd(socket, cmd, params) {
    if (!params) 
    params = [];
    var msg = {
    id: client_id,
    method: cmd,    
    params: params
    };
    socket.send(JSON.stringify(msg));
}

var socket = new WebSocket('wss://ws.gate.io/v3');

socket.onopen = function () {
    console.log("Connected");
    socket_send_cmd(socket, 'trades.subscribe', ["ETH_USDT", "BTC_USDT"]);
};
socket.onmessage = function (e) {
    console.log('Server: ' + e.data);
}

Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

OKEx disconnection

OKEx disconnection after 10s or so. May be ping related. Or may need a semaphore to throttle large subscribes.

okex / okex3 remote_id conflict

Exchange
okex

Subscription type
Level2 orderbook updates

Describe the bug
Mismatch in exchanges id for ccxt and ccxws.

To Reproduce

We use ccxt for fetching markets list and ccxws to listen market data. If we get markets list from ccxt for okex and then we subscribe to Level2 updates in ccxws library - we get this error:

warn: failure response {"event":"error","message":"Channel spot/depth:eth_btc doesn't exist","errorCode":30040}

Expected behavior
Success subscription.

Additional context
In documentation ETH-BTC market mentioned, as we see eth_btc substituted in subscription.

okex3 exchange class fetches correct data

CCXT client name parity

Ensure there is parity between the client name in ccxws and ccxt.

  • create alias in index.js
  • update README with preferred client (more version specific).

kraken orderbook updates are different than bitfinex

Exchange
kraken

Subscription type
L2updates and L2snapshots

Describe the bug
bitfinex/kraken have different updates. When using bitfinex and L2updates and L2snapshots, i get a working, valid orderbook. When I use kraken in the same system, it doesnt work/update. What is going on there? Do i need to incorporate trades?

** steps to reproduce**
cant really reproduce as its production code, but is there documentation missing? I'm leaning towards implementing the websockets of kraken myself as binance and bitfinex both work but kraken is just not working properly.

Is there something i'm missing?

Bitfinex updates parsing error

Exchange
Bitfinex

Subscription type
Level2 orderbook updates

Describe the bug
Library returns channel number as a price of the update (557880.00000000 price for BTC/USDT pair)

Expected behavior
A clear and concise description of what you expected to happen.

Additional context

Bitfinex returns for updates [ channel_id, price, count, amout ], and the current code parses it as: let [price, count, size] = msg;

Bittrex bug

Exchange
Bittrex

Subscription type
trades

Describe the bug
crawler/node_modules/ccxws/src/exchanges/bittrex-client.js:216
onerror: err => winston.error("error", err).error,
^/src/exchanges/bittrex-client.js:216
onerror: err => winston.error("error", err).error,
^

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'net was worong'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Add exchange Ethfiniex

Please provide as much information as possible to make the addition of the exchange easier:

Exchange URL
https://www.ethfinex.com/api_docs

Exchange API URL
https://www.ethfinex.com/api_docs

Additional information about Websocket connection
Implements similar interface to Bitfinex. Client should be implemented in similar manner.


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Add semaphore to throttle connections for BasicMultiClient

Coinex hangs when you subscribe to all markets, Gate.io limits to 50 requests/sec. We need to add a semaphore to throttle subscriptions inside of BasicMultiClient.

Semaphore will need to wait connection connection of the BasicClient before moving releasing the semaphore.

Add exchange FatBTC

Exchange API URL
https://github.com/fatbtc/fatbtc-api-websocket

Additional information about Websocket connection
Looks to support Tickers, Trades, and L2 orderbooks (not sure if snapshots or update+snapshot)


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and smallest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Add exchange Coinsuper

Exchange API URL
https://github.com/coinsuperapi?tab=repositories

Additional information about Websocket connection
Looks to support Tickers, Trades, and L2 Updates (+Snapshot at start)

Requires using an API key to connect.


Refer to Contributing Guide for additional information.

  • Create client in src/exchanges that follows CCXWS library interface (refer to README)
  • Create client test suite in src/exchanges to validate subscribe/unsubscribe methods and that data parsing is correct
  • Add a lowercase export to index.js
  • Implement subscribe to tickers sending logic
    • must support calling subscribe multiple times in a row with different markets
  • Implement subscribe to trades
    • must support calling multiple times in a row with different markets
  • Implement subscribe to orderbooks/depth
    • should default to highest limit and highest resolution interval
    • determine if exchange supports snapshots, updates, or both
    • if exchange supports broadcasting depth updates, CCXWS should initiate a snapshot request when subscribe for a market is called and broadcast a snapshot event

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.