technical_analysis: TWAP & VWAP + TA methods to candles and link to existing RPC server for GCTCLI prototyping (#970)

* kline: add weighted price helpers for candles

* twap/vwap: basic implementation and hook to rpc for protype

* ta: cont implementation. (WIP)

* kline: Add tests

* kline: add helpers

* ta: full impl.

* kline: remove support for macd and add in correlation-coefficient handling

* rpc: change naming convention

* linter: fix

* protolinter: fix

* linter: ++

* kline: reinstate macd handling after adding in check

* glorious: nits

* gctcl: linter

* Update exchanges/kline/weighted_price.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* glorious: nits v2.0

* kline: fix test

* huobi-tests: shift from next quarter to this weeks contracts as they were erroring out in tests.

* btcmarkets: update supported kline intervals

* zb: fix test

* rpcserver: fix bug and tests

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2022-07-08 15:21:56 +10:00
committed by GitHub
parent 68db4155bf
commit 7da745120f
21 changed files with 3509 additions and 325 deletions

View File

@@ -119,6 +119,7 @@ type GoCryptoTraderServiceClient interface {
GetFuturesPositions(ctx context.Context, in *GetFuturesPositionsRequest, opts ...grpc.CallOption) (*GetFuturesPositionsResponse, error)
GetCollateral(ctx context.Context, in *GetCollateralRequest, opts ...grpc.CallOption) (*GetCollateralResponse, error)
Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error)
GetTechnicalAnalysis(ctx context.Context, in *GetTechnicalAnalysisRequest, opts ...grpc.CallOption) (*GetTechnicalAnalysisResponse, error)
}
type goCryptoTraderServiceClient struct {
@@ -1140,6 +1141,15 @@ func (c *goCryptoTraderServiceClient) Shutdown(ctx context.Context, in *Shutdown
return out, nil
}
func (c *goCryptoTraderServiceClient) GetTechnicalAnalysis(ctx context.Context, in *GetTechnicalAnalysisRequest, opts ...grpc.CallOption) (*GetTechnicalAnalysisResponse, error) {
out := new(GetTechnicalAnalysisResponse)
err := c.cc.Invoke(ctx, "/gctrpc.GoCryptoTraderService/GetTechnicalAnalysis", 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
@@ -1241,6 +1251,7 @@ type GoCryptoTraderServiceServer interface {
GetFuturesPositions(context.Context, *GetFuturesPositionsRequest) (*GetFuturesPositionsResponse, error)
GetCollateral(context.Context, *GetCollateralRequest) (*GetCollateralResponse, error)
Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error)
GetTechnicalAnalysis(context.Context, *GetTechnicalAnalysisRequest) (*GetTechnicalAnalysisResponse, error)
mustEmbedUnimplementedGoCryptoTraderServiceServer()
}
@@ -1539,6 +1550,9 @@ func (UnimplementedGoCryptoTraderServiceServer) GetCollateral(context.Context, *
func (UnimplementedGoCryptoTraderServiceServer) Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented")
}
func (UnimplementedGoCryptoTraderServiceServer) GetTechnicalAnalysis(context.Context, *GetTechnicalAnalysisRequest) (*GetTechnicalAnalysisResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetTechnicalAnalysis not implemented")
}
func (UnimplementedGoCryptoTraderServiceServer) mustEmbedUnimplementedGoCryptoTraderServiceServer() {}
// UnsafeGoCryptoTraderServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -3316,6 +3330,24 @@ func _GoCryptoTraderService_Shutdown_Handler(srv interface{}, ctx context.Contex
return interceptor(ctx, in, info, handler)
}
func _GoCryptoTraderService_GetTechnicalAnalysis_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetTechnicalAnalysisRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GoCryptoTraderServiceServer).GetTechnicalAnalysis(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gctrpc.GoCryptoTraderService/GetTechnicalAnalysis",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GoCryptoTraderServiceServer).GetTechnicalAnalysis(ctx, req.(*GetTechnicalAnalysisRequest))
}
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)
@@ -3687,6 +3719,10 @@ var GoCryptoTraderService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Shutdown",
Handler: _GoCryptoTraderService_Shutdown_Handler,
},
{
MethodName: "GetTechnicalAnalysis",
Handler: _GoCryptoTraderService_GetTechnicalAnalysis_Handler,
},
},
Streams: []grpc.StreamDesc{
{