mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-22 07:15:25 +00:00
add volume to stock history
This commit is contained in:
@@ -9,18 +9,17 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/patrickmn/go-cache"
|
|
||||||
"github.com/micro/micro/v3/service/errors"
|
"github.com/micro/micro/v3/service/errors"
|
||||||
"github.com/micro/micro/v3/service/logger"
|
"github.com/micro/micro/v3/service/logger"
|
||||||
pb "github.com/micro/services/stock/proto"
|
pb "github.com/micro/services/stock/proto"
|
||||||
|
"github.com/patrickmn/go-cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
re = regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)
|
re = regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Stock struct {
|
||||||
type Stock struct{
|
|
||||||
Api string
|
Api string
|
||||||
Key string
|
Key string
|
||||||
Cache *cache.Cache
|
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.High = respBody.High
|
||||||
rsp.Low = respBody.Low
|
rsp.Low = respBody.Low
|
||||||
rsp.Date = respBody.From
|
rsp.Date = respBody.From
|
||||||
|
rsp.Volume = respBody.Volume
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (s *Stock) Quote(ctx context.Context, req *pb.QuoteRequest, rsp *pb.QuoteResponse) error {
|
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.BidPrice = respBody.Bid
|
||||||
rsp.AskSize = respBody.Asize
|
rsp.AskSize = respBody.Asize
|
||||||
rsp.BidSize = respBody.Bsize
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user