Commit Graph

1955 Commits

Author SHA1 Message Date
Gareth Kirwan
52c6b3bf0b Websocket: Various refactors and test improvements (#1466)
* 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
2024-02-23 18:39:25 +11:00
Gareth Kirwan
40193bb8c3 Kucoin: Fix transient test failure on XMR (#1485)
Kucoin delisted XMR temporarily for margin trading.
That seems quite likely long term too, due to XMR's privacy features.

Replace XMR with TRX to hopefully avoid in future
2024-02-21 09:14:12 +11:00
Gareth Kirwan
422ebbe803 Common: Fix fmt msg lost in AppendError().Error() (#1484)
Retain the .msg field of a go fmt.Errorf .msg field returned by .Error()
when wrapping multiple errors.
This fixes a situation where a nested stack of errors would lose
formatting information, which is often used to supply identifying
context.
e.g.
```
err = fmt.Errorf("%w `%s`: %w", errParsingField, fieldName,
parsingError)
errs = common.AppendError(errs, err)
```

This isn't really an issue with our implementation; Calling Unwrap() on a
fmt.Errorf() which returns a wrapErrors will lose that formatting.
Our issue was that we were using just Unwrap() to bind together our
chain-of-custody.
2024-02-20 10:14:59 +11:00
dependabot[bot]
124371fdba build(deps): Bump google.golang.org/grpc from 1.61.0 to 1.61.1 (#1483)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.61.0 to 1.61.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.61.0...v1.61.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-20 09:25:42 +11:00
Adrian Gallagher
9f968151be ItBit: Remove exchange implementation (#1463) 2024-02-15 10:40:02 +11:00
Adrian Gallagher
08da42ddb7 CI/build: Update Go version, linters and fix minor issues (#1473)
* 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
2024-02-14 11:02:06 +11:00
Gareth Kirwan
9ff502bac2 Binance: Fix UpdateOrderExecutionLimits margin test (#1464)
Calls for limits for margin asset were not doing anything if spot is
enabled.
This caused intermittent failures when the sequence of tests meant
margin was tested before spot, since the limits wouldn't be loaded.

But it also highlighted that API users calling Update Limits for margin
outside the context of a loop on all assets would not get an update.
Also intermittently when the loop of UpdateLimits on assets puts margin first
2024-02-12 18:03:11 +11:00
dependabot[bot]
58caf2c637 build(deps): Bump golang.org/x/net from 0.20.0 to 0.21.0 (#1476)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.20.0 to 0.21.0.
- [Commits](https://github.com/golang/net/compare/v0.20.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 17:44:41 +11:00
dependabot[bot]
41b8ab14a5 build(deps): Bump golangci/golangci-lint-action from 3 to 4 (#1474)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3 to 4.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 17:43:13 +11:00
dependabot[bot]
6a425e6905 build(deps): Bump codecov/codecov-action from 3 to 4 and set codecov token (#1470)
* build(deps): Bump codecov/codecov-action from 3 to 4

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add codecov token now that tokenless uploads are rejected

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2024-02-06 16:54:57 +11:00
Gareth Kirwan
2ad6147496 build: Require go 1.21 (#1467)
Our build toolchain is using 1.21 since #1313
This hides issues on 1.20 from go.mod
Notably uses of implied Generics and slices package seem okay, but would
fail for anyone running 1.20 locally
2024-02-06 16:53:36 +11:00
Scott
d88c3b7d3f Binance: Improve wsHandleData performance (#1452)
* improve binance handleData performance

* new benchmark

* enable all pairs to scale test

* hmmm

* updated benchmark

* type.Number improvement

* improve benchmark

* Update binance_websocket.go

* minor fixes post-merge
2024-02-06 16:52:13 +11:00
dependabot[bot]
6de314f8d1 build(deps): Bump github.com/grpc-ecosystem/grpc-gateway/v2 (#1469)
Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.19.0 to 2.19.1.
- [Release notes](https://github.com/grpc-ecosystem/grpc-gateway/releases)
- [Changelog](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/.goreleaser.yml)
- [Commits](https://github.com/grpc-ecosystem/grpc-gateway/compare/v2.19.0...v2.19.1)

---
updated-dependencies:
- dependency-name: github.com/grpc-ecosystem/grpc-gateway/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 17:28:26 +11:00
dependabot[bot]
70e66d920c build(deps): Bump github.com/mattn/go-sqlite3 from 1.14.20 to 1.14.22 (#1468)
Bumps [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) from 1.14.20 to 1.14.22.
- [Release notes](https://github.com/mattn/go-sqlite3/releases)
- [Commits](https://github.com/mattn/go-sqlite3/compare/v1.14.20...v1.14.22)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-sqlite3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 16:29:38 +11:00
Adrian Gallagher
d57fefbcfc engine/gRPC proxy: Fix mux regression and add test coverage (#1456)
* engine/gRPC proxy: Fix mux regression and enhance test coverage

* Use a temp dir for TLS creds and add credentials test tables

* Update GetRPCEndpoints grpcProxyName ListenAddr field

* Log unauthorised access attempts
2024-02-05 15:22:54 +11:00
Bea
e0c6e118ed Bitstamp/Kraken: Enhance test coverage (#1423)
* Bitstamp: Improve GetAccountTradingFees

* Bitstamp: Improve test coverage

* Bitstamp: Improve TestWithdrawInternationalBank and TestWithdrawFiat

* Bitstamp: Fix the failing tests WIP

* Bitstamp: Fix TestWithdraw mockTest

* Bitstamp: Fix TestWithdrawFiat

* Bitstamp: Fix TestWithdrawInternationalBank

* Bitstamp: Simplify conditions in TestGetDepositAddress

* Bitstamp: Switch Ws functions Errors to assert.Error

* Bitstamp: Fix TestSubmitOrder, update other errors

* Bitstamp: Fix TestGetOrderStatus, amend error comments

* Bitstamp: Fix TestGetOrderInfo

* Bitstamp: Fix TestTransferAccountBalance

* Bitstamp: Update TestGetWithdrawalsHistory, fix linter errors

* Bitstamp: Update TestGetRecentTrades, change type Withdrawal.Requests.Date

* Bitstamp: Update TestGetDepositAddress, TestBitstamp_OHLC, TestBitstamp_GetHistoricCandles, TestBitstamp_GetHistoricCandlesExtended

* Bitstamp: Fix tests

* Bitstamp: Fix the typos and linter, add a side test to TestGetTicker

* Bitstamp: Update WithdrawFiat and WithdrawFiatFundsToInternationalBank

* Bitstamp: Fix the error description

* Bitstamp: Fixup SkipTestIfCredentialsUnset

* Bitstamp: Fixup tests

* Bitstamp: Fix panic, skip live test TestWithdraw, amend mocktest

* Bitstamp: Fixup

* Bitstamp: Fixup

* Bitstamp: Fixup
2024-02-05 10:39:44 +11:00
Gareth Kirwan
68a6f5828f Binance: Subscribe/unsubscribe response handling (#1444)
* Binance: Fix subscription failures ignored

* Testing: Fix race on shared config singleton

* Config: Privatise Global config var

We should *either* use a private var *or* use an accessor, but it
doesn't make sense to mix paradigms.
Since GetConfig() is well established this instead removes the limited uses of direct public access and adds a Setter

* Zip: Fix test failure on http mocks
2024-02-02 19:27:17 +11:00
Bea
e16ee53746 Kucoin: Implement GetFuturesTickers, update UpdateTickers and enhance test coverage (#1431)
* Kucoin: update TestUpdateTickers, create GetFuturesTickers

* Kucoin: Update UpdateTickers, getFuturesTickers and testing

* Kucoin: Amend the GetFuturesTickers description, remove currency.ErrPairNotFound, return err

* Kucoin: Parallelilise GetFuturesTickers

* Kucoin: Revert to GetFuturesOpenContracts in GetTickers

* Kucoin: Append the errors, fixup linter

* Kucoin: Fix the race warning

* Kucoin: Fixup

* Kucoin: Move GetFuturesTickers to kucoin_futures
2024-02-02 17:03:48 +11:00
Gareth Kirwan
d7818ea956 Exchanges: Remove bespoke pair upgrade handling and abstract Start/Run (#1424)
* 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
2024-01-31 19:29:36 +11:00
Gareth Kirwan
682737f368 Websockets: Fix subscription failure on reconnect (#1457)
* Websockets: Fix subscription failure on reconnect

If a websocket is disconnected then the subscription map was left with
old subscriptions, causing:
`Okx websocket: subscription failure, channel already subscribed for ...`

* fixup! Websockets: Fix subscription failure on reconnect

Fixes review comment https://github.com/thrasher-corp/gocryptotrader/pull/1457#discussion_r1468947509
2024-01-30 12:34:13 +11:00
dependabot[bot]
2016bfca84 build(deps): Bump github.com/mattn/go-sqlite3 from 1.14.19 to 1.14.20 (#1461)
Bumps [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) from 1.14.19 to 1.14.20.
- [Release notes](https://github.com/mattn/go-sqlite3/releases)
- [Commits](https://github.com/mattn/go-sqlite3/compare/v1.14.19...v1.14.20)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-sqlite3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-30 11:20:44 +11:00
dependabot[bot]
68bb666527 build(deps): Bump google.golang.org/grpc from 1.60.1 to 1.61.0 (#1460)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.60.1 to 1.61.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.60.1...v1.61.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-30 10:06:03 +11:00
dependabot[bot]
11204e3f5a build(deps): Bump styfle/cancel-workflow-action from 0.12.0 to 0.12.1 (#1459)
Bumps [styfle/cancel-workflow-action](https://github.com/styfle/cancel-workflow-action) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/styfle/cancel-workflow-action/releases)
- [Commits](https://github.com/styfle/cancel-workflow-action/compare/0.12.0...0.12.1)

---
updated-dependencies:
- dependency-name: styfle/cancel-workflow-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-30 10:04:30 +11:00
dependabot[bot]
6e7fbe0108 build(deps): Bump bufbuild/buf-setup-action from 1.28.1 to 1.29.0 (#1458)
Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.28.1 to 1.29.0.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.28.1...v1.29.0)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-30 10:01:58 +11:00
Gareth Kirwan
23c82bead4 Bitfinex: Fix panic on TestUpdateTickers (#1454)
* Bitfinex: Handle Errors in tickers without panic

* Bitfinex: Use TypeAssertError for tickers

* Bitfinex: Refactor and improve ticker handling

* Unify Ticker response handling
* Simplify/Humanify errors in parsing ticker responses
* Remove polymorphic response handling for < 10 fields, seems [antiquated according to docs](https://docs.bitfinex.com/reference/rest-public-ticker)
* Add test coverage for tickers

* Bitfinex: Ignore resp format errs in GetTickers

We're still getting:
`received 'invalid ticker response format for tALT2612:USD field BidSize
from [100 <nil> 100 <nil> <nil> <nil> <nil> <nil> <nil> <nil>]`
too frequently right now.

Considered:
* Special casing tALT2612:*; However if it's happening with this curr
  it'll probably happen again
* Warning about the error; However it'd just be persistent,
  unactionable and annoying  noise in the logs of a running server

So the conclusion is to just silently ignore it

* Bitfinex: Accept locked market in TestUpdateTicker
2024-01-25 16:56:08 +11:00
Adrian Gallagher
804cee4287 ZB: Remove exchange implementation (#1450) 2024-01-25 15:45:55 +11:00
Scott
130642bab6 Kraken: Improve ticker batch performance (#1451)
* Speeds up ticks

* lintBONK

* WHOOPS

* fixes silly old typo 👀

* better error handling

* add some extra fields, use types.Num

* rm redundancy

* Inline single-use function, fix tests

* lint
2024-01-25 15:14:11 +11:00
Gareth Kirwan
e007f69f7c exchanges/websocket: Implement subscription configuration (#1394)
* 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.
2024-01-24 15:54:07 +11:00
dependabot[bot]
301551ac20 build(deps): Bump actions/cache from 3 to 4 (#1453)
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-23 11:11:00 +11:00
Scott
d907aab576 Huobi: Implement ticker batching (#1439)
* Add huobi ticker batching and tests

* sneaky funding rate fix, don't look

* better processing, better tests

* inline structs per shazbaz

* formatting expansion

* weird

* introduce time param, mini fixes

* linter splinter

* merge fix, kraken fix

* move comment, use require, add len
2024-01-22 15:19:47 +11:00
Gareth Kirwan
45d65c4906 Dispatch: Fix race during stop (#1443)
* Dispatch: Assertify tests

* Dispatch: Fix race during stop

If we have blocking writers, then we need to synchronise them exiting
before closing off their channels.

* Dispatch: Rename Routes mutex for clarity
2024-01-22 15:09:57 +11:00
Ryan O'Hara-Reid
0c40f90ceb requester: purge max request jobs (#1379)
* requester: purge max request jobs

* request: rm unused error

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
2024-01-22 12:48:45 +11:00
dependabot[bot]
d8ec20576d build(deps)/CI: Bump ikalnytskyi/action-setup-postgres from 4 to 5 and update GHA matrix configuration (#1449)
* build(deps): bump ikalnytskyi/action-setup-postgres from 4 to 5

Bumps [ikalnytskyi/action-setup-postgres](https://github.com/ikalnytskyi/action-setup-postgres) from 4 to 5.
- [Release notes](https://github.com/ikalnytskyi/action-setup-postgres/releases)
- [Commits](https://github.com/ikalnytskyi/action-setup-postgres/compare/v4...v5)

---
updated-dependencies:
- dependency-name: ikalnytskyi/action-setup-postgres
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* CI: Update GHA matrix config based on new postgres update

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2024-01-21 15:12:10 +11:00
Scott
59916a7869 CoinbasePRO: Fix websocket subscription errors (#1421)
* productids go on individual subs now

* unsubscribe too, support "last_match"
2024-01-16 15:48:28 +11:00
dependabot[bot]
e93a9f72c3 build(deps): bump golang.org/x/net from 0.19.0 to 0.20.0 (#1447)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.19.0 to 0.20.0.
- [Commits](https://github.com/golang/net/compare/v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-15 16:52:43 +11:00
Scott
b71bf1f3d1 exchanges/futures: Implement open interest (#1417)
* 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
2024-01-12 15:27:35 +11:00
Gareth Kirwan
614042110a Binance: Fix GetHistoricTrades failing live (#1442)
This test was failing with `-tags mock_test_off` because the API imposes
a default limit of 500 now, so we'd just get 500 trades and no batching.

If the user doesn't provide a limit, that means we need to assume
batching
2024-01-11 13:21:04 +11:00
Samuael A
fb6d12ac69 exchanges: Update Bybit exchange to V5 (#1301)
* 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
2024-01-11 12:35:46 +11:00
dependabot[bot]
db4f4bf63c build(deps): bump github.com/grpc-ecosystem/grpc-gateway/v2 (#1441)
Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.18.1 to 2.19.0.
- [Release notes](https://github.com/grpc-ecosystem/grpc-gateway/releases)
- [Changelog](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/.goreleaser.yml)
- [Commits](https://github.com/grpc-ecosystem/grpc-gateway/compare/v2.18.1...v2.19.0)

---
updated-dependencies:
- dependency-name: github.com/grpc-ecosystem/grpc-gateway/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-09 11:16:14 +11:00
dependabot[bot]
8835db15e6 build(deps): bump github.com/urfave/cli/v2 from 2.26.0 to 2.27.1 (#1437)
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.26.0 to 2.27.1.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v2.26.0...v2.27.1)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-02 11:38:26 +11:00
Bea
07300d1c70 Bitstamp: Fix GetWithdrawalRequests/GetWithdrawalsHistory date parsing and enhance test coverage (#1406)
* Bitstamp: Fix GetWithdrawalRequests date parsing

* Bitstamp: Add return error to GetWithdrawalsHistory

* Bitstamp: GetWithdrawalsHistory remove log.Errorf, add description to fmt.Errorf

* Bitstamp: Add tests
2023-12-29 14:19:23 +11:00
Gareth Kirwan
e866c8f08d Bitfinex: Fix UpdateTickers (#1427)
* Bitfinex: Fix TestUpdateTickers on ICE

Accept 5% failure rate of available pairs not working as tickers.

When Bitfinex [delisted ICE](https://www.bitfinex.com/posts/990) it's still coming back in all pub:conf and pub:info listings:
```
❯ curl -s https://api.bitfinex.com/v2/conf/pub:info:pair | jq -c '.[0][] | select(.[0] | test("(BTC|ICE|ZIL)USD")) '                                                                   ["BTCUSD",[null,null,null,"0.00006","2000.0",null,null,null,0.1,0.05,null,null]]
["ICEUSD",[null,null,null,"4.0","25000.0",null,null,null,null,null,null,null]]
["ZILUSD",[null,null,null,"40.0","1500000.0",null,null,null,null,null,null,null]]
```
_( I included ZIL to show a tradable pair without Margin fields )_
There's absolutely no sign it's not a tradable pair _until_ you ask for a ticker for it:
```
❯ curl -s https://api.bitfinex.com/v2/ticker/tICEUSD                                                                                                                                   ["error",10020,"symbol: invalid"]⏎
❯ curl -s https://api.bitfinex.com/v2/ticker/tBTCUSD                                                                                                                                   [42854,11.8920918,42855,12.71095442,-290,-0.00672292,42846,725.08132142,43288,41850]⏎
```

* fixup! Bitfinex: Fix TestUpdateTickers on ICE

* fixup! Bitfinex: Fix TestUpdateTickers on ICE

* Bitfinex: Fix UpdateTickers stopping on first error
2023-12-28 15:41:41 +11:00
Adrian Gallagher
e8e0ff3a35 CI: Add macOS, Windows x64 and Linux arm64 test support (#1422)
* CI: Add macOS, Windows and Linux arm64 support

* Modify arm64 job name to be inline with the others

* linter: Prevent cache from causing "Cannot open: File exists" issues

* Use setup-go and setup-node's inbuilt caching
2023-12-28 14:55:50 +11:00
Gareth Kirwan
2b3c63c5b3 Exchanges: Convert bespoke Number types to types.Number (#1429)
* Kucoin: Rename WsSpotTicker => WsSnapshot

* Kucoin: Replace kucoinNumber => types.Number

* Okcoin: Convert to types.Number

* Gateio: Convert to types.Number

* Okx: Convert to types.Number
2023-12-28 14:55:23 +11:00
Gareth Kirwan
9986e80e2d dispatch: Fix intermittent TestMuxPublish issue (#1412)
* Dispatch: Assertify TestMuxPublish

* Dispatch: Fix errDispatcherJobsAtLimit test fails

This test would fail intermittently when the jobs queue drained quickly
enough.
This sets the overload ceiling based on the default settings, and seems
a safe way of ensuring we get an error every time.

It adds a done channel guard around the goro test because otherwise
we'll get a panic occassionally when the goro outlives TestMaxPublish

* Dispatch: Add test for Publish receiving data

* Dispatch: Publish to all subscribers
2023-12-28 14:54:36 +11:00
dependabot[bot]
0a9fdbcdad build(deps): bump github.com/spf13/viper from 1.18.1 to 1.18.2 (#1432)
Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.18.1 to 1.18.2.
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](https://github.com/spf13/viper/compare/v1.18.1...v1.18.2)

---
updated-dependencies:
- dependency-name: github.com/spf13/viper
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-27 09:44:01 +11:00
dependabot[bot]
9bfbea1e82 build(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0 (#1434)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-27 09:42:00 +11:00
dependabot[bot]
90e154f492 build(deps): bump google.golang.org/protobuf from 1.31.0 to 1.32.0 (#1435)
Bumps google.golang.org/protobuf from 1.31.0 to 1.32.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-27 09:39:32 +11:00
dependabot[bot]
3c5ab63fae build(deps): bump google.golang.org/grpc from 1.60.0 to 1.60.1 (#1433)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.60.0 to 1.60.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.60.0...v1.60.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-27 09:36:29 +11:00
Gareth Kirwan
f05f24da8b Types: Switch convert.StringToFloat64 to types.Number (#1415)
* 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
2023-12-20 13:01:27 +11:00