mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Expose auth validator functionality for wrapper (#416)
* expose auth validator functionality for wrapper * Add REST validation after keys set, package account types for future syncing * Add transient error checking for initial creddemtial validation * fix command types * Addressed nits from glorious person * Amalgamate body within error when not between 2xx status, added btcmarket specific auth error check * nit fix for glorious person * Format fix * removed unused code * check transient first then validate if its an exchange specific authentication error, all others will be disregarded * Addressed glorious nits * Addressed glorious nits * Moved account processing to updateaccountinfo func and added in fetch account info * Add GRPC Account streaming (NOTE: could not complete until sync item added) * RM exchange check * Address xtda nits * RM comment code * Fix linter issues * used most recent protoc version * lbank linter issues fixed * Addressed nits and changed len check to range in for loops * Fixed timeout issue * thrasher nits addressed * add string holdings
This commit is contained in:
@@ -2,6 +2,7 @@ package modules
|
||||
|
||||
import (
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
||||
@@ -27,7 +28,7 @@ type Exchange interface {
|
||||
QueryOrder(exch, orderid string) (*order.Detail, error)
|
||||
SubmitOrder(exch string, submit *order.Submit) (*order.SubmitResponse, error)
|
||||
CancelOrder(exch, orderid string) (bool, error)
|
||||
AccountInformation(exch string) (*AccountInfo, error)
|
||||
AccountInformation(exch string) (account.Holdings, error)
|
||||
DepositAddress(exch string, currencyCode currency.Code) (string, error)
|
||||
WithdrawalFiatFunds(exch, bankaccountid string, request *withdraw.FiatRequest) (out string, err error)
|
||||
WithdrawalCryptoFunds(exch string, request *withdraw.CryptoRequest) (out string, err error)
|
||||
@@ -37,23 +38,3 @@ type Exchange interface {
|
||||
func SetModuleWrapper(wrapper GCT) {
|
||||
Wrapper = wrapper
|
||||
}
|
||||
|
||||
// AccountInfo is a Generic type to hold each exchange's holdings in
|
||||
// all enabled currencies
|
||||
type AccountInfo struct {
|
||||
Exchange string
|
||||
Accounts []Account
|
||||
}
|
||||
|
||||
// Account defines a singular account type with associated currencies
|
||||
type Account struct {
|
||||
ID string
|
||||
Currencies []AccountCurrencyInfo
|
||||
}
|
||||
|
||||
// AccountCurrencyInfo is a sub type to store currency name and value
|
||||
type AccountCurrencyInfo struct {
|
||||
CurrencyName currency.Code
|
||||
TotalValue float64
|
||||
Hold float64
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package exchange
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@@ -9,12 +8,12 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/engine"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
|
||||
"github.com/thrasher-corp/gocryptotrader/gctscript/modules"
|
||||
)
|
||||
|
||||
// Exchange implements all required methods for Wrapper
|
||||
@@ -120,29 +119,18 @@ func (e Exchange) CancelOrder(exch, orderID string) (bool, error) {
|
||||
}
|
||||
|
||||
// AccountInformation returns account information (balance etc) for requested exchange
|
||||
func (e Exchange) AccountInformation(exch string) (*modules.AccountInfo, error) {
|
||||
func (e Exchange) AccountInformation(exch string) (account.Holdings, error) {
|
||||
ex, err := e.GetExchange(exch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return account.Holdings{}, err
|
||||
}
|
||||
|
||||
r, err := ex.GetAccountInfo()
|
||||
accountInfo, err := ex.FetchAccountInfo()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return account.Holdings{}, err
|
||||
}
|
||||
|
||||
temp, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
accountInfo := modules.AccountInfo{}
|
||||
err = json.Unmarshal(temp, &accountInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &accountInfo, nil
|
||||
return accountInfo, nil
|
||||
}
|
||||
|
||||
// DepositAddress gets the address required to deposit funds for currency type
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
|
||||
"github.com/thrasher-corp/gocryptotrader/gctscript/modules"
|
||||
)
|
||||
|
||||
// Exchanges validator for test execution/scripts
|
||||
@@ -152,17 +152,17 @@ func (w Wrapper) CancelOrder(exch, orderid string) (bool, error) {
|
||||
}
|
||||
|
||||
// AccountInformation validator for test execution/scripts
|
||||
func (w Wrapper) AccountInformation(exch string) (*modules.AccountInfo, error) {
|
||||
func (w Wrapper) AccountInformation(exch string) (account.Holdings, error) {
|
||||
if exch == exchError.String() {
|
||||
return &modules.AccountInfo{}, errTestFailed
|
||||
return account.Holdings{}, errTestFailed
|
||||
}
|
||||
|
||||
return &modules.AccountInfo{
|
||||
return account.Holdings{
|
||||
Exchange: exch,
|
||||
Accounts: []modules.Account{
|
||||
Accounts: []account.SubAccount{
|
||||
{
|
||||
ID: exch,
|
||||
Currencies: []modules.AccountCurrencyInfo{
|
||||
Currencies: []account.Balance{
|
||||
{
|
||||
CurrencyName: currency.Code{
|
||||
Item: ¤cy.Item{
|
||||
|
||||
Reference in New Issue
Block a user