mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 07:26:48 +00:00
Kraken wsCancelAllOrders added, fix bugs in wsAddOrder, added new API endpoint CancelBatchOrders (#596)
* GetClosedOrder implemented for Kraken and Binance, fixed Binance MARKET order creaton, added rate, fee and cost fileds on SubmitOrder responce * return Trades on Binance SubmitOrder, new validation methods on Binance and kraken GetClosedOrderInfo * removed the Binance extra method GetClosedOrder * func description corrected * removed price, fee and cost from SimulateOrder response, as we get all necessary info in response to calculate them on client side * GetClosedOrder implementation moved to GetOrderInfo * changed GetOrderInfo params * removed Canceled order.Type used for Kraken * update QueryOrder in gctscript * add missed params to QueryOrder validator (gctscript) * fixed testing issues * GetClosedOrder implemented for Kraken and Binance, fixed Binance MARKET order creaton, added rate, fee and cost fileds on SubmitOrder responce * return Trades on Binance SubmitOrder, new validation methods on Binance and kraken GetClosedOrderInfo * removed the Binance extra method GetClosedOrder * func description corrected * removed price, fee and cost from SimulateOrder response, as we get all necessary info in response to calculate them on client side * GetClosedOrder implementation moved to GetOrderInfo * changed GetOrderInfo params * removed Canceled order.Type used for Kraken * update QueryOrder in gctscript * add missed params to QueryOrder validator (gctscript) * fixed testing issues * pull previous changes * linter issues fix * updated query_order exmple in gctscript, fixed params check * removed orderPair unnecessary conversion * added wsCancelAllOrders, fixed bugs * fixed Kraken wsAddOrder method * cleanup * CancelBatchOrders implementation * changed CancelBatchOrders signature * fixed tests and wrappers * btcmarkets_test fix * cleanup * cleanup * changed CancelBatchOrders signature * fmt * Update configtest.json * Update configtest.json * rollback configtest * refactored Kraken wsHandleData to allow tests * removed unnecessary error test in TestWsAddOrderJSON * dependencies updates Co-authored-by: Vazha Bezhanishvili <vazha.bezhanishvili@elegro.eu>
This commit is contained in:
3710
gctrpc/rpc.pb.go
3710
gctrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@@ -899,6 +899,40 @@ func local_request_GoCryptoTrader_CancelOrder_0(ctx context.Context, marshaler r
|
||||
|
||||
}
|
||||
|
||||
func request_GoCryptoTrader_CancelBatchOrders_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CancelBatchOrdersRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.CancelBatchOrders(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_GoCryptoTrader_CancelBatchOrders_0(ctx context.Context, marshaler runtime.Marshaler, server GoCryptoTraderServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CancelBatchOrdersRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.CancelBatchOrders(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_GoCryptoTrader_CancelAllOrders_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CancelAllOrdersRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -3144,6 +3178,29 @@ func RegisterGoCryptoTraderHandlerServer(ctx context.Context, mux *runtime.Serve
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_GoCryptoTrader_CancelBatchOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/gctrpc.GoCryptoTrader/CancelBatchOrders")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_GoCryptoTrader_CancelBatchOrders_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_GoCryptoTrader_CancelBatchOrders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_GoCryptoTrader_CancelAllOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -4783,6 +4840,26 @@ func RegisterGoCryptoTraderHandlerClient(ctx context.Context, mux *runtime.Serve
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_GoCryptoTrader_CancelBatchOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/gctrpc.GoCryptoTrader/CancelBatchOrders")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_GoCryptoTrader_CancelBatchOrders_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_GoCryptoTrader_CancelBatchOrders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_GoCryptoTrader_CancelAllOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -5769,6 +5846,8 @@ var (
|
||||
|
||||
pattern_GoCryptoTrader_CancelOrder_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelorder"}, ""))
|
||||
|
||||
pattern_GoCryptoTrader_CancelBatchOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelbatchorders"}, ""))
|
||||
|
||||
pattern_GoCryptoTrader_CancelAllOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "cancelallorders"}, ""))
|
||||
|
||||
pattern_GoCryptoTrader_GetEvents_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getevents"}, ""))
|
||||
@@ -5925,6 +6004,8 @@ var (
|
||||
|
||||
forward_GoCryptoTrader_CancelOrder_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_GoCryptoTrader_CancelBatchOrders_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_GoCryptoTrader_CancelAllOrders_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_GoCryptoTrader_GetEvents_0 = runtime.ForwardResponseMessage
|
||||
|
||||
@@ -46,7 +46,7 @@ message RPCEndpoint {
|
||||
}
|
||||
|
||||
message GetRPCEndpointsResponse {
|
||||
map<string, RPCEndpoint> endpoints = 1;
|
||||
map<string, RPCEndpoint> endpoints = 1;
|
||||
}
|
||||
|
||||
message GenericExchangeNameRequest {
|
||||
@@ -158,7 +158,7 @@ message Orderbooks {
|
||||
}
|
||||
|
||||
message GetOrderbooksResponse {
|
||||
repeated Orderbooks orderbooks = 1;
|
||||
repeated Orderbooks orderbooks = 1;
|
||||
}
|
||||
|
||||
message GetAccountInfoRequest {
|
||||
@@ -301,14 +301,14 @@ message OrderDetails {
|
||||
}
|
||||
|
||||
message TradeHistory {
|
||||
int64 creation_time = 1;
|
||||
string id = 2;
|
||||
double price = 3;
|
||||
double amount = 4;
|
||||
string exchange = 5;
|
||||
string asset_type = 6;
|
||||
string order_side = 7;
|
||||
double fee = 8;
|
||||
int64 creation_time = 1;
|
||||
string id = 2;
|
||||
double price = 3;
|
||||
double amount = 4;
|
||||
string exchange = 5;
|
||||
string asset_type = 6;
|
||||
string order_side = 7;
|
||||
double fee = 8;
|
||||
}
|
||||
|
||||
message GetOrdersRequest {
|
||||
@@ -384,6 +384,23 @@ message CancelOrderRequest {
|
||||
string side = 7;
|
||||
}
|
||||
|
||||
message CancelBatchOrdersRequest {
|
||||
string exchange = 1;
|
||||
string account_id = 2;
|
||||
string orders_id = 3;
|
||||
CurrencyPair pair = 4;
|
||||
string asset_type = 5;
|
||||
string wallet_address = 6;
|
||||
string side = 7;
|
||||
}
|
||||
|
||||
message CancelBatchOrdersResponse {
|
||||
message Orders {
|
||||
map<string, string> order_status = 1;
|
||||
}
|
||||
repeated Orders orders = 1;
|
||||
}
|
||||
|
||||
message CancelAllOrdersRequest {
|
||||
string exchange = 1;
|
||||
}
|
||||
@@ -394,6 +411,7 @@ message CancelAllOrdersResponse {
|
||||
map<string, string> order_status = 2;
|
||||
}
|
||||
repeated Orders orders = 1;
|
||||
int64 count = 2;
|
||||
}
|
||||
|
||||
message GetEventsRequest {}
|
||||
@@ -760,7 +778,7 @@ message WebsocketGetInfoRequest {
|
||||
message WebsocketGetInfoResponse {
|
||||
string exchange = 1;
|
||||
bool supported = 2;
|
||||
bool enabled = 3;
|
||||
bool enabled = 3;
|
||||
bool authenticated_supported = 4;
|
||||
bool authenticated = 5;
|
||||
string running_url = 6;
|
||||
@@ -1028,6 +1046,13 @@ service GoCryptoTrader {
|
||||
};
|
||||
}
|
||||
|
||||
rpc CancelBatchOrders (CancelBatchOrdersRequest) returns (CancelBatchOrdersResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/cancelbatchorders"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc CancelAllOrders (CancelAllOrdersRequest) returns (CancelAllOrdersResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/cancelallorders"
|
||||
|
||||
@@ -107,6 +107,38 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/cancelbatchorders": {
|
||||
"post": {
|
||||
"operationId": "GoCryptoTrader_CancelBatchOrders",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gctrpcCancelBatchOrdersResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/gctrpcCancelBatchOrdersRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"GoCryptoTrader"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/cancelorder": {
|
||||
"post": {
|
||||
"operationId": "GoCryptoTrader_CancelOrder",
|
||||
@@ -2557,20 +2589,6 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"CancelAllOrdersResponseOrders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exchange": {
|
||||
"type": "string"
|
||||
},
|
||||
"order_status": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gctrpcAccount": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2688,7 +2706,73 @@
|
||||
"orders": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/CancelAllOrdersResponseOrders"
|
||||
"$ref": "#/definitions/gctrpcCancelAllOrdersResponseOrders"
|
||||
}
|
||||
},
|
||||
"count": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gctrpcCancelAllOrdersResponseOrders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exchange": {
|
||||
"type": "string"
|
||||
},
|
||||
"order_status": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gctrpcCancelBatchOrdersRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exchange": {
|
||||
"type": "string"
|
||||
},
|
||||
"account_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"orders_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"pair": {
|
||||
"$ref": "#/definitions/gctrpcCurrencyPair"
|
||||
},
|
||||
"asset_type": {
|
||||
"type": "string"
|
||||
},
|
||||
"wallet_address": {
|
||||
"type": "string"
|
||||
},
|
||||
"side": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gctrpcCancelBatchOrdersResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"orders": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gctrpcCancelBatchOrdersResponseOrders"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"gctrpcCancelBatchOrdersResponseOrders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"order_status": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ type GoCryptoTraderClient interface {
|
||||
SimulateOrder(ctx context.Context, in *SimulateOrderRequest, opts ...grpc.CallOption) (*SimulateOrderResponse, error)
|
||||
WhaleBomb(ctx context.Context, in *WhaleBombRequest, opts ...grpc.CallOption) (*SimulateOrderResponse, error)
|
||||
CancelOrder(ctx context.Context, in *CancelOrderRequest, opts ...grpc.CallOption) (*GenericResponse, error)
|
||||
CancelBatchOrders(ctx context.Context, in *CancelBatchOrdersRequest, opts ...grpc.CallOption) (*CancelBatchOrdersResponse, error)
|
||||
CancelAllOrders(ctx context.Context, in *CancelAllOrdersRequest, opts ...grpc.CallOption) (*CancelAllOrdersResponse, error)
|
||||
GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, error)
|
||||
AddEvent(ctx context.Context, in *AddEventRequest, opts ...grpc.CallOption) (*AddEventResponse, error)
|
||||
@@ -406,6 +407,15 @@ func (c *goCryptoTraderClient) CancelOrder(ctx context.Context, in *CancelOrderR
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *goCryptoTraderClient) CancelBatchOrders(ctx context.Context, in *CancelBatchOrdersRequest, opts ...grpc.CallOption) (*CancelBatchOrdersResponse, error) {
|
||||
out := new(CancelBatchOrdersResponse)
|
||||
err := c.cc.Invoke(ctx, "/gctrpc.GoCryptoTrader/CancelBatchOrders", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *goCryptoTraderClient) CancelAllOrders(ctx context.Context, in *CancelAllOrdersRequest, opts ...grpc.CallOption) (*CancelAllOrdersResponse, error) {
|
||||
out := new(CancelAllOrdersResponse)
|
||||
err := c.cc.Invoke(ctx, "/gctrpc.GoCryptoTrader/CancelAllOrders", in, out, opts...)
|
||||
@@ -970,6 +980,7 @@ type GoCryptoTraderServer interface {
|
||||
SimulateOrder(context.Context, *SimulateOrderRequest) (*SimulateOrderResponse, error)
|
||||
WhaleBomb(context.Context, *WhaleBombRequest) (*SimulateOrderResponse, error)
|
||||
CancelOrder(context.Context, *CancelOrderRequest) (*GenericResponse, error)
|
||||
CancelBatchOrders(context.Context, *CancelBatchOrdersRequest) (*CancelBatchOrdersResponse, error)
|
||||
CancelAllOrders(context.Context, *CancelAllOrdersRequest) (*CancelAllOrdersResponse, error)
|
||||
GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error)
|
||||
AddEvent(context.Context, *AddEventRequest) (*AddEventResponse, error)
|
||||
@@ -1116,6 +1127,9 @@ func (UnimplementedGoCryptoTraderServer) WhaleBomb(context.Context, *WhaleBombRe
|
||||
func (UnimplementedGoCryptoTraderServer) CancelOrder(context.Context, *CancelOrderRequest) (*GenericResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelOrder not implemented")
|
||||
}
|
||||
func (UnimplementedGoCryptoTraderServer) CancelBatchOrders(context.Context, *CancelBatchOrdersRequest) (*CancelBatchOrdersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelBatchOrders not implemented")
|
||||
}
|
||||
func (UnimplementedGoCryptoTraderServer) CancelAllOrders(context.Context, *CancelAllOrdersRequest) (*CancelAllOrdersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelAllOrders not implemented")
|
||||
}
|
||||
@@ -1828,6 +1842,24 @@ func _GoCryptoTrader_CancelOrder_Handler(srv interface{}, ctx context.Context, d
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _GoCryptoTrader_CancelBatchOrders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CancelBatchOrdersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GoCryptoTraderServer).CancelBatchOrders(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/gctrpc.GoCryptoTrader/CancelBatchOrders",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GoCryptoTraderServer).CancelBatchOrders(ctx, req.(*CancelBatchOrdersRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _GoCryptoTrader_CancelAllOrders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CancelAllOrdersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -2795,6 +2827,10 @@ var _GoCryptoTrader_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "CancelOrder",
|
||||
Handler: _GoCryptoTrader_CancelOrder_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CancelBatchOrders",
|
||||
Handler: _GoCryptoTrader_CancelBatchOrders_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CancelAllOrders",
|
||||
Handler: _GoCryptoTrader_CancelAllOrders_Handler,
|
||||
|
||||
Reference in New Issue
Block a user