Added fetching currency exchange rate and conversion support.

This commit is contained in:
Adrian Gallagher
2014-11-24 22:09:59 +11:00
parent 3b5df9f78f
commit 9ae33e95fe
8 changed files with 239 additions and 59 deletions

View File

@@ -24,14 +24,35 @@ type ItBit struct {
ClientKey, APISecret, UserID string
}
func (i *ItBit) GetTicker(currency string) (bool) {
type ItBitTicker struct {
Pair string
Bid float64 `json:",string"`
BidAmt float64 `json:",string"`
Ask float64 `json:",string"`
AskAmt float64 `json:",string"`
LastPrice float64 `json:",string"`
LastAmt float64 `json:",string"`
Volume24h float64 `json:",string"`
VolumeToday float64 `json:",string"`
High24h float64 `json:",string"`
Low24h float64 `json:",string"`
HighToday float64 `json:",string"`
LowToday float64 `json:",string"`
OpenToday float64 `json:",string"`
VwapToday float64 `json:",string"`
Vwap24h float64 `json:",string"`
ServertimeUTC string
}
func (i *ItBit) GetTicker(currency string) (ItBitTicker) {
path := ITBIT_API_URL + "/markets/" + currency + "/ticker"
err := SendHTTPRequest(path, true, nil)
var itbitTicker ItBitTicker
err := SendHTTPRequest(path, true, &itbitTicker)
if err != nil {
fmt.Println(err)
return false
return ItBitTicker{}
}
return true
return itbitTicker
}
func (i *ItBit) GetOrderbook(currency string) (bool) {