diff --git a/alphapointhttp.go b/alphapointhttp.go index a20334d1..14628c81 100644 --- a/alphapointhttp.go +++ b/alphapointhttp.go @@ -216,6 +216,8 @@ func (a *Alphapoint) GetTickerPrice(currency string) TickerPrice { return tickerPrice } + + func (a *Alphapoint) GetTrades(symbol string, startIndex, count int) (AlphapointTrades, error) { request := make(map[string]interface{}) request["ins"] = symbol diff --git a/anxhttp.go b/anxhttp.go index 9e90cac7..4e5b849f 100644 --- a/anxhttp.go +++ b/anxhttp.go @@ -197,6 +197,10 @@ func (a *ANX) GetTickerPrice(currency string) TickerPrice { return tickerPrice } +func (a *ANX) GetEnabledCurrencies() []string { + return a.EnabledPairs +} + func (a *ANX) GetAPIKey(username, password, otp, deviceID string) (string, string) { request := make(map[string]interface{}) request["nonce"] = strconv.FormatInt(time.Now().UnixNano(), 10)[0:13] diff --git a/interfaces.go b/interfaces.go index ea2b2d0d..add48245 100644 --- a/interfaces.go +++ b/interfaces.go @@ -7,5 +7,6 @@ type IBotExchange interface { GetName() string IsEnabled() bool GetTickerPrice(currency string) TickerPrice + //GetEnabledCurrencies() []string } diff --git a/restfulRouter.go b/restfulRouter.go index 063be8d8..b412908a 100644 --- a/restfulRouter.go +++ b/restfulRouter.go @@ -2,7 +2,6 @@ package main import ( "net/http" - "github.com/gorilla/mux" ) diff --git a/restfulRoutes.go b/restfulRoutes.go index bdf42b62..1941d55d 100644 --- a/restfulRoutes.go +++ b/restfulRoutes.go @@ -12,22 +12,5 @@ type Route struct { type Routes []Route var routes = Routes{ - Route{ - "Index", - "GET", - "/", - Index, - }, - Route{ - "TodoIndex", - "GET", - "/todos", - TodoIndex, - }, - Route{ - "TodoShow", - "GET", - "/todos/{todoId}", - TodoShow, - }, + } \ No newline at end of file diff --git a/tickerRoutes.go b/tickerRoutes.go index 396bf7d1..47404dda 100644 --- a/tickerRoutes.go +++ b/tickerRoutes.go @@ -26,9 +26,39 @@ func jsonTickerResponse(w http.ResponseWriter, r *http.Request) { } } +func getAllActiveTickersResponse(w http.ResponseWriter, r *http.Request) { + var response[] TickerPrice + //bot.config.Cryptocurrencies + for i := 0; i < len(bot.exchanges); i++ { + if bot.exchanges[i] != nil { + if(bot.exchanges[i].IsEnabled()) { + for _, exch := range bot.config.Exchanges { + if(bot.exchanges[i].GetName() == exch.Name) { + for _, enabledPair := range exch.BaseCurrencies { + response = append(response, bot.exchanges[i].GetTickerPrice(enabledPair)) + } + } + } + } + } + } + + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + if err := json.NewEncoder(w).Encode(response); err != nil { + panic(err) + } +} + var exchangeRoutes = Routes{ Route{ - "Index", + "AllActiveExchangesAndCurrencies", + "GET", + "/exchanges/enabled/latest/all", + getAllActiveTickersResponse, + }, + Route{ + "IndividualExchangeAndCurrency", "GET", "/exchanges/{exchangeName}/latest/{currency}", jsonTickerResponse,