mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 07:26:44 +00:00
cli: rpc time parsing (#1107)
* fix rpc time parsing * Update cmd/gctcli/helpers.go Beautifully handled Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Fixes combined commit * uses ParseInLocation, parse with timezone, remove helper functions * lint Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/gctrpc"
|
||||
"github.com/urfave/cli/v2"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -295,15 +296,14 @@ func getTecnicalAnalysis(c *cli.Context, algo string) error {
|
||||
taEndTime, _ = c.Value("end").(string)
|
||||
}
|
||||
|
||||
s, err := time.Parse(common.SimpleTimeFormat, taStartTime)
|
||||
s, err := time.ParseInLocation(common.SimpleTimeFormat, taStartTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for start: %v", err)
|
||||
}
|
||||
e, err := time.Parse(common.SimpleTimeFormat, taEndTime)
|
||||
e, err := time.ParseInLocation(common.SimpleTimeFormat, taEndTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for end: %v", err)
|
||||
}
|
||||
|
||||
err = common.StartEndTimeCheck(s, e)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -335,8 +335,8 @@ func getTecnicalAnalysis(c *cli.Context, algo string) error {
|
||||
AssetType: asset,
|
||||
AlgorithmType: algo,
|
||||
Interval: taGranularity * int64(time.Second),
|
||||
Start: negateLocalOffsetTS(s),
|
||||
End: negateLocalOffsetTS(e),
|
||||
Start: timestamppb.New(s),
|
||||
End: timestamppb.New(e),
|
||||
Period: taPeriod,
|
||||
}
|
||||
|
||||
@@ -411,11 +411,11 @@ func getBollingerBands(c *cli.Context) error {
|
||||
taEndTime, _ = c.Value("end").(string)
|
||||
}
|
||||
|
||||
s, err := time.Parse(common.SimpleTimeFormat, taStartTime)
|
||||
s, err := time.ParseInLocation(common.SimpleTimeFormat, taStartTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for start: %v", err)
|
||||
}
|
||||
e, err := time.Parse(common.SimpleTimeFormat, taEndTime)
|
||||
e, err := time.ParseInLocation(common.SimpleTimeFormat, taEndTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for end: %v", err)
|
||||
}
|
||||
@@ -488,8 +488,8 @@ func getBollingerBands(c *cli.Context) error {
|
||||
AssetType: asset,
|
||||
AlgorithmType: "BBANDS",
|
||||
Interval: taGranularity * int64(time.Second),
|
||||
Start: negateLocalOffsetTS(s),
|
||||
End: negateLocalOffsetTS(e),
|
||||
Start: timestamppb.New(s),
|
||||
End: timestamppb.New(e),
|
||||
Period: taPeriod,
|
||||
StandardDeviationUp: taStdDevUp,
|
||||
StandardDeviationDown: taStdDevDown,
|
||||
@@ -567,11 +567,11 @@ func getMACD(c *cli.Context) error {
|
||||
taEndTime, _ = c.Value("end").(string)
|
||||
}
|
||||
|
||||
s, err := time.Parse(common.SimpleTimeFormat, taStartTime)
|
||||
s, err := time.ParseInLocation(common.SimpleTimeFormat, taStartTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for start: %v", err)
|
||||
}
|
||||
e, err := time.Parse(common.SimpleTimeFormat, taEndTime)
|
||||
e, err := time.ParseInLocation(common.SimpleTimeFormat, taEndTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for end: %v", err)
|
||||
}
|
||||
@@ -629,8 +629,8 @@ func getMACD(c *cli.Context) error {
|
||||
AssetType: asset,
|
||||
AlgorithmType: "MACD",
|
||||
Interval: taGranularity * int64(time.Second),
|
||||
Start: negateLocalOffsetTS(s),
|
||||
End: negateLocalOffsetTS(e),
|
||||
Start: timestamppb.New(s),
|
||||
End: timestamppb.New(e),
|
||||
Period: taPeriod,
|
||||
SlowPeriod: taSlowPeriod,
|
||||
FastPeriod: taFastPeriod,
|
||||
@@ -707,11 +707,11 @@ func getCoco(c *cli.Context) error {
|
||||
taEndTime, _ = c.Value("end").(string)
|
||||
}
|
||||
|
||||
s, err := time.Parse(common.SimpleTimeFormat, taStartTime)
|
||||
s, err := time.ParseInLocation(common.SimpleTimeFormat, taStartTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for start: %v", err)
|
||||
}
|
||||
e, err := time.Parse(common.SimpleTimeFormat, taEndTime)
|
||||
e, err := time.ParseInLocation(common.SimpleTimeFormat, taEndTime, time.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid time format for end: %v", err)
|
||||
}
|
||||
@@ -781,8 +781,8 @@ func getCoco(c *cli.Context) error {
|
||||
AssetType: asset,
|
||||
AlgorithmType: "COCO",
|
||||
Interval: taGranularity * int64(time.Second),
|
||||
Start: negateLocalOffsetTS(s),
|
||||
End: negateLocalOffsetTS(e),
|
||||
Start: timestamppb.New(s),
|
||||
End: timestamppb.New(e),
|
||||
Period: taPeriod,
|
||||
OtherExchange: otherExchange,
|
||||
OtherPair: &gctrpc.CurrencyPair{Base: otherPair.Base.String(), Quote: otherPair.Quote.String()},
|
||||
|
||||
Reference in New Issue
Block a user