mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 07:26:47 +00:00
Coinbase: Update exchange implementation (#1480)
* Slight enhance of Coinbase tests Continual enhance of Coinbase tests The revamp continues Oh jeez the Orderbook part's unfinished don't look Coinbase revamp, Orderbook still unfinished * Coinbase revamp; CreateReport is still WIP * More coinbase improvements; onto sandbox testing * Coinbase revamp continues * Coinbase revamp continues * Coinbasepro revamp is ceaseless * Coinbase revamp, starting on advanced trade API * Coinbase Advanced Trade Starts in Ernest V3 done, onto V2 Coinbase revamp nears completion Coinbase revamp nears completion Test commit should fail Coinbase revamp nears completion * Coinbase revamp stage wrapper * Coinbase wrapper coherence continues * Coinbase wrapper continues writhing * Coinbase wrapper & codebase cleanup * Coinbase updates & wrap progress * More Coinbase wrapper progress * Wrapper is wrapped, kinda * Test & type checking * Coinbase REST revamp finished * Post-merge fix * WS revamp begins * WS Main Revamp Done? * CB websocket tidying up * Coinbase WS wrapperupperer * Coinbase revamp done?? * Linter progress * Continued lint cleanup * Further lint cleanup * Increased lint coverage * Does this fix all sloppy reassigns & shadowing? * Undoing retry policy change * Documentation regeneration * Coinbase code improvements * Providing warning about known issue * Updating an error to new format * Making gocritic happy * Review adherence * Endpoints moved to V3 & nil pointer fixes * Removing seemingly superfluous constant * Glorious improvements * Removing unused error * Partial public endpoint addition * Slight improvements * Wrapper improvements; still a few errors left in other packages * A lil Coinbase progress * Json cleaning * Lint appeasement * Config repair * Config fix (real) * Little fix * New public endpoint incorporation * Additional fixes * Improvements & Appeasements * LineSaver * Additional fixes * Another fix * Fixing picked nits * Quick fixies * Lil fixes * Subscriptions: Add List.Enabled * CoinbasePro: Add subscription templating * fixup! CoinbasePro: Add subscription templating * fixup! CoinbasePro: Add subscription templating * Comment fix * Subsequent fixes * Issues hopefully fixed * Lint fix * Glorious fixes * Json formatting * ShazNits * (L/N)i(n/)t * Adding a test * Tiny test improvement * Template patch testing * Fixes * Further shaznits * Lint nit * JWT move and other fixes * Small nits * Shaznit, singular * Post-merge fix * Post-merge fixes * Typo fix * Some glorious nits * Required changes * Stop going * Alias attempt * Alias fix & test cleanup * Test fix * GetDepositAddress logic improvement * Status update: Fixed * Lint fix * Happy birthday to PR 1480 * Cleanups * Necessary nit corrections * Fixing sillybug * As per request * Programming progress * Order fixes * Further fixies * Test fix * Pre-merge fixes * More shaznits * Context * Sonic error handling * Import fix * Better Sonic error handling * Perfect Sonic error handling? * F purge * Coinbase improvements * API Update Conformity * Coinbase continuation * Coinbase order improvements * Coinbase order improvements * CreateOrderConfig improvements * Managing API updates * Coinbase API update progression * jwt rename * Comment link fix * Coinbase v2 cleanup * Post-merge fixes * Review fixes * GK's suggestions * Linter fix * Minor gbjk fixes * Nit fixes * Merge fix * Lint fixes * Coinbase rename stage 1 * Coinbase rename stage 2 * Coinbase rename stage 3 * Coinbase rename stage 4 * Coinbase rename final fix * Coinbase: PoC on converting to request structs * Applying requested changes * Many review fixes, handled * Thrashed by nits * More minor modifications * The last nit!? --------- Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
@@ -25,7 +25,6 @@ var (
|
||||
|
||||
var (
|
||||
errHoldingsIsNil = errors.New("holdings cannot be nil")
|
||||
errExchangeNameUnset = errors.New("exchange name unset")
|
||||
errNoExchangeSubAccountBalances = errors.New("no exchange sub account balances")
|
||||
errBalanceIsNil = errors.New("balance is nil")
|
||||
errNoCredentialBalances = errors.New("no balances associated with credentials")
|
||||
@@ -107,7 +106,7 @@ func ProcessChange(exch string, changes []Change, c *Credentials) error {
|
||||
// TODO: Add jurisdiction and differentiation between APIKEY holdings.
|
||||
func GetHoldings(exch string, creds *Credentials, assetType asset.Item) (Holdings, error) {
|
||||
if exch == "" {
|
||||
return Holdings{}, errExchangeNameUnset
|
||||
return Holdings{}, common.ErrExchangeNameNotSet
|
||||
}
|
||||
|
||||
if creds.IsEmpty() {
|
||||
@@ -171,7 +170,7 @@ func GetHoldings(exch string, creds *Credentials, assetType asset.Item) (Holding
|
||||
// GetBalance returns the internal balance for that asset item.
|
||||
func GetBalance(exch, subAccount string, creds *Credentials, a asset.Item, c currency.Code) (*ProtectedBalance, error) {
|
||||
if exch == "" {
|
||||
return nil, fmt.Errorf("cannot get balance: %w", errExchangeNameUnset)
|
||||
return nil, fmt.Errorf("cannot get balance: %w", common.ErrExchangeNameNotSet)
|
||||
}
|
||||
|
||||
if !a.IsValid() {
|
||||
@@ -222,7 +221,7 @@ func (s *Service) Save(incoming *Holdings, creds *Credentials) error {
|
||||
}
|
||||
|
||||
if incoming.Exchange == "" {
|
||||
return fmt.Errorf("cannot save holdings: %w", errExchangeNameUnset)
|
||||
return fmt.Errorf("cannot save holdings: %w", common.ErrExchangeNameNotSet)
|
||||
}
|
||||
|
||||
if creds.IsEmpty() {
|
||||
@@ -316,7 +315,7 @@ func (s *Service) Save(incoming *Holdings, creds *Credentials) error {
|
||||
// Update updates the balance for a specific exchange and credentials
|
||||
func (s *Service) Update(exch string, changes []Change, creds *Credentials) error {
|
||||
if exch == "" {
|
||||
return fmt.Errorf("%w: %w", errCannotUpdateBalance, errExchangeNameUnset)
|
||||
return fmt.Errorf("%w: %w", errCannotUpdateBalance, common.ErrExchangeNameNotSet)
|
||||
}
|
||||
|
||||
if creds.IsEmpty() {
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestGetHoldings(t *testing.T) {
|
||||
assert.ErrorIs(t, err, errHoldingsIsNil)
|
||||
|
||||
err = Process(&Holdings{}, nil)
|
||||
assert.ErrorIs(t, err, errExchangeNameUnset)
|
||||
assert.ErrorIs(t, err, common.ErrExchangeNameNotSet)
|
||||
|
||||
holdings := Holdings{Exchange: "Test"}
|
||||
|
||||
@@ -111,7 +111,7 @@ func TestGetHoldings(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = GetHoldings("", nil, asset.Spot)
|
||||
assert.ErrorIs(t, err, errExchangeNameUnset)
|
||||
assert.ErrorIs(t, err, common.ErrExchangeNameNotSet)
|
||||
|
||||
_, err = GetHoldings("bla", nil, asset.Spot)
|
||||
assert.ErrorIs(t, err, errCredentialsAreNil)
|
||||
@@ -182,7 +182,7 @@ func TestGetBalance(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := GetBalance("", "", nil, asset.Empty, currency.Code{})
|
||||
assert.ErrorIs(t, err, errExchangeNameUnset)
|
||||
assert.ErrorIs(t, err, common.ErrExchangeNameNotSet)
|
||||
|
||||
_, err = GetBalance("bruh", "", nil, asset.Empty, currency.Code{})
|
||||
assert.ErrorIs(t, err, asset.ErrNotSupported)
|
||||
@@ -320,7 +320,7 @@ func TestSave(t *testing.T) {
|
||||
assert.ErrorIs(t, err, errHoldingsIsNil)
|
||||
|
||||
err = s.Save(&Holdings{}, nil)
|
||||
assert.ErrorIs(t, err, errExchangeNameUnset)
|
||||
assert.ErrorIs(t, err, common.ErrExchangeNameNotSet)
|
||||
|
||||
err = s.Save(&Holdings{
|
||||
Exchange: "TeSt",
|
||||
@@ -410,7 +410,7 @@ func TestUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := &Service{exchangeAccounts: make(map[string]*Accounts), mux: dispatch.GetNewMux(nil)}
|
||||
err := s.Update("", nil, nil)
|
||||
assert.ErrorIs(t, err, errExchangeNameUnset)
|
||||
assert.ErrorIs(t, err, common.ErrExchangeNameNotSet)
|
||||
|
||||
err = s.Update("test", nil, nil)
|
||||
assert.ErrorIs(t, err, errCredentialsAreNil)
|
||||
|
||||
Reference in New Issue
Block a user