exchanges: Change wrapper function FetchTradablePairs to return currency.Pairs (#1093)

* exchanges: FetchTradablePairs currency pair slice return (1)

* exchanges: finish conversion

* thrasher: nits + linter

* exchanges: shift var dec into for loop

* exchanges: Apply changes thanks @thrasher-

* Update exchanges/alphapoint/alphapoint_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher: nitters

* Update exchanges/bitflyer/bitflyer_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher: fix more nitters

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2022-12-09 15:40:34 +11:00
committed by GitHub
parent 2ac165a477
commit e4d487e586
43 changed files with 488 additions and 579 deletions

View File

@@ -152,29 +152,35 @@ func (b *Bitflyer) Run() {
}
// FetchTradablePairs returns a list of the exchanges tradable pairs
func (b *Bitflyer) FetchTradablePairs(ctx context.Context, a asset.Item) ([]string, error) {
pairs, err := b.GetMarkets(ctx)
func (b *Bitflyer) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error) {
symbols, err := b.GetMarkets(ctx)
if err != nil {
return nil, err
}
format, err := b.GetPairFormat(a, false)
if err != nil {
return nil, err
}
var products []string
for i := range pairs {
if pairs[i].Alias != "" && a == asset.Futures {
products = append(products, pairs[i].Alias)
} else if pairs[i].Alias == "" &&
pairs := make([]currency.Pair, 0, len(symbols))
for i := range symbols {
var pair currency.Pair
if symbols[i].Alias != "" && a == asset.Futures {
pair, err = currency.NewPairFromString(symbols[i].Alias)
if err != nil {
return nil, err
}
pairs = append(pairs, pair)
} else if symbols[i].Alias == "" &&
a == asset.Spot &&
strings.Contains(pairs[i].ProductCode,
format.Delimiter) {
products = append(products, pairs[i].ProductCode)
strings.Contains(symbols[i].ProductCode, format.Delimiter) {
pair, err = currency.NewPairFromString(symbols[i].ProductCode)
if err != nil {
return nil, err
}
pairs = append(pairs, pair)
}
}
return products, nil
return pairs, nil
}
// UpdateTradablePairs updates the exchanges available pairs and stores
@@ -187,12 +193,7 @@ func (b *Bitflyer) UpdateTradablePairs(ctx context.Context, forceUpdate bool) er
return err
}
p, err := currency.NewPairsFromStrings(pairs)
if err != nil {
return err
}
err = b.UpdatePairs(p, assets[x], false, forceUpdate)
err = b.UpdatePairs(pairs, assets[x], false, forceUpdate)
if err != nil {
return err
}