Skip to content

Commit

Permalink
feat: added 52 week range
Browse files Browse the repository at this point in the history
  • Loading branch information
achannarasappa committed Mar 3, 2021
1 parent 213ae8b commit 6802452
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions internal/quote/quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type ResponseQuote struct {
PreMarketChange float64 `json:"preMarketChange"`
PreMarketChangePercent float64 `json:"preMarketChangePercent"`
PreMarketPrice float64 `json:"preMarketPrice"`
FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh"`
FiftyTwoWeekLow float64 `json:"fiftyTwoWeekLow"`
QuoteType string `json:"quoteType"`
}

Expand Down
4 changes: 2 additions & 2 deletions internal/ui/component/watchlist/watchlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ func textQuoteRange(quote Quote) string {
StyleNeutral(" - ") +
ConvertFloatToString(quote.PriceDayHigh, quote.IsVariablePrecision) +
"\n" +
ConvertFloatToString(quote.PriceDayLow, quote.IsVariablePrecision) +
ConvertFloatToString(quote.FiftyTwoWeekLow, quote.IsVariablePrecision) +
StyleNeutral(" - ") +
ConvertFloatToString(quote.PriceDayHigh, quote.IsVariablePrecision)
ConvertFloatToString(quote.FiftyTwoWeekHigh, quote.IsVariablePrecision)
}

return textDayRange
Expand Down
14 changes: 8 additions & 6 deletions internal/ui/component/watchlist/watchlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ Google Inc. ↓ -32.02 (-1.35
ExtraInfoFundamentals: true,
},
})
m.Width = 135
m.Width = 165
m.Quotes = []Quote{
{
ResponseQuote: ResponseQuote{
Expand All @@ -454,12 +454,14 @@ Google Inc. ↓ -32.02 (-1.35
RegularMarketOpen: 1000.0,
RegularMarketDayHigh: 1500.0,
RegularMarketDayLow: 500.0,
FiftyTwoWeekHigh: 2000.0,
FiftyTwoWeekLow: 300.0,
},
Price: 5000.0,
PricePrevClose: 1000.0,
PriceOpen: 1000.0,
PriceDayHigh: 2000.0,
PriceDayLow: 1000.0,
PriceDayHigh: 200.0,
PriceDayLow: 100.0,
Change: 1000.0,
ChangePercent: 20.0,
IsActive: true,
Expand All @@ -468,10 +470,10 @@ Google Inc. ↓ -32.02 (-1.35
},
}
expected := strings.Join([]string{
"BTC-USD ● Day Range: 1000.00 Prev. Close: 1000.00 5000.00",
"Bitcoin 52wk Range: 1000.00 Open: 1000.00 ↑ 1000.00 (20.00%)",
"BTC-USD ● Day Range: 1000.00 Prev. Close: 1000.00 5000.00 5000.00",
"Bitcoin 52wk Range: 300.00 Open: 1000.00 ↑ 1000.00 (20.00%) ↑ 1000.00 (20.00%)",
}, "\n")
Expect("\n" + removeFormatting(m.View())).To(Equal("\n" + expected))
Expect("\n" + removeFormatting(m.View())).To(BeIdenticalTo("\n" + expected))
})

When("there is no day range", func() {
Expand Down

0 comments on commit 6802452

Please sign in to comment.