mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
bitget: implement QueryAccount
This commit is contained in:
parent
40762cad35
commit
4a64701e16
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user