Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coinbase: Update exchange implementation #1480

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a006163
Slight enhance of Coinbase tests
cranktakular Sep 12, 2023
074f367
Merge branch 'master' into coinbase_api_revamp
cranktakular Oct 8, 2023
bd9f2dd
Coinbase revamp; CreateReport is still WIP
cranktakular Oct 9, 2023
25fcd2e
More coinbase improvements; onto sandbox testing
cranktakular Oct 16, 2023
5d3fd99
Coinbase revamp continues
cranktakular Oct 23, 2023
3aca36b
Coinbase revamp continues
cranktakular Oct 23, 2023
f58b76d
Merge branch 'coinbase_api_revamp' of github.com:cranktakular/gocrypt…
cranktakular Oct 23, 2023
eded160
Coinbasepro revamp is ceaseless
cranktakular Oct 24, 2023
5a0ba23
Coinbase revamp, starting on advanced trade API
cranktakular Nov 1, 2023
88e6713
Coinbase Advanced Trade Starts in Ernest
cranktakular Nov 7, 2023
aa2efef
Coinbase revamp stage wrapper
cranktakular Nov 28, 2023
3560599
Merge branch 'master' into coinbase_api_revamp
cranktakular Nov 28, 2023
4593828
Coinbase wrapper coherence continues
cranktakular Nov 28, 2023
a8cae40
Coinbase wrapper continues writhing
cranktakular Dec 5, 2023
0564e45
Coinbase wrapper & codebase cleanup
cranktakular Dec 11, 2023
4f5ccb5
Coinbase updates & wrap progress
cranktakular Dec 19, 2023
9a6c7e6
More Coinbase wrapper progress
cranktakular Dec 27, 2023
2896b3e
Wrapper is wrapped, kinda
cranktakular Jan 2, 2024
ffb43d8
Test & type checking
cranktakular Jan 9, 2024
7dd4589
Coinbase REST revamp finished
cranktakular Jan 16, 2024
6d7ac5f
Merge branch 'master' into coinbase_api_revamp
cranktakular Jan 16, 2024
2881841
Post-merge fix
cranktakular Jan 16, 2024
2166886
WS revamp begins
cranktakular Jan 16, 2024
35eda67
WS Main Revamp Done?
cranktakular Jan 22, 2024
6ac86cd
CB websocket tidying up
cranktakular Jan 31, 2024
cfe6e11
Coinbase WS wrapperupperer
cranktakular Feb 6, 2024
2f770d5
Coinbase revamp done??
cranktakular Feb 14, 2024
3e54528
Merge branch 'master' into coinbase_api_revamp
cranktakular Feb 14, 2024
2f05c05
Linter progress
cranktakular Feb 20, 2024
005af4a
Continued lint cleanup
cranktakular Feb 20, 2024
2b5df7c
Further lint cleanup
cranktakular Feb 20, 2024
93d6722
Increased lint coverage
cranktakular Feb 20, 2024
529f7f3
Does this fix all sloppy reassigns & shadowing?
cranktakular Feb 20, 2024
8bb2561
Undoing retry policy change
cranktakular Feb 20, 2024
5f813e3
Documentation regeneration
cranktakular Feb 20, 2024
c7d7ac2
Coinbase code improvements
cranktakular Feb 27, 2024
8cdc78a
Providing warning about known issue
cranktakular Feb 27, 2024
19245e3
Merge branch 'master' into coinbase_api_revamp
cranktakular Feb 27, 2024
79ac205
Updating an error to new format
cranktakular Feb 27, 2024
e073757
Making gocritic happy
cranktakular Feb 27, 2024
a65fc38
Review adherence
cranktakular Mar 7, 2024
254efe7
Merge branch 'master' into coinbase_api_revamp
cranktakular Mar 7, 2024
14ab490
Endpoints moved to V3 & nil pointer fixes
cranktakular Mar 7, 2024
bee2878
Removing seemingly superfluous constant
cranktakular Mar 8, 2024
1d51a2e
Glorious improvements
cranktakular Apr 9, 2024
90e20e1
Merge master, resolving conflict
cranktakular Apr 14, 2024
4d1afc2
Removing unused error
cranktakular Apr 14, 2024
55596d8
Partial public endpoint addition
cranktakular Apr 15, 2024
343052b
Slight improvements
cranktakular Apr 22, 2024
ea43046
Wrapper improvements; still a few errors left in other packages
cranktakular Apr 30, 2024
6dbb243
A lil Coinbase progress
cranktakular May 7, 2024
f3fc162
Merge with master + improvements
cranktakular May 7, 2024
a5a3bad
Json cleaning
cranktakular May 7, 2024
742b21e
Lint appeasement
cranktakular May 7, 2024
71e0fa5
Config repair
cranktakular May 7, 2024
01ccd01
Config fix (real)
cranktakular May 7, 2024
228c3ba
Merge master maybe?
cranktakular May 30, 2024
91d4b24
Little fix
cranktakular May 30, 2024
75425fd
New public endpoint incorporation
cranktakular Jun 11, 2024
44ff400
Merge branch 'master' into coinbase_api_revamp
cranktakular Jun 11, 2024
eec8a5d
Additional fixes
cranktakular Jun 11, 2024
bbcc27b
Improvements & Appeasements
cranktakular Jun 11, 2024
e8a06e8
LineSaver
cranktakular Jun 11, 2024
d70d599
Merge branch 'master' into coinbase_api_revamp
cranktakular Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ shazbert | https://github.com/shazbert
dependabot[bot] | https://github.com/apps/dependabot
gloriousCode | https://github.com/gloriousCode
dependabot-preview[bot] | https://github.com/apps/dependabot-preview
xtda | https://github.com/xtda
gbjk | https://github.com/gbjk
xtda | https://github.com/xtda
lrascao | https://github.com/lrascao
Rots | https://github.com/Rots
vazha | https://github.com/vazha
ydm | https://github.com/ydm
vazha | https://github.com/vazha
Rots | https://github.com/Rots
Beadko | https://github.com/Beadko
ermalguni | https://github.com/ermalguni
MadCozBadd | https://github.com/MadCozBadd
Beadko | https://github.com/Beadko
vadimzhukck | https://github.com/vadimzhukck
140am | https://github.com/140am
marcofranssen | https://github.com/marcofranssen
geseq | https://github.com/geseq
samuael | https://github.com/samuael
marcofranssen | https://github.com/marcofranssen
140am | https://github.com/140am
TaltaM | https://github.com/TaltaM
dackroyd | https://github.com/dackroyd
cranktakular | https://github.com/cranktakular
khcchiu | https://github.com/khcchiu
yangrq1018 | https://github.com/yangrq1018
woshidama323 | https://github.com/woshidama323
crackcomm | https://github.com/crackcomm
azhang | https://github.com/azhang
andreygrehov | https://github.com/andreygrehov
bretep | https://github.com/bretep
Christian-Achilli | https://github.com/Christian-Achilli
mshogin | https://github.com/mshogin
herenow | https://github.com/herenow
tk42 | https://github.com/tk42
soxipy | https://github.com/soxipy
cornelk | https://github.com/cornelk
gam-phon | https://github.com/gam-phon
herenow | https://github.com/herenow
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2023 The GoCryptoTrader Developers
Copyright (c) 2014-2024 The GoCryptoTrader Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,36 +141,36 @@ Binaries will be published once the codebase reaches a stable condition.

|User|Contribution Amount|
|--|--|
| [thrasher-](https://github.com/thrasher-) | 684 |
| [shazbert](https://github.com/shazbert) | 315 |
| [dependabot[bot]](https://github.com/apps/dependabot) | 228 |
| [gloriousCode](https://github.com/gloriousCode) | 224 |
| [thrasher-](https://github.com/thrasher-) | 689 |
| [shazbert](https://github.com/shazbert) | 316 |
| [dependabot[bot]](https://github.com/apps/dependabot) | 254 |
| [gloriousCode](https://github.com/gloriousCode) | 229 |
| [dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | 88 |
| [gbjk](https://github.com/gbjk) | 61 |
| [xtda](https://github.com/xtda) | 47 |
| [gbjk](https://github.com/gbjk) | 42 |
| [lrascao](https://github.com/lrascao) | 27 |
| [Rots](https://github.com/Rots) | 15 |
| [vazha](https://github.com/vazha) | 15 |
| [ydm](https://github.com/ydm) | 15 |
| [vazha](https://github.com/vazha) | 15 |
| [Rots](https://github.com/Rots) | 15 |
| [Beadko](https://github.com/Beadko) | 15 |
| [ermalguni](https://github.com/ermalguni) | 14 |
| [MadCozBadd](https://github.com/MadCozBadd) | 13 |
| [Beadko](https://github.com/Beadko) | 11 |
| [vadimzhukck](https://github.com/vadimzhukck) | 10 |
| [140am](https://github.com/140am) | 8 |
| [marcofranssen](https://github.com/marcofranssen) | 8 |
| [geseq](https://github.com/geseq) | 8 |
| [samuael](https://github.com/samuael) | 7 |
| [samuael](https://github.com/samuael) | 8 |
| [marcofranssen](https://github.com/marcofranssen) | 8 |
| [140am](https://github.com/140am) | 8 |
| [TaltaM](https://github.com/TaltaM) | 6 |
| [dackroyd](https://github.com/dackroyd) | 5 |
| [cranktakular](https://github.com/cranktakular) | 5 |
| [khcchiu](https://github.com/khcchiu) | 5 |
| [yangrq1018](https://github.com/yangrq1018) | 4 |
| [woshidama323](https://github.com/woshidama323) | 3 |
| [crackcomm](https://github.com/crackcomm) | 3 |
| [azhang](https://github.com/azhang) | 2 |
| [andreygrehov](https://github.com/andreygrehov) | 2 |
| [bretep](https://github.com/bretep) | 2 |
| [Christian-Achilli](https://github.com/Christian-Achilli) | 2 |
| [mshogin](https://github.com/mshogin) | 2 |
| [herenow](https://github.com/herenow) | 2 |
| [tk42](https://github.com/tk42) | 2 |
| [soxipy](https://github.com/soxipy) | 2 |
| [cornelk](https://github.com/cornelk) | 2 |
| [gam-phon](https://github.com/gam-phon) | 2 |
| [herenow](https://github.com/herenow) | 2 |
Expand Down
11 changes: 11 additions & 0 deletions cmd/exchange_wrapper_standards/exchange_wrapper_standards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func TestAllExchangeWrappers(t *testing.T) {
ctx, cancelFn = context.WithTimeout(context.Background(), 0)
cancelFn()
}

// blocked exchanges are not able to be tested at any level
if common.StringDataContains(blockedExchanges, name) {
t.Skipf("skipping blocked exchange %v", name)
}

exch, assetPairs := setupExchange(ctx, t, name, cfg)
executeExchangeWrapperTests(ctx, t, exch, assetPairs)
})
Expand Down Expand Up @@ -598,6 +604,11 @@ var blockedCIExchanges = []string{
"bybit", // bybit API is banned from executing within the US where github Actions is ran
}

// blockedExchanges are exchanges that are not able to be tested in general
var blockedExchanges = []string{
"coinbasepro", // coinbasepro API requires authentication for almost every endpoint
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you've thought about this already, but worth mentioning in case it hasn't been covered already:
As a design pattern I think it's preferable to find any way to consolidate all information about an exchange onto it's own packages.

Off the top of my head I'm thinking about adding an exported constant using build tags for tests, and then using reflect to check for it.
The things I'm aiming for with that are:

  • No cost or boilerplate to exchanges which don't care
  • No production runtime cost
  • More information about the exchange is consolidated into it's dir, making it easier to find and delete in one go

I'm not suggesting you need to do this, especially in light of blockedCIExchanges already existing, but wanted to share it in case you want to engage, and for any other work in flight where it's appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After incorporating public endpoints from an earlier version of the API, I no longer need that blockedExchanges variable to exist so I've removed it.

Moving towards that sort of design for other similar stuff within those standards seems like a good idea, but I think it's a bit out of scope for my current work.

// unsupportedAssets contains assets that cannot handle
// normal processing for testing. This is to be used very sparingly
var unsupportedAssets = []asset.Item{
Expand Down
5 changes: 4 additions & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ var (
ErrNotYetImplemented = errors.New("not yet implemented")
// ErrFunctionNotSupported defines a standardised error for an unsupported
// wrapper function by an API
ErrFunctionNotSupported = errors.New("unsupported wrapper function")
ErrFunctionNotSupported = errors.New("unsupported wrapper function")
// ErrExchangeNameUnset defines a common error across the code base for
// when the exchange name is unset
ErrExchangeNameUnset = errors.New("exchange name unset")
errInvalidCryptoCurrency = errors.New("invalid crypto currency")
// ErrDateUnset is an error for start end check calculations
ErrDateUnset = errors.New("date unset")
Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
)

var (
// errExchangeConfigIsNil defines an error when the config is nil
errExchangeConfigIsNil = errors.New("exchange config is nil")
// ErrExchangeConfigIsNil defines an error when the config is nil
ErrExchangeConfigIsNil = errors.New("exchange config is nil")
errPairsManagerIsNil = errors.New("currency pairs manager is nil")
)

Expand Down Expand Up @@ -1905,7 +1905,7 @@ func (c *Config) GetDataPath(elem ...string) string {
// Validate checks if exchange config is valid
func (c *Exchange) Validate() error {
if c == nil {
return errExchangeConfigIsNil
return ErrExchangeConfigIsNil
}

if c.ConnectionMonitorDelay <= 0 {
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2290,8 +2290,8 @@ func TestMigrateConfig(t *testing.T) {

func TestExchangeConfigValidate(t *testing.T) {
err := (*Exchange)(nil).Validate()
if !errors.Is(err, errExchangeConfigIsNil) {
t.Fatalf("received: '%v' but expected: '%v'", err, errExchangeConfigIsNil)
if !errors.Is(err, ErrExchangeConfigIsNil) {
t.Fatalf("received: '%v' but expected: '%v'", err, ErrExchangeConfigIsNil)
}

err = (&Exchange{}).Validate()
Expand Down
5 changes: 4 additions & 1 deletion currency/code_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3021,12 +3021,15 @@ var (
FI = NewCode("FI")
USDM = NewCode("USDM")
USDTM = NewCode("USDTM")
CBETH = NewCode("CBETH")
PYUSD = NewCode("PYUSD")
EUROC = NewCode("EUROC")
LSETH = NewCode("LSETH")
LEVER = NewCode("LEVER")
NESS = NewCode("NESS")
KAS = NewCode("KAS")
NEXT = NewCode("NEXT")
VEXT = NewCode("VEXT")
PYUSD = NewCode("PYUSD")
SAIL = NewCode("SAIL")
VV = NewCode("VV")
ORDI = NewCode("ORDI")
Expand Down
2 changes: 1 addition & 1 deletion currency/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewBTCUSD() Pair {
return NewPair(BTC, USD)
}

// NewPairDelimiter splits the desired currency string at delimiter, the returns
// NewPairDelimiter splits the desired currency string at delimiter, then returns
// a Pair struct
func NewPairDelimiter(currencyPair, delimiter string) (Pair, error) {
if !strings.Contains(currencyPair, delimiter) {
Expand Down
74 changes: 37 additions & 37 deletions engine/currency_state_manager.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# GoCryptoTrader package Currency state manager

<img src="/common/gctlogo.png?raw=true" width="350px" height="350px" hspace="70">


[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml)
[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager)
[![Coverage Status](http://codecov.io/github/thrasher-corp/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-corp/gocryptotrader?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader)


This currency_state_manager package is part of the GoCryptoTrader codebase.

## This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader).

Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk)
# GoCryptoTrader package Currency state manager
<img src="/common/gctlogo.png?raw=true" width="350px" height="350px" hspace="70">
[![Build Status](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/thrasher-corp/gocryptotrader/actions/workflows/tests.yml)
[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-corp/gocryptotrader/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/thrasher-corp/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-corp/gocryptotrader/engine/currency_state_manager)
[![Coverage Status](http://codecov.io/github/thrasher-corp/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-corp/gocryptotrader?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-corp/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-corp/gocryptotrader)
This currency_state_manager package is part of the GoCryptoTrader codebase.
## This is still in active development
You can track ideas, planned features and what's in progress on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader).
Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://join.slack.com/t/gocryptotrader/shared_invite/enQtNTQ5NDAxMjA2Mjc5LTc5ZDE1ZTNiOGM3ZGMyMmY1NTAxYWZhODE0MWM5N2JlZDk1NDU0YTViYzk4NTk3OTRiMDQzNGQ1YTc4YmRlMTk)

## Current Features for Currency state manager
+ The state manager keeps currency states up to date, which include:
Expand All @@ -27,22 +27,22 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
+ This allows for an internal state check to compliment internal and external
strategies.


## Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md).
+ Pull requests need to be based on and opened against the `master` branch.

## Donations

<img src="https://github.com/thrasher-corp/gocryptotrader/blob/master/web/src/assets/donate.png?raw=true" hspace="70">

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

## Contribution
Please feel free to submit any pull requests or suggest any desired features to be added.
When submitting a PR, please abide by our coding guidelines:
+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/doc/coding_style.md).
+ Pull requests need to be based on and opened against the `master` branch.

## Donations
<img src="https://github.com/thrasher-corp/gocryptotrader/blob/master/web/src/assets/donate.png?raw=true" hspace="70">
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
***bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc***
4 changes: 2 additions & 2 deletions engine/datahistory_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1195,11 +1195,11 @@ func (m *DataHistoryManager) validateJob(job *DataHistoryJob) error {
exchangeName := job.Exchange
if job.DataType == dataHistoryCandleValidationSecondarySourceType {
if job.SecondaryExchangeSource == "" {
return fmt.Errorf("job %s %w, secondary exchange name required to lookup existing results", job.Nickname, errExchangeNameUnset)
return fmt.Errorf("job %s %w, secondary exchange name required to lookup existing results", job.Nickname, common.ErrExchangeNameUnset)
}
exchangeName = job.SecondaryExchangeSource
if job.Exchange == "" {
return fmt.Errorf("job %s %w, exchange name required to lookup existing results", job.Nickname, errExchangeNameUnset)
return fmt.Errorf("job %s %w, exchange name required to lookup existing results", job.Nickname, common.ErrExchangeNameUnset)
}
}
exch, err := m.exchangeManager.GetExchangeByName(exchangeName)
Expand Down
8 changes: 4 additions & 4 deletions engine/datahistory_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,14 @@ func TestValidateJob(t *testing.T) {

dhj.DataType = dataHistoryCandleValidationSecondarySourceType
err = m.validateJob(dhj)
if !errors.Is(err, errExchangeNameUnset) {
t.Errorf("error '%v', expected '%v'", err, errExchangeNameUnset)
if !errors.Is(err, common.ErrExchangeNameUnset) {
t.Errorf("error '%v', expected '%v'", err, common.ErrExchangeNameUnset)
}
dhj.SecondaryExchangeSource = "lol"
dhj.Exchange = ""
err = m.validateJob(dhj)
if !errors.Is(err, errExchangeNameUnset) {
t.Errorf("error '%v', expected '%v'", err, errExchangeNameUnset)
if !errors.Is(err, common.ErrExchangeNameUnset) {
t.Errorf("error '%v', expected '%v'", err, common.ErrExchangeNameUnset)
}
}

Expand Down
7 changes: 3 additions & 4 deletions engine/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ var (
errExchangeNotEnabled = errors.New("exchange is not enabled")
errExchangeBaseNotFound = errors.New("cannot get exchange base")
errInvalidArguments = errors.New("invalid arguments received")
errExchangeNameUnset = errors.New("exchange name unset")
errCurrencyPairUnset = errors.New("currency pair unset")
errInvalidTimes = errors.New("invalid start and end times")
errAssetTypeUnset = errors.New("asset type unset")
Expand Down Expand Up @@ -2199,7 +2198,7 @@ func (s *RPCServer) GetOrderbookStream(r *gctrpc.GetOrderbookStreamRequest, stre
// GetExchangeOrderbookStream streams all orderbooks associated with an exchange
func (s *RPCServer) GetExchangeOrderbookStream(r *gctrpc.GetExchangeOrderbookStreamRequest, stream gctrpc.GoCryptoTraderService_GetExchangeOrderbookStreamServer) error {
if r.Exchange == "" {
return errExchangeNameUnset
return common.ErrExchangeNameUnset
}

if _, err := s.GetExchangeByName(r.Exchange); err != nil {
Expand Down Expand Up @@ -2267,7 +2266,7 @@ func (s *RPCServer) GetExchangeOrderbookStream(r *gctrpc.GetExchangeOrderbookStr
// GetTickerStream streams the requested updated ticker
func (s *RPCServer) GetTickerStream(r *gctrpc.GetTickerStreamRequest, stream gctrpc.GoCryptoTraderService_GetTickerStreamServer) error {
if r.Exchange == "" {
return errExchangeNameUnset
return common.ErrExchangeNameUnset
}

if _, err := s.GetExchangeByName(r.Exchange); err != nil {
Expand Down Expand Up @@ -2338,7 +2337,7 @@ func (s *RPCServer) GetTickerStream(r *gctrpc.GetTickerStreamRequest, stream gct
// GetExchangeTickerStream streams all tickers associated with an exchange
func (s *RPCServer) GetExchangeTickerStream(r *gctrpc.GetExchangeTickerStreamRequest, stream gctrpc.GoCryptoTraderService_GetExchangeTickerStreamServer) error {
if r.Exchange == "" {
return errExchangeNameUnset
return common.ErrExchangeNameUnset
}

if _, err := s.GetExchangeByName(r.Exchange); err != nil {
Expand Down
7 changes: 3 additions & 4 deletions exchanges/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func init() {

var (
errHoldingsIsNil = errors.New("holdings cannot be nil")
errExchangeNameUnset = errors.New("exchange name unset")
errExchangeHoldingsNotFound = errors.New("exchange holdings not found")
errAssetHoldingsNotFound = errors.New("asset holdings not found")
errExchangeAccountsNotFound = errors.New("exchange accounts not found")
Expand Down Expand Up @@ -75,7 +74,7 @@ func Process(h *Holdings, 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.ErrExchangeNameUnset
}

if creds.IsEmpty() {
Expand Down Expand Up @@ -143,7 +142,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, ai 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.ErrExchangeNameUnset)
}

if !ai.IsValid() {
Expand Down Expand Up @@ -192,7 +191,7 @@ func (s *Service) Update(incoming *Holdings, creds *Credentials) error {
}

if incoming.Exchange == "" {
return fmt.Errorf("cannot update holdings: %w", errExchangeNameUnset)
return fmt.Errorf("cannot update holdings: %w", common.ErrExchangeNameUnset)
}

if creds.IsEmpty() {
Expand Down