From 32e4dcb63dae351c8f97b6289ef564d2ff14f4f7 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Tue, 23 Apr 2019 11:02:30 +1000 Subject: [PATCH] Bitmex: Fix UpdateTicker/UpdateOrderbook wrappers UpdateTicker: drop need for start timestamp as the latest entry will always be returned by default UpdateOrderbook: fix string comparison so that orderbook entries will actually be appended NOTE: As of this time, Bitmex doesn't support a ticker API endpoint so the only two options are a) last trade for an asset (which GCT uses) or b) orderbook data query Fixes issue: https://github.com/thrasher-/gocryptotrader/issues/282 --- exchanges/bitmex/bitmex_wrapper.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/exchanges/bitmex/bitmex_wrapper.go b/exchanges/bitmex/bitmex_wrapper.go index 2a206756..02431657 100644 --- a/exchanges/bitmex/bitmex_wrapper.go +++ b/exchanges/bitmex/bitmex_wrapper.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" "math" + "strings" "sync" - "time" "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency" @@ -61,10 +61,9 @@ func (b *Bitmex) UpdateTicker(p currency.Pair, assetType string) (ticker.Price, currency := exchange.FormatExchangeCurrency(b.Name, p) tick, err := b.GetTrade(&GenericRequestParams{ - Symbol: currency.String(), - StartTime: time.Now().Format(time.RFC3339), - Reverse: true, - Count: 1}) + Symbol: currency.String(), + Reverse: true, + Count: 1}) if err != nil { return tickerPrice, err } @@ -109,12 +108,12 @@ func (b *Bitmex) UpdateOrderbook(p currency.Pair, assetType string) (orderbook.B } for _, ob := range orderbookNew { - if ob.Side == exchange.SellOrderSide.ToString() { + if strings.ToUpper(ob.Side) == exchange.SellOrderSide.ToString() { orderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: float64(ob.Size), Price: ob.Price}) continue } - if ob.Side == exchange.BuyOrderSide.ToString() { + if strings.ToUpper(ob.Side) == exchange.BuyOrderSide.ToString() { orderBook.Bids = append(orderBook.Bids, orderbook.Item{Amount: float64(ob.Size), Price: ob.Price}) continue