Skip to content

Commit fd9aaf0

Browse files
cranktakulargbjk
andauthored
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>
1 parent d957dda commit fd9aaf0

File tree

78 files changed

+8850
-3937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+8850
-3937
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
2828
| BTCMarkets | Yes | Yes | NA |
2929
| BTSE | Yes | Yes | NA |
3030
| Bybit | Yes | Yes | NA |
31-
| CoinbasePro | Yes | Yes | No|
31+
| Coinbase | Yes | Yes | No|
3232
| COINUT | Yes | Yes | NA |
3333
| Deribit | Yes | Yes | No |
3434
| Exmo | Yes | NA | NA |

backtester/eventhandlers/exchange/exchange_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func TestPlaceOrder(t *testing.T) {
202202
Base: &event.Base{},
203203
}
204204
_, err = e.placeOrder(t.Context(), decimal.NewFromInt(1), decimal.NewFromInt(1), decimal.Zero, false, true, f, bot.OrderManager)
205-
assert.ErrorIs(t, err, engine.ErrExchangeNameIsEmpty)
205+
assert.ErrorIs(t, err, gctcommon.ErrExchangeNameNotSet)
206206

207207
f.Exchange = testExchange
208208
require.NoError(t, exch.UpdateOrderExecutionLimits(t.Context(), asset.Spot), "UpdateOrderExecutionLimits must not error")

backtester/funding/funding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ func (f *FundManager) HasExchangeBeenLiquidated(ev common.Event) bool {
801801
// help calculate collateral
802802
func (f *FundManager) SetFunding(exchName string, item asset.Item, balance *account.Balance, initialFundsSet bool) error {
803803
if exchName == "" {
804-
return engine.ErrExchangeNameIsEmpty
804+
return gctcommon.ErrExchangeNameNotSet
805805
}
806806
if !item.IsValid() {
807807
return asset.ErrNotSupported

backtester/funding/funding_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ func TestSetFunding(t *testing.T) {
709709
t.Parallel()
710710
f := &FundManager{}
711711
err := f.SetFunding("", 0, nil, false)
712-
assert.ErrorIs(t, err, engine.ErrExchangeNameIsEmpty)
712+
assert.ErrorIs(t, err, gctcommon.ErrExchangeNameNotSet)
713713

714714
err = f.SetFunding(exchName, 0, nil, false)
715715
assert.ErrorIs(t, err, asset.ErrNotSupported)

cmd/documentation/exchanges_templates/coinbasepro.tmpl renamed to cmd/documentation/exchanges_templates/coinbase.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{{define "exchanges coinbasepro" -}}
1+
{{define "exchanges coinbase" -}}
22
{{template "header" .}}
3-
## CoinbasePro Exchange
3+
## Coinbase Exchange
44

55
### Current Features
66

@@ -31,7 +31,7 @@ main.go
3131
var c exchange.IBotExchange
3232
3333
for i := range bot.Exchanges {
34-
if bot.Exchanges[i].GetName() == "CoinbasePro" {
34+
if bot.Exchanges[i].GetName() == "Coinbase" {
3535
c = bot.Exchanges[i]
3636
}
3737
}

cmd/documentation/exchanges_templates/exchanges_trade_readme.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ _b in this context is an `IBotExchange` implemented struct_
5151
| BTCMarkets | Yes | Yes | No |
5252
| BTSE | Yes | Yes | No |
5353
| Bybit | Yes | Yes | Yes |
54-
| CoinbasePro | Yes | Yes | No|
54+
| Coinbase | Yes | Yes | No|
5555
| COINUT | Yes | Yes | No |
5656
| Deribit | Yes | Yes | Yes |
5757
| Exmo | Yes | NA | No |

cmd/documentation/root_templates/root_readme.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
2929
| BTCMarkets | Yes | Yes | NA |
3030
| BTSE | Yes | Yes | NA |
3131
| Bybit | Yes | Yes | NA |
32-
| CoinbasePro | Yes | Yes | No|
32+
| Coinbase | Yes | Yes | No|
3333
| COINUT | Yes | Yes | NA |
3434
| Deribit | Yes | Yes | No |
3535
| Exmo | Yes | NA | NA |

cmd/exchange_wrapper_standards/exchange_wrapper_standards_test.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,18 @@ func setupExchange(ctx context.Context, t *testing.T, name string, cfg *config.C
9292
exch.SetDefaults()
9393
exchCfg.API.AuthenticatedSupport = true
9494
exchCfg.API.Credentials = getExchangeCredentials(name)
95-
9695
err = exch.Setup(exchCfg)
9796
if err != nil {
9897
t.Fatalf("Cannot setup %v exchange Setup %v", name, err)
9998
}
100-
10199
err = exch.UpdateTradablePairs(ctx, true)
102100
require.Truef(t, errors.Is(err, context.DeadlineExceeded) || err == nil, "Exchange %s UpdateTradablePairs must not error: %s", name, err)
103101
b := exch.GetBase()
104-
105102
assets := b.CurrencyPairs.GetAssetTypes(false)
106103
require.NotEmptyf(t, assets, "Exchange %s must have assets", name)
107104
for _, a := range assets {
108105
require.NoErrorf(t, b.CurrencyPairs.SetAssetEnabled(a, true), "Exchange %s SetAssetEnabled must not error for asset %s: %s", name, a, err)
109106
}
110-
111107
// Add +1 to len to verify that exchanges can handle requests with unset pairs and assets
112108
assetPairs := make([]assetPair, 0, len(assets)+1)
113109
assets:
@@ -147,7 +143,6 @@ assets:
147143
})
148144
}
149145
assetPairs = append(assetPairs, assetPair{})
150-
151146
return exch, assetPairs
152147
}
153148

@@ -191,7 +186,6 @@ func executeExchangeWrapperTests(ctx context.Context, t *testing.T, exch exchang
191186
continue
192187
}
193188
method := actualExchange.MethodByName(methodName)
194-
195189
var assetLen int
196190
for y := range method.Type().NumIn() {
197191
input := method.Type().In(y)
@@ -391,6 +385,7 @@ func generateMethodArg(ctx context.Context, t *testing.T, argGenerator *MethodAr
391385
Description: "1337",
392386
Amount: 1,
393387
ClientOrderID: "1337",
388+
WalletID: "7331",
394389
}
395390
if argGenerator.MethodName == "WithdrawCryptocurrencyFunds" {
396391
req.Type = withdraw.Crypto
@@ -614,10 +609,9 @@ var unsupportedAssets = []asset.Item{
614609

615610
var unsupportedExchangeNames = []string{
616611
"testexch",
617-
"bitflyer", // Bitflyer has many "ErrNotYetImplemented, which is true, but not what we care to test for here
618-
"btse", // TODO rm once timeout issues resolved
619-
"poloniex", // outdated API // TODO rm once updated
620-
"coinbasepro", // outdated API // TODO rm once updated
612+
"bitflyer", // Bitflyer has many "ErrNotYetImplemented, which is true, but not what we care to test for here
613+
"btse", // TODO rm once timeout issues resolved
614+
"poloniex", // outdated API // TODO rm once updated
621615
}
622616

623617
// cryptoChainPerExchange holds the deposit address chain per exchange

common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var (
5555

5656
// Public common Errors
5757
var (
58+
ErrExchangeNameNotSet = errors.New("exchange name not set")
5859
ErrNotYetImplemented = errors.New("not yet implemented")
5960
ErrFunctionNotSupported = errors.New("unsupported wrapper function")
6061
ErrAddressIsEmptyOrInvalid = errors.New("address is empty or invalid")

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ func (c *Config) CheckExchangeConfigValues() error {
916916
continue
917917
}
918918
if e.Name == "" {
919-
log.Errorf(log.ConfigMgr, "%s: #%d", errExchangeNameEmpty, i)
919+
log.Errorf(log.ConfigMgr, "%s: #%d", common.ErrExchangeNameNotSet, i)
920920
e.Enabled = false
921921
continue
922922
}

0 commit comments

Comments
 (0)