mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-18 15:10:03 +00:00
* Subscriptions: Add List.AssetPairs * Subscriptions: Add Template and QualifiedChannel These fields separate the concept of what the channel is from the qualified resource name * Subscriptions: Add List.SetStates() * Subscriptions: Add List.QualifiedChannels * Subscriptions: Rename testsubs.EqualLists * Binance: Switch to ExpandTemplates * Binance: Update ConfigTest format * Subscriptions: Test Coverage improvements * Subscriptions: Reenterant List.ExpandTemplates * Subscriptions: Move templates from subscriptions to exchanges * Binance: Inline subscription template and improvements
39 lines
1.6 KiB
Cheetah
39 lines
1.6 KiB
Cheetah
{{define "exchanges subscription" -}}
|
|
{{template "header" .}}
|
|
# Exchange Subscriptions
|
|
|
|
Exchange Subscriptions are streams of data delivered via websocket.
|
|
|
|
GoCryptoTrader engine will subscribe automatically to configured channels.
|
|
A subset of exchanges currently support user configured channels, with the remaining using hardcoded defaults.
|
|
See configuration Features.Subscriptions for whether an exchange is configurable.
|
|
|
|
## Templating
|
|
|
|
Exchange Contributors should implement `GetSubscriptionTemplate` to return a text/template Template.
|
|
|
|
Exchanges are free to implement template caching, a map or a mono-template, inline or file templates.
|
|
|
|
The template is provided with a single context structure:
|
|
```go
|
|
S *subscription.Subscription
|
|
AssetPairs map[asset.Item]currency.Pairs
|
|
AssetSeparator string
|
|
PairSeparator string
|
|
```
|
|
|
|
Subscriptions may fan out many channels for assets and pairs, to support exchanges which require individual subscriptions.
|
|
To allow the template to communicate how to handle its output it should use the provided separators:
|
|
- AssetSeparator should be added at the end of each section related to assets
|
|
- PairSeparator should be added at the end of each pair
|
|
|
|
We use separators like this because it allows mono-templates to decide at runtime whether to fan out.
|
|
|
|
See exchanges/subscription/testdata/subscriptions.tmpl for an example mono-template showcasing various features
|
|
|
|
Templates do not need to worry about joining around separators; Trailing separators will be stripped automatically.
|
|
|
|
{{template "contributions"}}
|
|
{{template "donations" .}}
|
|
{{end}}
|