mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-13 02:23:51 +00:00
use uint32 for groupID
This commit is contained in:
parent
cd5ac1ddf5
commit
3c5071b87e
|
@ -51,19 +51,20 @@ type OrderService struct {
|
||||||
|
|
||||||
// Order represents one returned order (POST order/GET order/GET orders) on the max platform.
|
// Order represents one returned order (POST order/GET order/GET orders) on the max platform.
|
||||||
type Order struct {
|
type Order struct {
|
||||||
ID uint64 `json:"id,omitempty" db:"exchange_id"`
|
ID uint64 `json:"id,omitempty"`
|
||||||
Side string `json:"side" db:"side"`
|
Side string `json:"side"`
|
||||||
OrderType OrderType `json:"ord_type,omitempty" db:"order_type"`
|
OrderType OrderType `json:"ord_type"`
|
||||||
Price string `json:"price" db:"price"`
|
Price string `json:"price,omitempty"`
|
||||||
AveragePrice string `json:"avg_price,omitempty" db:"average_price"`
|
StopPrice string `json:"stop_price,omitempty"`
|
||||||
State OrderState `json:"state,omitempty" db:"state"`
|
AveragePrice string `json:"avg_price,omitempty"`
|
||||||
Market string `json:"market,omitempty" db:"market"`
|
State OrderState `json:"state,omitempty"`
|
||||||
Volume string `json:"volume" db:"volume"`
|
Market string `json:"market,omitempty"`
|
||||||
RemainingVolume string `json:"remaining_volume,omitempty" db:"remaining_volume"`
|
Volume string `json:"volume"`
|
||||||
ExecutedVolume string `json:"executed_volume,omitempty" db:"executed_volume"`
|
RemainingVolume string `json:"remaining_volume,omitempty"`
|
||||||
TradesCount int64 `json:"trades_count,omitempty" db:"trades_count"`
|
ExecutedVolume string `json:"executed_volume,omitempty"`
|
||||||
GroupID int64 `json:"group_id,omitempty" db:"group_id"`
|
TradesCount int64 `json:"trades_count,omitempty"`
|
||||||
ClientOID string `json:"client_oid,omitempty" db:"client_oid"`
|
GroupID uint32 `json:"group_id,omitempty"`
|
||||||
|
ClientOID string `json:"client_oid,omitempty"`
|
||||||
CreatedAt time.Time `json:"-" db:"created_at"`
|
CreatedAt time.Time `json:"-" db:"created_at"`
|
||||||
CreatedAtMs int64 `json:"created_at_in_ms,omitempty"`
|
CreatedAtMs int64 `json:"created_at_in_ms,omitempty"`
|
||||||
InsertedAt time.Time `json:"-" db:"inserted_at"`
|
InsertedAt time.Time `json:"-" db:"inserted_at"`
|
||||||
|
@ -247,7 +248,7 @@ type OrderCancelAllRequest struct {
|
||||||
|
|
||||||
side *string
|
side *string
|
||||||
market *string
|
market *string
|
||||||
groupID *int64
|
groupID *uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OrderCancelAllRequest) Side(side string) *OrderCancelAllRequest {
|
func (r *OrderCancelAllRequest) Side(side string) *OrderCancelAllRequest {
|
||||||
|
@ -260,7 +261,7 @@ func (r *OrderCancelAllRequest) Market(market string) *OrderCancelAllRequest {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *OrderCancelAllRequest) GroupID(groupID int64) *OrderCancelAllRequest {
|
func (r *OrderCancelAllRequest) GroupID(groupID uint32) *OrderCancelAllRequest {
|
||||||
r.groupID = &groupID
|
r.groupID = &groupID
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
@ -382,21 +383,51 @@ type MultiOrderResponse []struct {
|
||||||
type CreateMultiOrderRequest struct {
|
type CreateMultiOrderRequest struct {
|
||||||
client *RestClient
|
client *RestClient
|
||||||
|
|
||||||
params MultiOrderRequestParams
|
market *string
|
||||||
|
groupID *uint32
|
||||||
|
orders []Order
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *CreateMultiOrderRequest) GroupID(groupID uint32) *CreateMultiOrderRequest {
|
||||||
|
r.groupID = &groupID
|
||||||
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CreateMultiOrderRequest) Market(market string) *CreateMultiOrderRequest {
|
func (r *CreateMultiOrderRequest) Market(market string) *CreateMultiOrderRequest {
|
||||||
r.params.Market = market
|
r.market = &market
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CreateMultiOrderRequest) AddOrders(orders ...Order) *CreateMultiOrderRequest {
|
func (r *CreateMultiOrderRequest) AddOrders(orders ...Order) *CreateMultiOrderRequest {
|
||||||
r.params.Orders = append(r.params.Orders, orders...)
|
r.orders = append(r.orders, orders...)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CreateMultiOrderRequest) Do(ctx context.Context) (multiOrderResponse *MultiOrderResponse, err error) {
|
func (r *CreateMultiOrderRequest) Do(ctx context.Context) (multiOrderResponse *MultiOrderResponse, err error) {
|
||||||
req, err := r.client.newAuthenticatedRequest("POST", "v2/orders/multi/onebyone", r.params)
|
var payload = map[string]interface{}{}
|
||||||
|
|
||||||
|
if r.market != nil {
|
||||||
|
payload["market"] = r.market
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("parameter market is required")
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.groupID != nil {
|
||||||
|
payload["group_id"] = r.groupID
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(r.orders) == 0 {
|
||||||
|
return nil, errors.New("parameter orders can not be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear group id
|
||||||
|
for i := range r.orders {
|
||||||
|
r.orders[i].GroupID = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
payload["orders"] = r.orders
|
||||||
|
|
||||||
|
req, err := r.client.newAuthenticatedRequest("POST", "v2/orders/multi/onebyone", payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return multiOrderResponse, errors.Wrapf(err, "order create error")
|
return multiOrderResponse, errors.Wrapf(err, "order create error")
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ type OrderUpdate struct {
|
||||||
|
|
||||||
TradesCount int64 `json:"tc"`
|
TradesCount int64 `json:"tc"`
|
||||||
|
|
||||||
GroupID int64 `json:"gi"`
|
GroupID uint32 `json:"gi"`
|
||||||
ClientOID string `json:"ci"`
|
ClientOID string `json:"ci"`
|
||||||
CreatedAtMs int64 `json:"T"`
|
CreatedAtMs int64 `json:"T"`
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func parserOrderUpdate(v *fastjson.Value) OrderUpdate {
|
||||||
RemainingVolume: string(v.GetStringBytes("rv")),
|
RemainingVolume: string(v.GetStringBytes("rv")),
|
||||||
ExecutedVolume: string(v.GetStringBytes("ev")),
|
ExecutedVolume: string(v.GetStringBytes("ev")),
|
||||||
TradesCount: v.GetInt64("tc"),
|
TradesCount: v.GetInt64("tc"),
|
||||||
GroupID: v.GetInt64("gi"),
|
GroupID: uint32(v.GetInt("gi")),
|
||||||
ClientOID: string(v.GetStringBytes("ci")),
|
ClientOID: string(v.GetStringBytes("ci")),
|
||||||
CreatedAtMs: v.GetInt64("T"),
|
CreatedAtMs: v.GetInt64("T"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user