add volume to stock history

This commit is contained in:
Asim Aslam
2021-06-20 17:43:21 +01:00
parent 466990f74e
commit 5db7872fa7

View File

@@ -9,18 +9,17 @@ import (
"regexp"
"time"
"github.com/patrickmn/go-cache"
"github.com/micro/micro/v3/service/errors"
"github.com/micro/micro/v3/service/logger"
pb "github.com/micro/services/stock/proto"
"github.com/patrickmn/go-cache"
)
var (
re = regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)
)
type Stock struct{
type Stock struct {
Api string
Key string
Cache *cache.Cache
@@ -83,7 +82,7 @@ func (s *Stock) History(ctx context.Context, req *pb.HistoryRequest, rsp *pb.His
rsp.High = respBody.High
rsp.Low = respBody.Low
rsp.Date = respBody.From
rsp.Volume = respBody.Volume
return nil
}
func (s *Stock) Quote(ctx context.Context, req *pb.QuoteRequest, rsp *pb.QuoteResponse) error {
@@ -119,7 +118,7 @@ func (s *Stock) Quote(ctx context.Context, req *pb.QuoteRequest, rsp *pb.QuoteRe
rsp.BidPrice = respBody.Bid
rsp.AskSize = respBody.Asize
rsp.BidSize = respBody.Bsize
rsp.Timestamp = time.Unix(0, respBody.Timestamp * int64(time.Millisecond)).UTC().Format(time.RFC3339Nano)
rsp.Timestamp = time.Unix(0, respBody.Timestamp*int64(time.Millisecond)).UTC().Format(time.RFC3339Nano)
return nil
}