* build/ci: Update Go to v1.24, golangci-lint to v1.64.5 and fix issues
* Address shazbert's nitters
* linter/config: Fix new linter issue and use versionSize const
* Address gk's nitters and fix additional linter issue after rebase
* Address glorious nits
* staticcheck: Fix additional linter issues after upgrading to Go 1.24.1 and golangci-lint v1.64.6
Also addresses nits
* Improve testing, assertify usage and use common.ErrParsingWSField
* TestCreateNewStrategy: Replace must > should wording
* tag optional sonic and allow full library conversion
* Add workflow and disallow arm and darwin usage
* Add basic hotswap benchmark
* linter: fix
* use bash
* linter: fix?
* Fix whoopsie, add to make file, also add mention in features list.
* test enforcement
* actually read documentation see if this works
* linter: fix
* linter: fix
* sonic: bump tagged version
* encoding/json: drop build tag arch and os filters
* encoding/json: consolidate tests
* encoding/json: log build tag usage
* rm superfluous builds
* glorious/nits: add template change and regen docs
* glorious/nits: update commentary on nolint directive
* glorious/nits: rm init func and log results in main.go
* Test to actually pull flag in
* linter: fix
* thrasher: nits
* gk: nits 4 goflags goooooooooo!
* gk: nits rn
* make sonic default json implementation
* screen 386
* linter: fix
* Add commentary
* glorious: nits Makefile not working
* gk: nits
* gk: nits whoops
* whoopsirino
* mention 32bit systems won't be sonic
* gk: super-duper nit of extremes
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* update acccount ratelimits and added missing endpoints
* completed mapping missing trade accoung REST endpoints and Rate Limit
* added orderbook trading missing REST endpoints
* Added few missing endpoints and unit tests
* Completed grid trading and signal bot trading with unit tests
* Added Recurring Buy endpoints and corresponding unit tests
* Added copy trading endpoints and unit tests
* added newly added block trading and spread endpoints
* completed mapping spread endpoints
* Added new endpoints and unit tests
* Added round 1: Okx types and converts update.
* Update endpoints handling and types update
* Removed constants, updated unit tests, and updated endpoint methods
* Slight endpoint and unit test update
* Added spread and other websocket endpoints and update
* completed Spread WS Orderbook handler
* Added missing spread channels and handlers
* Adding Bussinss websocket and missing subscriptions, update unit tests, and endpoints
* Added spread endpoints to wrapper and unit tests update
* Added missing websocket subscriptions and copy trading endpoints
* Added missing endpoints and re-organize business websocket handlers
* Docs update
* Endpoints code updates
* types, unit test and endpoints update
* Minor unit tests update
* spelling fix
* fix unit test issues
* Updating unit tests error handling
* Updating unit tests error handling
* Unit tests assertion handling update
* Unit tests update
* Resolve linter issues
* linter issues fix
* Orderbook unit test error fix
* Minor fixes
* Change on test handling and types
* Updating unit tests and cleanups
* Fix unit test issues
* Add ratelimit test and update unit tests and methods
* Update method parameters and error declarations
* Added lending endpoints, unit tests, and update endpoint methods and error declarations
* Update ratelimiters, add missing lending and trading endpoints and unit tests
* Update websocket authentication and subscription handling
* Minor update to unit test and types
* Types, error handling, and other minor updates
* Update unit tests and endpoint functions
* error declarations update and unit tests
* Overall update on unit endpoint, unit tests, and types
* Adding review fixes
* Update on endpoints, order types, and unit tests
* Update unit tests and endpoint functions
* Update on endpoint and update missing parameters
* Implemented and tested newly added trading endpoints
* endpoints update and unit tests
* Update missing endpoints and update overall code
* added and testing funding and fiat related endpoints
* Update on convert and fiat related endpoints
* linter fix, types, endpoints, and unit tests update
* linter issues fix
* revert changes on tempos
* Fix Panic and update websocket auth calls handling
* config linter issue fix
* Fix panic issues and update unit tests
* Fix race condition, TestAllExchangeWrappers unit test issues
* Fix withdrawal manager test issue
* Rename ClosePositionForContractrID --> ClosePositionForContractID
* Rename ClosePositionForContractrID --> ClosePositionForContractID
* Fix error
* endpoints update and fix unit test issues
* added unit tests, updated comments, and code sections
* revert change in defaultSubscriptions
* few types comments update
* Minor changes
* remove lending endpoints
* rm mistakenly added code
* fix unit test
* minor unit test fix
* Adding offline error tests, update endpoints function, config update
* Update unit test coverage for offline error handliing
* Updating wrapper algo order coverage, endpoint calls, and unit tests
* Updating wrapper trade functions to accomodate algo orders
* update wrapper unit tests
* Fix wrapper order functions offline errors handling
* Tested and updated wrapper order functions
* Address review comments
* update order unit tests, and okx endpoint functions
* finalize affected order, endpoint, and margin endpoints
* Slight change on margin unit test
* fix margin unit test issues
* Minor change on unit test
* updates on contract settlement and future contract wrapper function
* add test coverage for contract functions and minor fix on wrapper
* Overall update and unit testing
* codespell, unit tests, type declaration and naming, and code-structure updates
* margin types value and validation function fix
* Update tests and helper funcs
* Improve test coverage
* helper functions and unit tests update
* Fix margin unit test
* Minor review updates
* minor fix on if statement
* Update helper functions
* error handling and functions naming update
* update comment
* minor error return fixes
* minor unit test fix
* Minor fix on spread websocket orders handling
* codespell fix
* skip orderbook depth with incomplete price
* skip orderbook depth with incomplete price
* exchanges: Fix gateio/coinbase test failures
* OKX: Fix TestGetAssetsFromInstrumentTypeOrID race
* GateIO: Add/improve comments
* GateIO: Rid additional API call for FetchTradablePairs and provide additional context for test
* GateIO: Prompt test reviewers to take action if BTC settlement is supported again
* gateio: Add multi asset websocket support WIP.
* meow
* Add tests and shenanigans
* integrate flushing and for enabling/disabling pairs from rpc shenanigans
* some changes
* linter: fixes strikes again.
* Change name ConnectionAssociation -> ConnectionCandidate for better clarity on purpose. Change connections map to point to candidate to track subscriptions for future dynamic connections holder and drop struct ConnectionDetails.
* Add subscription tests (state functional)
* glorious:nits + proxy handling
* Spelling
* linter: fixerino
* instead of nil, dont do nil.
* clean up nils
* cya nils
* don't need to set URL or check if its running
* stop ping handler routine leak
* * Fix bug where reader routine on error that is not a disconnection error but websocket frame error or anything really makes the reader routine return and then connection never cycles and the buffer gets filled.
* Handle reconnection via an errors.Is check which is simpler and in that scope allow for quick disconnect reconnect without waiting for connection cycle.
* Dial now uses code from DialContext but just calls context.Background()
* Don't allow reader to return on parse binary response error. Just output error and return a non nil response
* Allow rollback on connect on any error across all connections
* fix shadow jutsu
* glorious/gk: nitters - adds in ws mock server
* linter: fix
* fix deadlock on connection as the previous channel had no reader and would hang connection reader for eternity.
* gk: nits
* Leak issue and edge case
* gk: nits
* gk: drain brain
* glorious: nits
* Update exchanges/stream/websocket.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* glorious: nits
* add tests
* linter: fix
* After merge
* Add error connection info
* Fix edge case where it does not reconnect made by an already closed connection
* stream coverage
* glorious: nits
* glorious: nits removed asset error handling in stream package
* linter: fix
* rm block
* Add basic readme
* fix asset enabled flush cycle for multi connection
* spella: fix
* linter: fix
* Add glorious suggestions, fix some race thing
* reinstate name before any routine gets spawned
* stop on error in mock tests
* glorious: nits
* glorious: nits found in CI build
* Add test for drain, bumped wait times as there seems to be something happening on macos CI builds, used context.WithTimeout because its instant.
* mutex across shutdown and connect for protection
* lint: fix
* test time withoffset, reinstate stop
* fix whoops
* const trafficCheckInterval; rm testmain
* y
* fix lint
* bump time check window
* stream: fix intermittant test failures while testing routines and remove code that is not needed.
* spells
* cant do what I did
* protect race due to routine.
* update testURL
* use mock websocket connection instead of test URL's
* linter: fix
* remove url because its throwing errors on CI builds
* connections drop all the time, don't need to worry about not being able to echo back ws data as it can be easily reviewed _test file side.
* remove another superfluous url thats not really set up for this
* spawn overwatch routine when there is no errors, inline checker instead of waiting for a time period, add sleep inline with echo handler as this is really quick and wanted to ensure that latency is handing correctly
* linter: fixerino uperino
* glorious: panix
* linter: things
* whoops
* defer lock and use functions that don't require locking in SetProxyAddress
* lint: fix
* thrasher: nits
---------
Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* consolidate type to types package and share across code base
* rm convert type and convert codebase
* rm irrelavant test cases
* Fix tests
* glorious nits
* Update exchanges/gateio/gateio_types.go
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* thrasher: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* CI/build: Update Go version, linters and fix minor issues
* linters: Add intrange, copyloopvar, additional go vet linters to match gopls and fix issues
* Add in initial handling for quote/base currency deployment requirements
* include client order ID checking
* glorious: suggestions
* spell and fix
* linter/context/test
* rework tests and order side specific requirements
* linter
* mend panic at the disco
* mending more panics at the disco
* anudda fix brudda
* glorious: NITTTTTT BOOOOOMB
* leftover things and stuff
* whoops
* tie in gateio
* glorious: nit fixes life and everything.
* thrasher: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* Websocket: Use ErrSubscribedAlready
instead of errChannelAlreadySubscribed
* Subscriptions: Replace Pair with Pairs
Given that some subscriptions have multiple pairs, support that as the
standard.
* Docs: Update subscriptions in add new exch
* RPC: Update Subscription Pairs
* Linter: Disable testifylint.Len
We deliberately use Equal over Len to avoid spamming the contents of large Slices
* Websocket: Add suffix to state consts
* Binance: Subscription Pairs support
* Bitfinex: Subscription Pairs support
* Bithumb: Subscription Pairs support
* Bitmex: Subscription Pairs support
* Bitstamp: Subscription Pairs support
* BTCMarkets: Subscription Pairs support
* BTSE: Subscription Pairs support
* Coinbase: Subscription Pairs support
* Coinut: Subscription Pairs support
* GateIO: Subscription Pairs support
* Gemini: Subscription Pairs support and improvement
* Hitbtc: Subscription Pairs support
* Huboi: Subscription Pairs support
* Kucoin: Subscription Pairs support
* Okcoin: Subscription Pairs support
* Poloniex: Subscription Pairs support
* Kraken: Add subscription Pairs support
Note: This is a naieve implementation because we want to rebase the
kraken websocket rewrite on top of this
* Bybit: Subscription Pairs support
* Okx: Subscription Pairs support
* Bitmex: Subsription configuration
* Fixes unauthenticated websocket left as CanUseAuth
* Fixes auth subs happening privately
* CoinbasePro: Subscription Configuration
* Consolidate ProductIDs when all subscriptions are for the same list
* Websocket: Log actual sent message when Verbose
* Subscriptions: Improve clarity of which key is which in Match
* Subscriptions: Lint fix for HugeParam
* Subscriptions: Add AddPairs and move keys from test
* Subscriptions: Simplify subscription keys and add key types
* Subscriptions: Add List.GroupPairs Rename sub.AddPairs
* Subscription: Fix ExactKey not matching 0 pairs
* Subscriptions: Remove unused IdentityKey and HasPairKey
* Subscriptions: Fix GetKey test
* Subscriptions: Test coverage improvements
* Websocket: Change State on Add/Remove
* Subscriptions: Improve error context
* Subscriptions: Fix Enable: false subs not ignored
* Bitfinex: Fix WsAuth test failing on DataHandler
DataHandler is eaten by dataMonitor now, so we need to use ToRoutine
* Deribit: Subscription Pairs support
* Websocket: Accept nil lists for checkSubscriptions
If the user passes in a nil (implicitly empty) list, we would not panic.
Therefore the burden of correctness about that data lies with them.
The list of subscriptions is empty, and that's okay, and possibly
convenient
* Websocket: Add context to NilPointer errors
* Subscriptions: Add context to nil errors
* Exchange: Fix error expectations in UnsubToWSChans
* initial consolidation of rate limiting code to request package to reduce bespoke code implementation
* continued
* finish abstraction
* lint
* exchanges: fix tests
* linter: fix
* poloniex: fix auth rate limit not being set
* ratelimiter: convert from token to weight
* glorious: nits addressed with fire
* linter: rip
* change func name set -> get
* fix test
* derbit: impl
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* Tests: Move and simplify TestFixtureToDataHandler
* Currency: Fix PairsManager.Load breaking matcher
* Tests: Add multi-instance cache to UpdatePairsOnce
* Kraken: Fix TestUpdateTickers race error
Calling StorePairs on global instance can lead to race
* Bitfinex: Fix TestUpdateTickers racing intermittently
* Currency: Fix concurrent access to PM formats
* Currency: Fix SupportsAsset implementation
This should delegate entirely to PairManager's IsAssetSupported
* Okx: Fix PM intrusion, rm GetPairFromInstrumentID
* Exchange: Fix SetGlobalPairsManager to set asset enabled
* Bitflyer: Fix race on set TestGetCurrURL
TestGetCurrencyTradeURL would fail sometimes due to sequencing of
enabling futures but not having pairs for it.
* Tests: Simplify usage pattern for FixtureToDH
* initial purge and benchmarks proof before rn overhaul
* rn LinkedList -> Tranche(s) and purge references
* roll out acrost exchanges
* linterino
* rn silly billy label
* linter strikes AAAAAGAIN!
* fix some things
* rm comment
* Add actual comparison from master to branch benchmark for sorting algorithms
* lower case via git mv YAAY!
* drop code
* convert type name
* glorious: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* Shift wrapper function GetDefaultConfig to exchange.Base method definition, to ensure set defaults doesn't get called twice and to reduce code
* rm alphapoint bootstrap method as is defined as exchange.Base method
* add tests
* glorious: make it a function and make it IBOTEXCHANGE
---------
Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
* Websocket: Remove IsInit and simplify SetProxyAddress
IsInit was basically the same as IsConnected.
Any time Connect was called both would be set to true.
Any time we had a disconnect they'd both be set to false
Shutdown() incorrectly didn't setInit(false)
SetProxyAddress simplified to only reconnect a connected Websocket.
Any other state means it hasn't been Connected, or it's about to
reconnect anyway.
There's no handling for IsConnecting previously, either, so I've wrapped
that behind the main mutex.
* Websocket: Expand and Assertify tests
* Websocket: Simplify state transistions
* Websocket: Simplify Connecting/Connected state
* Websocket: Tests and errors for websocket
* Websocket: Make WebsocketNotEnabled a real error
This allows for testing and avoids the repetition.
If each returned error is a error.New() you can never use errors.Is()
* Websocket: Add more testable errors
* Websocket: Improve GenerateMessageID test
Testing just the last id doesn't feel very robust
* Websocket: Protect Setup() from races
* Websocket: Use atomics instead of mutex
This was spurred by looking at the setState call in trafficMonitor and
the effect on blocking and efficiency.
With the new atomic types in Go 1.19, and the small types in use here,
atomics should be safe for our usage. bools should be truly atomic,
and uint32 is atomic when the accepted value range is less than one byte/uint8 since
that can be written atomicly by concurrent processors.
Maybe that's not even a factor any more, however we don't even have to worry enough to check.
* Websocket: Fix and simplify traffic monitor
trafficMonitor had a check throttle at the end of the for loop to stop it just gobbling the (blocking) trafficAlert channel non-stop.
That makes sense, except that nothing is sent to the trafficAlert channel if there's no listener.
So that means that it's out by one second on the trafficAlert, because any traffic received during the pause is doesn't try to send a traffic alert.
The unstopped timer is deliberately leaked for later GC when shutdown.
It won't delay/block anything, and it's a trivial memory leak during an infrequent event.
Deliberately Choosing to recreate the timer each time instead of using Stop, drain and reset
* Websocket: Split traficMonitor test on behaviours
* Websocket: Remove trafficMonitor connected status
trafficMonitor does not need to set the connection to be connected.
Connect() does that. Anything after that should result in a full
shutdown and restart. It can't and shouldn't become connected
unexpectedly, and this is most likely a race anyway.
Also dropped trafficCheckInterval to 100ms to mitigate races of traffic
alerts being buffered for too long.
* Websocket: Set disconnected earlier in Shutdown
This caused a possible race where state is still connected, but we start
to trigger interested actors via ShutdownC and Wait.
They may check state and then call Shutdown again, such as
trafficMonitor
* Websocket: Wait 5s for slow tests to pass traffic draining
Keep getting failures upstream on test rigs.
Think they can be very contended, so this pushes the boundary right out
to 5s
* CI/build: Update Go version, linters and fix minor issues
* Bump golangci-lint to v1.56.1
* BinanceUS: Make uint usage consistent
* Throw blank identifiers into the trash
* Exchanges: Remove Pair upgrade handling
Now redundant behind #1401. These paths should never be met.
Several legacy coin upgrade paths being deprecated as well: ZUSD and CNY
Expecting any users with bad config from 3+ years ago would have to
reset anyway.
Also: At the time the intention of this was to upgrade the config
format.
However now, instead, it'd mostly serve to reset enabled pairs if
there's a config mistake, which doesn't feel right.
* Kraken: Fix typo in Kraken type struct
* Exchanges: Abstract exchange Start() and Run()
* Exchanges: Add test for abstracted Start
* Exchanges: Move Start to Bootstrap
* Simplify waitgroup usage
* Add call to exchange.Bootstrap to allow overide or supplementation
* Exchanges: Concurrent common bootstap actions
* Gateio: Remove incorrect Run in test
* GateIO: Fix pair dependencies in tests
This ensures that the pairs are initialised no more than needed and
kind-of just-in-time.
Better pattern might be to use a function to get these pairs when we
need them.
* Exchanges: Complete UpdatePairs before ExecLims
If we're going to update pairs, it needs to complete before we check for
limits to avoid errors on old pairs
* Exchanges: Remove Start and Run from tmpl
Since they're replaced by bootstrap now and shouldn't need customisation
normally
* Alphapoint: Move Start to Bootstrap
* GateIO: Fix linter shadow var
* Websockets: Move Subscription to its own package
This allows the small type to be imported from both `config` and from
`stream` without an import cycle, so we don't have to repeat ourselves
* Subs: Renamed Currency to Pair
This was being mis-used through much of the code, and since we're
already touching everything, we might as well fix it
* Websockets: Add Subscription configuration
* Binance: Add subscription configuration
* Kucoin: Subscription configuration
* Simplify GenerateDefaultSubs
* Improve TestGenSubs coverage
* Test Candle Sub generation
* Support Candle intervals
* Full responsibility for formatting Channel name on GenerateDefaultSubs
OR consumer of Subscribe
* Simplify generatePayloads as a result
* Fix test coverage of asset types in processMarketSnapshot
* Exchanges: Abstract ParallelChanOp
* Tests: Generic ws mock instances
* Kucoin: Fix intermittent conflict in test currs
Use isolated test instance for `TestGetOpenInterest`.
`TestGetOpenInterest` would occassionally change pairs before
GenerateDefault Subs.
* adds open interest to exchanges
* ADDS TESTING YEAH
* New endpoints, BTSE, RPCS, cached
* slight design change, begin gateio
You will need to get cached for
each exchange that supports it
* gateio, huobi, rpc
* fix up kraken, cache retrieval
* okx, gateio
* finalising all implementations and tests
* definitely my final ever commit on this
* Well, well, well
* final v2
* quick fix of bug
* test coverage, assert notempty, test helper
Added a new testhelper for currency
management because its very annoying
in a parallel test setting which wastes
so much space otherwise
* minimises REST requests for Open Interest
* types.Number merge misses
* Minimises Kraken REST calls
* len change, value -> pointer receiver
* further fixup
* fixes gateio, batch calculates open interest
* single gateio, lint const fixes
* rejig and more thorough oi for huobi
* formatting expansion
* minor fix for handling expiring contracts
* rm unused Binance strings
* add bybit support, fix bybit issues
* oopsie doopsie, dont look at my whoopsie
* Fix issue, remove feature
* move an irrelevant function for the pr
* mini bybit upgrades
* fixes cli request bug
* Adding Bybit public endpoints
* Completed adding market endpoints
* Added trade endpoints
* Adding position endpoints
* completing position endpoints
* Adding Pre-upgrade endpoints
* Completed adding Pre-upgrade and Account endpoints
* Added asset endpoints
* Added user endpoints and unit tests
* Adding spot leverage and margin trade endpoints
* spot margin trade added
* added spot-margin-trade, institutional lending, c2c lending, and broker
* Adding wrapper funnctions
* Working on wrapper public methods
* Added wrapper functions and unit tests
* Added websocket support with unit tests
* Update websocket handlers and added rate-limiter
* wrapper function, websocket handlers, and linter issues fixe
* unit tests fixes and codespell correction
* Update documentation
* Minor websocket handling fix and URL consts merging
* types, unit test other updates
* Updated websocket and methods based on review
* Added GetFeeByType method with unit test and fixes
* add filter for Unified and Normal endpoints
* Mock recording and unit tests update
* minor linter issue fix
* websocket and rest tests and fix
* change asset types and wrapper methods update
* rm: forgotten panic message
* endpoints, websocket and unit tests update
* Added and updated endpoints and unit test
* linter and spell fix
* unit test and orders update
* Update on endpoints, fields, config pairs and formating, and unit tests
* minor update on responses
* Fix unit test and types
* Unit tests, models, and wrapper issues fix and mock test recording
* rm print statement
* Fix issue, add FundingRate wrapper func, mock record
* minor type and unit test update
* Update on order handling and unit test
* Minor test
* Minor fix in wrapper
* unit tests update, recording, and documentation update
* Unit tests and minor wrapper function update
* minor unit test fix
* Added newly added endpoints, unit tests, and mock recording
* Rename GetInstruments -> GetInstrumentInfo
* doc update
* Minor unit tests update
* Minor unit test and wrapper update
* Fix linter issue
* Add unit test and minor updates
* Revert websocket error declaration
* Revert websocket error declaration
* Balace --> Balance
* Fix config issues
* Added next funding time minor fix
* Update GetLatestFundingRates and record mock test data
* Added LatestFundingRate time
* Fix test issue of TestAllExchangeWrappers
* config pairs update
* configtest spot pairs update
* Minor update on options UpdateOrderExecutionLimits wrapper func
* Linter issue fix and added new currency codes
* Added new currency codes
* Update bybit pairs in config_example
* config assets pair format update
* Types: Add Number type
* Types: Switch StringToFloat64 for Number
This change mostly just renames the type.
convert package and StringToFloat64 represent actions, not types,
and make it misleading to use outside of the API context,
especially when using it for a Float64ToString operation.
* Common: Remove StringToFloat64
Replaced by types.Number
* fixup! Types: Switch StringToFloat64 for Number
Second pass at Okx
* Spellcheck: Fix whitespace handling for okx line
* Okx: Remove UpdateTradablePairs from TestMain
When running individual tests we do not want to be forced to update
trading pairs.
It also does not seem to be required, since disabling UpdateTradingPairs
entirely doesn't stop any tests from passing.
If it is required we can enact this pattern:
```
func TestUpdateTradablePairs(t *testing.T) {
t.Parallel()
updatePairsOnce(t)
}
var updatePairsGuard sync.Once
func updatePairsOnce(tb testing.TB) {
tb.Helper()
updatePairsGuard.Do(func() {
err := ok.UpdateTradablePairs(context.Background(), true)
assert.NoError(tb, err, "UpdateTradablePairs should not error")
})
```
* Okx: Fix GetBlockTrades url
Endpoint was wrong
Not convinced we should prefix with market vs public, but not
committing a driveby
* Okx: Expand test coverage for GetBlockTrades
* Okx: Fix GetPublicBlockTrades
Was marked as an authenticated API call, and it's not.
Also renames it because without the context of "Block" (or RFQ) it's
misleading.
Adds tests.
* Okx: Fix GetPublicBlockTrades to be public
Expand coverage of GetBlockTrade and GetPublicBlockTrades
* Okx: Fix GetInsuranceFundInformation "" resp
When amount is "" this was erroring
* Test: Standardise configtest.json
Simple jq formatting of configtest
git diff -w or github ignore whitespaces should show no changes.
Any conflicts, just accept --ours and reformat it. Or not :o)
* adds funding rate implementations and improvements
* merge fixes x1
* lint
* kucoin funding rates func make
* migrate sync-manager to keys
* some kucoin work
* adds some kucoin wrapper funcs
* ehhh, todo
* kucoin position
* start of orders
* adds the kucoin tests yay
* multiplier
* nits, EWS includes order limits
* NotYetImplemented, IsPerp improvements, cleaning
* lint, test fix, huobi time
* fixes issues, improves testing
* fixes linters I WRECKED
* local lint but remote lint, lint, lint, lint
* fixes err
* skip CI
* lint
* Supported rates, binance endpoints
* fixes weird mocktest problems
* no, CZ is invalid
* fixes some new EWS test errors
* Websockets: Add keys to websocket subscriptions
* This switches all RO uses of the mutex to use a RLock method.
* The mutex used for discrete field access has had scope drift from
name 'connectionMutex' so rename to more appropriate fieldsMutex
* The mutex used for Set/CanUseAuthEndpoints moves from the
subscriptions endpoint to the fieldsMutex
* Add GetSubscription by key
* Expose stream.Matcher type
* Bitfinex: Subscribe and Unsubscribe atomicly
* Fix Auth failures ignored
* This change makes it so that Subscribe and Unsubscribe wait for success
** Tells the DataHandler about errors
** Errors are returned to consumers
* Subscribes concurrently to the channels
* It also simplifies the chanId to stream mapping
* Removes unable to locate chanID: %d errors which are just noise
* Paves the way for unified channelSubscription id handling
* Adds support for subId for Book subscriptions, which is more robust
* Vastly simplifies what we need to test TestWsSubscribedResponse
This test was working to ensure that the various fancy key parsing
mechanisms all worked. Now that we use subId, we just need a thorough
test of that
* Expose Match.Set in order to capture websocket incoming data
Can't see another way of doing this. Doesn't seem too bad
* Allow tests to run with auth or WS
These flags made it difficult to run the tests whilst working on
websockets
* Enable API auth and WS in testconfig
This change minimises the changes requires for a full test run against
live endpoints, so that new contributors have a clearer testing path.
I cannot see any reason to turn WS off and Auth endpoints off when we're
not going to run API tests without Creds being set, and we're not going
to do live fire tests without canManipulateRealOrders
* TestWsSubscribe and various fixes
** Enables the websocket for live non-authed integration tests by default
** Adds an integration test for subscriptions
** Changes the Ws tests to respect canManipulateRealOrders
** Uses WsConnect instead of setupWs; fixes seqNo config not sent for WS tests
** Allows api creds to live in config/testdata.json which might be
less likely to accidentally commit, and less obtrusive
* Bitfinex: Support period and timeframe for Candles
* Fixes manual Subscribe() symbol or key formatting
* Unifies handling of params for DefaultSubscriptions and manual
subsrciptions
* Bitfinex: Handle conf and info WS channel events
* Bitfinex: Better tests for subscriptions
* fixup! Websockets: Add keys to websocket subscriptions
* fixup! Bitfinex: Subscribe and Unsubscribe atomicly
* fixup! Websockets: Add keys to websocket subscriptions
* Websockets: Add Pending subscription status
Add a status tracker so that Sub/Unsub can prevent duplicates,
and also fixes when first message comes before we have added the sub
to the tracker
* Websockets: Add State instead of pending
This change allows more clarity about the current state and
checks for specifically already Unsubing
* Bitfinex: Fix first sub message maybe lost
The only link we have between a sub req and the sub resp is the subID.
And the only link we have between a sub message and the sub is the chanID.
We can't derive a link using Pair or anything else.
This meant that by sending the resp and its chanID down the IncomingData
channel, we allowed the channel reader to maybe process the next
message, the first message on the channel, before the runtime executed
the switch back to subscribeToChan waiting on the chan.
To fix this, we key initially on subId.(string), and then replace it
with chanId.(int64) when we have it *inside* the wsHandleData so we
know we've procedurally handled it before the next message.
subscribeToChan is then free to remove the subId keyed Sub regardless of
error or not
If there's an error, we don't need to inline handling because there
won't be any second update.
Expands test coverage to make sure those subId keyed subscriptions are
removed.
* Websocket: Validate state in SetChanState
* fixup! Bitfinex: Fix first sub message maybe lost
* Websockets: Rename RemoveUnsuccessfulSubs
Implementation doesn't imply Unsuccessful or need to.
This change supports the registering of Pending subs
* Bitfinex: Fix race in Tests
* okx: books 5 (cherry-pick)
* okx: shift types to types file, remove commented code and updated field name to better reflect pushed type
* linter: fix
* remove slowness
* * Introduce function checksubscriptions and shift check of subscriptions to internal websocket package
* Shift Max websocket connection int to Websocket setup (temp) for this use case only.
* glorious: nits
* linter: fix
* websocket: don't try and subscribed with nothing to subscribe to.
* Update exchanges/stream/websocket_test.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* glorious: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Okx: Fix WS order fields
* Fixes float64 with string annotation erroring on empty strings:
Okx Order Push Data error json: invalid use of ,string struct tag, trying to unmarshal "" into float64
Specifically this came from px field from a market order
* Switch to convert.StringToFloat64 instead of okxNumericalValue
* Fix typo in Notional* field names; Ironically prevented them from erroring
* Okx: Add tests for first order fields
* Okx: CID and maybe set WS order Filled time
* Tests: Set TestFixtureToDataHandler to t.Helper
* Orders: Add UnmarshalJSON to order.Side
* Okx: Fix FillTime not parsed for PendingOrder
* Okx: Switch to order.Side Unmarshal throughout
* Okx: Add Fee and FeeAsset to order processing
* Okx: Fix WS order.Detail amounts and Test
This fixes Amount vs QuoteAmount for market sells where tgtCcy is
quote_ccy
* Add comment to order.Side.UnmarshalJSON
* Okx: Replace PendingOrderItem Unmarshal with local types
* Okx: string type for WS order reduceOnly
Note: Not yet in unit tests, since it's not part of the spot tests I was
originally fixing. I'll circle back to adding full test support for
Reduce only and deleveraging positions.
* Okx: Fix TestOrderPushData Amount
We were expecting 0 when we're given a quoteAmount
In reality, we'll calculate the size from the price
* Okx: Fix order and remAmount in wsOrders
Improved handling for Float64 issues and boundaries when the order is
fully executed but not yet marked as Filled
* Fix ErrSideIsInvalid in tests
* all in a days work
* cleanup
* cleanup for real, also stop it binance.json
* minor coverage
* adds gateio to the slurry
* cleanup of types
* verbose verbose verbose verbose verbose verbose
* fixes huobi parsing issue
* fix bybit contract identification
* cleanup
* merge fixes
* addresses many big problems raised by SHAZ
* tracking errors and fixes
* funding rate if avail, fixes currency formatting
* Addresses nits and sneaks in extra fixes
* lint
* minor fixes after rebase
* better contract splitter for currencies like T-USDT
* forgot to add the exchange name like a fool
* merge fixes x1
* kucoin, direction, contract size
* rn direction, fix kucoin time
* WHOOPS
* Update exchanges/kucoin/kucoin_wrapper.go
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* misdirection
---------
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* Okx: Remove redundant asset types from conversion
* Okx: Fix list of private channels for subscription
* Okx: Fix ws order update Acc and Rem amounts
The amounts aren't treated as deltas by anything receiving them
upstream, e.g. orderManager or wsRoutineManager.
So we should treat them the same as the REST implementation
* Okx: Add context to stream unmarshall errors
I encountered a series of errors with unmarshalling from okx and have no
idea what the messages which weren't valid json actually were.
This fix adds the raw message for context to the error
* Okx: Reduce ping interval
Seeing occassional disconnects and suspect dropping the ping interval
down might help
* Fix ClientSupplier and ClientSupplied inconsist
This simply removes the Supplie. part in favour of the simpler name used
in binance. Seems safe since its already inconsistent and not populated
in at least ws order handlin
* Okx: Fix ClientOrderID ignored in ws orders
* Okx: Standardise Rfq abbrev; Fix RfqIDs
* Okx: Fix RfqIds outside of ClientRfqIds
* Okx: Simplify TestUpdateOrderExecutionLimits
* Okx: Fix panic on no avgPrice and QuoteAmount
* init
* surprise train commit
* basic distinctions
* the terms of binance are confusing
* renames and introduction of allocatedMargin
* add new margin funcs
* pulling out wires
* implement proper getposition stuff
* bad coding day
* investigate order manager next
* a broken mess, but a progressing one
* finally completes some usdtmargined stuff
* coinMfutures eludes me
* expand to okx
* imports fix
* completes okx wrapper implementations
* cleans and polishes before rpc implementations
* rpc setup, order manager features, exch features
* more rpc, collateral and margin things
* mini test
* looking at rpc response, expansion of features
* reorganising before the storm
* changing how futures requests work
* cleanup and tests of cli usage
* remove silly client side logic
* cleanup
* collateral package, typo fix, margin err, rpc derive
* uses convert.StringToFloat ONLY ON STRUCTS FROM THIS PR
* fix binance order history bug
* niteroos
* adds new funcs to exchange standards testing
* more post merge fixes
* fix binance
* replace simepletimeformat
* fix for merge
* merge fixes
* micro fixes
* order side now required for leverage
* fix up the rest
* global -> portfolio collateral
* Update exchanges/collateral/collateral_test.go
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* adds fields and todos
* rm field redundancy
* lint fix oopsie daisy
* fixes panic, expands error and cli explanations (sorry shaz)
* ensures casing is appropriate for underlying
* Adds a shiny TODO
---------
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* exchanges: Add function to get standard config
* exchanges: add tests (cherry-pick here and above)
* after pick stuff
* cleanup
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* 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
* 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