mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-23 23:16:49 +00:00
Expand RetrieveConfigCurrencyPairs to support different asset types
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user