Spaces:
Running
Running
File size: 9,276 Bytes
1b020cf ea7820c 1b020cf ea7820c 1b020cf ea7820c 1b020cf ea7820c 1b020cf ea7820c 1b020cf ea7820c 1b020cf ea7820c 1b020cf ea7820c ea314d3 3b81cd2 ea7820c 1b020cf ea7820c 1b020cf 3b81cd2 ea7820c 1b020cf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
import React, { useState } from "react";
import "./App.css";
// π§© Company-to-Ticker mapping
const companyToTicker = {
"Agilent Technologies, Inc.": "A",
"AAALY": "AAALY",
"AAC": "AAC",
"AAC Technologies Holdings Inc.": "AACAY",
"American Airlines Group Inc.": "AAL",
"Atlantic American Corporation": "AAME",
"Applied Optoelectronics, Inc.": "AAOI",
"AAON, Inc.": "AAON",
"Advance Auto Parts, Inc.": "AAP",
"Apple Inc.": "AAPL",
"American Assets Trust, Inc.": "AAT",
"AAVL": "AAVL",
"AAWW": "AAWW",
"AllianceBernstein Holding L.P.": "AB",
"AbbVie Inc.": "ABBV",
"ABC": "ABC",
"Ameris Bancorp": "ABCB",
"Cambium Learning Group, Inc.": "ABCD",
"ABCO": "ABCO",
"Asbury Automotive Group, Inc.": "ABG",
"ABIO": "ABIO",
"American Biltrite Inc.": "ABLT",
"ABM Industries Incorporated": "ABM",
"ABMD": "ABMD",
"Arbor Realty Trust, Inc.": "ABR",
"Abbott Laboratories": "ABT",
"Aboitiz Equity Ventures, Inc.": "ABTZY",
"ACADIA Pharmaceuticals Inc.": "ACAD",
"Accor SA": "ACCYY",
"Air Canada": "ACDVF",
"Adicet Bio, Inc.": "ACET",
"ACFC": "ACFC",
"AMC Financial Holdings Inc.": "ACFL",
"Acorn Energy, Inc.": "ACFN",
"ACG": "ACG",
"Agricultural Bank of China Limited": "ACGBY",
"Arch Capital Group Ltd.": "ACGL",
"Acadia Healthcare Company, Inc.": "ACHC",
"ACHN": "ACHN",
"ACI Worldwide, Inc.": "ACIW",
"Axcelis Technologies, Inc.": "ACLS",
"Accenture plc": "ACN",
"ACNB Corporation": "ACNB",
"ACOR": "ACOR",
"Abrdn Income Credit Strategies Fund": "ACP",
"Ares Commercial Real Estate Corporation": "ACRE",
"ACRX": "ACRX",
"ACST": "ACST",
"Actua Corporation": "ACTA",
"Acacia Research Corporation": "ACTG",
"Acura Pharmaceuticals, Inc.": "ACUR",
"Acciona, S.A.": "ACXIF",
"Adobe Inc.": "ADBE",
"Agree Realty Corporation": "ADC",
"adidas AG": "ADDYY",
"Aida Engineering, Ltd.": "ADERY",
"ADES": "ADES",
"Analog Devices, Inc.": "ADI",
"Archer-Daniels-Midland Company": "ADM",
"ADMA Biologics, Inc.": "ADMA",
"ADMP": "ADMP",
"Automatic Data Processing, Inc.": "ADP",
"Adaptive Biotechnologies Corporation": "ADPT",
"Autodesk, Inc.": "ADSK",
"ADTRAN Holdings, Inc.": "ADTN",
"Addus HomeCare Corporation": "ADUS",
"Ayala Pharmaceuticals, Inc.": "ADXS",
"Ameren Corporation": "AEE",
"Aehr Test Systems, Inc.": "AEHR",
"Advanced Energy Industries, Inc.": "AEIS",
"AEL": "AEL",
"Adacel Technologies Limited": "AELTF",
"Agnico Eagle Mines Limited": "AEM",
"American Eagle Outfitters, Inc.": "AEO",
"American Electric Power Company, Inc.": "AEP",
"AerCap Holdings N.V.": "AER",
"AERI": "AERI",
"Aetna Inc.": "AET",
"AEY": "AEY",
"AEZS": "AEZS",
"AFAM": "AFAM",
"AllianceBernstein National Municipal Income Fund, Inc.": "AFB",
"Athens Bancshares Corporation": "AFCB",
"American Financial Group, Inc.": "AFG",
"Air France-KLM SA": "AFLYY",
"AFMD": "AFMD",
"AmTrust Financial Services, Inc.": "AFSI",
"AFT": "AFT",
"First Majestic Silver Corp.": "AG",
"Abrdn Global Dynamic Dividend Fund": "AGD",
"Agenus Inc.": "AGEN",
"Alamos Gold Inc.": "AGI",
"Agios Pharmaceuticals, Inc.": "AGIO",
"Federal Agricultural Mortgage Corporation": "AGM",
"AGNC Investment Corp.": "AGNC",
"Assured Guaranty Ltd.": "AGO",
"Agile Group Holdings Limited": "AGPYY",
"Adecoagro S.A.": "AGRO",
"AF Gruppen ASA": "AGRUF",
"AGRX": "AGRX",
"AGTC": "AGTC",
"Agilysys, Inc.": "AGYS",
"Aegean Airlines S.A.": "AGZNF",
"Anhui Conch Cement Company Limited": "AHCHY",
"AHGP": "AHGP",
"Armada Hoffler Properties, Inc.": "AHH",
"Asahi Kasei Corporation": "AHKSY",
"AHL": "AHL",
"Koninklijke Ahold Delhaize N.V.": "AHODF",
"AHPI": "AHPI",
"Ashford Hospitality Trust, Inc.": "AHT",
"C3.ai, Inc.": "AI",
"Aurubis AG": "AIAGF",
"AIF": "AIF",
"American International Group, Inc.": "AIG",
"AIMC": "AIMC",
"Albany International Corp.": "AIN",
"Airports of Thailand Public Company Limited": "AIPUY",
"Global X Artificial Intelligence & Technology ETF": "AIQ",
"Air Industries Group": "AIRI",
"Air T, Inc.": "AIRT",
"Applied Industrial Technologies, Inc.": "AIT",
"Apartment Investment and Management Company": "AIV",
"Assurant, Inc.": "AIZ",
"Arthur J. Gallagher & Co.": "AJG",
"Ajinomoto Co., Inc.": "AJINY",
"AJIS Co., Ltd.": "AJISF",
"Akamai Technologies, Inc.": "AKAM",
"Akebia Therapeutics, Inc.": "AKBA",
"Akbank T.A.S.": "AKBTY",
"Embotelladora Andina S.A.": "AKO-A",
"Acadia Realty Trust": "AKR",
"Akzo Nobel N.V.": "AKZOY",
"Albemarle Corporation": "ALB",
"Alpha Bank S.A.": "ALBKY",
"Alico, Inc.": "ALCO",
"Aldeyra Therapeutics, Inc.": "ALDX",
"Alexander & Baldwin, Inc.": "ALEX",
"Align Technology, Inc.": "ALGN",
"Allegiant Travel Company": "ALGT",
"ALIM": "ALIM",
"ALIOF": "ALIOF",
"Alaska Air Group, Inc.": "ALK",
"Alkermes plc": "ALKS",
"The Allstate Corporation": "ALL",
"Allegion plc": "ALLE",
"Allot Ltd.": "ALLT",
"Ally Financial Inc.": "ALLY",
"Alnylam Pharmaceuticals, Inc.": "ALNY",
"Analogic Corporation": "ALOG",
"Astellas Pharma Inc.": "ALPMY",
"ALR": "ALR",
"ALSD": "ALSD",
"Alstom SA": "ALSMY",
"Allison Transmission Holdings, Inc.": "ALSN",
"ALTR": "ALTR",
"Autoliv, Inc.": "ALV",
"Amadeus IT Group, S.A.": "AMADY",
"Applied Materials, Inc.": "AMAT",
"Ambarella, Inc.": "AMBA",
"Ambac Financial Group, Inc.": "AMBC",
"American Business Bank": "AMBZ",
"AMC Entertainment Holdings, Inc.": "AMC",
"Andatee China Marine Fuel Services Corporation": "AMCF",
"AMC Networks Inc.": "AMCX",
"Advanced Micro Devices, Inc.": "AMD",
"AMETEK, Inc.": "AME",
"Amedisys, Inc.": "AMED",
"Affiliated Managers Group, Inc.": "AMG",
"Amgen Inc.": "AMGN",
"American Homes 4 Rent": "AMH",
"Atrium Mortgage Investment Corporation": "AMIVF",
"A.P. Moller - Maersk A/S": "AMKBY",
"Amkor Technology, Inc.": "AMKR",
"AMNB": "AMNB",
"AMOT": "AMOT",
"Ameriprise Financial, Inc.": "AMP",
"Amphastar Pharmaceuticals, Inc.": "AMPH",
"Amarin Corporation plc": "AMRN",
"AMRS": "AMRS",
"American Superconductor Corporation": "AMSC",
"AMSWA": "AMSWA",
"American Tower Corporation": "AMT",
"AMTD IDEA Group": "AMTD",
"Aemetis, Inc.": "AMTX",
"American Woodmark Corporation": "AMWD",
"America Movil, S.A.B. de C.V.": "AMX",
"Amazon.com, Inc.": "AMZN",
"AutoNation, Inc.": "AN",
"ANAC": "ANAC",
"Anchor Bancorp": "ANCB",
"Access National Corporation": "ANCX",
"The Andersons, Inc.": "ANDE",
"Arista Networks Inc": "ANET",
"Abercrombie & Fitch Co.": "ANF",
"Angi Inc.": "ANGI",
"AngioDynamics, Inc.": "ANGO",
"Anika Therapeutics, Inc.": "ANIK",
"ANI Pharmaceuticals, Inc.": "ANIP",
"ANR": "ANR",
"Anthera Pharmaceuticals, Inc.": "ANTH",
"Sphere 3D Corp.": "ANY",
"Abrdn Total Dynamic Dividend Fund": "AOD",
"Aon plc": "AON"
};
// π§ Reverse mapping (Ticker β Company)
const tickerToCompany = Object.fromEntries(
Object.entries(companyToTicker).map(([k, v]) => [v, k])
);
function App() {
const [inputValue, setInputValue] = useState("");
const [ticker, setTicker] = useState("");
const [companyName, setCompanyName] = useState("");
const [forecast, setForecast] = useState("");
const [loading, setLoading] = useState(false);
// π Handle input (detect if company or ticker)
const handleInputChange = (e) => {
const value = e.target.value.trim();
setInputValue(value);
// Check if user entered a known company name
if (companyToTicker[value]) {
setTicker(companyToTicker[value]);
setCompanyName(value);
}
// Or if entered a known ticker
else if (tickerToCompany[value.toUpperCase()]) {
setTicker(value.toUpperCase());
setCompanyName(tickerToCompany[value.toUpperCase()]);
} else {
setTicker("");
setCompanyName("");
}
};
// π Call Gradio backend API
const handleForecast = async () => {
if (!ticker) {
setForecast("β οΈ Please enter a valid company name or ticker.");
return;
}
setLoading(true);
try {
const response = await fetch(
`${window.location.origin}/api/predict?ticker_symbol=${ticker}`
);
const data = await response.json();
setForecast(data || "No prediction result found.");
} catch (error) {
console.error(error);
setForecast("β Error fetching forecast from backend.");
} finally {
setLoading(false);
}
};
return (
<div className="App">
<h1>π Stock Price Forecaster (LSTM)</h1>
<p>Enter a company name or ticker to predict the next dayβs close price.</p>
<input
type="text"
placeholder="e.g., Apple Inc. or AAPL"
value={inputValue}
onChange={handleInputChange}
className="input-box"
/>
{companyName && ticker && (
<p className="info-text">
π’ <b>{companyName}</b> β πΉ <b>{ticker}</b>
</p>
)}
<button onClick={handleForecast} disabled={loading}>
{loading ? "Predicting..." : "Get Forecast"}
</button>
{forecast && (
<div className="result-box">
<h3>Prediction Result</h3>
<p>{forecast}</p>
</div>
)}
</div>
);
}
export default App;
|