diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index 8c3d7a25..fbe32f31 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -126,7 +126,7 @@ func (c *CoinbasePro) UpdateOrderbook(p pair.CurrencyPair, assetType string) (or } for x := range obNew.Asks { - orderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: obNew.Bids[x].Amount, Price: obNew.Bids[x].Price}) + orderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: obNew.Asks[x].Amount, Price: obNew.Asks[x].Price}) } orderbook.ProcessOrderbook(c.GetName(), p, orderBook, assetType) diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index da9a96fa..023471c6 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -200,6 +200,10 @@ func (g *Gateio) GetOrderbook(symbol string) (Orderbook, error) { var ob Orderbook + if len(resp.Asks) == 0 { + return ob, errors.New("asks are empty") + } + // Asks are in reverse order for x := len(resp.Asks) - 1; x != 0; x-- { data := resp.Asks[x] @@ -217,6 +221,10 @@ func (g *Gateio) GetOrderbook(symbol string) (Orderbook, error) { ob.Asks = append(ob.Asks, OrderbookItem{Price: price, Amount: amount}) } + if len(resp.Bids) == 0 { + return ob, errors.New("bids are empty") + } + for x := range resp.Bids { data := resp.Bids[x] diff --git a/exchanges/huobi/huobi_wrapper.go b/exchanges/huobi/huobi_wrapper.go index c4e9368f..129abf6f 100644 --- a/exchanges/huobi/huobi_wrapper.go +++ b/exchanges/huobi/huobi_wrapper.go @@ -95,8 +95,15 @@ func (h *HUOBI) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Pric tickerPrice.Last = tick.Close tickerPrice.Volume = tick.Volume tickerPrice.High = tick.High - tickerPrice.Ask = tick.Ask[0] - tickerPrice.Bid = tick.Bid[0] + + if len(tick.Ask) > 0 { + tickerPrice.Ask = tick.Ask[0] + } + + if len(tick.Bid) > 0 { + tickerPrice.Bid = tick.Bid[0] + } + ticker.ProcessTicker(h.GetName(), p, tickerPrice, assetType) return ticker.GetTicker(h.Name, p, assetType) } diff --git a/exchanges/huobihadax/huobihadax_wrapper.go b/exchanges/huobihadax/huobihadax_wrapper.go index 7069581f..4cf3b6f9 100644 --- a/exchanges/huobihadax/huobihadax_wrapper.go +++ b/exchanges/huobihadax/huobihadax_wrapper.go @@ -59,8 +59,15 @@ func (h *HUOBIHADAX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker tickerPrice.Last = tick.Close tickerPrice.Volume = tick.Volume tickerPrice.High = tick.High - tickerPrice.Ask = tick.Ask[0] - tickerPrice.Bid = tick.Bid[0] + + if len(tick.Ask) > 0 { + tickerPrice.Ask = tick.Ask[0] + } + + if len(tick.Bid) > 0 { + tickerPrice.Bid = tick.Bid[0] + } + ticker.ProcessTicker(h.GetName(), p, tickerPrice, assetType) return ticker.GetTicker(h.Name, p, assetType) }