exchanges/websocket: Implement subscription configuration (#1394)

* Websockets: Move Subscription to its own package

This allows the small type to be imported from both `config` and from
`stream` without an import cycle, so we don't have to repeat ourselves

* Subs: Renamed Currency to Pair

This was being mis-used through much of the code, and since we're
already touching everything, we might as well fix it

* Websockets: Add Subscription configuration

* Binance: Add subscription configuration

* Kucoin: Subscription configuration

* Simplify GenerateDefaultSubs
* Improve TestGenSubs coverage
* Test Candle Sub generation
* Support Candle intervals
* Full responsibility for formatting Channel name on GenerateDefaultSubs
  OR consumer of Subscribe
* Simplify generatePayloads as a result
* Fix test coverage of asset types in processMarketSnapshot

* Exchanges: Abstract ParallelChanOp

* Tests: Generic ws mock instances

* Kucoin: Fix intermittent conflict in test currs

Use isolated test instance for `TestGetOpenInterest`.

`TestGetOpenInterest` would occassionally change pairs before
GenerateDefault Subs.
This commit is contained in:
Gareth Kirwan
2024-01-24 05:54:07 +01:00
committed by GitHub
parent 301551ac20
commit e007f69f7c
67 changed files with 3705 additions and 3167 deletions

View File

@@ -6,21 +6,21 @@
+ Contains configurations for:
- Exchanges for utilisation of a broad or minimal amount of enabled
exchanges [Example](#enable-exchange-via-config-example) for
enabling an exchange.
- Enable/Disable Exchanges. [See Example](#enable-exchange-via-config-example)
- Bank accounts for withdrawal and depositing FIAT between exchange and
your personal accounts [Example](#enable-bank-accounts-via-config-example).
your personal accounts. [See Example](#enable-bank-accounts-via-config-example)
- Portfolio to monitor online and offline accounts [Example](#enable-portfolio-via-config-example).
- Portfolio to monitor online and offline accounts. [See Example](#enable-portfolio-via-config-example)
- Currency configurations to set your foreign exchange provider accounts,
your preferred display currency, suitable FIAT currency and suitable
cryptocurrency [Example](#enable-currency-via-config-example).
cryptocurrency. [See Example](#enable-currency-via-config-example)
- Communication for utilisation of supported communication mediums e.g.
email events direct to your personal account [Example](#enable-communications-via-config-example).
email events direct to your personal account. [See Example](#enable-communications-via-config-example)
- Websocket subscription channels. [See Example](#configure-exchange-websocket-subscriptions)
# Config Examples
@@ -194,6 +194,38 @@ comm method and add in your contact list if available.
},
```
## Configure exchange websocket subscriptions
+ Websocket subscriptions provide a stream of data from an exchange.
Whilst subscriptions are specific to each exchange, some common examples are: candles, orderbook, ticker and allTrades.
You can configure any supported channels in your exchange, but most likely you just want to disable some of the defaults, or change the default intervals.
You cannot configure an empty list of subscriptions, instead set all of the subscriptions to enabled: false.
See the section `exchange.features.enabled.subscriptions` for configuring subscriptions:
```js
"subscriptions": [
{
"enabled": true,
"channel": "ticker"
},
{
"enabled": false,
"channel": "allTrades"
},
{
"enabled": true,
"channel": "candles",
"interval": "1m"
},
{
"enabled": true,
"channel": "orderbook",
"interval": "100ms"
}
]
```
## Configure Network Time Server