mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
add volume to stock history
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user