poloniex: filter non-liquid and unused assets (#1185)

* poloniex: filter non-liquid and unused assets

* glorious: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2023-05-08 15:41:49 +10:00
committed by GitHub
parent f6fbe77f8c
commit 31efa4f35e
3 changed files with 17 additions and 6 deletions

View File

@@ -99,7 +99,6 @@ func (l *Lbank) SetDefaults() {
kline.IntervalCapacity{Interval: kline.ThirtyMin},
kline.IntervalCapacity{Interval: kline.OneHour},
kline.IntervalCapacity{Interval: kline.FourHour},
// NOTE: The supported time intervals below are returned
// offset to the Asia/HongKong time zone. This may lead to
// issues with candle quality and conversion as the

View File

@@ -1061,3 +1061,11 @@ func TestGetAvailableTransferChains(t *testing.T) {
t.Fatal(err)
}
}
func TestFetchTradablePairs(t *testing.T) {
t.Parallel()
_, err := p.FetchTradablePairs(context.Background(), asset.Spot)
if err != nil {
t.Error(err)
}
}

View File

@@ -265,21 +265,25 @@ func (p *Poloniex) Run(ctx context.Context) {
// FetchTradablePairs returns a list of the exchanges tradable pairs
func (p *Poloniex) FetchTradablePairs(ctx context.Context, _ asset.Item) (currency.Pairs, error) {
// TODO: Upgrade to new API version for fetching operational pairs.
resp, err := p.GetTicker(ctx)
if err != nil {
return nil, err
}
pairs := make([]currency.Pair, len(resp))
var target int
for key := range resp {
pairs := make([]currency.Pair, 0, len(resp))
for key, info := range resp {
// Poloniex returns 0 for highest bid and lowest ask if support has been
// dropped from the front end. We don't want to add these pairs.
if info.HighestBid == 0 || info.LowestAsk == 0 {
continue
}
var pair currency.Pair
pair, err = currency.NewPairFromString(key)
if err != nil {
return nil, err
}
pairs[target] = pair
target++
pairs = append(pairs, pair)
}
return pairs, nil
}