* WS: Relay disconnect errors to subscribers
Subscribers probably care when the WS got disconncted.
Tell them and expose a method to test the error for matching
* Fix linter error
* Engine: Fix false test passes for nil OrderManager
TestWebsocketRoutineManagerSetup tests that passing a nil value returns errNilOrderManager;
However that's not actually what would happen when order manager is configured off.
The arguments to setupWebsocketRoutineManager are interface types.
When a nil pointer of interface type is passed, it does NOT equal nil.
nil is a primitive type.
A nil pointer of interface type has the value (nil;type).
See [the Go lang spec](https://golang.org/ref/spec#Comparison_operators):
```
Interface values are comparable. Two interface values are equal if they have identical dynamic types and equal dynamic values or if both have value nil.
```
So that means that whilst this test was passing, because it was sending
in a real nil value and comparing it to a real nil, that's not what
would happen at runtime. At runtime the bot.OrderManager would be a nil
pointer to a concrete type *OrderManager, and so not comparible to nil.
This commit just fixes that oversight, and explains the often
misunderstood mechanics of comparing interface types to nil.
In practical terms this means that the tests assert that the WSRM would
not run without a OM, but in fact it actually would. And panic later.
This commit SHOULD introduce a FAILing test. Sorry if you're bisecting.
* WSM: Fix error on OrderManager not enabled
It's okay for OrderManager to not be enabled; It's configurable.
Remove the WSM setup protection and move it to runtime using IsRunning.
Left the WSM deps so they can be fixed as apporpriate to each.
* orderbook: Check assignment of time values and reject if not set.
* linter: fix
* buffer: additional linter winter fixter
* Implement through pending exchanges
* finished push
* linty: minty
* gomod: tidy
* thrasher: nits
* glorious: nits
* orderbook: purge type now in favour of external call allocation
* orderbook: push last param
* orderbook: only 1 unlock call is needed
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
When Kraken has a disconnect or failure that sets SetCanUseAuthenticatedEndpoints(false),
it's never re-enabled when the websocket is reconnected
That means all subsequent requests would fall back to rest
* Kraken: Fix error on WS update without status
* Kraken: Fix parsing of WS updates without Desc
* Kraken: Fix WS market order handling
* Kraken: Fix tests in parallel using DataHandler
* WebsocketManager: Fix order summary printing
* Kraken: Fix parallel tests race with DataHandler
* Kraken: Issue a classification err on asset 404
* Kraken: Switch to testify and close fixture
* Bitfinex: Fix cancel/update order WS ack not seen
Fixes#1288
* Bitfinex: Fix ws Unsubscribe and Resubscribe
Unsubscribe needed to use the channel id.
Resubscribe needs to have the original subscription params.
* Bitfinex: Fix ws Trades Fees on te
The ws channel for authenticated Trades sends two types of update:
* te, Trade Executed
* tu, Trade Execution Update
Only the second one contains fee information.
[See the docs](https://docs.bitfinex.com/reference/ws-auth-trades)
This commit fixes:
`exchange Bitfinex websocket error - unable to type assert trade fee`
after an executed market trade on the te update
* Bitfinex: Fix error on ws auth ok
This fixes:
`Bitfinex Could not find an existing channel subscription: account Pair:
ChannelID: 0`
It's not clear from history why we'd want to store a reference to the
ubiquitous 0 channel like this, but it's definitely wrong, and anything
that attempts to get channel information about 0 chan needs to be fixed
anyway.
* Bitfinex: Refactor wsUpdate handling
This commit doesn't break out all the sub-updater, but attempts to do
something about the unmanagable size of ws update handling
* Binfinex: Fix linter issue on chanId casing
* Bitfinex: Fix linter outdent complaint
* Bitfinex: Fix linter issues on test
* Bitfinex: Fix TestWsTradingPairSnapshot chan lookup
* Bitfinex: Remove unnecessary WsAddSubs in test
* Bitfinex: Fix TestWsSubscribedResponse chan
* Bitfinex: Throw a specific error for bad event
* Bitfinex: WS Type assertions for positionSnapshots
* Bitfinex: tradeUpdate type assertion
* Bitfinex: Reinstate default subscriptions
* Bitfinex: Assert chan assetType is the same
* Bitfinex: Lowercase error string
* Bitfinex: Refactor WS eventType/chanId handling
* Bitfinex: Fix linter issues
* Bitfinex: Fix delimiter for pairs with more than 6 chars
* Bitfinex: Fix WS handling of subscribed symbols
This simplifies the handling of subscription symbols.
Now that we know the channel up front from handling the subscribed
response we can limit the parsing forms needed
* Bitfinex: Placate the linter
* Bitfinex: Disable margin assets for WS
Margin WS Currently not fully implemented and causes subscription collisions with spot
* Bitfinex: Fix parsing of 4 part funding keys
This improves overall handling and errors on a few current assumptions
about key structure
* Bitfinex: Linter fixes
* Bitfinex: Remove key parsing from assetPairFromSymbol
* Bitfinex: Use native error wrapping
* Bitfinex: Skip disabled assets in default ws subs
* Orderbook: Add GetDepth to Base
Base.GetDepth returns the concrete book of which Base is a copy
This is probably useful for immutably monitoring orderbook health and state
whereas FetchOrderbook would trigger a refresh.
* Orderbook: Reword GetDepth comment
* Orderbook: Add test for Base.GetDepth
* allows sync manager customisation for values and logs
* config-example add
* who doesnt like more coverage?
* ensures you can actually disable it via config el oh el
* less ifs, better control
* fix verbose
* sync trades default false
* fix summary being printed when not enabled
* fixes config checker and output
* nits
* I can put this behind me now
* Fixed logCaSiNg
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* combines if statements
---------
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This prevents the frequent (5x / hour) disconn/reconns we're seeing with a
10s or even 20s traffic timeout.
I'd like to base the interval on the traffic timeout / 2, but that's
non-trivial right now, and 8s isn't an excessive default
* starting public endpoints
* Adding public endpoints
* added public spot market endpoints
* websocket subscriptions updates
* websocket push data handlers completing
* linter fix
* Added funding private endpoints
* Adding authenticated account endpoints
* Added fiat and OTC-RFQ authenticated endpoints
* trading authenticated endpoints
* completing trade endpoints and add public wrapper endpoints
* Authenticated wrapper functions and corresponding unit test
* Adding authenticated websocket endpoint and fixing wrapper functions
* Documentation and exchange websocket update
* update websocket orderbook checksum handling
* linter issues fix and unit test update
* remove invalid orderbook endpoint and unit test
* Documentation, handlers, and model types update
* minot fix
* Minor fixes
* Updating unit tests and added missing endpoints
* Add missing credential check
* Minor unit test fixes
* fix minor linter issue
* add snaphot test unit test
* Fix on update checksum and documentation update
* update exchange, add UpdateOrderExecutionLimits, and update documentation
* Minor fix on tickers fetching
* Minor websocket fix and smaill unit tests
* Minor websocket and naming fixes
* uncomment default channels
* Fix type and unit test issues
* websocket channels and data handling update
* Update Advanced-Algo websocket handling and minor fixes
* documentation and minor code fixes
* Fix name changes
* documentation contribution update
* intervalToString method update
* fix exchange_wrapper_standard tests
* Fix minor issues based on exchange_wrapper_standards_test
* Fix wrapper extended candlestick check
* websocket orders fetching error check method update
* Exchange name check and change
* docs: Add missing contributors
---------
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* stream/buffer: Adds key map optimisation (cherry-pick)
* stream/buffer: Add buffer to DataHandler intermediary. Add field InitialUpdate bool to toggle when first update is seen for initial sync.
* whoops
* buffer: Add difference benchmarks for reference
* glorious: nits (reverting out of context changes)
* RM unused error that will be used later
* purge: benchmark
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* fixes tests
* pair formats and extra fixes
* quick change before shazbert sees
* sneaky lint
* adds bybit mock testing and fixes test
* whoops
* error response instead
* classic forgetting to lint
* bybit live test no longer auto-records results
* ty thrasher- Update exchanges/bybit/bybit_wrapper.go
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
---------
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* Bitstamp: Fix orderbook snapshot blanking LastUpdate
Drive-By: Remove:
`Bitstamp BTC/USDT spot orderbook has zero bid price, filtering.`
It's unactionable and happens every snapshot right now
* Bitstamp: Use ob timestamps for LastUpdate
Obviously.
* SubmitOrder- order.Buy replaced with IsLong
Progresses #1270
* Btcmarkets: order.Buy and order.Sell changed to order.Bid and order.Ask
* Bithumb: SubmitOrder- order.Buy replaced with IsLong
Progresses #1270
* Binanceus: SubmitOrder- order.Buy replaced with IsLong
Progresses #1720
* Bistamp: SubmitOrder- order.Buy replaced with IsLong
Progresses #1270
* Bitfinex: Changed order Side to IsLong
* Binance:switch added to SubmitOrder
* Binance: Replaced Buy and Sell in SubmitOrder with IsLong and IsShort
* Binance:SubmitOrder if statement for order side simplified
* Bitfinex: Fix ws new/modify Order Fields
Fixes Type, Amount and Symbol for new order, and IsShort for modify
order
* Bitfinex: Fix ws order type for margin
Also unifies the pair symbol method to standardised fixCasing
* Fix lint warning on shadow err
* Bitfinex: Remove CustomID duplication for ws
* Kraken: Fix GetActiveOrders AssetType and CancelOrder wrappers
AssetType wasn't set when calling GetActiveOrders and no default case handling was in CancelOrder
* Kraken: Add basic CancelOrder wrapper asset coverage
* Kraken: Add AssetType to GetOrderInfo
* Kraken: Add order status for open orders
* Bitfinex: Order Execution Limits and Testing
* Bitfinex: added proposed changes
* Bitfinex: lint fixes- removed the unnecessary whitespace and replaced the value with indexing
* Bitfinex: Moved data len check before the string conversion, moved the error for the array conversion before the info len check
* Bitfinex: Change GetSiteInfoConfigData to return slice, add tests
* Bitfinex: Fixed lint issue by preallocating pairs
* kraken: fix websocket orderbook processing
* kraken: clean
* glorious: nits also add todo
* more: add required checksum to TODO for future, move variable to top
* glorious: get mad
* orderbook: fix retrieve issue
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* Kraken: Load asset limits for pairs
* Kraken: Add test for spot order limit loading
* Kraken: move Limits to UpdateExecutionLimits
* Kraken: Whitespace fixed
* Kraken: added ErrNotYetImplemented for the futures
* Kraken: Fix FetchTradablePairs Loading Limits
* Kraken: changed the error to match the Go 1.13 error package
---------
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>