gocryptotrader
gocryptotrader copied to clipboard
exchanges/websocket: Add multi-asset websocket support
PR Description
This PR adds a structure for multi-asset web-socket connection support, integrates the WebSocket initialization method of each exchange's web-socket implementation, and integrates and tests the existing exchange web-socket implementation with the new structure.
Fixes # (issue)
Type of change
Please delete options that are not relevant and add an x
in []
as the item is complete.
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and also, consider improving test coverage whilst working on a certain feature or package.
- [ ] go test ./... -race
- [x] golangci-lint run
- [x] Test X
Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally and on Github Actions/AppVeyor with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
At present it does not respect enabled/disabled status:
CLI:
go run . websocket disable bybit
{
"status": "success",
"data": "websocket disabled"
}%
GCT:
[INFO] | SYNC | 20/06/2023 12:29:56 | Bybit websocket ETH-USDT SPOT TICKER: Last 0.00000000 Ask 1733.22000000 Bid 1733.21000000 High 0.00000000 Low 0.00000000 Volume 0.00000000
...
It continues to retreive updates.
Same goes for the other way around: CLI:
go run . websocket enable bybit
{
"status": "success",
"data": "websocket enabled"
}%
GCT:
[ERROR] | WEBSOCKET | 20/06/2023 12:31:45 | exchange_websocket_not_enabled
[ERROR] | WEBSOCKET | 20/06/2023 12:31:45 | exchange_websocket_not_enabled
[ERROR] | WEBSOCKET | 20/06/2023 12:31:45 | exchange_websocket_not_enabled
[ERROR] | WEBSOCKET | 20/06/2023 12:31:45 | exchange_websocket_not_enabled
...
[INFO] | SYNC | 20/06/2023 12:31:52 | Bybit REST BTC-USDT SPOT ORDERBOOK: Bids len: 100 Amount: 40.045890 BTC. Total value: 1076825.14066108 Asks len: 100 Amount: 53.459005 BTC. Total value: 1439965.5263056096
These are the kinds of things you will need to be considering for such a global solution
The exchanges LoadExchange method is giving the exchange config according to the terminal input.
WebSocket is disabled in the input but the config is returning another WebSocket enabled .