CoinbasePro: Fix websocket ticker inconsistency

Addresses issue: https://github.com/thrasher-/gocryptotrader/issues/270
This commit is contained in:
Adrian Gallagher
2019-04-06 15:04:06 +11:00
parent 3956613831
commit 8251fdd6ae
2 changed files with 26 additions and 19 deletions

View File

@@ -1,5 +1,7 @@
package coinbasepro
import "time"
// Product holds product information
type Product struct {
ID string `json:"id"`
@@ -428,17 +430,21 @@ type WebsocketHeartBeat struct {
// WebsocketTicker defines ticker websocket response
type WebsocketTicker struct {
Type string `json:"type"`
Sequence int64 `json:"sequence"`
ProductID string `json:"product_id"`
Price float64 `json:"price,string"`
Open24H float64 `json:"open_24h,string"`
Volume24H float64 `json:"volumen_24h,string"`
Low24H float64 `json:"low_24h,string"`
High24H float64 `json:"high_24h,string"`
Volume30D float64 `json:"volume_30d,string"`
BestBid float64 `json:"best_bid,string"`
BestAsk float64 `json:"best_ask,string"`
Type string `json:"type"`
Sequence int64 `json:"sequence"`
ProductID string `json:"product_id"`
Price float64 `json:"price,string"`
Open24H float64 `json:"open_24h,string"`
Volume24H float64 `json:"volumen_24h,string"`
Low24H float64 `json:"low_24h,string"`
High24H float64 `json:"high_24h,string"`
Volume30D float64 `json:"volume_30d,string"`
BestBid float64 `json:"best_bid,string"`
BestAsk float64 `json:"best_ask,string"`
Side string `json:"side"`
Time time.Time `json:"time,string"`
TradeID int64 `json:"trade_id"`
LastSize float64 `json:"last_size,string"`
}
// WebsocketOrderbookSnapshot defines a snapshot response

View File

@@ -155,14 +155,15 @@ func (c *CoinbasePro) WsHandleData() {
}
c.Websocket.DataHandler <- exchange.TickerData{
Timestamp: time.Now(),
Pair: currency.NewPairFromString(ticker.ProductID),
AssetType: "SPOT",
Exchange: c.GetName(),
OpenPrice: ticker.Price,
HighPrice: ticker.High24H,
LowPrice: ticker.Low24H,
Quantity: ticker.Volume24H,
Timestamp: ticker.Time,
Pair: currency.NewPairFromString(ticker.ProductID),
AssetType: "SPOT",
Exchange: c.GetName(),
OpenPrice: ticker.Open24H,
HighPrice: ticker.High24H,
LowPrice: ticker.Low24H,
ClosePrice: ticker.Price,
Quantity: ticker.Volume24H,
}
case "snapshot":