remove unused get trades method

This commit is contained in:
c9s 2022-04-20 13:47:12 +08:00
parent 387c0bfb8b
commit f3eafd5cd8
5 changed files with 69 additions and 71 deletions

View File

@ -723,11 +723,11 @@ func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since
Exchange: types.ExchangeMax,
ApplyTime: types.Time(time.Unix(d.CreatedAt, 0)),
Asset: toGlobalCurrency(d.Currency),
Amount: fixedpoint.MustNewFromString(d.Amount),
Amount: d.Amount,
Address: "",
AddressTag: "",
TransactionID: d.TxID,
TransactionFee: fixedpoint.MustNewFromString(d.Fee),
TransactionFee: d.Fee,
TransactionFeeCurrency: d.FeeCurrency,
// WithdrawOrderID: d.WithdrawOrderID,
// Network: d.Network,

View File

@ -4,8 +4,6 @@ package max
//go:generate -command PostRequest requestgen -method POST
import (
"context"
"github.com/c9s/requestgen"
"github.com/c9s/bbgo/pkg/fixedpoint"
@ -81,27 +79,7 @@ type GetVipLevelRequest struct {
}
func (s *AccountService) NewGetVipLevelRequest() *GetVipLevelRequest {
return &GetVipLevelRequest{ client: s.client }
}
func (s *AccountService) VipLevel() (*VipLevel, error) {
req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/members/vip_level", nil, nil, nil)
if err != nil {
return nil, err
}
response, err := s.client.SendRequest(req)
if err != nil {
return nil, err
}
var vipLevel VipLevel
err = response.DecodeJSON(&vipLevel)
if err != nil {
return nil, err
}
return &vipLevel, nil
return &GetVipLevelRequest{client: s.client}
}
//go:generate GetRequest -url "v2/members/accounts/:currency" -type GetAccountRequest -responseType .Account
@ -115,12 +93,6 @@ func (s *AccountService) NewGetAccountRequest() *GetAccountRequest {
return &GetAccountRequest{client: s.client}
}
func (s *AccountService) NewGetWithdrawalHistoryRequest() *GetWithdrawHistoryRequest {
return &GetWithdrawHistoryRequest{
client: s.client,
}
}
//go:generate GetRequest -url "v2/members/accounts" -type GetAccountsRequest -responseType []Account
type GetAccountsRequest struct {
client requestgen.AuthenticatedAPIClient
@ -170,13 +142,13 @@ func (s *AccountService) NewGetDepositHistoryRequest() *GetDepositHistoryRequest
}
type Withdraw struct {
UUID string `json:"uuid"`
Currency string `json:"currency"`
CurrencyVersion string `json:"currency_version"` // "eth"
Amount string `json:"amount"`
Fee string `json:"fee"`
FeeCurrency string `json:"fee_currency"`
TxID string `json:"txid"`
UUID string `json:"uuid"`
Currency string `json:"currency"`
CurrencyVersion string `json:"currency_version"` // "eth"
Amount fixedpoint.Value `json:"amount"`
Fee fixedpoint.Value `json:"fee"`
FeeCurrency string `json:"fee_currency"`
TxID string `json:"txid"`
// State can be "submitting", "submitted",
// "rejected", "accepted", "suspect", "approved", "delisted_processing",
@ -195,9 +167,15 @@ type Withdraw struct {
type GetWithdrawHistoryRequest struct {
client requestgen.AuthenticatedAPIClient
currency string `param:"currency"`
from int64 `param:"from"` // seconds
to int64 `param:"to"` // seconds
state string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
limit int `param:"limit"`
currency string `param:"currency"`
from *int64 `param:"from"` // seconds
to *int64 `param:"to"` // seconds
state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
limit *int `param:"limit"`
}
func (s *AccountService) NewGetWithdrawalHistoryRequest() *GetWithdrawHistoryRequest {
return &GetWithdrawHistoryRequest{
client: s.client,
}
}

View File

@ -70,3 +70,23 @@ func TestAccountService_GetVipLevelRequest(t *testing.T) {
assert.NotNil(t, vipLevel)
t.Logf("vipLevel: %+v", vipLevel)
}
func TestAccountService_GetWithdrawHistoryRequest(t *testing.T) {
key, secret, ok := integrationTestConfigured(t, "MAX")
if !ok {
t.SkipNow()
}
ctx := context.Background()
client := NewRestClient(ProductionAPIURL)
client.Auth(key, secret)
req := client.AccountService.NewGetWithdrawalHistoryRequest()
req.Currency("usdt")
withdraws, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, withdraws)
assert.NotEmpty(t, withdraws)
t.Logf("withdraws: %+v", withdraws)
}

View File

@ -17,22 +17,22 @@ func (g *GetWithdrawHistoryRequest) Currency(currency string) *GetWithdrawHistor
}
func (g *GetWithdrawHistoryRequest) From(from int64) *GetWithdrawHistoryRequest {
g.from = from
g.from = &from
return g
}
func (g *GetWithdrawHistoryRequest) To(to int64) *GetWithdrawHistoryRequest {
g.to = to
g.to = &to
return g
}
func (g *GetWithdrawHistoryRequest) State(state string) *GetWithdrawHistoryRequest {
g.state = state
g.state = &state
return g
}
func (g *GetWithdrawHistoryRequest) Limit(limit int) *GetWithdrawHistoryRequest {
g.limit = limit
g.limit = &limit
return g
}
@ -57,25 +57,37 @@ func (g *GetWithdrawHistoryRequest) GetParameters() (map[string]interface{}, err
// assign parameter of currency
params["currency"] = currency
// check from field -> json key from
from := g.from
if g.from != nil {
from := *g.from
// assign parameter of from
params["from"] = from
// assign parameter of from
params["from"] = from
} else {
}
// check to field -> json key to
to := g.to
if g.to != nil {
to := *g.to
// assign parameter of to
params["to"] = to
// assign parameter of to
params["to"] = to
} else {
}
// check state field -> json key state
state := g.state
if g.state != nil {
state := *g.state
// assign parameter of state
params["state"] = state
// assign parameter of state
params["state"] = state
} else {
}
// check limit field -> json key limit
limit := g.limit
if g.limit != nil {
limit := *g.limit
// assign parameter of limit
params["limit"] = limit
// assign parameter of limit
params["limit"] = limit
} else {
}
return params, nil
}

View File

@ -16,7 +16,6 @@ import (
"net/http/httputil"
"net/url"
"regexp"
"strconv"
"strings"
"sync/atomic"
"time"
@ -349,17 +348,6 @@ func (c *RestClient) sendAuthenticatedRequest(m string, refURL string, data map[
return response, err
}
// FIXME: should deprecate the polling usage from the websocket struct
func (c *RestClient) GetTrades(market string, lastTradeID int64) ([]byte, error) {
params := url.Values{}
params.Add("market", market)
if lastTradeID > 0 {
params.Add("from", strconv.Itoa(int(lastTradeID)))
}
return c.get("/trades", params)
}
// get sends GET http request to the api endpoint, the urlPath must start with a slash '/'
func (c *RestClient) get(urlPath string, values url.Values) ([]byte, error) {
var reqURL = c.BaseURL.String() + urlPath