MCPcopy
hub / github.com/thrasher-corp/gocryptotrader / GetAccountBalances

Method GetAccountBalances

engine/rpcserver.go:593–614  ·  view source on GitHub ↗

GetAccountBalances returns an account balance for a specific exchange.

(ctx context.Context, r *gctrpc.GetAccountBalancesRequest)

Source from the content-addressed store, hash-verified

591
592// GetAccountBalances returns an account balance for a specific exchange.
593func (s *RPCServer) GetAccountBalances(ctx context.Context, r *gctrpc.GetAccountBalancesRequest) (*gctrpc.GetAccountBalancesResponse, error) {
594 assetType, err := asset.New(r.AssetType)
595 if err != nil {
596 return nil, err
597 }
598
599 e, err := s.GetExchangeByName(r.Exchange)
600 if err != nil {
601 return nil, err
602 }
603
604 if err := checkParams(r.Exchange, e, assetType, currency.EMPTYPAIR); err != nil {
605 return nil, err
606 }
607
608 resp, err := e.GetCachedSubAccounts(ctx, assetType)
609 if err != nil {
610 return nil, err
611 }
612
613 return accountBalanceResp(r.Exchange, resp), nil
614}
615
616// UpdateAccountBalances forces an update of the account balances.
617func (s *RPCServer) UpdateAccountBalances(ctx context.Context, r *gctrpc.GetAccountBalancesRequest) (*gctrpc.GetAccountBalancesResponse, error) {

Callers 2

TestGetAccountBalancesFunction · 0.95

Calls 5

NewFunction · 0.92
checkParamsFunction · 0.85
accountBalanceRespFunction · 0.85
GetExchangeByNameMethod · 0.65
GetCachedSubAccountsMethod · 0.65

Tested by 2

TestGetAccountBalancesFunction · 0.76