mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
max: fix order cancel request payload
This commit is contained in:
parent
de11ef10f5
commit
336fb4d25b
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrderStateToQuery int
|
type OrderStateToQuery int
|
||||||
|
@ -24,16 +25,16 @@ const (
|
||||||
OrderStateWait = OrderState("wait")
|
OrderStateWait = OrderState("wait")
|
||||||
OrderStateConvert = OrderState("convert")
|
OrderStateConvert = OrderState("convert")
|
||||||
OrderStateFinalizing = OrderState("finalizing")
|
OrderStateFinalizing = OrderState("finalizing")
|
||||||
OrderStateFailed = OrderState("failed")
|
OrderStateFailed = OrderState("failed")
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrderType string
|
type OrderType string
|
||||||
|
|
||||||
// Order types that the API can return.
|
// Order types that the API can return.
|
||||||
const (
|
const (
|
||||||
OrderTypeMarket = OrderType("market")
|
OrderTypeMarket = OrderType("market")
|
||||||
OrderTypeLimit = OrderType("limit")
|
OrderTypeLimit = OrderType("limit")
|
||||||
OrderTypeStopLimit = OrderType("stop_limit")
|
OrderTypeStopLimit = OrderType("stop_limit")
|
||||||
OrderTypeStopMarket = OrderType("stop_market")
|
OrderTypeStopMarket = OrderType("stop_market")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -192,22 +193,10 @@ func (s *OrderService) Cancel(orderID uint64, clientOrderID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderCancelRequestParams struct {
|
type OrderCancelRequestParams struct {
|
||||||
ID uint64 `json:"id"`
|
*PrivateRequestParams
|
||||||
ClientOrderID string `json:"client_oid"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p OrderCancelRequestParams) Map() map[string]interface{} {
|
ID uint64 `json:"id,omitempty"`
|
||||||
payload := make(map[string]interface{})
|
ClientOrderID string `json:"client_oid,omitempty"`
|
||||||
|
|
||||||
if p.ID > 0 {
|
|
||||||
payload["id"] = p.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(p.ClientOrderID) > 0 {
|
|
||||||
payload["client_oid"] = p.ClientOrderID
|
|
||||||
}
|
|
||||||
|
|
||||||
return payload
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderCancelRequest struct {
|
type OrderCancelRequest struct {
|
||||||
|
@ -227,13 +216,13 @@ func (r *OrderCancelRequest) ClientOrderID(id string) *OrderCancelRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OrderCancelRequest) Do(ctx context.Context) error {
|
func (r *OrderCancelRequest) Do(ctx context.Context) error {
|
||||||
payload := r.params.Map()
|
req, err := r.client.newAuthenticatedRequest("POST", "v2/order/delete", &r.params)
|
||||||
req, err := r.client.newAuthenticatedRequest("POST", "v2/order/delete", payload)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = r.client.sendRequest(req)
|
response, err := r.client.sendRequest(req)
|
||||||
|
log.Infof("response: %+v", response)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +257,7 @@ func (s *OrderService) Get(orderID uint64) (*Order, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiOrderRequestParams struct {
|
type MultiOrderRequestParams struct {
|
||||||
PrivateRequestParams
|
*PrivateRequestParams
|
||||||
|
|
||||||
Market string `json:"market"`
|
Market string `json:"market"`
|
||||||
Orders []Order `json:"orders"`
|
Orders []Order `json:"orders"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user