Skip to content

Commit

Permalink
Merge pull request c9s#519 from narumiruna/grpc/fix-query-klines-time
Browse files Browse the repository at this point in the history
grpc: add start/end time to fix queryklines
  • Loading branch information
c9s committed Apr 12, 2022
2 parents 8705f38 + d836126 commit fad9449
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 fad9449

Please sign in to comment.