diff --git a/pkg/exchange/bitget/convert.go b/pkg/exchange/bitget/convert.go index 30eb8e1b4..0836b4dd0 100644 --- a/pkg/exchange/bitget/convert.go +++ b/pkg/exchange/bitget/convert.go @@ -1,7 +1,25 @@ package bitget -import "strings" +import ( + "strings" + + "github.com/c9s/bbgo/pkg/exchange/bitget/bitgetapi" + "github.com/c9s/bbgo/pkg/fixedpoint" + "github.com/c9s/bbgo/pkg/types" +) func toGlobalSymbol(s string) string { return strings.ToUpper(s) } + +func toGlobalBalance(asset bitgetapi.AccountAsset) types.Balance { + return types.Balance{ + Currency: asset.CoinName, + Available: asset.Available, + Locked: asset.Lock.Add(asset.Frozen), + Borrowed: fixedpoint.Zero, + Interest: fixedpoint.Zero, + NetAsset: fixedpoint.Zero, + MaxWithdrawAmount: fixedpoint.Zero, + } +} diff --git a/pkg/exchange/bitget/exchange.go b/pkg/exchange/bitget/exchange.go index b9efe48de..cae7d3a0c 100644 --- a/pkg/exchange/bitget/exchange.go +++ b/pkg/exchange/bitget/exchange.go @@ -116,8 +116,21 @@ func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval type } func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) { - // TODO implement me - panic("implement me") + req := e.client.NewGetAccountAssetsRequest() + resp, err := req.Do(ctx) + if err != nil { + return nil, err + } + + bals := types.BalanceMap{} + for _, asset := range resp { + b := toGlobalBalance(asset) + bals[asset.CoinName] = b + } + + account := types.NewAccount() + account.UpdateBalances(bals) + return account, nil } func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error) {