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-28 08:06:16 +00:00
|
|
|
// create type alias
|
2022-05-26 11:52:38 +00:00
|
|
|
type WalletType = maxapi.WalletType
|
2022-05-24 09:40:00 +00:00
|
|
|
type Order = maxapi.Order
|
2022-05-28 08:06:16 +00:00
|
|
|
type Trade = maxapi.Trade
|
2022-05-28 08:47:41 +00:00
|
|
|
type Account = maxapi.Account
|
2022-05-24 09:40:00 +00:00
|
|
|
|
|
|
|
// 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-06-01 11:56:10 +00:00
|
|
|
func (s *OrderService) NewGetWalletAccountsRequest(walletType WalletType) *GetWalletAccountsRequest {
|
|
|
|
return &GetWalletAccountsRequest{client: s.Client, walletType: walletType}
|
|
|
|
}
|
|
|
|
|
2022-05-28 08:48:51 +00:00
|
|
|
func (s *OrderService) NewCreateWalletOrderRequest(walletType WalletType) *CreateWalletOrderRequest {
|
2022-05-28 08:47:41 +00:00
|
|
|
return &CreateWalletOrderRequest{client: s.Client, walletType: walletType}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 08:48:51 +00:00
|
|
|
func (s *OrderService) NewGetWalletOrderHistoryRequest(walletType WalletType) *GetWalletOrderHistoryRequest {
|
2022-05-28 08:47:41 +00:00
|
|
|
return &GetWalletOrderHistoryRequest{client: s.Client, walletType: walletType}
|
2022-05-26 11:52:38 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 08:48:51 +00:00
|
|
|
func (s *OrderService) NewGetWalletOpenOrdersRequest(walletType WalletType) *GetWalletOpenOrdersRequest {
|
2022-05-28 08:47:41 +00:00
|
|
|
return &GetWalletOpenOrdersRequest{client: s.Client, walletType: walletType}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 08:48:51 +00:00
|
|
|
func (s *OrderService) NewCancelWalletOrderAllRequest(walletType WalletType) *CancelWalletOrderAllRequest {
|
2022-05-28 08:47:41 +00:00
|
|
|
return &CancelWalletOrderAllRequest{client: s.Client, walletType: walletType}
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 08:47:41 +00:00
|
|
|
//go:generate GetRequest -url "/api/v3/wallet/:walletType/accounts" -type GetWalletAccountsRequest -responseType []Account
|
|
|
|
type GetWalletAccountsRequest struct {
|
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
|
|
|
walletType WalletType `param:"walletType,slug,required"`
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:generate PostRequest -url "/api/v3/wallet/:walletType/orders" -type CreateWalletOrderRequest -responseType .Order
|
|
|
|
type CreateWalletOrderRequest 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-28 08:47:41 +00:00
|
|
|
//go:generate GetRequest -url "/api/v3/wallet/:walletType/orders/history" -type GetWalletOrderHistoryRequest -responseType []Order
|
|
|
|
type GetWalletOrderHistoryRequest 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"`
|
2022-05-24 09:40:00 +00:00
|
|
|
|
2022-05-26 11:52:38 +00:00
|
|
|
market string `param:"market,required"`
|
|
|
|
fromID *uint64 `param:"from_id"`
|
|
|
|
limit *uint `param:"limit"`
|
|
|
|
}
|
|
|
|
|
2022-05-28 08:47:41 +00:00
|
|
|
//go:generate GetRequest -url "/api/v3/wallet/:walletType/orders/open" -type GetWalletOpenOrdersRequest -responseType []Order
|
|
|
|
type GetWalletOpenOrdersRequest struct {
|
2022-05-26 11:52:38 +00:00
|
|
|
client requestgen.AuthenticatedAPIClient
|
|
|
|
|
|
|
|
walletType WalletType `param:"walletType,slug,required"`
|
|
|
|
market string `param:"market,required"`
|
2022-05-24 09:40:00 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 08:47:41 +00:00
|
|
|
//go:generate DeleteRequest -url "/api/v3/wallet/:walletType/orders" -type CancelWalletOrderAllRequest -responseType []Order
|
|
|
|
type CancelWalletOrderAllRequest 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
|
|
|
}
|
|
|
|
|