Skip to content

Commit 694e3cf

Browse files
yf data improvements
1 parent 17e0c7f commit 694e3cf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/util/yf_data.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ def append_price_data(price_key, change_key):
4242
append_price_data("regularMarketPrice", "regularMarketChangePercent")
4343

4444
# Calculate volume
45-
volume = stock_info.get("regularMarketVolume", 0) * prices[-1] if prices else 0
45+
volume: float = (
46+
stock_info.get("regularMarketVolume", 0) * prices[-1] if prices else 0
47+
)
4648

4749
# Prepare return values
48-
url = f"https://finance.yahoo.com/quote/{ticker}"
49-
exchange = stock_info.get("exchange", [])
50+
url: str = f"https://finance.yahoo.com/quote/{ticker}"
51+
exchange: str = stock_info.get("exchange", [])
5052

5153
return volume, url, exchange, prices, changes if changes else ["N/A"], ticker
5254

@@ -91,7 +93,7 @@ async def get_stock_info(
9193

9294
if asset_type == "stock":
9395
stock_info = yf_info(ticker, do_format_change)
94-
if stock_info:
96+
if stock_info and stock_info[0] > 0: # or price == []
9597
return stock_info
9698

9799
# Check TradingView data

0 commit comments

Comments
 (0)