* 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
* 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
* updates config
* wrapper configuration
* updates exchange readme
* adds SendAuthHTTPRequest and SendHTTPRequest
* adds ratelimit file
* adds test case and minor fixes
* improve error handling
* update testcases and improve GetSymbols API
* adds SPOT API's
* minor fix
* WIP
* WIP
* adds test case
* adds check in test case
* fixes in Auth. HTTP
* improvements
* adds trade, kline support and testcases
* adds SPOT API and testcases for same
* adds SPOT API and testcases
* adds SPOT API and testcase
* WIP
* adds API's
* adds API's
* adds test cases
* adds comment to exported data types
* adds API and test cases
* adds API
* adds API
* rearrange functions
* WIP: adds API
* adds API for Post Order SPOT
* adds API and few fixes
* fixes
* WIP
* WIP
* add PostBulkOrder API and its test case
* fix issues
* adds cancel order APIs and test cases for same
* add minor test fixes
* add API
* adds API
* fixes
* add API
* adds API and test cases
* fix test
* adds API
* adds test
* fix test
* adds API and test
* adds deposit API and test cases
* WIP
* adds API and test cases
* WIP
* WIP
* add public future API and test cases
* WIP
* remove v2 API and replace them with v1
* update test cases
* adds future order API and test cases
* adds futures order API
* adds API
* add API and test cases
* adds API and test cases
* adds API and test cases
* adds API and test cases
* Adding wrapper functions
* Fix on wrapper function
* Adding websocket support
* Complete addressing WS push datas
* Adding spot push data unit tests
* adding futures websocket push data handlers
* Adding futures websocket push data handlers
* Added unit tests
* Updating unit tests
* Updating wrapper and unit test functions
* Adding missing wrapper functions and code cleaning up
* Resolved linter issues
* Fixing websocket issues
* Fixing websocket issues
* Slight fix on config_example file
* Minor update
* Basic nits updates
* Fix minor linter issues
* Minor update
* Minor unit test update
* Minor unit test update
* Code update and linter issues fix
* Removed unnecessary type conversion codes
* Monor update based on review comment
* Fix based on review comments
* Adding rate-limiter
* Websocket update and overall minor fixes
* Removed IsAssetTypeEnabled method implementation
* Fix connection and formatting issues
* Updating orderbook issues
* Very minor label fix
* Minor error returning fix
* code cleaning up and minor spelling fix
* Updates on unit test
* Update on unit tests and slight code structure
* unit test update
* orderbook update and minor fix
* fix on race
* Mini linter fix
* fix minor parameter and unit test issues
* handler funcs and models update
* Fixing websocket and unit test issues
* order side string for active orders
* Fix on websocket and unit tests
* Minor type changes
* Minor Orderbook fix and unit test update
* Small fix on orderbook
* Updating orderbook functionality
* FIx on websocket orderbook handlers
* Small update on kucoin websocket
* fix missed review comments
* fix based on review comments
* Updating websocket orderbook and fixing unit tests
* Minor fixes
* unit test update
* Updating unit test according to enabled asset type
* toggle canManipulateRealOrders const
* Unit test update
* Fix minor issues
* minor fix
* documentation fix
* wrapper coverage and unused params fix
* testing and minor changes
* documentation, websocket and unit test update
* minor linter fix
* Websocket spot/margin subscription update
* minor ticker update fix
* minor fixes on endpoints
* timestamp and number convert method and unit tests
* timestamp convert minor update
* minor type and conversion fix
* create a common timestamp convert and fix minor issues
* linter and ticker fix
* Updating unit tests and order placing endpoint methods
* Added a pairs check
* Fix config test error
* rm unused error variable
* Fix source of linter issue
* code update: convert, wrapper and websocket fix
* minor code update
* Websocket code and unit tests update
* Websocket ticker ask/bid type change and small error msg fix
* docs update
* fix: websocket orderbook handling
* change orderbook channel to marketOrderbookLevel2Channels and fix websocket orderbook update
* Minor func rename and reciever change
* Minor orderbook unit test issue fix
* comment: about why we used a random delimiter '-' for futures
* update config files and FetchTradablePair func for futures pairs
* futures config pairs update
* remove ConnextionMonitorDelay from websocket setup
* fix on types and futures pair conversion
* updating config pairs
* change NewPairFromString to DeriveFrom
* unit tests update
* unit tests update
* Added TickerBatching
* added GetStandardConfig to GetDefaultConfig
---------
Co-authored-by: Jaydeep Rajpurohit <jaydeeppurohit1996@gmail.com>
* 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>
* 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