* 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>
* Kraken: Fix Balances reporting 0 Free
This switches to BalancesEx(tended) to get Held assets so we can
construct a Total, Held and Free.
Without this fix we get 0 balance from GetFree()
Haven't added tests because no construct for mocks and it's private
data. Considering adding mocks a bridge to far for this fix.
* Kraken: Simplify GetBalance
* Okx: Fix panic during shutdown due to race
Error:
```
panic: runtime error: slice bounds out of range [:13340] with capacity 8192
bufio.(*Reader).Read(0x14000038540, {0x1400059cffc?, 0x4?, 0x0?})
/usr/local/go/src/bufio/bufio.go:250 +0x33c
github.com/gorilla/websocket.(*messageReader).Read(0x1400098bb78, {0x1400059cffc, 0x4, 0x4})
/Users/gbjk/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:1050 +0x208
io.ReadAll({0x12f36c618, 0x1400098bb78})
/usr/local/go/src/io/io.go:701 +0xe4
io/ioutil.ReadAll(...)
/usr/local/go/src/io/ioutil/ioutil.go:27
github.com/gorilla/websocket.(*Conn).ReadMessage(0x3?)
/Users/gbjk/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:1097 +0x54
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*WebsocketConnection).ReadMessage(0x140006622d0)
/Users/gbjk/go/pkg/mod/github.com/gbjk/gocryptotrader@v0.0.0-20230619070715-ae6f283f6be6/exchanges/stream/websocket_connection.go:217 +0x30
github.com/thrasher-corp/gocryptotrader/exchanges/okx.(*Okx).wsFunnelConnectionData(0x140019321e0?, {0x106909450, 0x140006622d0})
/Users/gbjk/go/pkg/mod/github.com/gbjk/gocryptotrader@v0.0.0-20230619070715-ae6f283f6be6/exchanges/okx/okx_websocket.go:346 +0x94
created by github.com/thrasher-corp/gocryptotrader/exchanges/okx.(*Okx).WsConnect
/Users/gbjk/go/pkg/mod/github.com/gbjk/gocryptotrader@v0.0.0-20230619070715-ae6f283f6be6/exchanges/okx/okx_websocket.go:234 +0x134
exit status 2
```
This happens when there's a race in calls to bufio because it over-reads. See [this comment](https://github.com/golang/go/issues/42289#issuecomment-723393783)
Detected using go -race:
```
WARNING: DATA RACE
Read at 0x00c000818bc0 by goroutine 2156:
github.com/gorilla/websocket.(*Conn).NextReader()
/Users/gbjk/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:1000 +0x38
github.com/gorilla/websocket.(*Conn).ReadMessage()
/Users/gbjk/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go:1093 +0x28
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*WebsocketConnection).ReadMessage()
/Users/gbjk/go/pkg/mod/github.com/gbjk/gocryptotrader@v0.0.0-20230619070715-ae6f283f6be6/exchanges/stream/websocket_connection.go:217 +0x44
github.com/thrasher-corp/gocryptotrader/exchanges/okx.(*Okx).wsFunnelConnectionData()
```
Because we started a new wsFunnelConnectionData for each re-connect.
This bug might apply to other exchanges.
* Okx: Fix websocket waitgroup going negative
Move the waitgroup additions to the actual places that use them
* Okx: Add nolint for revive
* Okx: Move wg Adds to outside goros
There is a risk of a race condition if we let the goros Add themselves.
* Okx: Simplify websocket reading
This fixes the issue that the WsRead and Multiplexer were intrinsically
linked to the websocket, even though they need to survive both
disconnects and Disable/Enables.
Messages are now handled in a goro, which means they might not be
sequential, but there's a very high chance that messages of the same
codepath will be handled sequentially. So orderbook, ticked and order
messages should be sequential
* Okx: Switch to blocking processing of ws msgs
* Okx: Remove nolint from Setup
Actioning a review comment: @gloriousCode prefers to avoid having to nolint this in favour of
a func call return.
* Okx: Remove redundant Wg use inside WsReadData
* Okx: Fix WsMultiplexer Re-Run() shutdown
* switch over to package defined const for time layout
* bump appveyor playa
* bumperino to latest while setting patherino
* whoooops
* bump VS version set GOROOT
* puge build cache
* Revert "puge build cache"
This reverts commit 315bb578afc19529457f435e52af2172f5143bc5.
* bumperino to test
* purge setting of golang directory for version and allow default
* purge cache state when file change
* whoops
* thrasher: nits
* don't need to flusherino the cacherino
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* initial concept of a nice validation tester for exchanges
* adds some datahandler design
* expand testing
* more tests and fixes
* minor end of day fix for bithumb
* fixes implementation issues
* more test coverage and improvements, but not sure if i should continue
* fix more wrapper implementations
* adds error type, more fixes
* changes signature, fixes implementations
* fixes more wrapper implementations
* one more bit
* more cleanup
* WOW things work?
* lintle 1/1337
* mini bump
* fixes all linting
* neaten
* GetOrderInfo+ asset pair fixes+improvements
* adds new websocket test
* expand ws testing
* fix bug, expand tests, improve implementation
* code coverage of a lot of new codes
* fixes everything
* reverts accidental changes
* minor fixes from reviewing code
* removes Bitfinex cancelBatchOrder implementation
* fixes dumb baby typo for babies
* mini nit fixes
* so many nits to address
* addresses all the nits
* Titlecase
* switcheroo
* removes websocket testing for now
* fix appveyor, minor test fix
* fixes typo, re-kindles killed kode
* skip binance wrapper tests when running CI
* expired context, huobi okx fixes
* kodespull
* fix ordering
* time fix because why not
* fix exmo, others
* hopefully this fixes all of my life's problems
* last thing today
* huobi, more like hypotrophy
* golangci-lint, more like mypooroldknee-splint
* fix huobi times by removing them
* should fix okx currency issues
* blocks the application
* adds last little contingency for pairs
* addresses most nits and new problems
* lovely fixed before seeing why okx sucks
* fixes issues with okx websocket
* the classic receieieivaier
* lintle
* adds test and fixes existing tests
* expands error handling messages during setup
* fixes dumb okx bugs introduced
* quick fix for lint and exmo
* fixes nixes
* fix exmo deposit issue
* lint
* fixes issue with extra asset runs missing
* fix surprise race
* all the lint and merge fixes
* fixes surprise bugs in OKx
* fixes issues with times and chains
* fixing all the merge stuff
* merge fix
* rm logs and a panic potential
* lovely lint lament
* an easy demonstration of scenario, but not of initial purpose
* put it in the bin
* Revert "put it in the bin"
This reverts commit 15c6490f713233d43f10957367fcbf18e3818bdd.
* re-add after immediate error popup
* fix mini poor test design
* okx okay
* merge fixes
* fixes issues discovered in lovely test
* I FORGOT TO COMMIT THIS
* nit fixaroonaboo
* forgoetten test fix
* revert old okx asset intrument work
* fixes
* revert problems I didnt understand. update bybit
* fix merge bugs
* test cleanup
* further improvements
* reshuffle and lint
* rm redundant CI_TEST by rm the CI_TEST field that is redundant
* path fix
* move to its own section, dont run on 32 bit + appveyor
* lint
* fix lbank
* address nits
* let it rip
* fix failing test time range
* niteroo boogaloo
* mod tidy, use common.SimpleTimeFormat
* Add test for dispatch channel reuse
* Dispatcher - make chans bidirectional
* No need to to keep the type assertion separate from the Get()
* Unexport Pipe's channel and add getter
* Okx: Fix Instrument unmarshal
This fixes: `json: invalid use of ,string struct tag, trying to unmarshal "" into float64`
when TwapSz or other fields are empty, which happened briefly today.
As a DriveBy it also simplifies the exposed Instrument type to native
types only.
* Okx: Add missing InstrumentFamily to Instrument
* Okx: Add Instrument Unmarshal tests
DriveBy: Removes stray newline in type conversions
* Okx: Fix empty line upsetting linter
* bitfinex: filter security pairs from spot trading
* asset: add securities type
* bitfinex: remove print
* linter: fix
* gomod tidy
* glorious: nits
* bitfinex: just some orderbook fun and added a pass through for bitfinex funding rate when rate == 0
* bitfinex: move update function from testmain to localised test
* test: fix up
* glorious:nits
* bitfinex; fix casing test
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
When an existing ws disconnects the connection manager goro will call Connect.
This prevents Connect trying to start another connection manager if it's
already running
* Adding Public Endpoints and test functions
* Adding public endpoints and test functions
* Adding private spot endpoints
* Adding private endpoints and corresponding tests for margin
* Adding Margin Private endpoints
* Adding cross margin and flash swap endpoints
* Adding futures private endpoints
* Adding futures private endpoints and corresponding tests
* Adding Options and SubAccount endpoints and their unit tests
* Adding Wrapper functions
* Complete wrapper functions and corresponding unit test functions
* Fixing wrapper issues and adding websocket functions
* Update of Spot websocket and adding futures websocket handlers
* completed futures WS push data endpoints
* Completed Options websocket endpoints
* Adding websocket support for delivery futures and slight update on endpoint funcs
* Added Delivery websocket support and fix linter issues
* Update on Unit tests
* fix slight currency format error
* Fix slight endpoint tempos
* Update on conditional statements and unit tests issues
* fixing slight tempos
* Slight model and websocket data push method change
* Fix unit test tempos and updating models
* Fix on code structures and update on unit tests
* Slight code fix
* Remove print statements
* Update on tradable pairs fetch eps
* Fix websocket tempos
* Adding types to websocket routine manager
* Fix slight issues
* Slight fixes
* Updating wrapper funcs and models
* Slight update
* Update on test
* Update on tradable pairs
* update conditional statements
* Fixing slight issues
* Updating unit tests
* Minor fixes depending review comments
* Remove redundant method declaration
* Adding missing intervals
* Updating fetch tradable pairs
* update tradable pairs issues
* Addressing small tempos
* Slight fix on ticker
* Minor Fixes
* Minor review comment fixes
* Unit test and minor code updates
* Slight code updates
* Minor updates depending review comments
* Fixes
* Updating incoming message matcher
* Fix missing merge issue
* Fix minor wrapper issues
* Updating ratelimit and other issues
* Updating endpoint models and adding missing eps
* Update on code structure and models
* Minor codespell fixes
* Minor update on models
* fix unit test panic
* Minor race fix
* Fix issues in generating signature and unit tests
* Minor update on wrapper and unit tests
* Minor fix on wrapper
* Mini linter issues fix
* Minor fix
* endpoint fixes and slight update
* Minor fixes
* Updating exchange functions and unit tests
* Unit test and wrapper updates
* Remove options candlestick support
* Minor unit test and wrapper fix
* Unit test update
* minor fix on unit test and wrapper
* endpoints constants name change
* Add minor wrapper issues
* endpoint constants update
* endpoint url updates
* Updating subscriptions
* fixing dual mode endpoint methods
* minor fix
* rm small tempo
* Update on websocket orderbook handling
* Orderbook and currency pair update
* fix linter and test issues
* minor helper function update
* Fix wrapper coverage and wrapper issues
* delete unused variables
* Minor fix on ReadData() call
* separating websocket handlers
* separating websocket handlers
* Minor fix on enabled pair
* minor fix
* check instrument availability in spot
* create a separate subscriber for sake of multiple websocket connection
* linter fix
* minor websocket and gateio endpoints fix
* fix nil pointer exception
* minor fixes
* spelling fix decerializes -> deserializes
* fix Bitfinex unit test issues
* minor unknown currency pair labling fix
* minor currency pair handling fix
* slight update on GetDepositAddress wrapper unit test
* setting max request job to 200
* fixing numerical and timestamp type convert
* fix value overflow error
* change method of parsing orderbook price
* unifying timestamp conversion types to gateioTime
---------
Co-authored-by: Samuael Adnew <samuaelad@Samuaels-MacBook-Air.local>
Ping handler for okx is not the RFC compat version gorilla would
support. Even if it was, I think the UseGorillaHandler is
broken/misconceived because it does not send keepalive pings, it responds to them.
This also increases the delay to 27, in keeping with the 30 second
timeout documented.
I think this issue was hidden by the noisy default subs.
When just using funding-rates, it showed straight away.
* Binance: Fix Exchange Order Limits not populating
The order of the filters cannot be trusted. New filters have been added
after the 2nd filter, breaking all filter passing afterwards.
This adds a basic test that the data is being populated, but more could
be done on testing.
We should have stricter typing on the filters, perhaps by unmarshalling into
json.RawMessage initially and then into typed stuct fields based on the
filterType. Finally we should spot both missing and unhandled filters, at least in
tests.
* Binance: Add TODO for unhandled filterTypes
* OKX: Support exchange order limits
Adds support for PriceStepIncrementSize and MinAmount limits
* OKX: Test UpdateOrderExecutionLimits on all assets
* OKX: Added asset types for order limit tests
It looks like this was an oversight.
No other exchange uses the funding account for balance and it wouldn't
make sense.
Again, this aims to be minimally invasive and backwards compatible, so
GetBalance is left alone to preserve compat.
* exmo: filter pairs that are not currently enabled by last update time
* stop filtering, add tests to qualify all deployable can be retrieved
* glorious: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* okx: fix get cryptocurrency deposit address for chain bug
* Update exchanges/okx/okx_wrapper.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Update exchanges/okx/okx_wrapper.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Revert "Update exchanges/okx/okx_wrapper.go"
This reverts commit 4345f57ce0e984f562ec576aeebc09407a1d2544.
* okx: temp filter for available transfer chain
* glorious: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
The channels for the ws multiplexer weren't made;
so any interaction with it would block.
Tests passed because they invasively setup the multiplexer.
There are quite a few architectural risks with this implementation
pattern, such as leaking an uncancellable goro in a for-select loop.
Ideally WsConnect should take a cancellable context and any selects
should watch for ctx.Done()
That's a very invasive and pervasive change though, so this fix is as minimal and
atomic as possible.
Will consider opening a PR for cancellable context or improving this
multiplexer pattern.
* exchanges/sharedtestvalues: implement new functions to handle test skipping and announcements for standardising.
* exchanges: fin test impl.
* linter: fixes
* exchange_template: fix test
* allocate so it doesn't make a panic at the disco
* glorious: nits
* glorious: nits
* Update exchanges/sharedtestvalues/sharedtestvalues.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Update exchanges/sharedtestvalues/sharedtestvalues.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* glorious: nits
* linter: fix
* linter: shhhh
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* exchanges: add setTimeWindow boolean to GetKlineRequest params to differentiate between a set time period return from endpoint.
* glorious: nits
* exchange: conjugation
* Update exchanges/exchange.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* glorious: nits and an assortment of differences
* exchanges: remove some comments
* glorious: nits
* cleanup
* tests: fix
* Update exchanges/hitbtc/hitbtc_wrapper.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Update exchanges/kline/kline.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Update exchanges/kline/kline_test.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* glorious: nits
* kline: fix test
* rm unused variables
* almost: nits
* glorious: nits
* linter: fix
* rm unused variable
* Refactored comment in the okex tests to ensure that it accurately reflects the variable name and the issue related to the time window, as requested by GloriousCode. The previous comment did not align with the identifier assigned to the property, which could cause confusion and misunderstanding among other programmers or stakeholders. The updated comment will improve the clarity and readability of the codebase and make it easier to understand the intended purpose of the associated variables. The change was made with the aim of improving the overall quality and maintainability of the code.
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* engine: shutdown and unload exchange when engine is stopped
* linter: fixes
* engine/exchMan: add nil check
* engine/exchanges: add shutdown method to exchanges, rm len check lock not needed, expanded code coverage, address some nits
* exchMan: report all failed shutdowns across exchanges, implement timer and monitoring routines.
* exchMan: improve shutdown sequence and aloc.
* further improvement
* exchman: log from warn to error
* websockconnection: Suppress error return when closure is caused by library
* linter: fix
* fix racies
* add note on why not parallel tests
* glorious: nits
* spelling kween
* thrasher: nits
* engine: change print of setting using reflection, I keep forgetting to implement this so program around forgetfulness
* engine/exchange_management: remove wait group and just rely on intermediary lock
* glorious: nits
* Update common/common.go
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* Update main.go
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* wrapper_coverage/exchanges: cancel context to not send rest requests/ populate context through functions that do rest requests
* linter: fix
* exchange_template: fix test
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* common: adjust common error slice to allow multi errors.Is matching and conform to interface better
* zb: forgot to save?
* linties: fixies
* linties: word change as well.
* nitters: glorious
* buts
* nitters: fix glorious bug
* Update common/common.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* nitters: shifty
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>