engine/exchanges: Add GetCurrencyTradeURL wrapper func/gRPC endpoint (#1521)

* beginning the concept

* expands testing and implementations

* test standardisation, expansion

* more

* finish remainder, add rpc func

* lint

* grammar? I barely know her!

* wow i forgot something wow wow wow wow

* rm SendPayload

* enFixio!

* improve binance long-dated support

* update test design, update wrapper funcs

* adds kraken futures, adds bybit support

* fixes SIMPLE bugs

* s is for sucks

* fixed option url x2

* fixed silly test
This commit is contained in:
Scott
2024-05-03 17:01:17 +10:00
committed by GitHub
parent 0676c78bec
commit f1ff951199
83 changed files with 3922 additions and 2265 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1522,6 +1522,16 @@ message OpenInterestDataResponse {
double open_interest = 4;
}
message GetCurrencyTradeURLRequest {
string exchange = 1;
string asset = 2;
CurrencyPair pair = 3;
}
message GetCurrencyTradeURLResponse {
string url = 1;
}
service GoCryptoTraderService {
rpc GetInfo(GetInfoRequest) returns (GetInfoResponse) {
option (google.api.http) = {get: "/v1/getinfo"};
@@ -2068,4 +2078,7 @@ service GoCryptoTraderService {
rpc GetOpenInterest(GetOpenInterestRequest) returns (GetOpenInterestResponse) {
option (google.api.http) = {get: "/v1/getopeninterest"};
}
rpc GetCurrencyTradeURL(GetCurrencyTradeURLRequest) returns (GetCurrencyTradeURLResponse) {
option (google.api.http) = {get: "/v1/getcurrencytradeurl"};
}
}

View File

@@ -1531,6 +1531,60 @@
]
}
},
"/v1/getcurrencytradeurl": {
"get": {
"operationId": "GoCryptoTraderService_GetCurrencyTradeURL",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetCurrencyTradeURLResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "exchange",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "asset",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.delimiter",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.base",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "pair.quote",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"GoCryptoTraderService"
]
}
},
"/v1/getdatahistoryjobdetails": {
"get": {
"operationId": "GoCryptoTraderService_GetDataHistoryJobDetails",
@@ -4730,6 +4784,7 @@
"currencies": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcAccountCurrencyInfo"
}
}
@@ -4861,6 +4916,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrders"
}
},
@@ -4902,6 +4958,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrders"
}
}
@@ -5225,6 +5282,7 @@
"currencyStates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCurrencyState"
}
}
@@ -5303,6 +5361,7 @@
"jobResults": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcDataHistoryJobResult"
}
},
@@ -5340,6 +5399,7 @@
"results": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcDataHistoryJob"
}
}
@@ -5365,6 +5425,7 @@
"addresses": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcDepositAddress"
}
}
@@ -5486,6 +5547,7 @@
"rates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcFundingRate"
}
},
@@ -5575,6 +5637,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderDetails"
}
},
@@ -5734,6 +5797,7 @@
"scripts": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcGCTScript"
}
}
@@ -5799,6 +5863,7 @@
"accounts": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcAccount"
}
}
@@ -5810,6 +5875,7 @@
"events": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcAuditEvent"
}
}
@@ -5884,12 +5950,14 @@
"currencyBreakdown": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCollateralForCurrency"
}
},
"positionBreakdown": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCollateralByPosition"
}
}
@@ -5962,6 +6030,14 @@
}
}
},
"gctrpcGetCurrencyTradeURLResponse": {
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
},
"gctrpcGetEventsResponse": {
"type": "object",
"properties": {
@@ -6090,6 +6166,7 @@
"forexProviders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcForexProvider"
}
}
@@ -6101,6 +6178,7 @@
"forexRates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcForexRatesConversion"
}
}
@@ -6120,6 +6198,7 @@
"positions": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcFuturePosition"
}
}
@@ -6163,6 +6242,7 @@
"candle": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCandle"
}
}
@@ -6260,6 +6340,7 @@
"positions": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcFuturePosition"
}
}
@@ -6271,6 +6352,7 @@
"rates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcMarginRate"
}
},
@@ -6307,6 +6389,7 @@
"data": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOpenInterestDataResponse"
}
}
@@ -6492,6 +6575,7 @@
"orderbooks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbooks"
}
}
@@ -6523,6 +6607,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderDetails"
}
}
@@ -6534,6 +6619,7 @@
"portfolio": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcPortfolioAddress"
}
}
@@ -6545,12 +6631,14 @@
"coinTotals": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCoin"
}
},
"coinsOffline": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCoin"
}
},
@@ -6563,6 +6651,7 @@
"coinsOnline": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCoin"
}
},
@@ -6627,6 +6716,7 @@
"tickers": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTickers"
}
}
@@ -6714,6 +6804,7 @@
"addresses": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOfflineCoinSummary"
}
}
@@ -6831,6 +6922,7 @@
"trades": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTradeHistory"
}
},
@@ -6869,12 +6961,14 @@
"bids": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookItem"
}
},
"asks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookItem"
}
},
@@ -6899,6 +6993,7 @@
"orderbooks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookResponse"
}
}
@@ -7018,6 +7113,7 @@
"trades": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcSavedTrades"
}
}
@@ -7078,6 +7174,7 @@
"pairs": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcCurrencyPair"
}
},
@@ -7214,6 +7311,7 @@
"orders": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcOrderbookItem"
}
},
@@ -7284,6 +7382,7 @@
"trades": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTrades"
}
}
@@ -7341,6 +7440,7 @@
"tickers": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcTickerResponse"
}
}
@@ -7530,6 +7630,7 @@
"subscriptions": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcWebsocketSubscription"
}
}
@@ -7719,6 +7820,7 @@
"event": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gctrpcWithdrawalEventResponse"
}
}
@@ -7785,6 +7887,7 @@
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}

View File

@@ -133,6 +133,7 @@ const (
GoCryptoTraderService_SetLeverage_FullMethodName = "/gctrpc.GoCryptoTraderService/SetLeverage"
GoCryptoTraderService_ChangePositionMargin_FullMethodName = "/gctrpc.GoCryptoTraderService/ChangePositionMargin"
GoCryptoTraderService_GetOpenInterest_FullMethodName = "/gctrpc.GoCryptoTraderService/GetOpenInterest"
GoCryptoTraderService_GetCurrencyTradeURL_FullMethodName = "/gctrpc.GoCryptoTraderService/GetCurrencyTradeURL"
)
// GoCryptoTraderServiceClient is the client API for GoCryptoTraderService service.
@@ -253,6 +254,7 @@ type GoCryptoTraderServiceClient interface {
SetLeverage(ctx context.Context, in *SetLeverageRequest, opts ...grpc.CallOption) (*SetLeverageResponse, error)
ChangePositionMargin(ctx context.Context, in *ChangePositionMarginRequest, opts ...grpc.CallOption) (*ChangePositionMarginResponse, error)
GetOpenInterest(ctx context.Context, in *GetOpenInterestRequest, opts ...grpc.CallOption) (*GetOpenInterestResponse, error)
GetCurrencyTradeURL(ctx context.Context, in *GetCurrencyTradeURLRequest, opts ...grpc.CallOption) (*GetCurrencyTradeURLResponse, error)
}
type goCryptoTraderServiceClient struct {
@@ -1427,6 +1429,15 @@ func (c *goCryptoTraderServiceClient) GetOpenInterest(ctx context.Context, in *G
return out, nil
}
func (c *goCryptoTraderServiceClient) GetCurrencyTradeURL(ctx context.Context, in *GetCurrencyTradeURLRequest, opts ...grpc.CallOption) (*GetCurrencyTradeURLResponse, error) {
out := new(GetCurrencyTradeURLResponse)
err := c.cc.Invoke(ctx, GoCryptoTraderService_GetCurrencyTradeURL_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GoCryptoTraderServiceServer is the server API for GoCryptoTraderService service.
// All implementations must embed UnimplementedGoCryptoTraderServiceServer
// for forward compatibility
@@ -1545,6 +1556,7 @@ type GoCryptoTraderServiceServer interface {
SetLeverage(context.Context, *SetLeverageRequest) (*SetLeverageResponse, error)
ChangePositionMargin(context.Context, *ChangePositionMarginRequest) (*ChangePositionMarginResponse, error)
GetOpenInterest(context.Context, *GetOpenInterestRequest) (*GetOpenInterestResponse, error)
GetCurrencyTradeURL(context.Context, *GetCurrencyTradeURLRequest) (*GetCurrencyTradeURLResponse, error)
mustEmbedUnimplementedGoCryptoTraderServiceServer()
}
@@ -1894,6 +1906,9 @@ func (UnimplementedGoCryptoTraderServiceServer) ChangePositionMargin(context.Con
func (UnimplementedGoCryptoTraderServiceServer) GetOpenInterest(context.Context, *GetOpenInterestRequest) (*GetOpenInterestResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetOpenInterest not implemented")
}
func (UnimplementedGoCryptoTraderServiceServer) GetCurrencyTradeURL(context.Context, *GetCurrencyTradeURLRequest) (*GetCurrencyTradeURLResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetCurrencyTradeURL not implemented")
}
func (UnimplementedGoCryptoTraderServiceServer) mustEmbedUnimplementedGoCryptoTraderServiceServer() {}
// UnsafeGoCryptoTraderServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -3977,6 +3992,24 @@ func _GoCryptoTraderService_GetOpenInterest_Handler(srv interface{}, ctx context
return interceptor(ctx, in, info, handler)
}
func _GoCryptoTraderService_GetCurrencyTradeURL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetCurrencyTradeURLRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GoCryptoTraderServiceServer).GetCurrencyTradeURL(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: GoCryptoTraderService_GetCurrencyTradeURL_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GoCryptoTraderServiceServer).GetCurrencyTradeURL(ctx, req.(*GetCurrencyTradeURLRequest))
}
return interceptor(ctx, in, info, handler)
}
// GoCryptoTraderService_ServiceDesc is the grpc.ServiceDesc for GoCryptoTraderService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -4416,6 +4449,10 @@ var GoCryptoTraderService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetOpenInterest",
Handler: _GoCryptoTraderService_GetOpenInterest_Handler,
},
{
MethodName: "GetCurrencyTradeURL",
Handler: _GoCryptoTraderService_GetCurrencyTradeURL_Handler,
},
},
Streams: []grpc.StreamDesc{
{