From a147d3d513d70b7a5623a1eb8b7e5d5b505872ae Mon Sep 17 00:00:00 2001 From: Charles Jackson Date: Sat, 29 Dec 2018 08:52:47 -0800 Subject: [PATCH] updated the tests for historic quotes --- quote/client_test.go | 15 ++++++++++++++- yfin.go | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/quote/client_test.go b/quote/client_test.go index 92c8914..3849936 100644 --- a/quote/client_test.go +++ b/quote/client_test.go @@ -28,7 +28,20 @@ func TestHistoricalQuote(t *testing.T) { assert.Nil(t, err) assert.NotNil(t, q) - assert.Equal(t, 185.80 , q) + high, _ := q.High.Float64() + low, _ := q.Low.Float64() + open, _ := q.Open.Float64() + close, _ := q.Open.Float64() + assert.Equal(t, 188.13999938964844, high) + assert.Equal(t, 187.5500030517578, low) + assert.Equal(t, 187.75, close) + assert.Equal(t, 187.75, open) +} + +func TestBadSymbolBar(t *testing.T) { + chart, err := GetHistoricalQuote("BADSYMBOL", 1, 11, 2018) + assert.Nil(t, chart) + assert.NotNil(t, err) } func TestGetPostMarketQuote(t *testing.T) { diff --git a/yfin.go b/yfin.go index 876f891..5f801e4 100644 --- a/yfin.go +++ b/yfin.go @@ -249,6 +249,16 @@ type ChartBar struct { Timestamp int } +type OHLCHistoric struct { + Open float64 + Low float64 + High float64 + Close float64 + AdjClose float64 + Volume int + Timestamp int +} + // ChartMeta is meta data associated with a chart response. type ChartMeta struct { Currency string `json:"currency"`