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

Function accountBalanceResp

engine/rpcserver.go:640–662  ·  view source on GitHub ↗
(eName string, s accounts.SubAccounts)

Source from the content-addressed store, hash-verified

638}
639
640func accountBalanceResp(eName string, s accounts.SubAccounts) *gctrpc.GetAccountBalancesResponse {
641 subAccts := make([]*gctrpc.Account, len(s))
642 for i, sa := range s {
643 subAccts[i] = &gctrpc.Account{
644 Id: sa.ID,
645 }
646 for curr, bal := range sa.Balances {
647 subAccts[i].Currencies = append(subAccts[i].Currencies, &gctrpc.AccountCurrencyInfo{
648 Currency: curr.String(),
649 TotalValue: bal.Total,
650 Hold: bal.Hold,
651 Free: bal.Free,
652 FreeWithoutBorrow: bal.AvailableWithoutBorrow,
653 Borrowed: bal.Borrowed,
654 UpdatedAt: timestamppb.New(bal.UpdatedAt),
655 })
656 }
657 }
658 return &gctrpc.GetAccountBalancesResponse{
659 Exchange: eName,
660 Accounts: subAccts,
661 }
662}
663
664// GetAccountBalancesStream streams an account balance for a specific exchange
665func (s *RPCServer) GetAccountBalancesStream(r *gctrpc.GetAccountBalancesRequest, stream gctrpc.GoCryptoTraderService_GetAccountBalancesStreamServer) error {

Callers 3

GetAccountBalancesMethod · 0.85
UpdateAccountBalancesMethod · 0.85

Calls 2

NewMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected