mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-24 23:16:52 +00:00
A completely broken commit which starts the process of retrieving all exchanges and currency data in one call for a frontend dashboard/db
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -7,5 +7,6 @@ type IBotExchange interface {
|
||||
GetName() string
|
||||
IsEnabled() bool
|
||||
GetTickerPrice(currency string) TickerPrice
|
||||
//GetEnabledCurrencies() []string
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user