Commit Graph

946 Commits

Author SHA1 Message Date
Ryan O'Hara-Reid
636adb8822 orderbook: Add methods for extracting associated details from depth (#1783)
* orderbook: return identification details from depth

* Add methods, drop error as you cannot deploy without it anyway, add tests

* Update exchanges/orderbook/depth_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* linter: fix

* gk: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
2025-02-20 16:10:07 +11:00
Ryan O'Hara-Reid
e99adca86f encoding/json: Add custom JSON package with build tag support for Sonic (#1623)
* 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>
2025-02-20 16:05:55 +11:00
Gareth Kirwan
dc2d7770fb Huobi: V2 subscription support (#1703)
* Huobi: assertify tests

* Testing: Add FixtureToDataHandlerWithErrors

* Huobi: Add V2 websocket support

* Huobi: Fix tests racing on updatePairsOnce

* Huobi: Remove unnecessary funnelData

* Huobi: Clarify V1/V2 pings

* Huobi: Switch to types.Time

* Huobi: Disable websocket Futures and CoinMarginedFutures support

* Huobi: Fix test failures on futureContracts

Per-instance future codes not getting cached causin occassional fails

* Huobi: Fix idiosyncratic naming using TestWs instead of TestWS

* Huobi: Run WS tests in parallel
2025-02-19 16:42:25 +11:00
Ryan O'Hara-Reid
08e015a125 exchanges/wrappers: Refactor fetch orderbook/ticker/account info funcs (#1440)
* acrost: Pull thread, examine

* fix tests

* linter

* fix_linter

* revert rm ctx param to limit breakages when merging usptream

* linter fix

* Add in priority update grouping so that tests pass

* Update cmd/exchange_wrapper_standards/exchange_wrapper_standards_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious nits

* fixed spelling

* whoopsie

* aanother whoops

* glorious: NITTERS!

* glorious: further nitters

* srry linter gods

* glorious: nits continued

* sub test p ara lel

* drop main t.Parallel

* fix whoops

* wrappertests: use context with cancel (test)

* linter: fix

* ensure primary execution

* kucoin test fix

* revert standards test changes and bypass non critical errors

* rm single override

* wrap exported error for accounts

* thrasher: nits ch name

* gk: nits

* gk: nits FetchTickerCached -> GetCachedTicker

* gk: nits rn FetchOrderbookCached -> GetCachedOrderbook

* gk: nits rn FetchAccountInfoCached -> GetCachedAccountInfo

* linter: fix

* gk: nits

* thrasher: nitters 1

* thrasher: nitters tmpls

* gk: nitter

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
2025-02-19 10:47:10 +11:00
Gareth Kirwan
5463e359bc Bitfinex: Fix websocket trade processing (#1754)
* Bitfinex: Fix WS trade processing

* Add handling for funding trades

Fixes #1746

* Linter: Disable shadow linting for err

It's been a year, and I'm still getting caught out by govet demanding I
don't shadow a var I was deliberately shadowing.
Made worse by an increase in clashes with stylecheck when they both want
opposite things on the same line.

* Bitfinex: Move websocket constants to websocket file

* Bitfinex: Rename channel consts

* Bitfinex: Send individual WS trades down the DataHandler
2025-02-17 13:20:14 +11:00
Ryan O'Hara-Reid
6613c56738 stream/buffer: remove time.ticker publish limiter for websocket orderbook updates (#1681)
* stream/buffer: remove publish period for for signalling change through data handler

* Add config upgrade and downgrade

* linter: fix

* GK: nits

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update config/versions/v3.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* config: fix up commited suggestion

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2025-02-10 16:15:33 +11:00
Ryan O'Hara-Reid
45652564f4 orderbook: fix fields not being retrieved when getting orderbook.Base (#1793)
* orderbook: fix fields not being retrieved

* glorious: nits

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
2025-02-10 13:54:02 +11:00
Samuael A.
5c892307c7 exchanges: Okx Update (#1420)
* 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
2025-02-10 10:44:48 +11:00
Gareth Kirwan
e6d456162a Codespell: Fix failures with v2.4.0 (#1790)
* Codespell: Fix new violations in 2.4.0

* Codespell: Move currency ignoring to regex

* Codespell: Add vendor to ignored files

* Codespell: Remove github action params duplicated from .codespellrc

.codespellrc already exists in the project

* Codespell: Remove unused freez from ignore words
2025-01-31 13:46:43 +11:00
Bea
63f49860ed Binance: Add order side to trade data (#1782)
* Add the initiating side to Binance trades

* Update TradeStream type, move trades declaraction

* Make side declaration in Binance trades consistent
2025-01-24 10:39:41 +11:00
Gareth Kirwan
4c7f48ae0e GateIO: Fix GetFuturesContractDetails for delivery futures and minor other fixes (#1766)
* GateIO: Fix GetFuturesContractDetails for Deliveries

Was returning the product of all the contracts, so 1444 instead of 38
contracts.

* GateIO: Fix GetOpenInterest returning asset.ErrNotEnabled

Using wrong error for pair not enabled

* GateIO: Rename GetSingleContract and GetSingleDeliveryContracts

Especially fixes GetSingleContract, which seems misleading to not say
Futures.
There's a load of `GetSingle*` here that should probably also be fixed,
but these two justified a dyno

* GateIO: Rename GateIOGetPersonalTradingHistory to GetMySpotTradingHistory

* GateIO: Rename GetMyPersonalTradingHistory to GetMyFuturesTradingHistory

* GateIO: Remove duplicate DeliveryTradingHistory

* GateIO: Rename Get*PersonalTradingHistory to GetMy*TradingHistory

* Linter: Disable shadow linting for err

It's been a year, and I'm still getting caught out by govet demanding I
don't shadow a var I was deliberately shadowing.
Made worse by an increase in clashes with stylecheck when they both want
opposite things on the same line.

* GateIO: Add missing Futures and tradinghistory fields

* GateIO: Improve WS Header parsing

This unifies handling for time_ms and time in response headers, since
options and delivery have only time, but spot has time_ms as well.
We use the better of the two results.

Also [improves performance 2x](https://gist.github.com/gbjk/7cacb63b9a256e745534bb05ca853c48)

* GateIO: Use time_ms WS fields where available

Removes the deprecated _time json fields and populates our Time fields
with the time_ms values
2025-01-14 15:19:17 +11:00
Gareth Kirwan
e4479557de Kucoin: Margin subscription fix and improvements (#1761)
As a GCT user with spot and margin assets enabled, but only margin asset enabled websocket subscriptions,
I should still get subscriptions for all the pairs in margin which are also in spot
Currently it only works when spot subscriptions are enabled. Otherwise the spot pairs are ignored.

Fixes #1755
2025-01-10 14:38:56 +11:00
Gareth Kirwan
1efd8e0db0 Subscriptions: Fix IBotExchange not implementing sub.IExchange (#1765)
Thusfar ExpandTemplates had only been called internally.
All methods consumers might want to get, in this case GetPairFormat,
need to be in the interface we're passing out, otherwise users can't
call them (or things that use them, like ExpandTemplates)
2025-01-10 11:21:02 +11:00
Ryan O'Hara-Reid
fcd78add96 bybit: Add protected subtype for account checking to reduce outbound requests (#1739)
* bybit: Add protected sub type for account checking to reduce outbound requests

* add type and string method plus fix linter with comment

* linter: fix

* whoops

* Update exchanges/bybit/bybit.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/bybit/bybit.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>
2025-01-07 12:03:32 +11:00
Gareth Kirwan
4fcee8489e Deribit: Add subscription configuration (#1636)
* Kline: Fix Raw Short, Marshal and Unmarshal

* Deribit: Rename GenerateDefaultSubs

* Deribit: Remove custom GetDefaultConfig

Moved to exchange base by #1472

* Deribit: Straight Rename of eps to endpoints

Since I had to ask what this abbreviation meant, I think we should
abandon it

* Deribit: Add Subscription configuration

* Deribit: Fix race on Setup with optionsRegex

Calling Setup twice would race on the assignment to this package var.

There was an option to just move the assignment to the package var declaration, but this
change improves the performance and allocations:
```
BenchmarkOptionPairToString-8            1000000              1239 ns/op             485 B/op         10 allocs/op
BenchmarkOptionPairToString2-8           3473804               656.2 ns/op           348 B/op          7 allocs/op
```

I've also removed the t.Run because even success the -v output from
tests would be very noisy, and I don't think we were getting any benefit
from it at all:
```
=== RUN   TestOptionPairToString
=== PAUSE TestOptionPairToString
=== CONT  TestOptionPairToString
=== RUN   TestOptionPairToString/BTC-30MAY24-61000-C
=== PAUSE TestOptionPairToString/BTC-30MAY24-61000-C
=== RUN   TestOptionPairToString/ETH-1JUN24-3200-P
=== PAUSE TestOptionPairToString/ETH-1JUN24-3200-P
=== RUN   TestOptionPairToString/SOL_USDC-31MAY24-162-P
=== PAUSE TestOptionPairToString/SOL_USDC-31MAY24-162-P
=== RUN   TestOptionPairToString/MATIC_USDC-6APR24-0d98-P
=== PAUSE TestOptionPairToString/MATIC_USDC-6APR24-0d98-P
=== CONT  TestOptionPairToString/BTC-30MAY24-61000-C
=== CONT  TestOptionPairToString/SOL_USDC-31MAY24-162-P
=== CONT  TestOptionPairToString/ETH-1JUN24-3200-P
=== CONT  TestOptionPairToString/MATIC_USDC-6APR24-0d98-P
--- PASS: TestOptionPairToString (0.00s)
    --- PASS: TestOptionPairToString/BTC-30MAY24-61000-C (0.00s)
    --- PASS: TestOptionPairToString/ETH-1JUN24-3200-P (0.00s)
    --- PASS: TestOptionPairToString/SOL_USDC-31MAY24-162-P (0.00s)
    --- PASS: TestOptionPairToString/MATIC_USDC-6APR24-0d98-P (0.00s)
```

( And that got worse with me adding more tests )
2025-01-03 08:55:58 +11:00
Ryan O'Hara-Reid
50448ec6a0 websocket/gateio: Add request functions for websocket multi-connection [SPOT] (#1598)
* 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

* stream match update

* update tests

* linter: fix

* glorious: nits + handle context cancellations

* 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.

* glorious: whooops

* gk: nits

* Leak issue and edge case

* Websocket: Add SendMessageReturnResponses

* whooooooopsie

* gk: nitssssss

* Update exchanges/stream/stream_match.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/stream/stream_match_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* linter: appease the linter gods

* gk: nits

* gk: drain brain

* started

* more changes before merge match pr

* gateio: still building out

* gateio: finish spot

* fix up tests in gateio

* Add tests for stream package

* rm unused field

* glorious: nits

* rn files, specifically set function names to asset and offload routing to websocket type.

* linter: fix

* glorious: nits

* add counter and update gateio

* fix collision issue

* 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

* upgrade to upstream merge

* 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

* dont need to make consecutive Unix() calls

* websocket: fix potential panic on error and no responses and adding waitForResponses

* rm json parser and handle in json package instead

* linter: fix

* linter: fix again

* * change field name OutboundRequestSignature to WrapperDefinedConnectionSignature for agnostic inbound and outbound connections.
* change method name GetOutboundConnection to GetConnection for agnostic inbound and outbound connections.
* drop outbound field map for improved performance just using a range and field check (less complex as well)
* change field name connections to connectionToWrapper for better clarity

* spells and magic and wands

* glorious: nits

* comparable check for signature

* mv err var

* glorious: nits and stuff

* attempt to fix race

* glorious: nits

* gk: nits; engine log cleanup

* gk: nits; OCD

* gk: nits; move function change file names

* gk: nits; 🚀

* gk: nits; convert variadic function and message inspection to interface and include a specific function for that handling so as to not need nil on every call

* gk: nits; continued

* gk: engine nits; rm loaded exchange

* gk: nits; drop WebsocketLoginResponse

* stream: Add match method EnsureMatchWithData

* gk: nits; rn Inspect to IsFinal

* gk: nits; rn to MessageFilter

* linter: fix

* gateio: update rate limit definitions (cherry-pick)

* Add test and missing

* Shared REST rate limit definitions with Websocket service, set lookup item to nil for systems that do not require rate limiting; add glorious nit

* integrate rate limits for websocket trading spot

* bitstamp: fix issue

* glorious: nits

* ch name and commentary

* fix bug add test

* rm a thing

* fix test

* Update engine/engine.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher: nits

* Update exchanges/stream/stream_match_test.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/stream/stream_match_test.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* GK: nits rn websocket functions

* explicit function names for single to multi outbound orders

* linter: fix

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2024-12-20 13:50:31 +11:00
Adrian Gallagher
143e336c03 exchanges: Fix GateIO/Coinbase test failures and OKX race (#1753)
* 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
2024-12-20 12:07:46 +11:00
Gareth Kirwan
16e5398dd5 HitBTC: Add subscription configuration (#1639)
* HitBTC: Upgrade test config

* HitBTC: Add subscription configuration
2024-12-17 11:04:23 +11:00
Ryan O'Hara-Reid
068a4535ed gateio: update rate limit definitions (#1733)
* gateio: update rate limit definitions (cherry-pick)

* Add test and missing

* Shared REST rate limit definitions with Websocket service, set lookup item to nil for systems that do not require rate limiting; add glorious nit

* gateio: fix race

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-12-12 15:08:24 +11:00
Gareth Kirwan
2a4c2d24a7 Bitstamp: Add subscription configuration (#1620)
* Bitstamp: Add subscription configuration

* Bitstamp: Handle sub/unsub responses

* Bitstamp: Fix TestWsOrderbook
2024-12-12 14:08:06 +11:00
Gareth Kirwan
00556f274d Subscriptions: Respect DisableAssetWebsocketSupport for assets (#1693)
* Bitmex: Add index asset to test config

* Subscriptions: Fix unsupported WS assets included

fixed 1692

* Bitmex: Assertify and fix tests

* Subscriptions: Fix all asset subs erroring on no enabled assets

Only subs with Empty asset should do anything when assets are empty.
If asset is set to all and no assets are enabled, we should return
nothing
2024-12-06 17:01:36 +11:00
Gareth Kirwan
66a3ff021e Gemini: Add subscription configuration (#1625)
* Gemini: Upgrade test config

* Gemini: Add subscription configuration

* Gemini: Fix negative waitgroup on shutdown

Fixes #1738
2024-12-06 13:13:32 +11:00
Gareth Kirwan
0c4b070ebc BTCMarkets: Add subscription configuration (#1624)
* Subscription: Add List.GroupByPairs

* BTCMarkets: Add subscription conf

* BTCMarkets: Upgrade test config
2024-12-05 14:50:10 +11:00
Gareth Kirwan
6b79e4c0b4 Bithumb: Add subscription configuration (#1618) 2024-12-05 12:02:23 +11:00
Scott
291b7b58ea exchanges/Bybit: Fix UpdateOrderExecutionLimits (#1731)
* potentially resolved

* fixes bug with symbol formatting

* fixing lints

* actually uses nextPageCursor

* refactor transforming symbols, add test

* shazbert1000
2024-12-03 10:12:39 +11:00
Ryan O'Hara-Reid
a0d82f2a7d common/math: Add math.Abs to PercentageDifference calculation (#1617)
* fix bug and add decimal calc

* pew pew

* Update common/math/math.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* nits: plus change name convention

* gk: nits and splits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
2024-11-27 10:27:15 +11:00
dependabot[bot]
0fb27542fe build(deps): Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#1727)
* build(deps): Bump github.com/stretchr/testify from 1.9.0 to 1.10.0

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* subscription: Fix assert.NotSame param usage

---------

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-11-26 11:19:49 +11:00
Ryan O'Hara-Reid
3c73d973f6 order: Add Side type MarshalJSON method (#1726)
* Add side MarshalJSON

* glorious: nits

* more removal

* Update exchanges/order/order_test.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2024-11-26 11:19:13 +11:00
Ryan O'Hara-Reid
3b2b15e256 gateio: Fix futures subscription generation (#1725)
* gateio/websocket: fix futures filtering when generating subscriptions

* rework test

* gk: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-11-25 17:49:19 +11:00
Gareth Kirwan
fa9549d142 Assets: Fix LinearContracts support (#1724)
* Assets: Fix LinearContracts support

* Assets: Fix False positives with IsValid

supportedFlag&a is true for every even number, making the test pretty
close to meaningless.

[This
fix](5b33bc5324)
was a viable fix maintaining bit shifted iota, but there's no benefit to
it at all.

Simplifying.
2024-11-25 15:35:25 +11:00
Ryan O'Hara-Reid
4bbaf75d34 currency: Fix edge case in NewCode where all string characters are digits (#1593)
* add fixes and test

* glorious: nits, privatise upper case field, add item field for case sensitivity for format checks, rm dead code.

* fix potential panic

* gk/glorious: nits

* gk: nits and other things

* improve commentary lol

* glorious+gk: nits and improvements (with no sillyness this time)

* Update currency/pairs.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher: nitssssss

* linter: fix

* bye bye silly boy

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2024-11-25 14:51:35 +11:00
Ryan O'Hara-Reid
1fab9c72d2 gateio: Remove listOfAssetsCurrencyPairEnabledFor method and optimise websocket asset processing (#1723)
* remove listOfAssetsCurrencyPairEnabledFor and optimise paths

* add helper method and further optimise

* glorious: nits thanksssss!

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-11-20 16:15:38 +11:00
Scott
85ecd0d4b8 Binance: update orderbook and ticker rate limits (#1697)
* updates some rate limits

* WOAH FRIDAY FAILURES

* remove secret code, DONT LOOK

* types.Number, rv ob num, fr changes

* ever so slight neaten

* Remove FundingRateInfo for CMF only

* revert to using the funding rate intervals
2024-11-13 15:32:08 +11:00
Gareth Kirwan
8f9ebcb521 BTSE: Add subscription configuration (#1616)
* BTSE: Add subscription configuration

* BTSE: Upgrade test config
2024-11-12 14:29:58 +11:00
Gareth Kirwan
0c0ae7bcaa Okx: Add subscription configuration (#1605) 2024-11-12 13:15:02 +11:00
Gareth Kirwan
fb0fd2e514 Huobi: Fix GetAvailableTransferChains returning unavailable chains (#1709) 2024-11-11 16:18:27 +11:00
Gareth Kirwan
56fa304e19 Huobi: Fix invalid contract type error when autoUpdatePairs is false (#1707)
We were relying on autoUpdatePairs to fetch contract types before we
need them. If the user disables it in config, we'll get them upfront.
2024-11-11 15:12:18 +11:00
Ryan O'Hara-Reid
4de4e3dc14 stream/buffer: Improve orderbook verification conditions and fix TestUpdateByIDAndAction test (#1682)
* don't need to verify if checksum available; don't retroactively verify snapshots

* glorious: nits + allow checksum/validation to be done on updateByIDAndAction

* possible slice manipulation issue fix for test

* thrasher: nit

* this should fix it now

* for subsystem usage disallow deploying a book twice

* reverts strict policy using deploy, it's used in a bunch of tests I don't want to touch just yet, left a note

* rm unused variable

* glorious: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-11-11 14:46:14 +11:00
Gareth Kirwan
a2a7fed273 Huobi: Add subscription configuration (#1604)
* Huobi: Update test config format

* Huobi: Add subscription configuration

* Huobi: Add subscription documentation

* Huobi: Clarify OB sub Levels usage

* Huobi: Enable websocket for tests

* Subscriptions: Rename ErrPrivateChannelName

Rename ErrPrivateChannelName to ErrUseConstChannelName
2024-11-11 14:19:25 +11:00
Ryan O'Hara-Reid
d4c4bf1bcd bybit: Add OrderbookLastUpdated field and ensure timestamp usage is correct (#1680)
* bybit: Add time field for orderbook and handle correct timings

* use UpdateID as this is the localised ID for this pair, rm check result.UpdateID == 1 just use snapshot

* general quick fixes across from #1672 which can be used straight away

* fix test

* glorious: nits

* thrasher: nits

* thrasher: nits thanks @thrasher-

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-11-08 15:35:18 +11:00
Adrian Gallagher
d172f3dfe1 gateio: Update contract settlement currencies (#1702)
* gateio: Update contract settlement currencies

* GateIO: Fix TestGetSettlementFromCurrency race
2024-11-08 10:11:13 +11:00
Adrian Gallagher
69bb645fc2 docs: Migrate development tracking from Trello to GitHub Projects (#1696)
* docs: Migrate development tracking from Trello to GitHub Projects

* docs: Replace non-template based references and correct templates
2024-11-08 10:10:49 +11:00
Gareth Kirwan
199d30d442 Bybit: Add subscription configuration for spot (#1601)
* Bybit: Subscription configuration for spot

* Bybit: Enable candles ws sub by default

* Orderbook: Use a RW mutex for depth

* Orderbook: Fix race on depth.VerifyOrderbook

Despite being protected by an ob level mutex, this needed to privatise
and protect the option var.
2024-11-05 16:05:38 +11:00
Gareth Kirwan
4d36ea4943 Bitmex: Fix handling index records in WS trade stream (#1685)
Fixes handling for Size == 0 index records sent to trade stream

fixes #1684
2024-10-25 19:57:34 +11:00
Gareth Kirwan
4c7c0bc533 Subscriptions: Relax subscription validation for non-existent pairs (#1635)
The subscription pairs do not need to be validated as enabled or
available. The check was just belt-and-braces and didn't have a specific
use-case in mind.

Coinbase has a use-case for wanting to subscribe to BTC-USD when it's
not enabled.

Moreover, it shouldn't be our job to check this. You want a sub expanded
with these pairs? Fine. Done. If it doesn't work, you can work out why
2024-10-23 15:34:01 +11:00
Gareth Kirwan
4fc1bf0ad1 Kucoin: Abstract a subscriptionNames for assets solution (#1669) 2024-10-23 12:05:47 +11:00
Gareth Kirwan
2232340d49 Bitmex: Subscription templating (#1586)
* Exchanges: Allow empty batches in ParallelChanOp

In keeping with both common.Batch and "It's not my responsibility",
ParallelChanOp should just do nothing when given an empty list (and
implicitly an empty batch size.
Whatever it's going to do, it'll delegate to common.Batch,
and this allows us to just inline calls:
```
	return common.AppendError(
		b.ParallelChanOp(subs.Public(), func(l subscription.List) error { return b.manageSubs(wsSubscribeMethod, l, wsPublicStream) }, len(subs)),
		b.ParallelChanOp(subs.Private(), func(l subscription.List) error { return b.manageSubs(wsSubscribeMethod, l, wsPrivateStream) }, len(subs)),
	)
```

* Bitmex: Test config updates

* Bitmex: Sub Templating

* Bitmex: Enable websocket for tests

* Bitmex: Handle subscription errors

This switches to multiplexing so that we know which errors belong to
which stream, particularly for the auth attempt

* Bitmex: Fix ws order side err going to data stream

Shouldn't fall into classification error if it's actually a parsing
error
2024-10-22 17:21:35 +11:00
Ryan O'Hara-Reid
bd2cc9d7bb gateio: Small update on fields and subscriptions (#1658)
* Cherry_pickable

* gateio/websocket: use millisecond time for more accurate push time

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2024-10-21 17:05:26 +11:00
Gareth Kirwan
ba77c9946d Bitfinex: Add subscription configuration and templating (#1597)
* Bitfinex: Correct comment about R0 OB

* Bitfinex: Test config updates

* Bitfinex: Add missing assets to configtest

* Bitfinex: Rename GenerateDefaultSubscriptions

* Bitfinex: Add Subscription configuration

* Subscriptions: Document panic in templates
2024-10-18 09:23:15 +11:00
Ryan O'Hara-Reid
9645b7b6e7 huobi: Swap ticker amount and volume values (#1679)
Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
2024-10-15 10:13:29 +11:00