Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,8 +21,8 @@ def get_stock_price(ticker: str) -> str:
|
|
21 |
|
22 |
try:
|
23 |
stock = yf.Ticker(ticker)
|
24 |
-
|
25 |
-
price =
|
26 |
currency = stock.fast_info.get("currency", "USD") # Alternative currency field
|
27 |
|
28 |
return f"{currency} {price:,.2f}" if price != "N/A" else "Price unavailable"
|
|
|
21 |
|
22 |
try:
|
23 |
stock = yf.Ticker(ticker)
|
24 |
+
hist = stock.history(period="1d") # Get 1-day historical price
|
25 |
+
price = hist["Close"].iloc[-1] # Get last closing price
|
26 |
currency = stock.fast_info.get("currency", "USD") # Alternative currency field
|
27 |
|
28 |
return f"{currency} {price:,.2f}" if price != "N/A" else "Price unavailable"
|