Skip to content

Commit

Permalink
grpc: add start/end time to fix queryklines
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed Apr 12, 2022
1 parent 8705f38 commit d836126
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 160 deletions.
12 changes: 12 additions & 0 deletions pkg/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"time"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -113,6 +114,17 @@ func (s *Server) QueryKLines(ctx context.Context, request *pb.QueryKLinesRequest
Limit: int(request.Limit),
}

endTime := time.Now()
if request.EndTime != 0 {
endTime = time.Unix(request.EndTime, 0)
}
options.EndTime = &endTime

if request.StartTime != 0 {
startTime := time.Unix(request.StartTime, 0)
options.StartTime = &startTime
}

klines, err := session.Exchange.QueryKLines(ctx, request.Symbol, types.Interval(request.Interval), options)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit d836126

Please sign in to comment.