BTSE: Drop need to check for commas after REST update

This commit is contained in:
Adrian Gallagher
2019-03-26 09:51:38 +11:00
parent 5d891e70e9
commit 5683fdd917
2 changed files with 9 additions and 32 deletions

View File

@@ -132,36 +132,13 @@ func (b *BTSE) GetTrades(symbol string) (*Trades, error) {
// GetTicker returns the ticker for a specified symbol
func (b *BTSE) GetTicker(symbol string) (*Ticker, error) {
type tickerResponse struct {
Price interface{} `json:"price"`
Size float64 `json:"size,string"`
Bid float64 `json:"bid,string"`
Ask float64 `json:"ask,string"`
Volume float64 `json:"volume,string"`
Time string `json:"time"`
}
var r tickerResponse
var t Ticker
endpoint := fmt.Sprintf("%s/%s", btseTicker, symbol)
err := b.SendHTTPRequest(http.MethodGet, endpoint, &r)
err := b.SendHTTPRequest(http.MethodGet, endpoint, &t)
if err != nil {
return nil, err
}
p := strings.Replace(r.Price.(string), ",", "", -1)
price, err := strconv.ParseFloat(p, 64)
if err != nil {
return nil, err
}
return &Ticker{
Price: price,
Size: r.Size,
Bid: r.Bid,
Ask: r.Ask,
Volume: r.Volume,
Time: r.Time,
}, nil
return &t, nil
}
// GetMarketStatistics gets market statistics for a specificed market

View File

@@ -31,12 +31,12 @@ type Trades []Trade
// Ticker stores the ticker data
type Ticker struct {
Price float64
Size float64
Bid float64
Ask float64
Volume float64
Time string
Price float64 `json:"price,string"`
Size float64 `json:"size,string"`
Bid float64 `json:"bid,string"`
Ask float64 `json:"ask,string"`
Volume float64 `json:"volume,string"`
Time string `json:"time"`
}
// MarketStatistics stores market statistics for a particular product