mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Adds exchange name to account info retrieval
Adds walletRoutes.go Adds method to get all exchange account stuff in go Adds method to get all exchange account stuff in server.js
This commit is contained in:
@@ -340,10 +340,15 @@ func (a *Alphapoint) GetAccountInfo() (AlphapointAccountInfo, error) {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (a *Alphapoint) GetName() string {
|
||||
return a.ExchangeName
|
||||
}
|
||||
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Alphapoint exchange
|
||||
func (a *Alphapoint) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
func (e *Alphapoint) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
account, err := a.GetAccountInfo()
|
||||
response.ExchangeName = e.GetName()
|
||||
account, err := e.GetAccountInfo()
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
@@ -430,6 +430,7 @@ func (a *ANX) GetDepositAddress(currency, name string, new bool) (string, error)
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the ANX exchange
|
||||
func (e *ANX) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -859,12 +859,17 @@ func (b *Bitfinex) GetAccountBalance() ([]BitfinexBalance, error) {
|
||||
}
|
||||
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Bitfinex exchange
|
||||
func (b *Bitfinex) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
func (e *Bitfinex) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
accountBalance, err := b.GetAccountBalance()
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetAccountBalance()
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
if !e.Enabled {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(accountBalance); i++ {
|
||||
var exchangeCurrency ExchangeAccountCurrencyInfo
|
||||
exchangeCurrency.CurrencyName = accountBalance[i].Currency
|
||||
|
||||
@@ -336,6 +336,7 @@ func (b *Bitstamp) GetBalance() (BitstampAccountBalance, error) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Bitstamp exchange
|
||||
func (e *Bitstamp) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetBalance()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -193,6 +193,7 @@ func (b *BrightonPeak) GetAccountInfo() (AlphapointAccountInfo, error) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the BrightonPeak exchange
|
||||
func (e *BrightonPeak) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetAccountInfo()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -351,6 +351,7 @@ func (b *BTCC) GetAccountInfo(infoType string) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Kraken exchange
|
||||
func (e *BTCC) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,7 @@ func (b *BTCE) GetAccountInfo() (BTCEAccountInfo, error) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the BTCE exchange
|
||||
func (e *BTCE) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetAccountInfo()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -425,6 +425,7 @@ func (b *BTCMarkets) GetAccountBalance() ([]BTCMarketsAccountBalance, error) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the BTCMarkets exchange
|
||||
func (e *BTCMarkets) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetAccountBalance()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -52,7 +52,7 @@ func SaveAllSettings(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
var configRoutes = Routes{
|
||||
var ConfigRoutes = Routes{
|
||||
Route{
|
||||
"GetAllSettings",
|
||||
"GET",
|
||||
|
||||
@@ -465,6 +465,7 @@ func (g *GDAX) GetAccount(account string) (GDAXAccountResponse, error) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the GDAX exchange
|
||||
func (e *GDAX) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetAccounts()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -316,6 +316,7 @@ func (g *Gemini) GetBalances() ([]GeminiBalance, error) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Gemini exchange
|
||||
func (e *Gemini) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetBalances()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -296,5 +296,6 @@ func (h *HUOBI) SendAuthenticatedRequest(method string, v url.Values) error {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the HUOBI exchange
|
||||
func (e *HUOBI) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -196,6 +196,7 @@ func (i *ItBit) GetWallets(params url.Values) {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the ItBit exchange
|
||||
func (e *ItBit) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -325,6 +325,7 @@ func (k *Kraken) GetBalance() {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Kraken exchange
|
||||
func (e *Kraken) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ func (l *LakeBTC) GetAccountInfo() {
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the LakeBTC exchange
|
||||
func (e *LakeBTC) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -448,6 +448,7 @@ func (l *LocalBitcoins) SendAuthenticatedHTTPRequest(method, path string, values
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the LocalBitcoins exchange
|
||||
func (e *LocalBitcoins) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetWalletBalance()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -1094,6 +1094,7 @@ func (o *OKCoin) GetAccountRecords(symbol string, recType, currentPage, pageLeng
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the OKCoin exchange
|
||||
func (e *OKCoin) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
return response, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1032,6 +1032,7 @@ func (p *Poloniex) SendAuthenticatedHTTPRequest(method, endpoint string, values
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Poloniex exchange
|
||||
func (e *Poloniex) GetExchangeAccountInfo() (ExchangeAccountInfo, error) {
|
||||
var response ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
accountBalance, err := e.GetBalances()
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
||||
@@ -8,8 +8,9 @@ import (
|
||||
|
||||
func NewRouter(exchanges []IBotExchange) *mux.Router {
|
||||
router := mux.NewRouter().StrictSlash(true)
|
||||
allRoutes := append(routes, exchangeRoutes...)
|
||||
allRoutes = append(allRoutes, configRoutes...)
|
||||
allRoutes := append(routes, ExchangeRoutes...)
|
||||
allRoutes = append(allRoutes, ConfigRoutes...)
|
||||
allRoutes = append(allRoutes, WalletRoutes...)
|
||||
for _, route := range allRoutes {
|
||||
var handler http.Handler
|
||||
handler = route.HandlerFunc
|
||||
@@ -20,7 +21,6 @@ func NewRouter(exchanges []IBotExchange) *mux.Router {
|
||||
Path(route.Pattern).
|
||||
Name(route.Name).
|
||||
Handler(handler)
|
||||
|
||||
}
|
||||
return router
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ package main
|
||||
import "net/http"
|
||||
|
||||
type Route struct {
|
||||
Name string
|
||||
Method string
|
||||
Pattern string
|
||||
HandlerFunc http.HandlerFunc
|
||||
Name string
|
||||
Method string
|
||||
Pattern string
|
||||
HandlerFunc http.HandlerFunc
|
||||
}
|
||||
|
||||
type Routes []Route
|
||||
|
||||
var routes = Routes{
|
||||
|
||||
}
|
||||
var routes = Routes{}
|
||||
|
||||
@@ -65,7 +65,7 @@ func getAllActiveTickersResponse(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
var exchangeRoutes = Routes{
|
||||
var ExchangeRoutes = Routes{
|
||||
Route{
|
||||
"AllActiveExchangesAndCurrencies",
|
||||
"GET",
|
||||
|
||||
39
walletRoutes.go
Normal file
39
walletRoutes.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type AllEnabledExchangeAccounts struct {
|
||||
Data []ExchangeAccountInfo `json:"data"`
|
||||
}
|
||||
|
||||
func GetAllEnabledAccountInfo(w http.ResponseWriter, r *http.Request) {
|
||||
var response AllEnabledExchangeAccounts
|
||||
|
||||
for _, individualBot := range bot.exchanges {
|
||||
if individualBot != nil && individualBot.IsEnabled() {
|
||||
individualExchange, err := individualBot.GetExchangeAccountInfo()
|
||||
if err != nil {
|
||||
log.Println("Error encountered retrieving exchange account for '" + individualExchange.ExchangeName + "'")
|
||||
}
|
||||
response.Data = append(response.Data, individualExchange)
|
||||
}
|
||||
}
|
||||
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 WalletRoutes = Routes{
|
||||
Route{
|
||||
"AllEnabledAccountInfo",
|
||||
"GET",
|
||||
"/exchanges/enabled/accounts/all",
|
||||
GetAllEnabledAccountInfo,
|
||||
},
|
||||
}
|
||||
@@ -24,6 +24,14 @@ app.get('/data/all-enabled-currencies', function (req, res) {
|
||||
})
|
||||
});
|
||||
|
||||
app.get('/data/all-enabled-exchange-account-info', function (req, res) {
|
||||
request({
|
||||
url :'http://localhost:9050/exchanges/enabled/accounts/all'
|
||||
},function(err, resp, body){
|
||||
res.send(body);
|
||||
})
|
||||
});
|
||||
|
||||
app.get('/config/all', function (req, res) {
|
||||
request({
|
||||
url :'http://localhost:9050/config/all'
|
||||
|
||||
Reference in New Issue
Block a user