bbgo_origin/pkg/exchange/ftx/balance.go

30 lines
517 B
Go
Raw Normal View History

2021-02-08 10:59:36 +00:00
package ftx
import (
"context"
"encoding/json"
"fmt"
)
type balanceRequest struct {
*restRequest
}
func (r *balanceRequest) Balances(ctx context.Context) (balances, error) {
resp, err := r.
Method("GET").
ReferenceURL("api/wallet/balances").
DoAuthenticatedRequest(ctx)
if err != nil {
return balances{}, err
}
var b balances
if err := json.Unmarshal(resp.Body, &b); err != nil {
return balances{}, fmt.Errorf("failed to unmarshal balance response body to json: %w", err)
}
return b, nil
}