Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -127,21 +127,21 @@ def download_data(tickers, start_date, end_date, interval, output_dir):
|
|
| 127 |
"""
|
| 128 |
downloaded = []
|
| 129 |
os.makedirs(output_dir, exist_ok=True)
|
| 130 |
-
|
| 131 |
-
|
|
|
|
| 132 |
try:
|
| 133 |
stock = yf.Ticker(ticker)
|
| 134 |
data = stock.history(
|
| 135 |
start=start_date, end=end_date, interval=interval)
|
| 136 |
-
if data.empty:
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
st.error(f"Error downloading data for {ticker}: {e}")
|
| 145 |
return downloaded
|
| 146 |
|
| 147 |
# -----------------------------
|
|
@@ -197,22 +197,41 @@ def main():
|
|
| 197 |
st.header("Controls")
|
| 198 |
|
| 199 |
# Exclude the "test" group
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
# Date Range Selection
|
| 218 |
default_end = date.today()
|
|
@@ -475,7 +494,8 @@ def main():
|
|
| 475 |
if show_var:
|
| 476 |
var = predictor.calculate_var(
|
| 477 |
combined_data[ticker])
|
| 478 |
-
st.write(
|
|
|
|
| 479 |
if show_patterns or show_breakouts:
|
| 480 |
ticker_data = load_ticker_data(output_dir, ticker)
|
| 481 |
if ticker_data is not None:
|
|
@@ -525,8 +545,8 @@ def main():
|
|
| 525 |
- Data is downloaded automatically.
|
| 526 |
|
| 527 |
3. **Configure Predictives & Risk Tools** 🤖📊
|
| 528 |
-
-
|
| 529 |
-
-
|
| 530 |
- Configure these tools to complement your overall technical analysis.
|
| 531 |
|
| 532 |
4. **Enhance Your Analysis with Indicators** ⚙️
|
|
|
|
| 127 |
"""
|
| 128 |
downloaded = []
|
| 129 |
os.makedirs(output_dir, exist_ok=True)
|
| 130 |
+
|
| 131 |
+
progress_bar = st.progress(0)
|
| 132 |
+
for i, ticker in enumerate(tickers):
|
| 133 |
try:
|
| 134 |
stock = yf.Ticker(ticker)
|
| 135 |
data = stock.history(
|
| 136 |
start=start_date, end=end_date, interval=interval)
|
| 137 |
+
if not data.empty:
|
| 138 |
+
output_file = os.path.join(output_dir, f"{ticker}.csv")
|
| 139 |
+
data.to_csv(output_file)
|
| 140 |
+
downloaded.append(ticker)
|
| 141 |
+
except Exception:
|
| 142 |
+
pass
|
| 143 |
+
progress_bar.progress((i + 1) / len(tickers))
|
| 144 |
+
progress_bar.empty()
|
|
|
|
| 145 |
return downloaded
|
| 146 |
|
| 147 |
# -----------------------------
|
|
|
|
| 197 |
st.header("Controls")
|
| 198 |
|
| 199 |
# Exclude the "test" group
|
| 200 |
+
# Direct Ticker Input
|
| 201 |
+
ticker_input = st.text_input('Enter Ticker Symbol (e.g., AAPL):')
|
| 202 |
+
|
| 203 |
+
# Optional Asset Group Selection
|
| 204 |
+
use_groups = st.checkbox('Or select from predefined groups')
|
| 205 |
+
|
| 206 |
+
selected_tickers = []
|
| 207 |
+
|
| 208 |
+
if ticker_input:
|
| 209 |
+
selected_tickers.append(ticker_input.upper().strip())
|
| 210 |
+
|
| 211 |
+
if use_groups:
|
| 212 |
+
|
| 213 |
+
available_groups = [grp for grp in market_config.get(
|
| 214 |
+
'groups', {}).keys() if grp.lower() != "test"]
|
| 215 |
+
|
| 216 |
+
selected_groups = st.multiselect(
|
| 217 |
+
"Select Asset Groups", available_groups)
|
| 218 |
+
|
| 219 |
+
# Build the union of tickers from the selected groups
|
| 220 |
+
|
| 221 |
+
group_tickers = []
|
| 222 |
+
|
| 223 |
+
for group in selected_groups:
|
| 224 |
+
|
| 225 |
+
group_tickers.extend(market_config['groups'][group])
|
| 226 |
+
|
| 227 |
+
group_tickers = sorted(set(group_tickers))
|
| 228 |
+
|
| 229 |
+
if group_tickers:
|
| 230 |
+
|
| 231 |
+
group_selected = st.multiselect(
|
| 232 |
+
"Select Additional Tickers from Groups:", group_tickers)
|
| 233 |
+
|
| 234 |
+
selected_tickers.extend(group_selected)
|
| 235 |
|
| 236 |
# Date Range Selection
|
| 237 |
default_end = date.today()
|
|
|
|
| 494 |
if show_var:
|
| 495 |
var = predictor.calculate_var(
|
| 496 |
combined_data[ticker])
|
| 497 |
+
st.write(
|
| 498 |
+
f"Value at Risk (95%) for {ticker}: {var:.2%}")
|
| 499 |
if show_patterns or show_breakouts:
|
| 500 |
ticker_data = load_ticker_data(output_dir, ticker)
|
| 501 |
if ticker_data is not None:
|
|
|
|
| 545 |
- Data is downloaded automatically.
|
| 546 |
|
| 547 |
3. **Configure Predictives & Risk Tools** 🤖📊
|
| 548 |
+
- Predictive models combine historical data with real-time market signals to forecast trends—helping anticipate price movements and spot emerging opportunities.
|
| 549 |
+
- Risk analysis tools compute key metrics like Value at Risk (VaR) and perform stress tests to evaluate potential losses, giving critical insights into risk exposure.
|
| 550 |
- Configure these tools to complement your overall technical analysis.
|
| 551 |
|
| 552 |
4. **Enhance Your Analysis with Indicators** ⚙️
|