Added helper functions, exchange method to set currencies and bug fixes

This commit is contained in:
Adrian Gallagher
2018-01-18 12:45:19 +11:00
parent bb74b22ef7
commit 5a2c81346c
13 changed files with 159 additions and 14 deletions

View File

@@ -173,7 +173,13 @@ func (g *Gemini) GetTicker(currencyPair string) (Ticker, error) {
ticker.Last = resp.Last
ticker.Volume.Currency, _ = strconv.ParseFloat(resp.Volume[currencyPair[0:3]].(string), 64)
ticker.Volume.USD, _ = strconv.ParseFloat(resp.Volume["USD"].(string), 64)
if common.StringContains(currencyPair, "USD") {
ticker.Volume.USD, _ = strconv.ParseFloat(resp.Volume["USD"].(string), 64)
} else {
ticker.Volume.ETH, _ = strconv.ParseFloat(resp.Volume["ETH"].(string), 64)
ticker.Volume.BTC, _ = strconv.ParseFloat(resp.Volume["BTC"].(string), 64)
}
time, _ := resp.Volume["timestamp"].(float64)
ticker.Volume.Timestamp = int64(time)

View File

@@ -8,6 +8,8 @@ type Ticker struct {
Volume struct {
Currency float64
USD float64
BTC float64
ETH float64
Timestamp int64
}
}