Commit Graph

1855 Commits

Author SHA1 Message Date
dependabot[bot]
6107896d66 build(deps): bump bufbuild/buf-setup-action from 1.26.1 to 1.27.0 (#1362)
Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.26.1 to 1.27.0.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.26.1...v1.27.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>
2023-10-09 17:15:56 +11:00
dependabot[bot]
9e6383705f build(deps): bump golang.org/x/net from 0.15.0 to 0.16.0 (#1366)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.16.0.
- [Commits](https://github.com/golang/net/compare/v0.15.0...v0.16.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>
2023-10-09 17:13:54 +11:00
Gareth Kirwan
1212b6750e OrderManager: Fix race condition in submit with ws (#1336)
* 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>
2023-10-06 09:21:49 +11:00
Gareth Kirwan
d86da76b1f Bitstamp: Add auth channel subscription handling (#1333)
* 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>
2023-10-05 16:13:05 +11:00
Ryan O'Hara-Reid
4c928b496d engine: Adds new helper functions for default exchange deployment (#1243)
* 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>
2023-10-04 12:56:35 +11:00
Scott
91d699be9d maps: expansion of Key concept (#1349)
* 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
2023-10-04 10:19:41 +11:00
Ryan O'Hara-Reid
033a72b61a orderbook: fix race condition when function scope is in error (#1357)
* orderbook: fix race condition when in error

* Whoops
2023-10-03 16:08:31 +11:00
Ryan O'Hara-Reid
ecf0a5bcb3 spellcheck: fix and update (#1359)
* spellcheck: fix and update

* spellcheck: add exclude line for gateio_types
2023-10-03 16:07:03 +11:00
Scott
7f0faf7850 futures: add GetFuturesContractDetails wrapper function (#1274)
* 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>
2023-10-03 16:04:45 +11:00
Gareth Kirwan
08c27afded Okx: Various websocket fixes (#1335)
* 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
2023-10-03 11:01:36 +11:00
Samuael A
6105071114 exchanges: Add Kucoin support (#1102)
* 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>
2023-09-27 15:09:38 +10:00
Scott
5f2f6f884b Binance,Okx: Add Leverage, MarginType, Positions and CollateralMode support (#1220)
* 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>
2023-09-26 16:16:31 +10:00
dependabot[bot]
a2ae99ed7f build(deps): bump google.golang.org/grpc from 1.58.1 to 1.58.2 (#1355)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.1 to 1.58.2.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.1...v1.58.2)

---
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-09-25 16:42:45 +10:00
dependabot[bot]
e8c9123143 build(deps): bump google.golang.org/grpc from 1.58.0 to 1.58.1 (#1352)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.0 to 1.58.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.58.0...v1.58.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-09-18 17:16:52 +10:00
Ryan O'Hara-Reid
8b8d96c612 gate.io: Enforce the use of 'convert.StringToFloat64' and permit its use in outbound requests (#1308)
Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2023-09-18 17:15:27 +10:00
Bea
78fe6d5e79 Bitfinex: Ensure websocket configuration is sent with every connection (#1350)
* Bitfinex fix Websocket configured with every subscription

* Bitfinex rm whitespace, consolidate ConfigureWS
2023-09-18 17:13:55 +10:00
Ryan O'Hara-Reid
1adbc99526 exchanges: improves GetDefaultConfig method (#1245)
* 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>
2023-09-18 11:45:02 +10:00
Gareth Kirwan
ade2d9c5d2 Bitfinex: Resubscribe orderbook after checksum err (#1303)
* Bitfinex: Resubscribe orderbook after checksum err

* Bitfinex: chanForSub return only first match
2023-09-14 15:38:01 +10:00
Gareth Kirwan
c8ec22fe92 websocket: Relay disconnect errors to subscribers (#1347)
* 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
2023-09-14 10:14:04 +10:00
Scott
bcabf44b8c gctcli: Add colourful exchange-style rendering to orderbook fetching commands (optional) (#1348)
* fancybook

* fix bug

* oopsie-doodle

* now I remember why we don't use required
2023-09-14 10:10:22 +10:00
Gareth Kirwan
3218982b3a Engine: Integrate IsRunning into order manager interface; enhance websocket manager accordingly (#1337)
* Engine: Fix false test passes for nil OrderManager

TestWebsocketRoutineManagerSetup tests that passing a nil value returns errNilOrderManager;
However that's not actually what would happen when order manager is configured off.

The arguments to setupWebsocketRoutineManager are interface types.
When a nil pointer of interface type is passed, it does NOT equal nil.
nil is a primitive type.
A nil pointer of interface type has the value (nil;type).
See [the Go lang spec](https://golang.org/ref/spec#Comparison_operators):
```
Interface values are comparable. Two interface values are equal if they have identical dynamic types and equal dynamic values or if both have value nil.
```

So that means that whilst this test was passing, because it was sending
in a real nil value and comparing it to a real nil, that's not what
would happen at runtime. At runtime the bot.OrderManager would be a nil
pointer to a concrete type *OrderManager, and so not comparible to nil.

This commit just fixes that oversight, and explains the often
misunderstood mechanics of comparing interface types to nil.

In practical terms this means that the tests assert that the WSRM would
not run without a OM, but in fact it actually would. And panic later.

This commit SHOULD introduce a FAILing test. Sorry if you're bisecting.

* WSM: Fix error on OrderManager not enabled

It's okay for OrderManager to not be enabled; It's configurable.
Remove the WSM setup protection and move it to runtime using IsRunning.

Left the WSM deps so they can be fixed as apporpriate to each.
2023-09-11 17:14:59 +10:00
dependabot[bot]
2b504c86bb build(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4 (#1343)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  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-09-11 16:43:09 +10:00
dependabot[bot]
e6910421dd build(deps): bump actions/checkout from 3 to 4 (#1340)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-09-11 16:40:53 +10:00
Martin
bc26c53c32 backtester: Fix ensureOrderFitsWithinHLV (#1338)
Co-authored-by: xiaoniu <yang.ruoqi@outlook.com>
2023-09-11 16:38:19 +10:00
dependabot[bot]
c9040a862c build(deps): bump github.com/grpc-ecosystem/grpc-gateway/v2 (#1341)
Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.17.1 to 2.18.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.17.1...v2.18.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>
2023-09-11 16:37:27 +10:00
Gareth Kirwan
51f73300bb Bitfinex: Improve websocket type assertion checks for order processing (#1292)
* Bitfinex: Error if ws data id/cid is not a float64

* Bitfinex: Add annotation to WS id/cid assest errs
2023-09-07 15:43:38 +10:00
Ryan O'Hara-Reid
ad9de19d47 orderbook: Check assignment of time values and reject if not set (#1318)
* orderbook: Check assignment of time values and reject if not set.

* linter: fix

* buffer: additional linter winter fixter

* Implement through pending exchanges

* finished push

* linty: minty

* gomod: tidy

* thrasher: nits

* glorious: nits

* orderbook: purge type now in favour of external call allocation

* orderbook: push last param

* orderbook: only 1 unlock call is needed

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2023-09-07 11:00:16 +10:00
Gareth Kirwan
20143886ca Kraken: Fix WS Auth endpoints not re-enabled (#1334)
When Kraken has a disconnect or failure that sets SetCanUseAuthenticatedEndpoints(false),
it's never re-enabled when the websocket is reconnected
That means all subsequent requests would fall back to rest
2023-09-07 10:59:30 +10:00
Gareth Kirwan
253b9a5049 Kraken: Fix websocket order updates (#1327)
* Kraken: Fix error on WS update without status

* Kraken: Fix parsing of WS updates without Desc

* Kraken: Fix WS market order handling

* Kraken: Fix tests in parallel using DataHandler

* WebsocketManager: Fix order summary printing

* Kraken: Fix parallel tests race with DataHandler

* Kraken: Issue a classification err on asset 404

* Kraken: Switch to testify and close fixture
2023-09-05 13:22:34 +10:00
dependabot[bot]
052327343e build(deps): bump golang.org/x/text from 0.12.0 to 0.13.0 (#1332)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  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-09-05 09:00:26 +10:00
Adrian Gallagher
578dd0bafe Binance: Add crypto/flexible loan endpoints (#1331)
* Binance: Add crypto/flexible loan endpoints

* Address nitters

* Address shazbert's nitters
2023-09-01 16:46:53 +10:00
Gareth Kirwan
6ab4c27d1c Bitfinex: Refactor websocket wsUpdate handling and various improvements (#1317)
* Bitfinex: Fix cancel/update order WS ack not seen

Fixes #1288

* Bitfinex: Fix ws Unsubscribe and Resubscribe

Unsubscribe needed to use the channel id.
Resubscribe needs to have the original subscription params.

* Bitfinex: Fix ws Trades Fees on te

The ws channel for authenticated Trades sends two types of update:
* te, Trade Executed
* tu, Trade Execution Update

Only the second one contains fee information.
[See the docs](https://docs.bitfinex.com/reference/ws-auth-trades)

This commit fixes:
`exchange Bitfinex websocket error - unable to type assert trade fee`
after an executed market trade on the te update

* Bitfinex: Fix error on ws auth ok

This fixes:
`Bitfinex Could not find an existing channel subscription: account Pair:
ChannelID: 0`
It's not clear from history why we'd want to store a reference to the
ubiquitous 0 channel like this, but it's definitely wrong, and anything
that attempts to get channel information about 0 chan needs to be fixed
anyway.

* Bitfinex: Refactor wsUpdate handling

This commit doesn't break out all the sub-updater, but attempts to do
something about the unmanagable size of ws update handling

* Binfinex: Fix linter issue on chanId casing

* Bitfinex: Fix linter outdent complaint

* Bitfinex: Fix linter issues on test

* Bitfinex: Fix TestWsTradingPairSnapshot chan lookup

* Bitfinex: Remove unnecessary WsAddSubs in test

* Bitfinex: Fix TestWsSubscribedResponse chan

* Bitfinex: Throw a specific error for bad event

* Bitfinex: WS Type assertions for positionSnapshots

* Bitfinex: tradeUpdate type assertion

* Bitfinex: Reinstate default subscriptions

* Bitfinex: Assert chan assetType is the same

* Bitfinex: Lowercase error string

* Bitfinex: Refactor WS eventType/chanId handling

* Bitfinex: Fix linter issues

* Bitfinex: Fix delimiter for pairs with more than 6 chars

* Bitfinex: Fix WS handling of subscribed symbols

This simplifies the handling of subscription symbols.
Now that we know the channel up front from handling the subscribed
response we can limit the parsing forms needed

* Bitfinex: Placate the linter

* Bitfinex: Disable margin assets for WS

Margin WS Currently not fully implemented and causes subscription collisions with spot

* Bitfinex: Fix parsing of 4 part funding keys

This improves overall handling and errors on a few current assumptions
about key structure

* Bitfinex: Linter fixes

* Bitfinex: Remove key parsing from assetPairFromSymbol

* Bitfinex: Use native error wrapping

* Bitfinex: Skip disabled assets in default ws subs
2023-09-01 16:46:00 +10:00
Gareth Kirwan
9a0f261211 Orderbook: Add GetDepth to Base (#1328)
* Orderbook: Add GetDepth to Base

Base.GetDepth returns the concrete book of which Base is a copy
This is probably useful for immutably monitoring orderbook health and state
whereas FetchOrderbook would trigger a refresh.

* Orderbook: Reword GetDepth comment

* Orderbook: Add test for Base.GetDepth
2023-08-29 15:49:24 +10:00
Scott
d3102a08dc egnine/sync-manager: add config support (#1326)
* allows sync manager customisation for values and logs

* config-example add

* who doesnt like more coverage?

* ensures you can actually disable it via config el oh el

* less ifs, better control

* fix verbose

* sync trades default false

* fix summary being printed when not enabled

* fixes config checker and output

* nits

* I can put this behind me now

* Fixed logCaSiNg

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

* combines if statements

---------

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2023-08-29 15:48:41 +10:00
dependabot[bot]
04320f7aee build(deps): bump github.com/grpc-ecosystem/grpc-gateway/v2 (#1330)
Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.16.2 to 2.17.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.16.2...v2.17.1)

---
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>
2023-08-29 09:23:43 +10:00
Gareth Kirwan
ec312ca0d3 Bitstamp: Add websocket heartbeat (#1329)
This prevents the frequent (5x / hour) disconn/reconns we're seeing with a
10s or even 20s traffic timeout.
I'd like to base the interval on the traffic timeout / 2, but that's
non-trivial right now, and 8s isn't an excessive default
2023-08-29 09:22:50 +10:00
Ryan O'Hara-Reid
c5240153f9 orderbook: Add GetTranches and GetPair methods to Depth type (#1324)
* orderbook: Add GetTranches and GetPair methods to Depth type (cherry-pick)

* glorious: nits

* linter: fix

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2023-08-22 13:29:17 +10:00
Samuael A
9c83231696 exchanges: Update OKCoin V5 exchange support (#1206)
* starting public endpoints

* Adding public endpoints

* added public spot market endpoints

* websocket subscriptions updates

* websocket push data handlers completing

* linter fix

* Added funding private endpoints

* Adding authenticated account endpoints

* Added fiat and OTC-RFQ authenticated endpoints

* trading authenticated endpoints

* completing trade endpoints and add public wrapper endpoints

* Authenticated wrapper functions and corresponding unit test

* Adding authenticated websocket endpoint and fixing wrapper functions

* Documentation and exchange websocket update

* update websocket orderbook checksum handling

* linter issues fix and unit test update

* remove invalid orderbook endpoint and unit test

* Documentation, handlers, and model types update

* minot fix

* Minor fixes

* Updating unit tests and added missing endpoints

* Add missing credential check

* Minor unit test fixes

* fix minor linter issue

* add snaphot test unit test

* Fix on update checksum and documentation update

* update exchange, add UpdateOrderExecutionLimits, and update documentation

* Minor fix on tickers fetching

* Minor websocket fix and smaill unit tests

* Minor websocket and naming fixes

* uncomment default channels

* Fix type and unit test issues

* websocket channels and data handling update

* Update Advanced-Algo websocket handling and minor fixes

* documentation and minor code fixes

* Fix name changes

* documentation contribution update

* intervalToString method update

* fix exchange_wrapper_standard tests

* Fix minor issues based on exchange_wrapper_standards_test

* Fix wrapper extended candlestick check

* websocket orders fetching error check method update

* Exchange name check and change

* docs: Add missing contributors

---------

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2023-08-22 09:44:39 +10:00
Ryan O'Hara-Reid
a440fab4f3 stream/buffer: Reduces map lookups by using key struct (#1309)
* stream/buffer: Adds key map optimisation (cherry-pick)

* stream/buffer: Add buffer to DataHandler intermediary. Add field InitialUpdate bool to toggle when first update is seen for initial sync.

* whoops

* buffer: Add difference benchmarks for reference

* glorious: nits (reverting out of context changes)

* RM unused error that will be used later

* purge: benchmark

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
2023-08-21 16:28:38 +10:00
dependabot[bot]
f8024e1ee7 build(deps): bump bufbuild/buf-setup-action from 1.26.0 to 1.26.1 (#1325)
Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.26.0 to 1.26.1.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.26.0...v1.26.1)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-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>
2023-08-21 15:49:38 +10:00
Scott
c7b3ace78c testing: bybit references, bybit mock testing, pair formatting, standards improvement (#1322)
* fixes tests

* pair formats and extra fixes

* quick change before shazbert sees

* sneaky lint

* adds bybit mock testing and fixes test

* whoops

* error response instead

* classic forgetting to lint

* bybit live test no longer auto-records results

* ty thrasher- Update exchanges/bybit/bybit_wrapper.go

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

---------

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2023-08-21 14:48:56 +10:00
Gareth Kirwan
577817c46e bitfinex,okx: Fix websocket orderbook LastUpdated timestamps (#1315)
* Bitfinex: Fix WS orderbook LastUpdate empty

* Okx: Fix WS Orderbook LastUpdated unset by updates
2023-08-15 15:01:05 +10:00
Gareth Kirwan
4cfa6c4396 Bitstamp: Fix websocket orderbook snapshot blanking LastUpdate (#1319)
* Bitstamp: Fix orderbook snapshot blanking LastUpdate

Drive-By: Remove:
`Bitstamp BTC/USDT spot orderbook has zero bid price, filtering.`
It's unactionable and happens every snapshot right now

* Bitstamp: Use ob timestamps for LastUpdate

Obviously.
2023-08-15 14:22:40 +10:00
dependabot[bot]
8fc4ca9b11 build(deps): bump bufbuild/buf-setup-action from 1.25.1 to 1.26.0 (#1321)
Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.25.1 to 1.26.0.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.25.1...v1.26.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>
2023-08-15 10:58:17 +10:00
Adrian Gallagher
b25037dabc CI: Bump Go and golangci-lint versions (#1313) 2023-08-11 14:06:56 +10:00
Bea
26692669c6 exchanges/order: Improve order side handling in SubmitOrder (#1299)
* SubmitOrder- order.Buy replaced with IsLong

Progresses #1270

* Btcmarkets: order.Buy and order.Sell changed to order.Bid and order.Ask

* Bithumb: SubmitOrder- order.Buy replaced with IsLong

Progresses #1270

* Binanceus: SubmitOrder- order.Buy replaced with IsLong

Progresses #1720

* Bistamp: SubmitOrder- order.Buy replaced with IsLong

Progresses #1270

* Bitfinex: Changed order Side to IsLong

* Binance:switch added to SubmitOrder

* Binance: Replaced Buy and Sell in SubmitOrder with IsLong and IsShort

* Binance:SubmitOrder if statement for order side simplified
2023-08-11 14:05:43 +10:00
Romano
555bb76f4d exchanges/fill: Add test coverage (#1223)
* Fill go test

* Add return error into Update function

* Update exchanges/fill/fill_test.go

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

* GateIO: Fix websocket trade tests

* GateIO: More test coverage

* GateIO: Options tests

* GateIO: Fix woopsies

* Address nits

* GateIO: Fix nitters

---------

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2023-08-10 12:33:42 +10:00
Bea
067fae0e00 engine/sync_manager: Rename Update to WebsocketUpdate (#1300)
* sync_manager: Update replaced with WebsocketUpdate

* sync_manager: replaced TestSyncManagerUpdate with TestSyncManagerWebsocketUpdate

* Update engine/sync_manager.go

---------

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2023-08-07 16:40:09 +10:00
dependabot[bot]
4200447118 build(deps): bump bufbuild/buf-setup-action from 1.25.0 to 1.25.1 (#1304)
Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.25.0 to 1.25.1.
- [Release notes](https://github.com/bufbuild/buf-setup-action/releases)
- [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.25.0...v1.25.1)

---
updated-dependencies:
- dependency-name: bufbuild/buf-setup-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>
2023-08-07 16:09:49 +10:00
dependabot[bot]
70358501c1 build(deps): bump golang.org/x/net from 0.12.0 to 0.14.0 (#1305)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.12.0 to 0.14.0.
- [Commits](https://github.com/golang/net/compare/v0.12.0...v0.14.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>
2023-08-07 16:08:40 +10:00