Skip to content

Commit 684a8bb

Browse files
committed
added a historical quote function to Quote
1 parent ac8be96 commit 684a8bb

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

quote/client.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ func (i *Iter) Quote() *finance.Quote {
4040
return i.Current().(*finance.Quote)
4141
}
4242

43+
//Gives the Day's Close when you input a historical date
44+
func GetHistoricalQuote(symbol string, month int, day int, year int) (float64, error) {
45+
p := &chart.Params{
46+
Symbol: symbol,
47+
Start: &datetime.Datetime{Month: month, Day: day, Year: year},
48+
End: &datetime.Datetime{Month: month, Day: day+1, Year: year},
49+
Interval: datetime.OneDay,
50+
}
51+
iter := chart.Get(p)
52+
r := iter.Iter.Meta()
53+
v := reflect.ValueOf(r)
54+
55+
values := make([]interface{}, v.NumField())
56+
for i := 0; i < v.NumField(); i++ {
57+
values[i] = v.Field(i).Interface()
58+
}
59+
return values[8].(float64), nil
60+
}
61+
4362
// Get returns an Quote quote that matches the parameters specified.
4463
func Get(symbol string) (*finance.Quote, error) {
4564
i := List([]string{symbol})

0 commit comments

Comments
 (0)