diff --git a/cmd/portfolio/portfolio.go b/cmd/portfolio/portfolio.go index bc4bafcc..ea44cc34 100644 --- a/cmd/portfolio/portfolio.go +++ b/cmd/portfolio/portfolio.go @@ -8,6 +8,7 @@ import ( "github.com/thrasher-corp/gocryptotrader/config" "github.com/thrasher-corp/gocryptotrader/currency" + "github.com/thrasher-corp/gocryptotrader/exchanges/asset" "github.com/thrasher-corp/gocryptotrader/exchanges/bitfinex" "github.com/thrasher-corp/gocryptotrader/portfolio" ) @@ -95,7 +96,7 @@ func main() { Subtotal float64 } - cfg.RetrieveConfigCurrencyPairs(true) + cfg.RetrieveConfigCurrencyPairs(true, asset.Spot) portfolioMap := make(map[currency.Code]PortfolioTemp) total := float64(0) diff --git a/config/config.go b/config/config.go index 30db3fe7..f38b9dbc 100644 --- a/config/config.go +++ b/config/config.go @@ -1214,7 +1214,7 @@ func (c *Config) CheckCurrencyConfigValues() error { // RetrieveConfigCurrencyPairs splits, assigns and verifies enabled currency // pairs either cryptoCurrencies or fiatCurrencies -func (c *Config) RetrieveConfigCurrencyPairs(enabledOnly bool) error { +func (c *Config) RetrieveConfigCurrencyPairs(enabledOnly bool, assetType asset.Item) error { cryptoCurrencies := c.Currency.Cryptocurrencies fiatCurrencies := currency.GetFiatCurrencies() @@ -1223,6 +1223,11 @@ func (c *Config) RetrieveConfigCurrencyPairs(enabledOnly bool) error { continue } + supports, _ := c.SupportsExchangeAssetType(c.Exchanges[x].Name, assetType) + if !supports { + continue + } + baseCurrencies := c.Exchanges[x].BaseCurrencies for y := range baseCurrencies { if !fiatCurrencies.Contains(baseCurrencies[y]) { @@ -1232,12 +1237,17 @@ func (c *Config) RetrieveConfigCurrencyPairs(enabledOnly bool) error { } for x := range c.Exchanges { + supports, _ := c.SupportsExchangeAssetType(c.Exchanges[x].Name, assetType) + if !supports { + continue + } + var pairs []currency.Pair var err error if !c.Exchanges[x].Enabled && enabledOnly { - pairs, err = c.GetEnabledPairs(c.Exchanges[x].Name, asset.Spot) + pairs, err = c.GetEnabledPairs(c.Exchanges[x].Name, assetType) } else { - pairs, err = c.GetAvailablePairs(c.Exchanges[x].Name, asset.Spot) + pairs, err = c.GetAvailablePairs(c.Exchanges[x].Name, assetType) } if err != nil { diff --git a/config/config_test.go b/config/config_test.go index 1613817a..27f38894 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -735,7 +735,7 @@ func TestRetrieveConfigCurrencyPairs(t *testing.T) { "Test failed. TestRetrieveConfigCurrencyPairs.LoadConfig: %s", err.Error(), ) } - err = cfg.RetrieveConfigCurrencyPairs(true) + err = cfg.RetrieveConfigCurrencyPairs(true, asset.Spot) if err != nil { t.Errorf( "Test failed. TestRetrieveConfigCurrencyPairs.RetrieveConfigCurrencyPairs: %s", @@ -743,7 +743,7 @@ func TestRetrieveConfigCurrencyPairs(t *testing.T) { ) } - err = cfg.RetrieveConfigCurrencyPairs(false) + err = cfg.RetrieveConfigCurrencyPairs(false, asset.Spot) if err != nil { t.Errorf( "Test failed. TestRetrieveConfigCurrencyPairs.RetrieveConfigCurrencyPairs: %s", diff --git a/engine/helpers_test.go b/engine/helpers_test.go index 838275a3..8e82911b 100644 --- a/engine/helpers_test.go +++ b/engine/helpers_test.go @@ -35,7 +35,7 @@ func SetupTestHelpers(t *testing.T) { } testSetup = true } - err := Bot.Config.RetrieveConfigCurrencyPairs(true) + err := Bot.Config.RetrieveConfigCurrencyPairs(true, asset.Spot) if err != nil { t.Fatalf("Failed to retrieve config currency pairs. %s", err) }