Skip to content

Commit

Permalink
Update YahooFinance.price to handle defaults and dict
Browse files Browse the repository at this point in the history
  • Loading branch information
frefrik committed May 22, 2024
1 parent b99d79c commit d4dafd3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/src/yahoofinance.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ def quote(self):

@property
def price(self):
data = {}
data = {
"exchange": None,
"currency": None,
"price": None,
"change": None,
"changep": None,
"last_trade": None,
}
price = self.ticker.price[self.symbol]

if price:
if isinstance(price, dict):
data["exchange"] = price.get("exchangeName")
data["currency"] = price.get("currency")
data["price"] = price.get("regularMarketPrice")
Expand Down

0 comments on commit d4dafd3

Please sign in to comment.