* Kucoin: Fix unmarshalling of FuturesTicker resp
* Fix several string float64 fields not unmarshalling
* Fix time field misnamed; Make a time.Time
* Use order.Side for sides
* Add tests
This change opts to expose float64 instead of StringToFloat64 because
there's no wrapper to convert the type over, and it's not a websocket.
Essentially choosing to not expose internal convert types for methods
called directly.
Possible we'll eventually harmonise this with a types.Number or
something.
* Kucoin: FuturesRealTimeTicker => FuturesTicker
Kucoin only call it RealTime in the first sentence of their docs. None of the API names, endpoints or any thing mention RealTime.
This is just a ticker
* Tests: Improve clarity of failed push data
* Kucoin: Move PushData to a fixture file
This avoids both the linter errors, and the bloat.
Loses the name of the "test", but I think that's okay
* 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)
* Currency: Do not use a default forex provider
exchangerate.host now requires an API key.
Instead of finding a new Free (for now) default, this change simply
disables the currency exchange when nothing is enabled.
* SyncManager: Report ?.?? for an unknown forex amount
In a situation where we thought forex was available but we got an error,
this avoids showing 0.00 when there was actually an error.
* Currency: Tests for no default forex
* Currency: Use mock provider for tests
* Currency: Add API key to exchangerate.host
* Currency: Remove Exchangerate.host
Exchangerate.host was bought by apilayer, the old API deprecated, and
replaced with a proxy to the apilayer api.
We already have currencylayer support, so ther's no reason to keep exh.
Worth noting: New ERH keys actually work on currencylayer
* Currencies: Add test coverage for currency layer
* fixup! Currency: Tests for no default forex
Remove duplicate assignment
Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395#discussion_r1395178513)
* fixup! Currency: Add API key to exchangerate.host
Remove unused ErrVar
Fixes [review
comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395#discussion_r1396647418)
* fixup! Currency: Tests for no default forex
Fix spelling of override in test
Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395#discussion_r1396701476)
* fixup! SyncManager: Report ?.?? for an unknown forex amount
Fix display of non-positive currency conversions.
Fixes [review comment](https://github.com/thrasher-corp/gocryptotrader/pull/1395/files#r1398527134)
* Kucoin: Fix ProcessMarketSnapshot and add a test
* Kucoin: ProcessMarketSnapshot: move the check before the ticker
* Kucoin: remove time.sleep from the test, add if statement to processmarketSnapshot
* Kucoin: ProcessMarketSnapshot to send margin, spot and both margin and spot pair data
* Kucoin: range over listOfAssetsCurrencyPairEnabledFor which returns a slice
* Kucoin: linter fix and pointers placed
* Kucoin: removed AssetWebsocketSupport and ku.CurrencyPairs.IsAssetEnabled, linter error fixed, comment amended
* kucoin: fix unmarshal bug
* kucoin: Add time in force handling
* kucoin: fix test
* thrasher: nits
* kucoin_test: shift skip check down for coverage, rm market testing, change buy price to reduce chance of instant match
* kucoin: fix nits and force usage of uuid to rm conflicts
---------
Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
* cmd/exchange_template: Add wrapper function
* exchanges: force UpdateOrderExecutionLimits to wrappers as this is important for order deployment
* kucoin: Add spot order execution limits
* linter: fix
* glorious: nits
* kucoin: change from name to symbol for correct fee fetching and order deployment
* WHAAAAAAAT says Vitalik
* kucoin: Add futures limit support, fix insertion of non margin tradable pairs, update naming and add comments.
* kucoin: implement master branch changes
* Update exchanges/kucoin/kucoin_test.go
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* kucoin/test: update commentary
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Bitfinex: Replace errTypeAssert with common.GetTypeAssertError
* Bitfinex/common.GetTypeAssertError description to match the documentation
* Bitfinex/Correct typos, fix type in finalResp error
* Bitfinex: Comments amended from.Symbol to .Data
* Bitfinex: fix the typo
* Bitfinex: fix the comments
* 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
* sync manager: don't fall over to rest when websocket connection active
* glorious: nits and fix bug
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* 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>
* Bitstamp: WIP fixing trading fees
* Bitstamp/amended the TestGetFee test and currected the getTradingFee function
* Bitstamp: TestGetFee implemented for maker and taker
* Bitfinex: added a wrapped error
* Bitstamp: GetTradingFee and test updated, fetched from the API
Progresses #1271
* Bitstamp: minor changes- whitespace removal and comment added
* Bitstamp: fixed lint issues in TestGetBalance and TestGetTransactions
* Bitstamp:Typo in types TradingFee comment
* Bitstamp: GetAccountTradingFees at view the fees on all pairs
modified: exchanges/bitstamp/bitstamp.go
* Bitstamp: returning the TradingFee info instead of just MakerTakerFees
* Bitstamp:TestGetAccountTradingFees + TestGetAccountTradingFees added,data structure amended to match the outcome
* Bitstamp:error and a test for empty pair added in GetAccountTradingFee
* Bitstamp: RM the whitespace linter error
* 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
* OrderManager: Fix race condition in submit with ws
If the ws sees the order before processSubmittedOrder then it will have
assigned it an internal order id already and added it to the store.
Don't treat that as an error. Instead just use the newer ws details
* OrderManager: Fix error comparisson
Should always use errors.Is when possible
* Tests: Simplify btcusd test pair declaration
* OrderManager: Improve test readability
* OrderManager: Add orderstore.getByDetail test
* Return a fresh pointer from orderstore.getByDetail
This protects the order.Details in the store from direct access.
The use-case was to allow the returned objects to be references so that
future changes to them would be reflected.
However we're not ready yet to allow people to touch the orders
directly, because they're not protected directly by a mutex, and nothing
would stop consumers contaminating the integrity of the data.
We can revisit this topic later atomicly, but it's definitely tangental
to the cause of action for PR #1336.
* Fix GetByDetail tests to assert a new pointer
* OrderManager: Avoid possible lock races
This fix internalises the getByDetail because the implication of moving
lock ownership out of exists/getByDetail to consumers breaks the order
store struct encapsulation in a way we really don't want to.
It's also more efficient
* Fix spelling mistake
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* OrderManager: Fix TestSubmitOrder... description
* OrderManager: Improve clarity of comment
* OrderManager: Capitalise error message
On failure to add to orderstore, capitalise the error message
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
---------
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* Bitstamp: Add auth channel subscription handling
* Bitstamp: Avoid searching for asset type
We've hardcoded asset.Spot in order to find the pair.
Looking the asset up from the pair makes no sense.
* Bitstamp: Add type for wsOrders
* Bitstamp: Working test of Generic DataHandler
* Bitstamp: WS Order chan tests and remove type
orderType could be derived from status == New and Buy & price == 9+e9 or Sell & price == 0
But it would only be true for the first update and it really doesn't feel worth the risk
Consumers are going to have to merge to original request anyway
* Bitstamp: Linter fixes
* Kraken: Switch to shared fixture test
* Bitstamp: Fix lint on TestFixtureToDataHandler
* Engine: Add Clone for PairsManager
go-vet highlighted that the mutex here is a value when we copied the
PairsManager in a test.
Options to fix:
* Add a deep clone method to PairsManager
* Add a shallow clone method with a disclaimer
* Make the mutex a pointer
* Make the PairsManager itself a pointer
Options 3 and 4 are too invasive to justify changing at this point.
There's an inherent risk of PM being passed by value, but govet should
catch the copylock.
There's more risk in changing everything to use a pointer at this stage.
* Engine: Fix linter again, ironically
* Bitstamp: Rename OHLC const
* Bitstamp: Minor fixes to syntax
* Bitstamp: Simplify chanSymb=>pair
* Bitstamp: Still process order updates without ID
If there's a ClientOrderID we'll still process the order.
It doesn't seem likely we'd have this happen, but if it does we still
want consumers to get something.
* Bitstamp: Replace Clone with Lock methods
* Engine: Expose PairsManager's Mutex
Makes more sense than wrapping functions
* Bitstamp: Fix linter copylock (again)
* fixup! Engine: Expose PairsManager's Mutex
Omit Mutex from Json
* fixup! Bitstamp: Add auth channel subscription handling
Remove unused wsAuthToken
* Bitstamp: Simplify OrderData Unmarshal
* Bitstamp: Remove unused contexts
I added these following best practices, but the reality is that when/if
we get context awareness in GCT, there will be a lot more to fix and
this will be a drop in the ocean anyway.
* Bitstamp: Only call handleWSOrder for MyOrders
* Bitstamp: Avoid allocating again in handleWSOrder
* CurrencyPairs: Remove public mutex
Simplified to a Load method to avoid making mutex public
* Tests: Improve test readability and clarity
* Bitstamp: Wrap errWSPairParsingError
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* Bitstamp: FetchWSAuth mock and live test
---------
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
* engine: changes (cherry_pick_me_pls_ser)
* engine/helpers: refactor
* glorious nits: purge code
* engine/helpers: update tests so that we can ensure a default exchange and setup is good to go.
* -_-
* glorious: nits
---------
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
* moves everything to use single map keys, also breaks
* full rollout
* tests
* fix a little bug
* minor test fixups
* Fix Key use
* rm 🔑 from 🔑 struct name