Skip to content

Commit

Permalink
Bitmex: Fix UpdateTicker/UpdateOrderbook wrappers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thrasher- committed Apr 23, 2019
1 parent b02d03d commit 32e4dcb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions exchanges/bitmex/bitmex_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"fmt"
"math"
"strings"
"sync"
"time"

"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 32e4dcb

Please sign in to comment.