* Convert: Fix TimeFromUnixTimestampDecimal using local All parsed times should be in UTC * Subscriptions: Add IgnoringAssetsKey * Tests: Pass tb to curried WS handlers * Websocket: Make ErrNoMessageListener a public error * Kraken: Fix URLMap ignored for websocket URLs * Kraken: Move SeedAssets from Setup to Bootstrap Having SeedAssets in Setup is cruel and unusual because it calls the API. Most other interactive data seeding happens in Bootstrap. This made it so that fixing and creating unit tests for Kraken was painfully slow, particularly on flaky internet. * Kraken: Remove convert test Duplicate of convert_test.go TestTimeFromUnixTimestampDecimal * Kraken: Test config upgrades * Kraken: Sub Channel improvements * Use Websocket subscriptionChannels instead of local slice * Remove ChannelID - Deprecated in docs * Simplify ping handlers and hardcodes message * Add Depth as configurable orderbook channel param * Simplify auth/non-auth channel updates * Add configurable Book depth * Add configurable Candle timeframes Kraken: Simplify all WS handlers with reqId * Kraken: Subscription templating * Generate N+ subs for pairs If we generate one sub for all pairs, but then fan it out in the responses, we end up with a mis-match between the sub store and GenerateSubs, and when we do FlushChannels it will try to resub everything again. * Kraken: Rename channelName var throughout Avoid shadowing func of same name * Kraken: Add TestEnforceStandardChannelNames * Websocket: Fix Resubscribe erroring Duplicate
GoCryptoTrader package Subscription
This subscription package is part of the GoCryptoTrader codebase.
This is still in active development
You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.
Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack
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:
S *subscription.Subscription
AssetPairs map[asset.Item]currency.Pairs
AssetSeparator string
PairSeparator string
BatchSize 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 directives:
- AssetSeparator should be added at the end of each section related to assets
- PairSeparator should be added at the end of each pair
- BatchSize should be added with a number directly before AssetSeparator to indicate pairs have been batched
Example:
{{- range $asset, $pairs := $.AssetPairs }}
{{- range $b := batch $pairs 30 -}}
{{- $.S.Channel -}} : {{- $b.Join -}}
{{ $.PairSeparator }}
{{- end -}}
{{- $.BatchSize -}} 30
{{- $.AssetSeparator }}
{{- end }}
Assets and pairs should be output in the sequence in AssetPairs since text/template range function uses an sorted order for map keys.
Template functions may modify AssetPairs to update the subscription's pairs, e.g. Filtering out margin pairs already in spot subscription
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.
Contribution
Please feel free to submit any pull requests or suggest any desired features to be added.
When submitting a PR, please abide by our coding guidelines:
- Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
- Code must be documented adhering to the official Go commentary guidelines.
- Code must adhere to our coding style.
- Pull requests need to be based on and opened against the
masterbranch.
Donations
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc