mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-20 15:10:10 +00:00
bugfix: improve orderbook/ticker and currency logic
This commit is contained in:
@@ -581,6 +581,10 @@ func (s *Storage) IsFiatCurrency(c Code) bool {
|
||||
return c.Item.Role == Fiat
|
||||
}
|
||||
|
||||
if c == USDT {
|
||||
return false
|
||||
}
|
||||
|
||||
t, _ := GetTranslation(c)
|
||||
for _, d := range s.fiatCurrencies {
|
||||
if d.Match(c) || d.Match(t) {
|
||||
@@ -598,6 +602,10 @@ func (s *Storage) IsCryptocurrency(c Code) bool {
|
||||
return c.Item.Role == Cryptocurrency
|
||||
}
|
||||
|
||||
if c == USD {
|
||||
return false
|
||||
}
|
||||
|
||||
t, _ := GetTranslation(c)
|
||||
for _, d := range s.cryptocurrencies {
|
||||
if d.Match(c) || d.Match(t) {
|
||||
|
||||
@@ -124,7 +124,6 @@ func (e *EXMO) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.Bas
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
orderBook.Pair = x
|
||||
|
||||
var obItems []orderbook.Item
|
||||
for y := range data.Ask {
|
||||
@@ -144,7 +143,7 @@ func (e *EXMO) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.Bas
|
||||
}
|
||||
|
||||
orderBook.Bids = obItems
|
||||
orderBook.Pair = p
|
||||
orderBook.Pair = x
|
||||
orderBook.ExchangeName = e.GetName()
|
||||
orderBook.AssetType = assetType
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ func (k *Kraken) UpdateTicker(p currency.Pair, assetType string) (ticker.Price,
|
||||
|
||||
for _, x := range pairs {
|
||||
for y, z := range tickers {
|
||||
if !common.StringContains(y, x.Base.Upper().String()) &&
|
||||
if !common.StringContains(y, x.Base.Upper().String()) ||
|
||||
!common.StringContains(y, x.Quote.Upper().String()) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ func (p *Poloniex) UpdateOrderbook(currencyPair currency.Pair, assetType string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
orderBook.Pair = x
|
||||
|
||||
var obItems []orderbook.Item
|
||||
for y := range data.Bids {
|
||||
@@ -132,7 +131,7 @@ func (p *Poloniex) UpdateOrderbook(currencyPair currency.Pair, assetType string)
|
||||
orderbook.Item{Amount: obData.Amount, Price: obData.Price})
|
||||
}
|
||||
|
||||
orderBook.Pair = currencyPair
|
||||
orderBook.Pair = x
|
||||
orderBook.Asks = obItems
|
||||
orderBook.ExchangeName = p.GetName()
|
||||
orderBook.AssetType = assetType
|
||||
|
||||
@@ -168,6 +168,14 @@ func TestIsRelatablePairs(t *testing.T) {
|
||||
if !result {
|
||||
t.Fatal("Unexpected result")
|
||||
}
|
||||
|
||||
// Test edge case between two pairs when currency translations were causing
|
||||
// non-relational pairs to be relatable
|
||||
result = IsRelatablePairs(currency.NewPairFromStrings("EUR", "USD"),
|
||||
currency.NewPairFromStrings("BTC", "USD"), false)
|
||||
if result {
|
||||
t.Fatal("Unexpected result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetRelatableCryptocurrencies(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user