2022-05-24 09:40:00 +00:00
|
|
|
package v3
|
|
|
|
|
|
|
|
//go:generate -command GetRequest requestgen -method GET
|
|
|
|
//go:generate -command PostRequest requestgen -method POST
|
|
|
|
//go:generate -command DeleteRequest requestgen -method DELETE
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/c9s/requestgen"
|
|
|
|
|
|
|
|
maxapi "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
|
|
|
)
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
type WalletType string
|
|
|
|
|
|
|
|
const (
|
2022-05-24 10:00:52 +00:00
|
|
|
WalletTypeSpot WalletType = "spot"
|
|
|
|
WalletTypeMargin WalletType = "m"
|
2022-05-24 09:48:08 +00:00
|
|
|
)
|
|
|
|
|
2022-05-24 09:40:00 +00:00
|
|
|
type Order = maxapi.Order
|
|
|
|
|
|
|
|
// OrderService manages the Order endpoint.
|
|
|
|
type OrderService struct {
|
2022-05-26 10:49:18 +00:00
|
|
|
Client *maxapi.RestClient
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
func (s *OrderService) NewWalletCreateOrderRequest(walletType WalletType) *WalletCreateOrderRequest {
|
2022-05-26 10:49:18 +00:00
|
|
|
return &WalletCreateOrderRequest{client: s.Client, walletType: walletType}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
func (s *OrderService) NewWalletGetOrderRequest(walletType WalletType) *WalletGetOrderRequest {
|
2022-05-26 10:49:18 +00:00
|
|
|
return &WalletGetOrderRequest{client: s.Client, walletType: walletType}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
func (s *OrderService) NewWalletOrderCancelAllRequest(walletType WalletType) *WalletOrderCancelAllRequest {
|
2022-05-26 10:49:18 +00:00
|
|
|
return &WalletOrderCancelAllRequest{client: s.Client, walletType: walletType}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *OrderService) NewOrderCancelRequest() *OrderCancelRequest {
|
2022-05-26 10:49:18 +00:00
|
|
|
return &OrderCancelRequest{client: s.Client}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
func (s *OrderService) NewGetOrderRequest() *GetOrderRequest {
|
2022-05-26 10:49:18 +00:00
|
|
|
return &GetOrderRequest{client: s.Client}
|
2022-05-24 09:48:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//go:generate PostRequest -url "/api/v3/wallet/:walletType/orders" -type WalletCreateOrderRequest -responseType .Order -debug
|
|
|
|
type WalletCreateOrderRequest struct {
|
2022-05-24 09:40:00 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
walletType WalletType `param:"walletType,slug,required"`
|
|
|
|
market string `param:"market,required"`
|
|
|
|
side string `param:"side,required"`
|
|
|
|
volume string `param:"volume,required"`
|
|
|
|
orderType string `param:"ord_type"`
|
2022-05-24 09:40:00 +00:00
|
|
|
|
|
|
|
price *string `param:"price"`
|
|
|
|
stopPrice *string `param:"stop_price"`
|
|
|
|
clientOrderID *string `param:"client_oid"`
|
|
|
|
groupID *string `param:"group_id"`
|
|
|
|
}
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
//go:generate GetRequest -url "/api/v3/wallet/:walletType/orders" -type WalletGetOrderRequest -responseType .Order
|
|
|
|
type WalletGetOrderRequest struct {
|
2022-05-24 09:40:00 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
walletType WalletType `param:"walletType,slug,required"`
|
|
|
|
market string `param:"market,required"`
|
|
|
|
side string `param:"side,required"`
|
|
|
|
volume string `param:"volume,required"`
|
|
|
|
orderType string `param:"ord_type"`
|
2022-05-24 09:40:00 +00:00
|
|
|
|
|
|
|
price *string `param:"price"`
|
|
|
|
stopPrice *string `param:"stop_price"`
|
|
|
|
clientOrderID *string `param:"client_oid"`
|
|
|
|
groupID *string `param:"group_id"`
|
|
|
|
}
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
//go:generate DeleteRequest -url "/api/v3/wallet/:walletType/orders" -type WalletOrderCancelAllRequest -responseType []Order
|
|
|
|
type WalletOrderCancelAllRequest struct {
|
2022-05-24 09:40:00 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
2022-05-24 09:48:08 +00:00
|
|
|
walletType WalletType `param:"walletType,slug,required"`
|
|
|
|
side *string `param:"side"`
|
|
|
|
market *string `param:"market"`
|
|
|
|
groupID *uint32 `param:"groupID"`
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//go:generate PostRequest -url "/api/v3/order" -type OrderCancelRequest -responseType .Order
|
|
|
|
type OrderCancelRequest struct {
|
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
|
|
|
id *uint64 `param:"id,omitempty"`
|
|
|
|
clientOrderID *string `param:"client_oid,omitempty"`
|
|
|
|
}
|
2022-05-24 09:48:08 +00:00
|
|
|
|
|
|
|
//go:generate GetRequest -url "/api/v3/order" -type GetOrderRequest -responseType .Order
|
|
|
|
type GetOrderRequest struct {
|
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
|
|
|
id *uint64 `param:"id,omitempty"`
|
|
|
|
clientOrderID *string `param:"client_oid,omitempty"`
|
|
|
|
}
|