qbtrade/pkg/exchange/retry/account.go
2024-06-27 22:42:38 +08:00

44 lines
927 B
Go

package retry
import (
"context"
"git.qtrade.icu/lychiyu/qbtrade/pkg/types"
)
func QueryAccountUntilSuccessful(
ctx context.Context, ex types.ExchangeAccountService,
) (account *types.Account, err error) {
var op = func() (err2 error) {
account, err2 = ex.QueryAccount(ctx)
return err2
}
err = GeneralBackoff(ctx, op)
return account, err
}
func QueryAccountBalancesUntilSuccessful(
ctx context.Context, ex types.ExchangeAccountService,
) (bals types.BalanceMap, err error) {
var op = func() (err2 error) {
bals, err2 = ex.QueryAccountBalances(ctx)
return err2
}
err = GeneralBackoff(ctx, op)
return bals, err
}
func QueryAccountBalancesUntilSuccessfulLite(
ctx context.Context, ex types.ExchangeAccountService,
) (bals types.BalanceMap, err error) {
var op = func() (err2 error) {
bals, err2 = ex.QueryAccountBalances(ctx)
return err2
}
err = GeneralLiteBackoff(ctx, op)
return bals, err
}