Skip to content

Commit

Permalink
sometimes previousclose is null, use close
Browse files Browse the repository at this point in the history
  • Loading branch information
howeyc committed Feb 14, 2019
1 parent d5ade96 commit 7545402
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/lweb/handler_portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
type iexQuote struct {
Company string `json:"companyName"`
Exchange string `json:"primaryExchange"`
PreviousClose float64 `json:"close"`
Close float64 `json:"close"`
PreviousClose float64 `json:"previousClose"`
Last float64 `json:"latestPrice"`
}

Expand Down Expand Up @@ -109,13 +110,22 @@ func portfolioHandler(w http.ResponseWriter, r *http.Request, params martini.Par
quote, qerr := stockQuote(symbol)
if qerr == nil {
sprice = quote.Last
sclose = quote.PreviousClose
if quote.Close > 0 {
sclose = quote.Close
} else {
sclose = quote.PreviousClose
}
}
case "Fund":
quote, qerr := stockQuote(symbol)
if qerr == nil {
sprice = quote.Last
sclose = quote.PreviousClose
if quote.Close > 0 {
sclose = quote.Close
} else {
sclose = quote.PreviousClose
}
}
case "Crypto":
quote, qerr := cryptoQuote(symbol)
Expand Down

0 comments on commit 7545402

Please sign in to comment.