Spaces:
Sleeping
Sleeping
Faham
commited on
Commit
·
df534c5
1
Parent(s):
8e6c67f
FIX: stock tockers not coming in correctly
Browse files- Home.py +412 -36
- test_prophet_accuracy.py +1 -1
Home.py
CHANGED
|
@@ -11,6 +11,7 @@ from datetime import timedelta
|
|
| 11 |
import gnews
|
| 12 |
from bs4 import BeautifulSoup
|
| 13 |
import importlib.util
|
|
|
|
| 14 |
|
| 15 |
try:
|
| 16 |
from prophet import Prophet
|
|
@@ -66,77 +67,446 @@ discovered_tools = []
|
|
| 66 |
|
| 67 |
@st.cache_data(ttl=3600) # Cache for 1 hour
|
| 68 |
def get_available_tickers():
|
| 69 |
-
"""Fetch available tickers
|
| 70 |
try:
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
#
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
for index_val, row in stock_results.iterrows():
|
| 86 |
-
# Use the index as the ticker symbol
|
| 87 |
-
ticker = str(index_val)
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
| 96 |
return tickers_dict
|
| 97 |
else:
|
| 98 |
-
print("No
|
| 99 |
|
| 100 |
except Exception as e:
|
| 101 |
-
print(f"Error
|
| 102 |
|
| 103 |
-
# Fallback to
|
| 104 |
try:
|
| 105 |
-
print("Using fallback
|
| 106 |
-
|
| 107 |
|
| 108 |
-
#
|
| 109 |
-
|
|
|
|
| 110 |
"AAPL",
|
| 111 |
"MSFT",
|
| 112 |
"GOOGL",
|
| 113 |
"AMZN",
|
| 114 |
-
"TSLA",
|
| 115 |
"META",
|
| 116 |
"NVDA",
|
| 117 |
-
"
|
| 118 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
"JPM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
]
|
| 121 |
|
| 122 |
-
print(f"Loading {len(
|
| 123 |
|
| 124 |
# Get company names for each ticker
|
| 125 |
-
for ticker in
|
| 126 |
try:
|
| 127 |
ticker_obj = yf.Ticker(ticker)
|
| 128 |
info = ticker_obj.info
|
| 129 |
|
| 130 |
if info and (info.get("longName") or info.get("shortName")):
|
| 131 |
company_name = info.get("longName", info.get("shortName", ticker))
|
| 132 |
-
|
| 133 |
|
| 134 |
except Exception as e:
|
| 135 |
# Skip tickers that cause errors
|
| 136 |
continue
|
| 137 |
|
| 138 |
-
print(f"Successfully loaded {len(
|
| 139 |
-
return
|
| 140 |
|
| 141 |
except Exception as e:
|
| 142 |
st.error(f"Error fetching available tickers: {e}")
|
|
@@ -146,6 +516,12 @@ def get_available_tickers():
|
|
| 146 |
"TSLA": "Tesla Inc.",
|
| 147 |
"MSFT": "Microsoft Corporation",
|
| 148 |
"GOOGL": "Alphabet Inc. (Google)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
}
|
| 150 |
|
| 151 |
|
|
|
|
| 11 |
import gnews
|
| 12 |
from bs4 import BeautifulSoup
|
| 13 |
import importlib.util
|
| 14 |
+
import requests
|
| 15 |
|
| 16 |
try:
|
| 17 |
from prophet import Prophet
|
|
|
|
| 67 |
|
| 68 |
@st.cache_data(ttl=3600) # Cache for 1 hour
|
| 69 |
def get_available_tickers():
|
| 70 |
+
"""Fetch available tickers using multiple APIs and sources."""
|
| 71 |
try:
|
| 72 |
+
print("Fetching stock tickers from multiple sources...")
|
| 73 |
+
tickers_dict = {}
|
| 74 |
|
| 75 |
+
# Method 1: Try to get stocks from a free API
|
| 76 |
+
try:
|
| 77 |
+
print("Fetching stocks from API...")
|
| 78 |
+
# Try to get stocks from a free API endpoint
|
| 79 |
+
api_url = "https://api.polygon.io/v3/reference/tickers?market=stocks&active=true&limit=1000"
|
| 80 |
+
|
| 81 |
+
# Try alternative free APIs
|
| 82 |
+
apis_to_try = [
|
| 83 |
+
"https://api.twelvedata.com/stocks?country=US&exchange=NASDAQ",
|
| 84 |
+
"https://api.twelvedata.com/stocks?country=US&exchange=NYSE",
|
| 85 |
+
"https://api.twelvedata.com/stocks?country=US&exchange=AMEX",
|
| 86 |
+
]
|
| 87 |
+
|
| 88 |
+
for api_url in apis_to_try:
|
| 89 |
+
try:
|
| 90 |
+
response = requests.get(api_url, timeout=10)
|
| 91 |
+
if response.status_code == 200:
|
| 92 |
+
data = response.json()
|
| 93 |
+
if "data" in data:
|
| 94 |
+
for item in data["data"]:
|
| 95 |
+
ticker = item.get("symbol", "")
|
| 96 |
+
name = item.get("name", ticker)
|
| 97 |
+
if (
|
| 98 |
+
ticker and name and len(ticker) <= 5
|
| 99 |
+
): # Filter for likely stock tickers
|
| 100 |
+
tickers_dict[ticker] = name
|
| 101 |
+
print(f"Loaded {len(tickers_dict)} stocks from {api_url}")
|
| 102 |
+
break
|
| 103 |
+
except Exception as e:
|
| 104 |
+
print(f"Error with API {api_url}: {e}")
|
| 105 |
+
continue
|
| 106 |
|
| 107 |
+
except Exception as e:
|
| 108 |
+
print(f"Error fetching from APIs: {e}")
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
# Method 2: Try additional free APIs for more stocks
|
| 111 |
+
if len(tickers_dict) < 100: # Only if we didn't get enough from first APIs
|
| 112 |
+
try:
|
| 113 |
+
print("Fetching additional stocks from more APIs...")
|
| 114 |
+
|
| 115 |
+
# Try more free APIs
|
| 116 |
+
additional_apis = [
|
| 117 |
+
"https://api.twelvedata.com/stocks?country=US&exchange=NASDAQ&limit=500",
|
| 118 |
+
"https://api.twelvedata.com/stocks?country=US&exchange=NYSE&limit=500",
|
| 119 |
+
"https://api.twelvedata.com/stocks?country=US&exchange=AMEX&limit=500",
|
| 120 |
+
"https://api.twelvedata.com/stocks?country=CA&exchange=TSX&limit=200",
|
| 121 |
+
"https://api.twelvedata.com/stocks?country=GB&exchange=LSE&limit=200",
|
| 122 |
+
]
|
| 123 |
+
|
| 124 |
+
for api_url in additional_apis:
|
| 125 |
+
try:
|
| 126 |
+
response = requests.get(api_url, timeout=10)
|
| 127 |
+
if response.status_code == 200:
|
| 128 |
+
data = response.json()
|
| 129 |
+
if "data" in data:
|
| 130 |
+
for item in data["data"]:
|
| 131 |
+
ticker = item.get("symbol", "")
|
| 132 |
+
name = item.get("name", ticker)
|
| 133 |
+
if (
|
| 134 |
+
ticker and name and len(ticker) <= 5
|
| 135 |
+
): # Filter for likely stock tickers
|
| 136 |
+
if (
|
| 137 |
+
ticker not in tickers_dict
|
| 138 |
+
): # Avoid duplicates
|
| 139 |
+
tickers_dict[ticker] = name
|
| 140 |
+
print(f"Loaded additional stocks from {api_url}")
|
| 141 |
+
except Exception as e:
|
| 142 |
+
print(f"Error with additional API {api_url}: {e}")
|
| 143 |
+
continue
|
| 144 |
+
|
| 145 |
+
print(f"Loaded {len(tickers_dict)} total stocks from all APIs")
|
| 146 |
+
except Exception as e:
|
| 147 |
+
print(f"Error fetching from additional APIs: {e}")
|
| 148 |
|
| 149 |
+
# Method 3: Try to get stocks from Yahoo Finance screener (if available)
|
| 150 |
+
if len(tickers_dict) < 200: # Only if we need more
|
| 151 |
+
try:
|
| 152 |
+
print("Trying Yahoo Finance screener...")
|
| 153 |
+
# This is a fallback that doesn't hardcode tickers
|
| 154 |
+
# We'll try to get some popular stocks dynamically
|
| 155 |
+
popular_keywords = [
|
| 156 |
+
"technology",
|
| 157 |
+
"finance",
|
| 158 |
+
"healthcare",
|
| 159 |
+
"energy",
|
| 160 |
+
"consumer",
|
| 161 |
+
]
|
| 162 |
+
|
| 163 |
+
for keyword in popular_keywords:
|
| 164 |
+
try:
|
| 165 |
+
# Try to search for stocks by sector
|
| 166 |
+
search_url = f"https://api.twelvedata.com/stocks?search={keyword}&limit=50"
|
| 167 |
+
response = requests.get(search_url, timeout=10)
|
| 168 |
+
if response.status_code == 200:
|
| 169 |
+
data = response.json()
|
| 170 |
+
if "data" in data:
|
| 171 |
+
for item in data["data"]:
|
| 172 |
+
ticker = item.get("symbol", "")
|
| 173 |
+
name = item.get("name", ticker)
|
| 174 |
+
if (
|
| 175 |
+
ticker and name and len(ticker) <= 5
|
| 176 |
+
): # Filter for likely stock tickers
|
| 177 |
+
if (
|
| 178 |
+
ticker not in tickers_dict
|
| 179 |
+
): # Avoid duplicates
|
| 180 |
+
tickers_dict[ticker] = name
|
| 181 |
+
except Exception as e:
|
| 182 |
+
print(f"Error searching for {keyword}: {e}")
|
| 183 |
+
continue
|
| 184 |
+
|
| 185 |
+
print(
|
| 186 |
+
f"Loaded {len(tickers_dict)} total stocks (including sector searches)"
|
| 187 |
+
)
|
| 188 |
+
except Exception as e:
|
| 189 |
+
print(f"Error fetching from sector searches: {e}")
|
| 190 |
|
| 191 |
+
if len(tickers_dict) > 0:
|
| 192 |
+
print(
|
| 193 |
+
f"Successfully loaded {len(tickers_dict)} valid tickers from multiple sources"
|
| 194 |
+
)
|
| 195 |
return tickers_dict
|
| 196 |
else:
|
| 197 |
+
print("No tickers loaded from APIs, using fallback list")
|
| 198 |
|
| 199 |
except Exception as e:
|
| 200 |
+
print(f"Error in main ticker fetching: {e}")
|
| 201 |
|
| 202 |
+
# Fallback to comprehensive list if all APIs fail
|
| 203 |
try:
|
| 204 |
+
print("Using comprehensive fallback list...")
|
| 205 |
+
fallback_tickers = {}
|
| 206 |
|
| 207 |
+
# Comprehensive list of major stocks across sectors
|
| 208 |
+
fallback_ticker_list = [
|
| 209 |
+
# Technology
|
| 210 |
"AAPL",
|
| 211 |
"MSFT",
|
| 212 |
"GOOGL",
|
| 213 |
"AMZN",
|
|
|
|
| 214 |
"META",
|
| 215 |
"NVDA",
|
| 216 |
+
"TSLA",
|
| 217 |
+
"NFLX",
|
| 218 |
+
"ADBE",
|
| 219 |
+
"CRM",
|
| 220 |
+
"ORCL",
|
| 221 |
+
"INTC",
|
| 222 |
+
"AMD",
|
| 223 |
+
"QCOM",
|
| 224 |
+
"AVGO",
|
| 225 |
+
"TXN",
|
| 226 |
+
"MU",
|
| 227 |
+
"ADI",
|
| 228 |
+
"KLAC",
|
| 229 |
+
"LRCX",
|
| 230 |
+
"ASML",
|
| 231 |
+
"TSM",
|
| 232 |
+
"NVDA",
|
| 233 |
+
"AMD",
|
| 234 |
+
"INTC",
|
| 235 |
+
"QCOM",
|
| 236 |
+
"AVGO",
|
| 237 |
+
"TXN",
|
| 238 |
+
"MU",
|
| 239 |
+
"ADI",
|
| 240 |
+
# Financial
|
| 241 |
"JPM",
|
| 242 |
+
"BAC",
|
| 243 |
+
"WFC",
|
| 244 |
+
"GS",
|
| 245 |
+
"MS",
|
| 246 |
+
"C",
|
| 247 |
+
"USB",
|
| 248 |
+
"PNC",
|
| 249 |
+
"TFC",
|
| 250 |
+
"COF",
|
| 251 |
+
"AXP",
|
| 252 |
+
"BLK",
|
| 253 |
+
"SCHW",
|
| 254 |
+
"CME",
|
| 255 |
+
"ICE",
|
| 256 |
+
"SPGI",
|
| 257 |
+
"MCO",
|
| 258 |
+
"V",
|
| 259 |
+
"MA",
|
| 260 |
+
"PYPL",
|
| 261 |
+
# Healthcare
|
| 262 |
+
"JNJ",
|
| 263 |
+
"PFE",
|
| 264 |
+
"UNH",
|
| 265 |
+
"ABBV",
|
| 266 |
+
"MRK",
|
| 267 |
+
"TMO",
|
| 268 |
+
"ABT",
|
| 269 |
+
"DHR",
|
| 270 |
+
"BMY",
|
| 271 |
+
"AMGN",
|
| 272 |
+
"GILD",
|
| 273 |
+
"CVS",
|
| 274 |
+
"CI",
|
| 275 |
+
"ANTM",
|
| 276 |
+
"HUM",
|
| 277 |
+
"CNC",
|
| 278 |
+
"WBA",
|
| 279 |
+
"CAH",
|
| 280 |
+
"MCK",
|
| 281 |
+
"ABC",
|
| 282 |
+
# Consumer
|
| 283 |
+
"PG",
|
| 284 |
+
"KO",
|
| 285 |
+
"PEP",
|
| 286 |
+
"WMT",
|
| 287 |
+
"HD",
|
| 288 |
+
"MCD",
|
| 289 |
+
"SBUX",
|
| 290 |
+
"NKE",
|
| 291 |
+
"DIS",
|
| 292 |
+
"CMCSA",
|
| 293 |
+
"VZ",
|
| 294 |
+
"T",
|
| 295 |
+
"TMUS",
|
| 296 |
+
"CHTR",
|
| 297 |
+
"CMCSA",
|
| 298 |
+
"FOXA",
|
| 299 |
+
"NWSA",
|
| 300 |
+
"PARA",
|
| 301 |
+
"WBD",
|
| 302 |
+
"NFLX",
|
| 303 |
+
# Industrial
|
| 304 |
+
"BA",
|
| 305 |
+
"CAT",
|
| 306 |
+
"GE",
|
| 307 |
+
"MMM",
|
| 308 |
+
"HON",
|
| 309 |
+
"UPS",
|
| 310 |
+
"FDX",
|
| 311 |
+
"RTX",
|
| 312 |
+
"LMT",
|
| 313 |
+
"NOC",
|
| 314 |
+
"GD",
|
| 315 |
+
"LHX",
|
| 316 |
+
"TDG",
|
| 317 |
+
"TXT",
|
| 318 |
+
"DE",
|
| 319 |
+
"CNH",
|
| 320 |
+
"AGCO",
|
| 321 |
+
"KUB",
|
| 322 |
+
"EMR",
|
| 323 |
+
"ETN",
|
| 324 |
+
# Energy
|
| 325 |
+
"XOM",
|
| 326 |
+
"CVX",
|
| 327 |
+
"COP",
|
| 328 |
+
"EOG",
|
| 329 |
+
"SLB",
|
| 330 |
+
"PSX",
|
| 331 |
+
"VLO",
|
| 332 |
+
"MPC",
|
| 333 |
+
"OXY",
|
| 334 |
+
"HAL",
|
| 335 |
+
"BKR",
|
| 336 |
+
"NOV",
|
| 337 |
+
"FTI",
|
| 338 |
+
"WMB",
|
| 339 |
+
"KMI",
|
| 340 |
+
"ENB",
|
| 341 |
+
"EPD",
|
| 342 |
+
"ET",
|
| 343 |
+
"OKE",
|
| 344 |
+
"PXD",
|
| 345 |
+
# Real Estate
|
| 346 |
+
"AMT",
|
| 347 |
+
"PLD",
|
| 348 |
+
"CCI",
|
| 349 |
+
"EQIX",
|
| 350 |
+
"DLR",
|
| 351 |
+
"PSA",
|
| 352 |
+
"O",
|
| 353 |
+
"SPG",
|
| 354 |
+
"WELL",
|
| 355 |
+
"VICI",
|
| 356 |
+
"EQR",
|
| 357 |
+
"AVB",
|
| 358 |
+
"MAA",
|
| 359 |
+
"ESS",
|
| 360 |
+
"UDR",
|
| 361 |
+
"CPT",
|
| 362 |
+
"BXP",
|
| 363 |
+
"SLG",
|
| 364 |
+
"VNO",
|
| 365 |
+
"KIM",
|
| 366 |
+
# Utilities
|
| 367 |
+
"NEE",
|
| 368 |
+
"DUK",
|
| 369 |
+
"SO",
|
| 370 |
+
"D",
|
| 371 |
+
"AEP",
|
| 372 |
+
"SRE",
|
| 373 |
+
"XEL",
|
| 374 |
+
"WEC",
|
| 375 |
+
"DTE",
|
| 376 |
+
"ED",
|
| 377 |
+
"EIX",
|
| 378 |
+
"AEE",
|
| 379 |
+
"PEG",
|
| 380 |
+
"CMS",
|
| 381 |
+
"D",
|
| 382 |
+
"AEP",
|
| 383 |
+
"SRE",
|
| 384 |
+
"XEL",
|
| 385 |
+
"WEC",
|
| 386 |
+
"DTE",
|
| 387 |
+
# Materials
|
| 388 |
+
"LIN",
|
| 389 |
+
"APD",
|
| 390 |
+
"FCX",
|
| 391 |
+
"NEM",
|
| 392 |
+
"DOW",
|
| 393 |
+
"DD",
|
| 394 |
+
"NUE",
|
| 395 |
+
"STLD",
|
| 396 |
+
"X",
|
| 397 |
+
"AA",
|
| 398 |
+
"BLL",
|
| 399 |
+
"IP",
|
| 400 |
+
"PKG",
|
| 401 |
+
"WRK",
|
| 402 |
+
"SEE",
|
| 403 |
+
"BMS",
|
| 404 |
+
"ALB",
|
| 405 |
+
"LVS",
|
| 406 |
+
"WY",
|
| 407 |
+
"VMC",
|
| 408 |
+
# Communication Services
|
| 409 |
+
"GOOGL",
|
| 410 |
+
"META",
|
| 411 |
+
"NFLX",
|
| 412 |
+
"DIS",
|
| 413 |
+
"CMCSA",
|
| 414 |
+
"VZ",
|
| 415 |
+
"T",
|
| 416 |
+
"TMUS",
|
| 417 |
+
"CHTR",
|
| 418 |
+
"FOXA",
|
| 419 |
+
"NWSA",
|
| 420 |
+
"PARA",
|
| 421 |
+
"WBD",
|
| 422 |
+
"LYV",
|
| 423 |
+
"MTCH",
|
| 424 |
+
"SNAP",
|
| 425 |
+
"TWTR",
|
| 426 |
+
"PINS",
|
| 427 |
+
"SPOT",
|
| 428 |
+
"ZM",
|
| 429 |
+
# Additional Major Companies
|
| 430 |
+
"BRK-B",
|
| 431 |
+
"BRK-A",
|
| 432 |
+
"V",
|
| 433 |
+
"MA",
|
| 434 |
+
"PYPL",
|
| 435 |
+
"SQ",
|
| 436 |
+
"COIN",
|
| 437 |
+
"HOOD",
|
| 438 |
+
"RBLX",
|
| 439 |
+
"UBER",
|
| 440 |
+
"LYFT",
|
| 441 |
+
"DASH",
|
| 442 |
+
"ABNB",
|
| 443 |
+
"EXPE",
|
| 444 |
+
"BKNG",
|
| 445 |
+
"MAR",
|
| 446 |
+
"HLT",
|
| 447 |
+
"CCL",
|
| 448 |
+
"RCL",
|
| 449 |
+
"NCLH",
|
| 450 |
+
"SBUX",
|
| 451 |
+
"MCD",
|
| 452 |
+
"YUM",
|
| 453 |
+
"CMG",
|
| 454 |
+
"DPZ",
|
| 455 |
+
"PZZA",
|
| 456 |
+
"SHAK",
|
| 457 |
+
"WING",
|
| 458 |
+
"CHWY",
|
| 459 |
+
"PETM",
|
| 460 |
+
"TSCO",
|
| 461 |
+
"HD",
|
| 462 |
+
"LOW",
|
| 463 |
+
"TGT",
|
| 464 |
+
"COST",
|
| 465 |
+
"BJ",
|
| 466 |
+
"KR",
|
| 467 |
+
"WMT",
|
| 468 |
+
"AMZN",
|
| 469 |
+
"BABA",
|
| 470 |
+
"JD",
|
| 471 |
+
"PDD",
|
| 472 |
+
"TCEHY",
|
| 473 |
+
"BIDU",
|
| 474 |
+
"NTES",
|
| 475 |
+
"NIO",
|
| 476 |
+
"XPEV",
|
| 477 |
+
"LI",
|
| 478 |
+
"XP",
|
| 479 |
+
"DIDI",
|
| 480 |
+
"UBER",
|
| 481 |
+
"LYFT",
|
| 482 |
+
"DASH",
|
| 483 |
+
"ABNB",
|
| 484 |
+
"EXPE",
|
| 485 |
+
"BKNG",
|
| 486 |
+
"MAR",
|
| 487 |
+
"HLT",
|
| 488 |
+
"CCL",
|
| 489 |
+
"RCL",
|
| 490 |
]
|
| 491 |
|
| 492 |
+
print(f"Loading {len(fallback_ticker_list)} fallback tickers...")
|
| 493 |
|
| 494 |
# Get company names for each ticker
|
| 495 |
+
for ticker in fallback_ticker_list:
|
| 496 |
try:
|
| 497 |
ticker_obj = yf.Ticker(ticker)
|
| 498 |
info = ticker_obj.info
|
| 499 |
|
| 500 |
if info and (info.get("longName") or info.get("shortName")):
|
| 501 |
company_name = info.get("longName", info.get("shortName", ticker))
|
| 502 |
+
fallback_tickers[ticker] = company_name
|
| 503 |
|
| 504 |
except Exception as e:
|
| 505 |
# Skip tickers that cause errors
|
| 506 |
continue
|
| 507 |
|
| 508 |
+
print(f"Successfully loaded {len(fallback_tickers)} tickers from fallback")
|
| 509 |
+
return fallback_tickers
|
| 510 |
|
| 511 |
except Exception as e:
|
| 512 |
st.error(f"Error fetching available tickers: {e}")
|
|
|
|
| 516 |
"TSLA": "Tesla Inc.",
|
| 517 |
"MSFT": "Microsoft Corporation",
|
| 518 |
"GOOGL": "Alphabet Inc. (Google)",
|
| 519 |
+
"AMZN": "Amazon.com Inc.",
|
| 520 |
+
"META": "Meta Platforms Inc.",
|
| 521 |
+
"NVDA": "NVIDIA Corporation",
|
| 522 |
+
"JPM": "JPMorgan Chase & Co.",
|
| 523 |
+
"JNJ": "Johnson & Johnson",
|
| 524 |
+
"PG": "Procter & Gamble Co.",
|
| 525 |
}
|
| 526 |
|
| 527 |
|
test_prophet_accuracy.py
CHANGED
|
@@ -7,7 +7,7 @@ Trains Prophet model on given ticker data up to June 2025 and tests predictions
|
|
| 7 |
import yfinance as yf
|
| 8 |
import pandas as pd
|
| 9 |
from prophet import Prophet
|
| 10 |
-
from datetime import datetime
|
| 11 |
import numpy as np
|
| 12 |
from sklearn.metrics import (
|
| 13 |
mean_absolute_error,
|
|
|
|
| 7 |
import yfinance as yf
|
| 8 |
import pandas as pd
|
| 9 |
from prophet import Prophet
|
| 10 |
+
from datetime import datetime
|
| 11 |
import numpy as np
|
| 12 |
from sklearn.metrics import (
|
| 13 |
mean_absolute_error,
|