mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 15:10:19 +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:
@@ -916,7 +916,7 @@ func (c *Config) CheckExchangeConfigValues() error {
|
||||
continue
|
||||
}
|
||||
if e.Name == "" {
|
||||
log.Errorf(log.ConfigMgr, "%s: #%d", errExchangeNameEmpty, i)
|
||||
log.Errorf(log.ConfigMgr, "%s: #%d", common.ErrExchangeNameNotSet, i)
|
||||
e.Enabled = false
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -83,7 +83,6 @@ var (
|
||||
|
||||
errNoEnabledExchanges = errors.New("no exchanges enabled")
|
||||
errCheckingConfigValues = errors.New("fatal error checking config values")
|
||||
errExchangeNameEmpty = errors.New("exchange name is empty")
|
||||
)
|
||||
|
||||
// Config is the overarching object that holds all the information for
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
v6 "github.com/thrasher-corp/gocryptotrader/config/versions/v6"
|
||||
v7 "github.com/thrasher-corp/gocryptotrader/config/versions/v7"
|
||||
v8 "github.com/thrasher-corp/gocryptotrader/config/versions/v8"
|
||||
v9 "github.com/thrasher-corp/gocryptotrader/config/versions/v9"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -22,4 +23,5 @@ func init() {
|
||||
Manager.registerVersion(6, &v6.Version{})
|
||||
Manager.registerVersion(7, &v7.Version{})
|
||||
Manager.registerVersion(8, &v8.Version{})
|
||||
Manager.registerVersion(9, &v9.Version{})
|
||||
}
|
||||
|
||||
29
config/versions/v9/v9.go
Normal file
29
config/versions/v9/v9.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package v9
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/buger/jsonparser"
|
||||
)
|
||||
|
||||
// Version is an ExchangeVersion to change the name of CoinbasePro to Coinbase
|
||||
type Version struct{}
|
||||
|
||||
// Exchanges returns just CoinbasePro and Coinbase
|
||||
func (*Version) Exchanges() []string { return []string{"CoinbasePro", "Coinbase"} }
|
||||
|
||||
// UpgradeExchange will change the exchange name from CoinbasePro to Coinbase
|
||||
func (*Version) UpgradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
||||
if n, err := jsonparser.GetString(e, "name"); err == nil && n == "CoinbasePro" {
|
||||
return jsonparser.Set(e, []byte(`"Coinbase"`), "name")
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// DowngradeExchange will change the exchange name from Coinbase to CoinbasePro
|
||||
func (*Version) DowngradeExchange(_ context.Context, e []byte) ([]byte, error) {
|
||||
if n, err := jsonparser.GetString(e, "name"); err == nil && n == "Coinbase" {
|
||||
return jsonparser.Set(e, []byte(`"CoinbasePro"`), "name")
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
37
config/versions/v9/v9_test.go
Normal file
37
config/versions/v9/v9_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package v9_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
v9 "github.com/thrasher-corp/gocryptotrader/config/versions/v9"
|
||||
)
|
||||
|
||||
func TestUpgradeExchange(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tt := range [][]string{
|
||||
{"CoinbasePro", "Coinbase"},
|
||||
{"Kraken", "Kraken"},
|
||||
{"Coinbase", "Coinbase"},
|
||||
} {
|
||||
out, err := new(v9.Version).UpgradeExchange(t.Context(), []byte(`{"name":"`+tt[0]+`"}`))
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, out)
|
||||
assert.Equalf(t, `{"name":"`+tt[1]+`"}`, string(out), "Test exchange name %s", tt[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestDowngradeExchange(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tt := range [][]string{
|
||||
{"Coinbase", "CoinbasePro"},
|
||||
{"Kraken", "Kraken"},
|
||||
{"CoinbasePro", "CoinbasePro"},
|
||||
} {
|
||||
out, err := new(v9.Version).DowngradeExchange(t.Context(), []byte(`{"name":"`+tt[0]+`"}`))
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, out)
|
||||
assert.Equalf(t, `{"name":"`+tt[1]+`"}`, string(out), "Test exchange name %s", tt[0])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user