Spaces:
Paused
Paused
Tonic commited on
get fundamental data
Browse files
app.py
CHANGED
|
@@ -4740,6 +4740,23 @@ def calculate_technical_indicators(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 4740 |
print(f"Error calculating technical indicators: {str(e)}")
|
| 4741 |
return df
|
| 4742 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4743 |
if __name__ == "__main__":
|
| 4744 |
import signal
|
| 4745 |
import atexit
|
|
|
|
| 4740 |
print(f"Error calculating technical indicators: {str(e)}")
|
| 4741 |
return df
|
| 4742 |
|
| 4743 |
+
def get_fundamental_data(symbol: str) -> dict:
|
| 4744 |
+
"""
|
| 4745 |
+
Fetch fundamental data for a given symbol using yfinance's info property.
|
| 4746 |
+
Returns a dictionary of fundamental data, or an empty dict if unavailable.
|
| 4747 |
+
"""
|
| 4748 |
+
try:
|
| 4749 |
+
ticker = yf.Ticker(symbol)
|
| 4750 |
+
info = retry_yfinance_request(lambda: ticker.info)
|
| 4751 |
+
if info is not None and isinstance(info, dict):
|
| 4752 |
+
return info
|
| 4753 |
+
else:
|
| 4754 |
+
print(f"No fundamental info available for {symbol}")
|
| 4755 |
+
return {}
|
| 4756 |
+
except Exception as e:
|
| 4757 |
+
print(f"Error fetching fundamental data for {symbol}: {str(e)}")
|
| 4758 |
+
return {} # Fallback to empty dict
|
| 4759 |
+
|
| 4760 |
if __name__ == "__main__":
|
| 4761 |
import signal
|
| 4762 |
import atexit
|