mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
maxapi: drop unused functions
This commit is contained in:
parent
d33b12ae81
commit
ce63723ff0
|
@ -1,25 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
maxapi "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
key := os.Getenv("MAX_API_KEY")
|
|
||||||
secret := os.Getenv("MAX_API_SECRET")
|
|
||||||
|
|
||||||
maxRest := maxapi.NewRestClient(maxapi.ProductionAPIURL)
|
|
||||||
maxRest.Auth(key, secret)
|
|
||||||
|
|
||||||
orders, err := maxRest.OrderService.All("maxusdt", 100, 1, maxapi.OrderStateDone)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, order := range orders {
|
|
||||||
log.Printf("%+v", order)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,18 +4,12 @@ package max
|
||||||
//go:generate -command PostRequest requestgen -method POST
|
//go:generate -command PostRequest requestgen -method POST
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
relUrlV2Orders *url.URL
|
|
||||||
relUrlV2OrdersMultiOneByOne *url.URL
|
|
||||||
)
|
|
||||||
|
|
||||||
func mustParseURL(s string) *url.URL {
|
func mustParseURL(s string) *url.URL {
|
||||||
u, err := url.Parse(s)
|
u, err := url.Parse(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -24,11 +18,6 @@ func mustParseURL(s string) *url.URL {
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
relUrlV2Orders = mustParseURL("v2/orders")
|
|
||||||
relUrlV2OrdersMultiOneByOne = mustParseURL("v2/orders/multi/onebyone")
|
|
||||||
}
|
|
||||||
|
|
||||||
type WalletType string
|
type WalletType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -111,34 +100,3 @@ type Order struct {
|
||||||
ClientOID string `json:"client_oid,omitempty"`
|
ClientOID string `json:"client_oid,omitempty"`
|
||||||
CreatedAt types.MillisecondTimestamp `json:"created_at"`
|
CreatedAt types.MillisecondTimestamp `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// All returns all orders for the authenticated account.
|
|
||||||
func (s *OrderService) All(market string, limit, page int, states ...OrderState) ([]Order, error) {
|
|
||||||
payload := map[string]interface{}{
|
|
||||||
"market": market,
|
|
||||||
"limit": limit,
|
|
||||||
"page": page,
|
|
||||||
"state": states,
|
|
||||||
"order_by": "desc",
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := s.client.newAuthenticatedRequest(context.Background(), "GET", "v2/orders", nil, payload, relUrlV2Orders)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
response, err := s.client.SendRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var orders []Order
|
|
||||||
if err := response.DecodeJSON(&orders); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return orders, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Options carry the option fields for REST API
|
|
||||||
type Options map[string]interface{}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user