From e1cf09c193d94d8b95597c6ec70759948e8e98b6 Mon Sep 17 00:00:00 2001 From: LifeOverIP <67293535+LifeOverIP@users.noreply.github.com> Date: Sun, 24 Apr 2022 17:10:24 -0500 Subject: [PATCH] PriceHistoryOptions fix for empty StartDate and EndDate (#23) --- priceHistory.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/priceHistory.go b/priceHistory.go index fbc74a5..21221ca 100644 --- a/priceHistory.go +++ b/priceHistory.go @@ -3,17 +3,18 @@ package tdameritrade import ( "context" "fmt" - "github.com/google/go-querystring/query" "time" + + "github.com/google/go-querystring/query" ) var ( - validPeriodTypes = []string{"day", "month", "year", "ytd"} + validPeriodTypes = []string{"day", "month", "year", "ytd"} validFrequencyTypes = []string{"minute", "daily", "weekly", "monthly"} ) const ( - defaultPeriodType = "day" + defaultPeriodType = "day" defaultFrequencyType = "minute" ) @@ -31,15 +32,15 @@ type PriceHistoryOptions struct { Period int `url:"period"` FrequencyType string `url:"frequencyType"` Frequency int `url:"frequency"` - EndDate time.Time `url:"endDate"` - StartDate time.Time `url:"startDate"` - NeedExtendedHoursData *bool `url:"needExtendedHoursData"` + EndDate time.Time `url:"endDate,omitempty"` + StartDate time.Time `url:"startDate,omitempty"` + NeedExtendedHoursData *bool `url:"needExtendedHoursData"` } type PriceHistory struct { Candles []struct { Close float64 `json:"close"` - Datetime int `json:"datetime"` + Datetime int `json:"datetime"` High float64 `json:"high"` Low float64 `json:"low"` Open float64 `json:"open"` @@ -108,4 +109,3 @@ func contains(s string, lst []string) bool { } return false } -