2020-10-02 02:10:59 +00:00
|
|
|
package max
|
|
|
|
|
2022-04-19 11:44:44 +00:00
|
|
|
//go:generate -command GetRequest requestgen -method GET
|
|
|
|
//go:generate -command PostRequest requestgen -method POST
|
|
|
|
|
2020-10-02 02:10:59 +00:00
|
|
|
import (
|
2022-05-26 11:52:38 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
2022-01-24 15:18:52 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
2020-10-02 02:10:59 +00:00
|
|
|
)
|
|
|
|
|
2022-05-26 11:52:38 +00:00
|
|
|
type WalletType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
WalletTypeSpot WalletType = "spot"
|
|
|
|
WalletTypeMargin WalletType = "m"
|
|
|
|
)
|
|
|
|
|
2020-10-02 02:10:59 +00:00
|
|
|
type OrderStateToQuery int
|
|
|
|
|
|
|
|
const (
|
|
|
|
All = iota
|
|
|
|
Active
|
|
|
|
Closed
|
|
|
|
)
|
|
|
|
|
2020-10-08 14:03:25 +00:00
|
|
|
type OrderState string
|
|
|
|
|
|
|
|
const (
|
2022-01-24 15:18:52 +00:00
|
|
|
OrderStateDone = OrderState("done")
|
2021-12-26 07:58:12 +00:00
|
|
|
|
2020-10-25 10:26:10 +00:00
|
|
|
OrderStateCancel = OrderState("cancel")
|
|
|
|
OrderStateWait = OrderState("wait")
|
|
|
|
OrderStateConvert = OrderState("convert")
|
|
|
|
OrderStateFinalizing = OrderState("finalizing")
|
2020-10-25 14:41:54 +00:00
|
|
|
OrderStateFailed = OrderState("failed")
|
2020-10-08 14:03:25 +00:00
|
|
|
)
|
|
|
|
|
2020-10-02 02:10:59 +00:00
|
|
|
type OrderType string
|
|
|
|
|
|
|
|
// Order types that the API can return.
|
|
|
|
const (
|
2020-10-25 14:41:54 +00:00
|
|
|
OrderTypeMarket = OrderType("market")
|
|
|
|
OrderTypeLimit = OrderType("limit")
|
2021-03-21 03:10:41 +00:00
|
|
|
OrderTypePostOnly = OrderType("post_only")
|
2020-10-25 14:41:54 +00:00
|
|
|
OrderTypeStopLimit = OrderType("stop_limit")
|
2020-10-25 10:26:10 +00:00
|
|
|
OrderTypeStopMarket = OrderType("stop_market")
|
2021-04-11 04:29:23 +00:00
|
|
|
OrderTypeIOCLimit = OrderType("ioc_limit")
|
2020-10-02 02:10:59 +00:00
|
|
|
)
|
|
|
|
|
2020-10-25 10:26:10 +00:00
|
|
|
type QueryOrderOptions struct {
|
|
|
|
GroupID int
|
2020-12-29 08:00:03 +00:00
|
|
|
Offset int
|
|
|
|
Limit int
|
2022-01-24 15:18:52 +00:00
|
|
|
Page int
|
2022-01-26 15:51:23 +00:00
|
|
|
OrderBy string
|
2020-10-25 10:26:10 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 02:10:59 +00:00
|
|
|
// OrderService manages the Order endpoint.
|
|
|
|
type OrderService struct {
|
|
|
|
client *RestClient
|
|
|
|
}
|
|
|
|
|
2022-05-26 11:52:38 +00:00
|
|
|
type SubmitOrder struct {
|
|
|
|
Side string `json:"side"`
|
|
|
|
Market string `json:"market"`
|
|
|
|
Price string `json:"price"`
|
|
|
|
StopPrice string `json:"stop_price,omitempty"`
|
|
|
|
OrderType OrderType `json:"ord_type"`
|
|
|
|
Volume string `json:"volume"`
|
|
|
|
GroupID uint32 `json:"group_id,omitempty"`
|
|
|
|
ClientOID string `json:"client_oid,omitempty"`
|
|
|
|
}
|
|
|
|
|
2020-10-02 02:10:59 +00:00
|
|
|
// Order represents one returned order (POST order/GET order/GET orders) on the max platform.
|
|
|
|
type Order struct {
|
2022-01-24 15:18:52 +00:00
|
|
|
ID uint64 `json:"id,omitempty"`
|
2022-05-27 11:20:45 +00:00
|
|
|
WalletType WalletType `json:"wallet_type,omitempty"`
|
2022-01-24 15:18:52 +00:00
|
|
|
Side string `json:"side"`
|
|
|
|
OrderType OrderType `json:"ord_type"`
|
2022-05-26 11:52:38 +00:00
|
|
|
Price fixedpoint.Value `json:"price,omitempty"`
|
|
|
|
StopPrice fixedpoint.Value `json:"stop_price,omitempty"`
|
|
|
|
AveragePrice fixedpoint.Value `json:"avg_price,omitempty"`
|
2022-01-24 15:18:52 +00:00
|
|
|
State OrderState `json:"state,omitempty"`
|
|
|
|
Market string `json:"market,omitempty"`
|
2022-05-26 11:52:38 +00:00
|
|
|
Volume fixedpoint.Value `json:"volume"`
|
|
|
|
RemainingVolume fixedpoint.Value `json:"remaining_volume,omitempty"`
|
|
|
|
ExecutedVolume fixedpoint.Value `json:"executed_volume,omitempty"`
|
2022-01-24 15:18:52 +00:00
|
|
|
TradesCount int64 `json:"trades_count,omitempty"`
|
|
|
|
GroupID uint32 `json:"group_id,omitempty"`
|
|
|
|
ClientOID string `json:"client_oid,omitempty"`
|
2022-05-27 11:20:45 +00:00
|
|
|
CreatedAt types.MillisecondTimestamp `json:"created_at"`
|
2022-04-19 11:44:44 +00:00
|
|
|
}
|