mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Expand portfolio to cover exchange balances
This commit is contained in:
@@ -88,7 +88,7 @@ func (e *Bitfinex) GetExchangeAccountInfo() (exchange.ExchangeAccountInfo, error
|
||||
|
||||
for i := 0; i < len(accountBalance); i++ {
|
||||
var exchangeCurrency exchange.ExchangeAccountCurrencyInfo
|
||||
exchangeCurrency.CurrencyName = accountBalance[i].Currency
|
||||
exchangeCurrency.CurrencyName = common.StringToUpper(accountBalance[i].Currency)
|
||||
exchangeCurrency.TotalValue = accountBalance[i].Amount
|
||||
exchangeCurrency.Hold = accountBalance[i].Available
|
||||
|
||||
|
||||
@@ -75,17 +75,28 @@ func (e *Bitstamp) GetExchangeAccountInfo() (exchange.ExchangeAccountInfo, error
|
||||
return response, err
|
||||
}
|
||||
|
||||
var btcExchangeInfo exchange.ExchangeAccountCurrencyInfo
|
||||
btcExchangeInfo.CurrencyName = "BTC"
|
||||
btcExchangeInfo.TotalValue = accountBalance.BTCBalance
|
||||
btcExchangeInfo.Hold = accountBalance.BTCReserved
|
||||
response.Currencies = append(response.Currencies, btcExchangeInfo)
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "BTC",
|
||||
TotalValue: accountBalance.BTCAvailable,
|
||||
Hold: accountBalance.BTCReserved,
|
||||
})
|
||||
|
||||
var usdExchangeInfo exchange.ExchangeAccountCurrencyInfo
|
||||
usdExchangeInfo.CurrencyName = "USD"
|
||||
usdExchangeInfo.TotalValue = accountBalance.USDBalance
|
||||
usdExchangeInfo.Hold = accountBalance.USDReserved
|
||||
response.Currencies = append(response.Currencies, usdExchangeInfo)
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "XRP",
|
||||
TotalValue: accountBalance.XRPAvailable,
|
||||
Hold: accountBalance.XRPReserved,
|
||||
})
|
||||
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "USD",
|
||||
TotalValue: accountBalance.USDAvailable,
|
||||
Hold: accountBalance.USDReserved,
|
||||
})
|
||||
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "EUR",
|
||||
TotalValue: accountBalance.EURAvailable,
|
||||
Hold: accountBalance.EURReserved,
|
||||
})
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
const (
|
||||
WarningBase64DecryptSecretKeyFailed = "WARNING -- Exchange %s unable to base64 decode secret key.. Disabling Authenticated API support."
|
||||
ErrExchangeNotFound = "Exchange not found in dataset."
|
||||
)
|
||||
|
||||
//ExchangeAccountInfo : Generic type to hold each exchange's holdings in all enabled currencies
|
||||
|
||||
@@ -70,7 +70,7 @@ func (e *GDAX) GetExchangeAccountInfo() (exchange.ExchangeAccountInfo, error) {
|
||||
for i := 0; i < len(accountBalance); i++ {
|
||||
var exchangeCurrency exchange.ExchangeAccountCurrencyInfo
|
||||
exchangeCurrency.CurrencyName = accountBalance[i].Currency
|
||||
exchangeCurrency.TotalValue = accountBalance[i].Balance
|
||||
exchangeCurrency.TotalValue = accountBalance[i].Available
|
||||
exchangeCurrency.Hold = accountBalance[i].Hold
|
||||
|
||||
response.Currencies = append(response.Currencies, exchangeCurrency)
|
||||
|
||||
@@ -131,16 +131,19 @@ type OKCoinUserInfo struct {
|
||||
BTC float64 `json:"btc,string"`
|
||||
LTC float64 `json:"ltc,string"`
|
||||
USD float64 `json:"usd,string"`
|
||||
CNY float64 `json:"cny,string"`
|
||||
} `json:"borrow"`
|
||||
Free struct {
|
||||
BTC float64 `json:"btc,string"`
|
||||
LTC float64 `json:"ltc,string"`
|
||||
USD float64 `json:"usd,string"`
|
||||
CNY float64 `json:"cny,string"`
|
||||
} `json:"free"`
|
||||
Freezed struct {
|
||||
BTC float64 `json:"btc,string"`
|
||||
LTC float64 `json:"ltc,string"`
|
||||
USD float64 `json:"usd,string"`
|
||||
CNY float64 `json:"cny,string"`
|
||||
} `json:"freezed"`
|
||||
UnionFund struct {
|
||||
BTC float64 `json:"btc,string"`
|
||||
|
||||
@@ -94,10 +94,37 @@ func (o *OKCoin) GetTickerPrice(currency string) (ticker.TickerPrice, error) {
|
||||
return tickerPrice, nil
|
||||
}
|
||||
|
||||
//TODO support for retrieving holdings from OKCOIN
|
||||
//GetExchangeAccountInfo : Retrieves balances for all enabled currencies for the OKCoin exchange
|
||||
func (e *OKCoin) GetExchangeAccountInfo() (exchange.ExchangeAccountInfo, error) {
|
||||
var response exchange.ExchangeAccountInfo
|
||||
response.ExchangeName = e.GetName()
|
||||
assets, err := e.GetUserInfo()
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "BTC",
|
||||
TotalValue: assets.Info.Funds.Free.BTC,
|
||||
Hold: assets.Info.Funds.Freezed.BTC,
|
||||
})
|
||||
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "LTC",
|
||||
TotalValue: assets.Info.Funds.Free.LTC,
|
||||
Hold: assets.Info.Funds.Freezed.LTC,
|
||||
})
|
||||
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "USD",
|
||||
TotalValue: assets.Info.Funds.Free.USD,
|
||||
Hold: assets.Info.Funds.Freezed.USD,
|
||||
})
|
||||
|
||||
response.Currencies = append(response.Currencies, exchange.ExchangeAccountCurrencyInfo{
|
||||
CurrencyName: "CNY",
|
||||
TotalValue: assets.Info.Funds.Free.CNY,
|
||||
Hold: assets.Info.Funds.Freezed.CNY,
|
||||
})
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ func (e *Poloniex) GetExchangeAccountInfo() (exchange.ExchangeAccountInfo, error
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
currencies := e.AvailablePairs
|
||||
for i := 0; i < len(currencies); i++ {
|
||||
|
||||
for x, y := range accountBalance.Currency {
|
||||
var exchangeCurrency exchange.ExchangeAccountCurrencyInfo
|
||||
exchangeCurrency.CurrencyName = currencies[i]
|
||||
exchangeCurrency.TotalValue = accountBalance.Currency[currencies[i]]
|
||||
exchangeCurrency.CurrencyName = x
|
||||
exchangeCurrency.TotalValue = y
|
||||
response.Currencies = append(response.Currencies, exchangeCurrency)
|
||||
}
|
||||
return response, nil
|
||||
|
||||
Reference in New Issue
Block a user