You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
944 B
38 lines
944 B
package trading |
|
|
|
import ( |
|
"context" |
|
"sig-pub/api/pb" |
|
) |
|
|
|
type TradingGrpcServer struct { |
|
pb.UnimplementedTradingServiceServer |
|
tradingService *TradingService |
|
} |
|
|
|
func NewTradingGrpcServer(tradingService *TradingService) *TradingGrpcServer { |
|
return &TradingGrpcServer{ |
|
tradingService: tradingService, |
|
} |
|
} |
|
|
|
func (svr *TradingGrpcServer) Init() (err error) { |
|
return |
|
} |
|
|
|
func (svr *TradingGrpcServer) IndicatorSeries(ctx context.Context, req *pb.ReqIndicatorSeries) (rsp *pb.RspIndicatorSeries, err error) { |
|
matrix, times, err := svr.tradingService.IndicatorSeries(req.Indicator, req.Window, req.Series) |
|
if err != nil { |
|
return |
|
} |
|
rsp = &pb.RspIndicatorSeries{} |
|
rsp.Matrix = matrix |
|
rsp.Times = times |
|
return |
|
} |
|
|
|
func (svr *TradingGrpcServer) StrategySeries(ctx context.Context, req *pb.ReqStrategySeries) (rsp *pb.RspStrategySeries, err error) { |
|
rsp = &pb.RspStrategySeries{} |
|
err = svr.tradingService.StrategySeries(req, rsp) |
|
return |
|
}
|
|
|