mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Config: Check asset type when obtaining pair format
This commit is contained in:
@@ -652,6 +652,16 @@ func (c *Config) GetPairFormat(exchName string, assetType asset.Item) (currency.
|
||||
return currency.PairFormat{}, err
|
||||
}
|
||||
|
||||
supports, err := c.SupportsExchangeAssetType(exchName, assetType)
|
||||
if err != nil {
|
||||
return currency.PairFormat{}, err
|
||||
}
|
||||
|
||||
if !supports {
|
||||
return currency.PairFormat{},
|
||||
fmt.Errorf("exchange %s does not support asset type %v", exchName, assetType)
|
||||
}
|
||||
|
||||
if exchCfg.CurrencyPairs == nil {
|
||||
return currency.PairFormat{}, errors.New("exchange currency pairs type is nil")
|
||||
}
|
||||
|
||||
@@ -590,24 +590,22 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
|
||||
func GetCryptocurrenciesByExchange(exchangeName string, enabledExchangesOnly, enabledPairs bool, assetType asset.Item) ([]string, error) {
|
||||
var cryptocurrencies []string
|
||||
for x := range Bot.Config.Exchanges {
|
||||
if Bot.Config.Exchanges[x].Name != exchangeName {
|
||||
if !strings.EqualFold(Bot.Config.Exchanges[x].Name, exchangeName) {
|
||||
continue
|
||||
}
|
||||
if enabledExchangesOnly && !Bot.Config.Exchanges[x].Enabled {
|
||||
continue
|
||||
}
|
||||
|
||||
exchName := Bot.Config.Exchanges[x].Name
|
||||
var pairs []currency.Pair
|
||||
var err error
|
||||
|
||||
var pairs []currency.Pair
|
||||
if enabledPairs {
|
||||
pairs, err = Bot.Config.GetEnabledPairs(exchName, assetType)
|
||||
pairs, err = Bot.Config.GetEnabledPairs(exchangeName, assetType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
pairs, err = Bot.Config.GetAvailablePairs(exchName, assetType)
|
||||
pairs, err = Bot.Config.GetAvailablePairs(exchangeName, assetType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ func (b *Bitfinex) SetDefaults() {
|
||||
|
||||
b.API.Endpoints.URLDefault = bitfinexAPIURLBase
|
||||
b.API.Endpoints.URL = b.API.Endpoints.URLDefault
|
||||
b.API.Endpoints.WebsocketURL = bitfinexWebsocket
|
||||
b.WebsocketInit()
|
||||
b.Websocket.Functionality = exchange.WebsocketTickerSupported |
|
||||
exchange.WebsocketTradeDataSupported |
|
||||
|
||||
@@ -111,6 +111,7 @@ func (b *Bitmex) SetDefaults() {
|
||||
|
||||
b.API.Endpoints.URLDefault = bitmexAPIURL
|
||||
b.API.Endpoints.URL = b.API.Endpoints.URLDefault
|
||||
b.API.Endpoints.WebsocketURL = bitmexWSURL
|
||||
b.WebsocketInit()
|
||||
b.Websocket.Functionality = exchange.WebsocketTradeDataSupported |
|
||||
exchange.WebsocketOrderbookSupported |
|
||||
|
||||
@@ -88,6 +88,7 @@ func (c *CoinbasePro) SetDefaults() {
|
||||
|
||||
c.API.Endpoints.URLDefault = coinbaseproAPIURL
|
||||
c.API.Endpoints.URL = c.API.Endpoints.URLDefault
|
||||
c.API.Endpoints.WebsocketURL = coinbaseproWebsocketURL
|
||||
c.WebsocketInit()
|
||||
c.Websocket.Functionality = exchange.WebsocketTickerSupported |
|
||||
exchange.WebsocketOrderbookSupported |
|
||||
|
||||
@@ -85,6 +85,7 @@ func (c *COINUT) SetDefaults() {
|
||||
|
||||
c.API.Endpoints.URLDefault = coinutAPIURL
|
||||
c.API.Endpoints.URL = c.API.Endpoints.URLDefault
|
||||
c.API.Endpoints.WebsocketURL = coinutWebsocketURL
|
||||
c.WebsocketInit()
|
||||
c.Websocket.Functionality = exchange.WebsocketTickerSupported |
|
||||
exchange.WebsocketOrderbookSupported |
|
||||
|
||||
@@ -87,6 +87,7 @@ func (h *HitBTC) SetDefaults() {
|
||||
|
||||
h.API.Endpoints.URLDefault = apiURL
|
||||
h.API.Endpoints.URL = h.API.Endpoints.URLDefault
|
||||
h.API.Endpoints.WebsocketURL = hitbtcWebsocketAddress
|
||||
h.WebsocketInit()
|
||||
h.Websocket.Functionality = exchange.WebsocketTickerSupported |
|
||||
exchange.WebsocketOrderbookSupported
|
||||
|
||||
@@ -88,6 +88,7 @@ func (h *HUOBI) SetDefaults() {
|
||||
|
||||
h.API.Endpoints.URLDefault = huobiAPIURL
|
||||
h.API.Endpoints.URL = h.API.Endpoints.URLDefault
|
||||
h.API.Endpoints.WebsocketURL = wsMarketURL
|
||||
h.WebsocketInit()
|
||||
h.Websocket.Functionality = exchange.WebsocketKlineSupported |
|
||||
exchange.WebsocketOrderbookSupported |
|
||||
|
||||
@@ -87,6 +87,7 @@ func (p *Poloniex) SetDefaults() {
|
||||
|
||||
p.API.Endpoints.URLDefault = poloniexAPIURL
|
||||
p.API.Endpoints.URL = p.API.Endpoints.URLDefault
|
||||
p.API.Endpoints.WebsocketURL = poloniexWebsocketAddress
|
||||
p.WebsocketInit()
|
||||
p.Websocket.Functionality = exchange.WebsocketTradeDataSupported |
|
||||
exchange.WebsocketOrderbookSupported |
|
||||
|
||||
@@ -90,6 +90,7 @@ func (z *ZB) SetDefaults() {
|
||||
z.API.Endpoints.URL = z.API.Endpoints.URLDefault
|
||||
z.API.Endpoints.URLSecondaryDefault = zbMarketURL
|
||||
z.API.Endpoints.URLSecondary = z.API.Endpoints.URLSecondaryDefault
|
||||
z.API.Endpoints.WebsocketURL = zbWebsocketAPI
|
||||
z.WebsocketInit()
|
||||
z.Websocket.Functionality = exchange.WebsocketTickerSupported |
|
||||
exchange.WebsocketOrderbookSupported |
|
||||
|
||||
Reference in New Issue
Block a user