kraken: when fetching tradable pairs filter by status (#1183)

* kraken: when fetching tradable pairs filter by status

* linter/nits: fixed

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2023-05-08 17:31:58 +10:00
committed by GitHub
parent 26edb59f6b
commit 22fd3562b2
3 changed files with 10 additions and 9 deletions

View File

@@ -90,7 +90,7 @@ func (k *Kraken) GetAssets(ctx context.Context) (map[string]*Asset, error) {
// GetAssetPairs returns a full asset pair list
// Parameter 'info' only supports 4 strings: "fees", "leverage", "margin", "info" <- (default)
func (k *Kraken) GetAssetPairs(ctx context.Context, assetPairs []string, info string) (map[string]AssetPairs, error) {
func (k *Kraken) GetAssetPairs(ctx context.Context, assetPairs []string, info string) (map[string]*AssetPairs, error) {
path := fmt.Sprintf("/%s/public/%s", krakenAPIVersion, krakenAssetPairs)
params := url.Values{}
var assets string
@@ -99,8 +99,8 @@ func (k *Kraken) GetAssetPairs(ctx context.Context, assetPairs []string, info st
params.Set("pair", assets)
}
var response struct {
Error []string `json:"error"`
Result map[string]AssetPairs `json:"result"`
Error []string `json:"error"`
Result map[string]*AssetPairs `json:"result"`
}
if info != "" {
if info != "margin" && info != "leverage" && info != "fees" && info != "info" {

View File

@@ -121,6 +121,7 @@ type AssetPairs struct {
MarginCall int `json:"margin_call"`
MarginStop int `json:"margin_stop"`
Ordermin string `json:"ordermin"`
Status string `json:"status"`
}
// Ticker is a standard ticker type

View File

@@ -357,24 +357,24 @@ func (k *Kraken) FetchTradablePairs(ctx context.Context, a asset.Item) (currency
}
pairs = make([]currency.Pair, 0, len(symbols))
for i := range symbols {
if strings.Contains(symbols[i].Altname, ".d") {
for _, info := range symbols {
if info.Status != "online" {
continue
}
base := assetTranslator.LookupAltname(symbols[i].Base)
base := assetTranslator.LookupAltname(info.Base)
if base == "" {
log.Warnf(log.ExchangeSys,
"%s unable to lookup altname for base currency %s",
k.Name,
symbols[i].Base)
info.Base)
continue
}
quote := assetTranslator.LookupAltname(symbols[i].Quote)
quote := assetTranslator.LookupAltname(info.Quote)
if quote == "" {
log.Warnf(log.ExchangeSys,
"%s unable to lookup altname for quote currency %s",
k.Name,
symbols[i].Quote)
info.Quote)
continue
}
pair, err = currency.NewPairFromStrings(base, quote)