From d8b8e7f2ace2cb5424977306a461a3a8fe08378d Mon Sep 17 00:00:00 2001 From: Edwin Date: Thu, 27 Jul 2023 17:35:33 +0800 Subject: [PATCH] pkg/exchange: rename OpenOrders to Orders --- .../bybit/bybitapi/get_open_order_request.go | 14 ++++++++------ .../bybitapi/get_open_orders_request_requestgen.go | 6 +++--- pkg/exchange/bybit/convert.go | 2 +- pkg/exchange/bybit/convert_test.go | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/exchange/bybit/bybitapi/get_open_order_request.go b/pkg/exchange/bybit/bybitapi/get_open_order_request.go index e56ea01c1..3634d005f 100644 --- a/pkg/exchange/bybit/bybitapi/get_open_order_request.go +++ b/pkg/exchange/bybit/bybitapi/get_open_order_request.go @@ -9,13 +9,13 @@ import ( //go:generate -command GetRequest requestgen -method GET -responseType .APIResponse -responseDataField Result //go:generate -command PostRequest requestgen -method POST -responseType .APIResponse -responseDataField Result -type OpenOrdersResponse struct { - List []OpenOrder `json:"list"` - NextPageCursor string `json:"nextPageCursor"` - Category string `json:"category"` +type OrdersResponse struct { + List []Order `json:"list"` + NextPageCursor string `json:"nextPageCursor"` + Category string `json:"category"` } -type OpenOrder struct { +type Order struct { OrderId string `json:"orderId"` OrderLinkId string `json:"orderLinkId"` BlockTradeId string `json:"blockTradeId"` @@ -59,7 +59,7 @@ type OpenOrder struct { UpdatedTime types.MillisecondTimestamp `json:"updatedTime"` } -//go:generate GetRequest -url "/v5/order/realtime" -type GetOpenOrdersRequest -responseDataType .OpenOrdersResponse +//go:generate GetRequest -url "/v5/order/realtime" -type GetOpenOrdersRequest -responseDataType .OrdersResponse type GetOpenOrdersRequest struct { client requestgen.AuthenticatedAPIClient @@ -75,6 +75,8 @@ type GetOpenOrdersRequest struct { cursor *string `param:"cursor,query"` } +// NewGetOpenOrderRequest queries unfilled or partially filled orders in real-time. To query older order records, +// please use the order history interface. func (c *RestClient) NewGetOpenOrderRequest() *GetOpenOrdersRequest { return &GetOpenOrdersRequest{ client: c, diff --git a/pkg/exchange/bybit/bybitapi/get_open_orders_request_requestgen.go b/pkg/exchange/bybit/bybitapi/get_open_orders_request_requestgen.go index d68c31f4d..aa9d13cc6 100644 --- a/pkg/exchange/bybit/bybitapi/get_open_orders_request_requestgen.go +++ b/pkg/exchange/bybit/bybitapi/get_open_orders_request_requestgen.go @@ -1,4 +1,4 @@ -// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Result -url /v5/order/realtime -type GetOpenOrdersRequest -responseDataType .OpenOrdersResponse"; DO NOT EDIT. +// Code generated by "requestgen -method GET -responseType .APIResponse -responseDataField Result -url /v5/order/realtime -type GetOpenOrdersRequest -responseDataType .OrdersResponse"; DO NOT EDIT. package bybitapi @@ -258,7 +258,7 @@ func (g *GetOpenOrdersRequest) GetSlugsMap() (map[string]string, error) { return slugs, nil } -func (g *GetOpenOrdersRequest) Do(ctx context.Context) (*OpenOrdersResponse, error) { +func (g *GetOpenOrdersRequest) Do(ctx context.Context) (*OrdersResponse, error) { // no body params var params interface{} @@ -283,7 +283,7 @@ func (g *GetOpenOrdersRequest) Do(ctx context.Context) (*OpenOrdersResponse, err if err := response.DecodeJSON(&apiResponse); err != nil { return nil, err } - var data OpenOrdersResponse + var data OrdersResponse if err := json.Unmarshal(apiResponse.Result, &data); err != nil { return nil, err } diff --git a/pkg/exchange/bybit/convert.go b/pkg/exchange/bybit/convert.go index 85ce0c013..add5def31 100644 --- a/pkg/exchange/bybit/convert.go +++ b/pkg/exchange/bybit/convert.go @@ -46,7 +46,7 @@ func toGlobalTicker(stats bybitapi.Ticker, time time.Time) types.Ticker { } } -func toGlobalOrder(order bybitapi.OpenOrder) (*types.Order, error) { +func toGlobalOrder(order bybitapi.Order) (*types.Order, error) { side, err := toGlobalSideType(order.Side) if err != nil { return nil, err diff --git a/pkg/exchange/bybit/convert_test.go b/pkg/exchange/bybit/convert_test.go index c5c8b497c..eddbce7cc 100644 --- a/pkg/exchange/bybit/convert_test.go +++ b/pkg/exchange/bybit/convert_test.go @@ -178,7 +178,7 @@ func TestToGlobalOrder(t *testing.T) { // "UpdatedTime": "2023-07-25 17:12:57.868 +0800 CST" //} timeNow := time.Now() - openOrder := bybitapi.OpenOrder{ + openOrder := bybitapi.Order{ OrderId: "1472539279335923200", OrderLinkId: "1690276361150", BlockTradeId: "",