mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
pkg/exchange: rename OpenOrders to Orders
This commit is contained in:
parent
270283d027
commit
d8b8e7f2ac
|
@ -9,13 +9,13 @@ import (
|
||||||
//go:generate -command GetRequest requestgen -method GET -responseType .APIResponse -responseDataField Result
|
//go:generate -command GetRequest requestgen -method GET -responseType .APIResponse -responseDataField Result
|
||||||
//go:generate -command PostRequest requestgen -method POST -responseType .APIResponse -responseDataField Result
|
//go:generate -command PostRequest requestgen -method POST -responseType .APIResponse -responseDataField Result
|
||||||
|
|
||||||
type OpenOrdersResponse struct {
|
type OrdersResponse struct {
|
||||||
List []OpenOrder `json:"list"`
|
List []Order `json:"list"`
|
||||||
NextPageCursor string `json:"nextPageCursor"`
|
NextPageCursor string `json:"nextPageCursor"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OpenOrder struct {
|
type Order struct {
|
||||||
OrderId string `json:"orderId"`
|
OrderId string `json:"orderId"`
|
||||||
OrderLinkId string `json:"orderLinkId"`
|
OrderLinkId string `json:"orderLinkId"`
|
||||||
BlockTradeId string `json:"blockTradeId"`
|
BlockTradeId string `json:"blockTradeId"`
|
||||||
|
@ -59,7 +59,7 @@ type OpenOrder struct {
|
||||||
UpdatedTime types.MillisecondTimestamp `json:"updatedTime"`
|
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 {
|
type GetOpenOrdersRequest struct {
|
||||||
client requestgen.AuthenticatedAPIClient
|
client requestgen.AuthenticatedAPIClient
|
||||||
|
|
||||||
|
@ -75,6 +75,8 @@ type GetOpenOrdersRequest struct {
|
||||||
cursor *string `param:"cursor,query"`
|
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 {
|
func (c *RestClient) NewGetOpenOrderRequest() *GetOpenOrdersRequest {
|
||||||
return &GetOpenOrdersRequest{
|
return &GetOpenOrdersRequest{
|
||||||
client: c,
|
client: c,
|
||||||
|
|
|
@ -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
|
package bybitapi
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ func (g *GetOpenOrdersRequest) GetSlugsMap() (map[string]string, error) {
|
||||||
return slugs, nil
|
return slugs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GetOpenOrdersRequest) Do(ctx context.Context) (*OpenOrdersResponse, error) {
|
func (g *GetOpenOrdersRequest) Do(ctx context.Context) (*OrdersResponse, error) {
|
||||||
|
|
||||||
// no body params
|
// no body params
|
||||||
var params interface{}
|
var params interface{}
|
||||||
|
@ -283,7 +283,7 @@ func (g *GetOpenOrdersRequest) Do(ctx context.Context) (*OpenOrdersResponse, err
|
||||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var data OpenOrdersResponse
|
var data OrdersResponse
|
||||||
if err := json.Unmarshal(apiResponse.Result, &data); err != nil {
|
if err := json.Unmarshal(apiResponse.Result, &data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
side, err := toGlobalSideType(order.Side)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -178,7 +178,7 @@ func TestToGlobalOrder(t *testing.T) {
|
||||||
// "UpdatedTime": "2023-07-25 17:12:57.868 +0800 CST"
|
// "UpdatedTime": "2023-07-25 17:12:57.868 +0800 CST"
|
||||||
//}
|
//}
|
||||||
timeNow := time.Now()
|
timeNow := time.Now()
|
||||||
openOrder := bybitapi.OpenOrder{
|
openOrder := bybitapi.Order{
|
||||||
OrderId: "1472539279335923200",
|
OrderId: "1472539279335923200",
|
||||||
OrderLinkId: "1690276361150",
|
OrderLinkId: "1690276361150",
|
||||||
BlockTradeId: "",
|
BlockTradeId: "",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user