diff --git a/alphapointhttp.go b/alphapointhttp.go index 14628c81..2714fa93 100644 --- a/alphapointhttp.go +++ b/alphapointhttp.go @@ -4,10 +4,11 @@ import ( "bytes" "errors" "fmt" - "github.com/gorilla/websocket" "log" "strconv" "time" + + "github.com/gorilla/websocket" ) const ( @@ -203,7 +204,7 @@ func (a *Alphapoint) GetTicker(symbol string) (AlphapointTicker, error) { return response, nil } -func (a *Alphapoint) GetTickerPrice(currency string) TickerPrice { +func (a *Alphapoint) GetTickerPrice(currency string) TickerPrice { var tickerPrice TickerPrice ticker, err := a.GetTicker(currency) if err != nil { @@ -212,12 +213,10 @@ func (a *Alphapoint) GetTickerPrice(currency string) TickerPrice { } tickerPrice.Ask = ticker.Ask tickerPrice.Bid = ticker.Bid - + return tickerPrice } - - func (a *Alphapoint) GetTrades(symbol string, startIndex, count int) (AlphapointTrades, error) { request := make(map[string]interface{}) request["ins"] = symbol @@ -341,6 +340,25 @@ func (a *Alphapoint) GetAccountInfo() (AlphapointAccountInfo, error) { return response, nil } +//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the Alphapoint exchange +func (a *Alphapoint) GetExchangeAccountInfo() (ExchangeAccountInfo, error) { + var response ExchangeAccountInfo + account, err := a.GetAccountInfo() + if err != nil { + return response, err + } + for i := 0; i < len(account.Currencies); i++ { + var exchangeCurrency ExchangeAccountCurrencyInfo + exchangeCurrency.CurrencyName = account.Currencies[i].Name + exchangeCurrency.TotalValue = account.Currencies[i].Balance + exchangeCurrency.Hold = account.Currencies[i].Hold + + response.Currencies = append(response.Currencies, exchangeCurrency) + } + //If it all works out + return response, nil +} + func (a *Alphapoint) GetAccountTrades(symbol string, startIndex, count int) (AlphapointTrades, error) { request := make(map[string]interface{}) request["ins"] = symbol diff --git a/interfaces.go b/interfaces.go index f6d66d03..c2d7a718 100644 --- a/interfaces.go +++ b/interfaces.go @@ -1,5 +1,6 @@ package main +//IBotExchange : Enforces standard functions for all exchanges supported in gocryptotrader type IBotExchange interface { Setup(exch Exchanges) Start() @@ -8,4 +9,5 @@ type IBotExchange interface { IsEnabled() bool GetTickerPrice(currency string) TickerPrice GetEnabledCurrencies() []string + GetExchangeAccountInfo() ExchangeAccountInfo } diff --git a/wallet.go b/wallet.go new file mode 100644 index 00000000..af6df3e0 --- /dev/null +++ b/wallet.go @@ -0,0 +1,13 @@ +package main + +//ExchangeAccountInfo : Generic type to hold each exchange's holdings in all enabled currencies +type ExchangeAccountInfo struct { + Currencies []ExchangeAccountCurrencyInfo +} + +//ExchangeAccountCurrencyInfo : Sub type to store currency name and value +type ExchangeAccountCurrencyInfo struct { + CurrencyName string + TotalValue int + Hold int +} diff --git a/web/app/views/wallets/wallets.html b/web/app/views/wallets/wallets.html new file mode 100644 index 00000000..b7f11eb4 --- /dev/null +++ b/web/app/views/wallets/wallets.html @@ -0,0 +1,28 @@ +
| Currency | +Last | +High | +Low | +Volume | +Bid | +Ask | +
|---|---|---|---|---|---|---|
| {{value.CryptoCurrency}} | +{{value.Last}} | +{{value.High}} | +{{value.Low}} | +{{value.Volume}} | +{{value.Bid}} | +{{value.Ask}} | +