From 931bcbfb34801d33ab9156585fdcde5ffacc5654 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Sat, 16 May 2015 16:30:26 +1000 Subject: [PATCH] Filled out ItBit Orderbook function. --- itbithttp.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/itbithttp.go b/itbithttp.go index 9515875e..b3399427 100644 --- a/itbithttp.go +++ b/itbithttp.go @@ -114,14 +114,27 @@ func (i *ItBit) GetTicker(currency string) ItBitTicker { return itbitTicker } -func (i *ItBit) GetOrderbook(currency string) bool { - path := ITBIT_API_URL + "/markets/" + currency + "/orders" - err := SendHTTPGetRequest(path, true, nil) +type ItbitOrderbookEntry struct { + Quantitiy float64 `json:"quantity,string"` + Price float64 `json:"price,string"` +} + +type ItBitOrderbookResponse struct { + ServerTimeUTC string `json:"serverTimeUTC"` + LastUpdatedTimeUTC string `json:"lastUpdatedTimeUTC"` + Ticker string `json:"ticker"` + Bids []ItbitOrderbookEntry `json:"bids"` + Asks []ItbitOrderbookEntry `json:"asks"` +} + +func (i *ItBit) GetOrderbook(currency string) (ItBitOrderbookResponse, error) { + response := ItBitOrderbookResponse{} + path := ITBIT_API_URL + "/markets/" + currency + "/order_book" + err := SendHTTPGetRequest(path, true, &response) if err != nil { - log.Println(err) - return false + return ItBitOrderbookResponse{}, err } - return true + return response, nil } func (i *ItBit) GetTradeHistory(currency, timestamp string) bool {