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, Exchange: types.ExchangeMax,
ApplyTime: types.Time(time.Unix(d.CreatedAt, 0)), ApplyTime: types.Time(time.Unix(d.CreatedAt, 0)),
Asset: toGlobalCurrency(d.Currency), Asset: toGlobalCurrency(d.Currency),
Amount: fixedpoint.MustNewFromString(d.Amount), Amount: d.Amount,
Address: "", Address: "",
AddressTag: "", AddressTag: "",
TransactionID: d.TxID, TransactionID: d.TxID,
TransactionFee: fixedpoint.MustNewFromString(d.Fee), TransactionFee: d.Fee,
TransactionFeeCurrency: d.FeeCurrency, TransactionFeeCurrency: d.FeeCurrency,
// WithdrawOrderID: d.WithdrawOrderID, // WithdrawOrderID: d.WithdrawOrderID,
// Network: d.Network, // Network: d.Network,

View File

@ -4,8 +4,6 @@ package max
//go:generate -command PostRequest requestgen -method POST //go:generate -command PostRequest requestgen -method POST
import ( import (
"context"
"github.com/c9s/requestgen" "github.com/c9s/requestgen"
"github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/fixedpoint"
@ -81,27 +79,7 @@ type GetVipLevelRequest struct {
} }
func (s *AccountService) NewGetVipLevelRequest() *GetVipLevelRequest { func (s *AccountService) NewGetVipLevelRequest() *GetVipLevelRequest {
return &GetVipLevelRequest{ client: s.client } 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
} }
//go:generate GetRequest -url "v2/members/accounts/:currency" -type GetAccountRequest -responseType .Account //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} 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 //go:generate GetRequest -url "v2/members/accounts" -type GetAccountsRequest -responseType []Account
type GetAccountsRequest struct { type GetAccountsRequest struct {
client requestgen.AuthenticatedAPIClient client requestgen.AuthenticatedAPIClient
@ -170,13 +142,13 @@ func (s *AccountService) NewGetDepositHistoryRequest() *GetDepositHistoryRequest
} }
type Withdraw struct { type Withdraw struct {
UUID string `json:"uuid"` UUID string `json:"uuid"`
Currency string `json:"currency"` Currency string `json:"currency"`
CurrencyVersion string `json:"currency_version"` // "eth" CurrencyVersion string `json:"currency_version"` // "eth"
Amount string `json:"amount"` Amount fixedpoint.Value `json:"amount"`
Fee string `json:"fee"` Fee fixedpoint.Value `json:"fee"`
FeeCurrency string `json:"fee_currency"` FeeCurrency string `json:"fee_currency"`
TxID string `json:"txid"` TxID string `json:"txid"`
// State can be "submitting", "submitted", // State can be "submitting", "submitted",
// "rejected", "accepted", "suspect", "approved", "delisted_processing", // "rejected", "accepted", "suspect", "approved", "delisted_processing",
@ -195,9 +167,15 @@ type Withdraw struct {
type GetWithdrawHistoryRequest struct { type GetWithdrawHistoryRequest struct {
client requestgen.AuthenticatedAPIClient client requestgen.AuthenticatedAPIClient
currency string `param:"currency"` currency string `param:"currency"`
from int64 `param:"from"` // seconds from *int64 `param:"from"` // seconds
to int64 `param:"to"` // seconds to *int64 `param:"to"` // seconds
state string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect state *string `param:"state"` // submitting, submitted, rejected, accepted, checking, refunded, canceled, suspect
limit int `param:"limit"` 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) assert.NotNil(t, vipLevel)
t.Logf("vipLevel: %+v", 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 { func (g *GetWithdrawHistoryRequest) From(from int64) *GetWithdrawHistoryRequest {
g.from = from g.from = &from
return g return g
} }
func (g *GetWithdrawHistoryRequest) To(to int64) *GetWithdrawHistoryRequest { func (g *GetWithdrawHistoryRequest) To(to int64) *GetWithdrawHistoryRequest {
g.to = to g.to = &to
return g return g
} }
func (g *GetWithdrawHistoryRequest) State(state string) *GetWithdrawHistoryRequest { func (g *GetWithdrawHistoryRequest) State(state string) *GetWithdrawHistoryRequest {
g.state = state g.state = &state
return g return g
} }
func (g *GetWithdrawHistoryRequest) Limit(limit int) *GetWithdrawHistoryRequest { func (g *GetWithdrawHistoryRequest) Limit(limit int) *GetWithdrawHistoryRequest {
g.limit = limit g.limit = &limit
return g return g
} }
@ -57,25 +57,37 @@ func (g *GetWithdrawHistoryRequest) GetParameters() (map[string]interface{}, err
// assign parameter of currency // assign parameter of currency
params["currency"] = currency params["currency"] = currency
// check from field -> json key from // check from field -> json key from
from := g.from if g.from != nil {
from := *g.from
// assign parameter of from // assign parameter of from
params["from"] = from params["from"] = from
} else {
}
// check to field -> json key to // check to field -> json key to
to := g.to if g.to != nil {
to := *g.to
// assign parameter of to // assign parameter of to
params["to"] = to params["to"] = to
} else {
}
// check state field -> json key state // check state field -> json key state
state := g.state if g.state != nil {
state := *g.state
// assign parameter of state // assign parameter of state
params["state"] = state params["state"] = state
} else {
}
// check limit field -> json key limit // check limit field -> json key limit
limit := g.limit if g.limit != nil {
limit := *g.limit
// assign parameter of limit // assign parameter of limit
params["limit"] = limit params["limit"] = limit
} else {
}
return params, nil return params, nil
} }

View File

@ -16,7 +16,6 @@ import (
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
"regexp" "regexp"
"strconv"
"strings" "strings"
"sync/atomic" "sync/atomic"
"time" "time"
@ -349,17 +348,6 @@ func (c *RestClient) sendAuthenticatedRequest(m string, refURL string, data map[
return response, err 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 '/' // 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) { func (c *RestClient) get(urlPath string, values url.Values) ([]byte, error) {
var reqURL = c.BaseURL.String() + urlPath var reqURL = c.BaseURL.String() + urlPath