mcli-framework 7.3.1__py3-none-any.whl → 7.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mcli-framework might be problematic. Click here for more details.
- mcli/app/commands_cmd.py +741 -0
- mcli/lib/auth/aws_manager.py +9 -64
- mcli/lib/auth/azure_manager.py +9 -64
- mcli/lib/auth/credential_manager.py +70 -1
- mcli/lib/auth/gcp_manager.py +11 -64
- mcli/ml/dashboard/app.py +6 -39
- mcli/ml/dashboard/app_integrated.py +288 -117
- mcli/ml/dashboard/app_supabase.py +8 -57
- mcli/ml/dashboard/app_training.py +10 -12
- mcli/ml/dashboard/common.py +167 -0
- mcli/ml/dashboard/overview.py +378 -0
- mcli/ml/dashboard/pages/cicd.py +4 -4
- mcli/ml/dashboard/pages/debug_dependencies.py +406 -0
- mcli/ml/dashboard/pages/gravity_viz.py +783 -0
- mcli/ml/dashboard/pages/monte_carlo_predictions.py +555 -0
- mcli/ml/dashboard/pages/predictions_enhanced.py +4 -2
- mcli/ml/dashboard/pages/scrapers_and_logs.py +25 -9
- mcli/ml/dashboard/pages/test_portfolio.py +54 -4
- mcli/ml/dashboard/pages/trading.py +80 -26
- mcli/ml/dashboard/streamlit_extras_utils.py +297 -0
- mcli/ml/dashboard/styles.py +55 -0
- mcli/ml/dashboard/utils.py +7 -0
- mcli/ml/dashboard/warning_suppression.py +34 -0
- mcli/ml/database/session.py +169 -16
- mcli/ml/predictions/monte_carlo.py +428 -0
- mcli/ml/trading/alpaca_client.py +82 -18
- mcli/self/self_cmd.py +182 -737
- {mcli_framework-7.3.1.dist-info → mcli_framework-7.5.0.dist-info}/METADATA +2 -3
- {mcli_framework-7.3.1.dist-info → mcli_framework-7.5.0.dist-info}/RECORD +33 -87
- mcli/__init__.py +0 -160
- mcli/__main__.py +0 -14
- mcli/app/__init__.py +0 -23
- mcli/app/model/__init__.py +0 -0
- mcli/app/video/__init__.py +0 -5
- mcli/chat/__init__.py +0 -34
- mcli/lib/__init__.py +0 -0
- mcli/lib/api/__init__.py +0 -0
- mcli/lib/auth/__init__.py +0 -1
- mcli/lib/config/__init__.py +0 -1
- mcli/lib/erd/__init__.py +0 -25
- mcli/lib/files/__init__.py +0 -0
- mcli/lib/fs/__init__.py +0 -1
- mcli/lib/logger/__init__.py +0 -3
- mcli/lib/performance/__init__.py +0 -17
- mcli/lib/pickles/__init__.py +0 -1
- mcli/lib/shell/__init__.py +0 -0
- mcli/lib/toml/__init__.py +0 -1
- mcli/lib/watcher/__init__.py +0 -0
- mcli/ml/__init__.py +0 -16
- mcli/ml/api/__init__.py +0 -30
- mcli/ml/api/routers/__init__.py +0 -27
- mcli/ml/auth/__init__.py +0 -45
- mcli/ml/backtesting/__init__.py +0 -39
- mcli/ml/cli/__init__.py +0 -5
- mcli/ml/config/__init__.py +0 -33
- mcli/ml/configs/__init__.py +0 -16
- mcli/ml/dashboard/__init__.py +0 -12
- mcli/ml/dashboard/components/__init__.py +0 -7
- mcli/ml/dashboard/pages/__init__.py +0 -6
- mcli/ml/data_ingestion/__init__.py +0 -39
- mcli/ml/database/__init__.py +0 -47
- mcli/ml/experimentation/__init__.py +0 -29
- mcli/ml/features/__init__.py +0 -39
- mcli/ml/mlops/__init__.py +0 -33
- mcli/ml/models/__init__.py +0 -94
- mcli/ml/monitoring/__init__.py +0 -25
- mcli/ml/optimization/__init__.py +0 -27
- mcli/ml/predictions/__init__.py +0 -5
- mcli/ml/preprocessing/__init__.py +0 -28
- mcli/ml/scripts/__init__.py +0 -1
- mcli/ml/trading/__init__.py +0 -60
- mcli/ml/training/__init__.py +0 -10
- mcli/mygroup/__init__.py +0 -3
- mcli/public/__init__.py +0 -1
- mcli/public/commands/__init__.py +0 -2
- mcli/self/__init__.py +0 -3
- mcli/workflow/__init__.py +0 -0
- mcli/workflow/daemon/__init__.py +0 -15
- mcli/workflow/dashboard/__init__.py +0 -5
- mcli/workflow/docker/__init__.py +0 -0
- mcli/workflow/file/__init__.py +0 -0
- mcli/workflow/gcloud/__init__.py +0 -1
- mcli/workflow/git_commit/__init__.py +0 -0
- mcli/workflow/interview/__init__.py +0 -0
- mcli/workflow/politician_trading/__init__.py +0 -4
- mcli/workflow/registry/__init__.py +0 -0
- mcli/workflow/repo/__init__.py +0 -0
- mcli/workflow/scheduler/__init__.py +0 -25
- mcli/workflow/search/__init__.py +0 -0
- mcli/workflow/sync/__init__.py +0 -5
- mcli/workflow/videos/__init__.py +0 -1
- mcli/workflow/wakatime/__init__.py +0 -80
- {mcli_framework-7.3.1.dist-info → mcli_framework-7.5.0.dist-info}/WHEEL +0 -0
- {mcli_framework-7.3.1.dist-info → mcli_framework-7.5.0.dist-info}/entry_points.txt +0 -0
- {mcli_framework-7.3.1.dist-info → mcli_framework-7.5.0.dist-info}/licenses/LICENSE +0 -0
- {mcli_framework-7.3.1.dist-info → mcli_framework-7.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Common utilities for MCLI ML Dashboards.
|
|
3
|
+
|
|
4
|
+
This module provides shared functionality across all dashboard variants to avoid code duplication.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import warnings
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Optional
|
|
11
|
+
|
|
12
|
+
import streamlit as st
|
|
13
|
+
from dotenv import load_dotenv
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def suppress_streamlit_warnings():
|
|
17
|
+
"""
|
|
18
|
+
Suppress common Streamlit, Plotly, and media file warnings.
|
|
19
|
+
|
|
20
|
+
Call this at the top of your dashboard file before importing other modules.
|
|
21
|
+
"""
|
|
22
|
+
# Suppress Streamlit warnings when used outside runtime context
|
|
23
|
+
warnings.filterwarnings("ignore", message=".*missing ScriptRunContext.*")
|
|
24
|
+
warnings.filterwarnings("ignore", message=".*No runtime found.*")
|
|
25
|
+
warnings.filterwarnings("ignore", message=".*Session state does not function.*")
|
|
26
|
+
warnings.filterwarnings("ignore", message=".*to view this Streamlit app.*")
|
|
27
|
+
|
|
28
|
+
# Suppress Plotly deprecation warnings
|
|
29
|
+
warnings.filterwarnings("ignore", message=".*keyword arguments have been deprecated.*")
|
|
30
|
+
warnings.filterwarnings("ignore", message=".*Use `config` instead.*")
|
|
31
|
+
|
|
32
|
+
# Suppress media file errors
|
|
33
|
+
warnings.filterwarnings("ignore", message=".*MediaFileHandler.*")
|
|
34
|
+
warnings.filterwarnings("ignore", message=".*Missing file.*")
|
|
35
|
+
warnings.filterwarnings("ignore", message=".*Bad filename.*")
|
|
36
|
+
|
|
37
|
+
# Suppress general warnings
|
|
38
|
+
warnings.filterwarnings("ignore", category=UserWarning)
|
|
39
|
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
40
|
+
|
|
41
|
+
# Suppress specific Streamlit media file errors in logging
|
|
42
|
+
import logging
|
|
43
|
+
|
|
44
|
+
logging.getLogger("streamlit.runtime.media_file_storage").setLevel(logging.ERROR)
|
|
45
|
+
logging.getLogger("streamlit.web.server.media_file_handler").setLevel(logging.ERROR)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def setup_page_config(
|
|
49
|
+
page_title: str = "MCLI ML Dashboard",
|
|
50
|
+
page_icon: str = "📊",
|
|
51
|
+
layout: str = "wide",
|
|
52
|
+
initial_sidebar_state: str = "expanded",
|
|
53
|
+
):
|
|
54
|
+
"""
|
|
55
|
+
Configure Streamlit page with standard settings.
|
|
56
|
+
|
|
57
|
+
IMPORTANT: This must be called before any other Streamlit commands.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
page_title: Title shown in browser tab
|
|
61
|
+
page_icon: Emoji or image icon
|
|
62
|
+
layout: "wide" or "centered"
|
|
63
|
+
initial_sidebar_state: "expanded" or "collapsed"
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
from mcli.ml.dashboard.common import setup_page_config
|
|
67
|
+
|
|
68
|
+
setup_page_config(page_title="ML Training Dashboard")
|
|
69
|
+
"""
|
|
70
|
+
st.set_page_config(
|
|
71
|
+
page_title=page_title,
|
|
72
|
+
page_icon=page_icon,
|
|
73
|
+
layout=layout,
|
|
74
|
+
initial_sidebar_state=initial_sidebar_state,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@st.cache_resource
|
|
79
|
+
def get_supabase_client():
|
|
80
|
+
"""
|
|
81
|
+
Get cached Supabase client with automatic credential detection.
|
|
82
|
+
|
|
83
|
+
Tries multiple sources in order:
|
|
84
|
+
1. Streamlit Cloud secrets (for deployed apps)
|
|
85
|
+
2. Environment variables (for local development)
|
|
86
|
+
3. .env.local file in supabase directory
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
Supabase Client instance or None if credentials not found
|
|
90
|
+
|
|
91
|
+
Example:
|
|
92
|
+
from mcli.ml.dashboard.common import get_supabase_client
|
|
93
|
+
|
|
94
|
+
client = get_supabase_client()
|
|
95
|
+
if client:
|
|
96
|
+
data = client.table('politicians').select('*').execute()
|
|
97
|
+
"""
|
|
98
|
+
from supabase import Client, create_client
|
|
99
|
+
|
|
100
|
+
# Try Streamlit secrets first (for Streamlit Cloud)
|
|
101
|
+
url = ""
|
|
102
|
+
key = ""
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
url = st.secrets.get("SUPABASE_URL", "")
|
|
106
|
+
key = st.secrets.get("SUPABASE_KEY", "") or st.secrets.get("SUPABASE_SERVICE_ROLE_KEY", "")
|
|
107
|
+
except (AttributeError, FileNotFoundError, KeyError):
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
# Fall back to environment variables (for local dev)
|
|
111
|
+
if not url or not key:
|
|
112
|
+
url = os.getenv("SUPABASE_URL", "")
|
|
113
|
+
key = os.getenv("SUPABASE_KEY", "") or os.getenv("SUPABASE_SERVICE_ROLE_KEY", "")
|
|
114
|
+
|
|
115
|
+
# Try loading from .env.local in supabase directory
|
|
116
|
+
if not url or not key:
|
|
117
|
+
env_path = Path(__file__).parent.parent.parent.parent.parent / "supabase" / ".env.local"
|
|
118
|
+
if env_path.exists():
|
|
119
|
+
load_dotenv(env_path)
|
|
120
|
+
url = os.getenv("SUPABASE_URL", "")
|
|
121
|
+
key = os.getenv("SUPABASE_KEY", "") or os.getenv("SUPABASE_SERVICE_ROLE_KEY", "")
|
|
122
|
+
|
|
123
|
+
if not url or not key:
|
|
124
|
+
st.warning(
|
|
125
|
+
"⚠️ Supabase credentials not found. Configure SUPABASE_URL and SUPABASE_KEY "
|
|
126
|
+
"in Streamlit Cloud secrets or environment variables."
|
|
127
|
+
)
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
try:
|
|
131
|
+
client = create_client(url, key)
|
|
132
|
+
|
|
133
|
+
# Test connection with a simple query
|
|
134
|
+
try:
|
|
135
|
+
# Try politicians table first (most common)
|
|
136
|
+
client.table("politicians").select("id").limit(1).execute()
|
|
137
|
+
except Exception:
|
|
138
|
+
# If politicians table doesn't exist, try another table
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
return client
|
|
142
|
+
except Exception as e:
|
|
143
|
+
st.error(f"❌ Failed to create Supabase client: {e}")
|
|
144
|
+
return None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def load_environment_variables():
|
|
148
|
+
"""
|
|
149
|
+
Load environment variables from various sources.
|
|
150
|
+
|
|
151
|
+
Tries loading from:
|
|
152
|
+
1. Current directory .env file
|
|
153
|
+
2. Parent supabase/.env.local file
|
|
154
|
+
|
|
155
|
+
Example:
|
|
156
|
+
from mcli.ml.dashboard.common import load_environment_variables
|
|
157
|
+
|
|
158
|
+
load_environment_variables()
|
|
159
|
+
api_key = os.getenv("API_KEY")
|
|
160
|
+
"""
|
|
161
|
+
# Try current directory
|
|
162
|
+
load_dotenv()
|
|
163
|
+
|
|
164
|
+
# Try supabase directory
|
|
165
|
+
env_path = Path(__file__).parent.parent.parent.parent.parent / "supabase" / ".env.local"
|
|
166
|
+
if env_path.exists():
|
|
167
|
+
load_dotenv(env_path)
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"""Overview page - Introduction to the Politician Trading Tracker"""
|
|
2
|
+
|
|
3
|
+
import streamlit as st
|
|
4
|
+
|
|
5
|
+
# Try to import streamlit-extras for enhanced UI
|
|
6
|
+
try:
|
|
7
|
+
from mcli.ml.dashboard.streamlit_extras_utils import (
|
|
8
|
+
section_header,
|
|
9
|
+
info_card,
|
|
10
|
+
vertical_space,
|
|
11
|
+
)
|
|
12
|
+
HAS_EXTRAS = True
|
|
13
|
+
except ImportError:
|
|
14
|
+
HAS_EXTRAS = False
|
|
15
|
+
section_header = lambda label, desc="", **kwargs: st.header(label)
|
|
16
|
+
info_card = None
|
|
17
|
+
vertical_space = lambda x: st.write("")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def show_overview():
|
|
21
|
+
"""Main overview page"""
|
|
22
|
+
|
|
23
|
+
# Hero section
|
|
24
|
+
st.markdown(
|
|
25
|
+
"""
|
|
26
|
+
<div style='text-align: center; padding: 2rem 0;'>
|
|
27
|
+
<h1 style='color: #1f77b4; font-size: 3rem; margin-bottom: 0.5rem;'>
|
|
28
|
+
📊 Politician Trading Tracker
|
|
29
|
+
</h1>
|
|
30
|
+
<h3 style='color: #666; font-weight: normal;'>
|
|
31
|
+
Track, Analyze & Replicate Congressional Trading Patterns
|
|
32
|
+
</h3>
|
|
33
|
+
</div>
|
|
34
|
+
""",
|
|
35
|
+
unsafe_allow_html=True
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
st.markdown("---")
|
|
39
|
+
|
|
40
|
+
# What is this?
|
|
41
|
+
section_header(
|
|
42
|
+
"🎯 What is Politician Trading Tracker?",
|
|
43
|
+
"Your comprehensive tool for analyzing Congressional stock trades",
|
|
44
|
+
divider="blue"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
st.markdown("""
|
|
48
|
+
This dashboard provides **real-time access** to Congressional stock trading disclosures,
|
|
49
|
+
allowing you to track when U.S. politicians buy and sell stocks, analyze their patterns,
|
|
50
|
+
and make informed investment decisions.
|
|
51
|
+
|
|
52
|
+
### Why Track Politician Trading?
|
|
53
|
+
|
|
54
|
+
📈 **Historical Outperformance**: Studies show Congressional portfolios often outperform the market
|
|
55
|
+
🔍 **Early Insights**: Politicians may have access to non-public information through briefings
|
|
56
|
+
💡 **Smart Money**: Following experienced investors can inform your strategy
|
|
57
|
+
📊 **Transparency**: Make use of public disclosure data for better decisions
|
|
58
|
+
""")
|
|
59
|
+
|
|
60
|
+
vertical_space(2)
|
|
61
|
+
|
|
62
|
+
# Key Features
|
|
63
|
+
section_header(
|
|
64
|
+
"✨ Key Features",
|
|
65
|
+
"Powerful tools for trading analysis",
|
|
66
|
+
divider="green"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
col1, col2, col3 = st.columns(3)
|
|
70
|
+
|
|
71
|
+
with col1:
|
|
72
|
+
st.markdown("""
|
|
73
|
+
### 📊 Data Tracking
|
|
74
|
+
- **Real-time updates** from official sources
|
|
75
|
+
- **Historical data** going back years
|
|
76
|
+
- **Multiple sources**: Senate, House, Senate Stock Watcher
|
|
77
|
+
- **Automated scraping** for latest disclosures
|
|
78
|
+
""")
|
|
79
|
+
|
|
80
|
+
with col2:
|
|
81
|
+
st.markdown("""
|
|
82
|
+
### 🤖 ML Predictions
|
|
83
|
+
- **Machine learning models** for stock prediction
|
|
84
|
+
- **Monte Carlo simulations** for risk analysis
|
|
85
|
+
- **Pattern recognition** in trading behavior
|
|
86
|
+
- **Price forecasting** based on historical data
|
|
87
|
+
""")
|
|
88
|
+
|
|
89
|
+
with col3:
|
|
90
|
+
st.markdown("""
|
|
91
|
+
### 💼 Trading Tools
|
|
92
|
+
- **Paper trading** integration (Alpaca)
|
|
93
|
+
- **Portfolio tracking** and management
|
|
94
|
+
- **Risk assessment** tools
|
|
95
|
+
- **Performance analytics**
|
|
96
|
+
""")
|
|
97
|
+
|
|
98
|
+
vertical_space(2)
|
|
99
|
+
|
|
100
|
+
# Quick Start Guide
|
|
101
|
+
section_header(
|
|
102
|
+
"🚀 Quick Start Guide",
|
|
103
|
+
"Get started in 3 easy steps",
|
|
104
|
+
divider="violet"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
st.markdown("""
|
|
108
|
+
### Step 1: Explore Trading Data
|
|
109
|
+
|
|
110
|
+
👉 Navigate to **"Scrapers & Logs"** to:
|
|
111
|
+
- View recent politician stock disclosures
|
|
112
|
+
- Search for specific politicians or stocks
|
|
113
|
+
- See transaction details (buy/sell amounts, dates)
|
|
114
|
+
- Export data for further analysis
|
|
115
|
+
|
|
116
|
+
### Step 2: Analyze with ML
|
|
117
|
+
|
|
118
|
+
👉 Go to **"Predictions"** or **"Monte Carlo Predictions"** to:
|
|
119
|
+
- See ML-generated stock predictions based on politician trades
|
|
120
|
+
- Run Monte Carlo simulations for risk analysis
|
|
121
|
+
- View expected returns and probability of profit
|
|
122
|
+
- Understand confidence intervals
|
|
123
|
+
|
|
124
|
+
### Step 3: Track Your Portfolio
|
|
125
|
+
|
|
126
|
+
👉 Use **"Trading Dashboard"** or **"Test Portfolio"** to:
|
|
127
|
+
- Create paper trading portfolios
|
|
128
|
+
- Replicate politician trades
|
|
129
|
+
- Track your performance
|
|
130
|
+
- Compare to market benchmarks
|
|
131
|
+
""")
|
|
132
|
+
|
|
133
|
+
vertical_space(2)
|
|
134
|
+
|
|
135
|
+
# Page Navigation Guide
|
|
136
|
+
section_header(
|
|
137
|
+
"🗺️ Page Navigation Guide",
|
|
138
|
+
"Explore all available features",
|
|
139
|
+
divider="orange"
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
# Create expandable sections for each page category
|
|
143
|
+
with st.expander("📊 **Data & Monitoring Pages**", expanded=True):
|
|
144
|
+
st.markdown("""
|
|
145
|
+
- **Pipeline Overview**: System status and data processing metrics
|
|
146
|
+
- **Scrapers & Logs**: Manual and automated data collection from government sources
|
|
147
|
+
- **System Health**: Monitor data pipeline health and API connections
|
|
148
|
+
- **LSH Jobs**: Background job status and processing queues
|
|
149
|
+
""")
|
|
150
|
+
|
|
151
|
+
with st.expander("🤖 **ML & Predictions Pages**"):
|
|
152
|
+
st.markdown("""
|
|
153
|
+
- **Predictions**: Enhanced ML predictions based on politician trading patterns
|
|
154
|
+
- **Monte Carlo Predictions**: Probabilistic simulation of price paths and returns
|
|
155
|
+
- **Model Performance**: Evaluation metrics for ML models
|
|
156
|
+
- **Model Training & Evaluation**: Train new models and compare performance
|
|
157
|
+
""")
|
|
158
|
+
|
|
159
|
+
with st.expander("💼 **Trading & Portfolio Pages**"):
|
|
160
|
+
st.markdown("""
|
|
161
|
+
- **Trading Dashboard**: Full-featured paper trading interface
|
|
162
|
+
- **Test Portfolio**: Simplified portfolio testing and tracking
|
|
163
|
+
- **Paper trading** via Alpaca API integration
|
|
164
|
+
- Track performance against politician portfolios
|
|
165
|
+
""")
|
|
166
|
+
|
|
167
|
+
with st.expander("⚙️ **Technical & DevOps Pages**"):
|
|
168
|
+
st.markdown("""
|
|
169
|
+
- **CI/CD Pipelines**: Monitor build and deployment pipelines
|
|
170
|
+
- **Workflows**: Track automated workflow executions
|
|
171
|
+
- **ML Processing**: Data preprocessing and feature engineering
|
|
172
|
+
- **Debug Dependencies**: Troubleshoot installation and import issues (useful for alpaca-py debugging)
|
|
173
|
+
""")
|
|
174
|
+
|
|
175
|
+
vertical_space(2)
|
|
176
|
+
|
|
177
|
+
# FAQ Section
|
|
178
|
+
section_header(
|
|
179
|
+
"❓ Frequently Asked Questions",
|
|
180
|
+
"Common questions answered",
|
|
181
|
+
divider="gray"
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
with st.expander("**Q: Is this legal? Can I really track politician trades?**"):
|
|
185
|
+
st.markdown("""
|
|
186
|
+
**A:** Yes, absolutely! The STOCK Act (Stop Trading on Congressional Knowledge Act)
|
|
187
|
+
requires members of Congress to publicly disclose their stock trades within 45 days.
|
|
188
|
+
This app aggregates and analyzes publicly available data.
|
|
189
|
+
|
|
190
|
+
All data comes from official sources:
|
|
191
|
+
- Senate eFiling system
|
|
192
|
+
- House Financial Disclosure reports
|
|
193
|
+
- Senate Stock Watcher (GitHub dataset)
|
|
194
|
+
""")
|
|
195
|
+
|
|
196
|
+
with st.expander("**Q: How recent is the data?**"):
|
|
197
|
+
st.markdown("""
|
|
198
|
+
**A:** Data freshness depends on the source:
|
|
199
|
+
|
|
200
|
+
- **Senate Stock Watcher**: Updated daily from official sources
|
|
201
|
+
- **Manual scrapers**: Run on-demand for latest disclosures
|
|
202
|
+
- **Automated jobs**: Process new filings regularly
|
|
203
|
+
|
|
204
|
+
Note: Due to the 45-day disclosure requirement, trades are not real-time.
|
|
205
|
+
You're seeing what politicians bought/sold 1-6 weeks ago.
|
|
206
|
+
""")
|
|
207
|
+
|
|
208
|
+
with st.expander("**Q: Can I actually trade based on this data?**"):
|
|
209
|
+
st.markdown("""
|
|
210
|
+
**A:** Yes! The dashboard includes:
|
|
211
|
+
|
|
212
|
+
- **Paper Trading**: Practice with virtual money via Alpaca paper trading API
|
|
213
|
+
- **Real Trading Integration**: Configure real Alpaca account (at your own risk)
|
|
214
|
+
- **Portfolio Tracking**: Monitor your replicated politician portfolios
|
|
215
|
+
|
|
216
|
+
⚠️ **Important Disclaimers:**
|
|
217
|
+
- Past performance doesn't guarantee future results
|
|
218
|
+
- Politician trades are disclosed 45 days late
|
|
219
|
+
- This is for educational/informational purposes
|
|
220
|
+
- Always do your own research before investing
|
|
221
|
+
""")
|
|
222
|
+
|
|
223
|
+
with st.expander("**Q: Which politicians can I track?**"):
|
|
224
|
+
st.markdown("""
|
|
225
|
+
**A:** The dashboard tracks:
|
|
226
|
+
|
|
227
|
+
- All U.S. Senators
|
|
228
|
+
- All U.S. Representatives
|
|
229
|
+
- High-profile traders (Pelosi, McConnell, etc.)
|
|
230
|
+
- Committee members with oversight of industries
|
|
231
|
+
|
|
232
|
+
Search by name in the **Predictions** or **Scrapers & Logs** pages.
|
|
233
|
+
""")
|
|
234
|
+
|
|
235
|
+
with st.expander("**Q: How do the ML predictions work?**"):
|
|
236
|
+
st.markdown("""
|
|
237
|
+
**A:** The system uses multiple techniques:
|
|
238
|
+
|
|
239
|
+
1. **Historical Pattern Analysis**: Identifies successful trading patterns
|
|
240
|
+
2. **Feature Engineering**: Incorporates politician profile, committee assignments, transaction size
|
|
241
|
+
3. **Machine Learning Models**: Trains on historical data to predict outcomes
|
|
242
|
+
4. **Monte Carlo Simulation**: Models thousands of possible price paths
|
|
243
|
+
5. **Risk Metrics**: Calculates probability of profit, Value at Risk, confidence intervals
|
|
244
|
+
|
|
245
|
+
See the **Model Training & Evaluation** page for technical details.
|
|
246
|
+
""")
|
|
247
|
+
|
|
248
|
+
with st.expander("**Q: What data sources does this use?**"):
|
|
249
|
+
st.markdown("""
|
|
250
|
+
**A:** Multiple official and curated sources:
|
|
251
|
+
|
|
252
|
+
**Primary Sources:**
|
|
253
|
+
- Senate eFiling system (senate.gov)
|
|
254
|
+
- House Financial Disclosure (clerk.house.gov)
|
|
255
|
+
- Senate Stock Watcher GitHub (curated dataset)
|
|
256
|
+
|
|
257
|
+
**Supporting Data:**
|
|
258
|
+
- UK Companies House API (for UK company data)
|
|
259
|
+
- Yahoo Finance (for stock prices and fundamentals)
|
|
260
|
+
- Alpaca API (for trading and market data)
|
|
261
|
+
""")
|
|
262
|
+
|
|
263
|
+
with st.expander("**Q: Is my trading data private?**"):
|
|
264
|
+
st.markdown("""
|
|
265
|
+
**A:** Yes! This is a personal dashboard:
|
|
266
|
+
|
|
267
|
+
- Paper trading portfolios are stored locally or in your Supabase instance
|
|
268
|
+
- No trading data is shared publicly
|
|
269
|
+
- API keys are stored securely in Streamlit secrets
|
|
270
|
+
- You control your own data
|
|
271
|
+
""")
|
|
272
|
+
|
|
273
|
+
with st.expander("**Q: What if I find a bug or have a feature request?**"):
|
|
274
|
+
st.markdown("""
|
|
275
|
+
**A:** Contributions welcome!
|
|
276
|
+
|
|
277
|
+
- **Report bugs**: Open an issue on GitHub
|
|
278
|
+
- **Request features**: Submit feature requests
|
|
279
|
+
- **Contribute**: Pull requests accepted
|
|
280
|
+
- **Documentation**: Help improve the docs
|
|
281
|
+
|
|
282
|
+
This is an open-source project built for the community.
|
|
283
|
+
""")
|
|
284
|
+
|
|
285
|
+
with st.expander("**Q: Why are some pages showing errors or not loading?**"):
|
|
286
|
+
st.markdown("""
|
|
287
|
+
**A:** Some pages require optional dependencies that may not be installed:
|
|
288
|
+
|
|
289
|
+
**Common Issues:**
|
|
290
|
+
- **Trading Dashboard/Test Portfolio**: Requires `alpaca-py` package
|
|
291
|
+
- **Advanced ML pages**: May require `torch` or `pytorch-lightning` (not available on Streamlit Cloud)
|
|
292
|
+
|
|
293
|
+
**Troubleshooting:**
|
|
294
|
+
1. Check the error message displayed at the top of the dashboard
|
|
295
|
+
2. Visit the **Debug Dependencies** page for detailed diagnostics
|
|
296
|
+
3. The Debug page shows:
|
|
297
|
+
- Which packages are installed
|
|
298
|
+
- Detailed import error messages
|
|
299
|
+
- Python environment information
|
|
300
|
+
- Troubleshooting suggestions
|
|
301
|
+
|
|
302
|
+
**Note:** Most pages have graceful fallbacks and will work with demo data if dependencies are missing.
|
|
303
|
+
""")
|
|
304
|
+
|
|
305
|
+
vertical_space(2)
|
|
306
|
+
|
|
307
|
+
# Getting Started Actions
|
|
308
|
+
section_header(
|
|
309
|
+
"🎬 Ready to Get Started?",
|
|
310
|
+
"Choose your path",
|
|
311
|
+
divider="rainbow"
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
col1, col2, col3 = st.columns(3)
|
|
315
|
+
|
|
316
|
+
with col1:
|
|
317
|
+
st.markdown("""
|
|
318
|
+
### 🔍 **Explore Data**
|
|
319
|
+
Start by browsing recent politician trades
|
|
320
|
+
|
|
321
|
+
👉 Go to **Scrapers & Logs**
|
|
322
|
+
""")
|
|
323
|
+
if st.button("View Trading Data", key="btn_scrapers", use_container_width=True):
|
|
324
|
+
st.info("Navigate to 'Scrapers & Logs' in the sidebar →")
|
|
325
|
+
|
|
326
|
+
with col2:
|
|
327
|
+
st.markdown("""
|
|
328
|
+
### 📊 **Run Analysis**
|
|
329
|
+
See ML predictions and simulations
|
|
330
|
+
|
|
331
|
+
👉 Go to **Monte Carlo Predictions**
|
|
332
|
+
""")
|
|
333
|
+
if st.button("Analyze Stocks", key="btn_monte_carlo", use_container_width=True):
|
|
334
|
+
st.info("Navigate to 'Monte Carlo Predictions' in the sidebar →")
|
|
335
|
+
|
|
336
|
+
with col3:
|
|
337
|
+
st.markdown("""
|
|
338
|
+
### 💼 **Start Trading**
|
|
339
|
+
Create a paper trading portfolio
|
|
340
|
+
|
|
341
|
+
👉 Go to **Trading Dashboard**
|
|
342
|
+
""")
|
|
343
|
+
if st.button("Paper Trade", key="btn_trading", use_container_width=True):
|
|
344
|
+
st.info("Navigate to 'Trading Dashboard' in the sidebar →")
|
|
345
|
+
|
|
346
|
+
vertical_space(2)
|
|
347
|
+
|
|
348
|
+
# Disclaimers
|
|
349
|
+
st.markdown("---")
|
|
350
|
+
st.markdown("""
|
|
351
|
+
### ⚠️ Important Disclaimers
|
|
352
|
+
|
|
353
|
+
- **Not Financial Advice**: This tool is for educational and informational purposes only
|
|
354
|
+
- **Do Your Research**: Always conduct your own due diligence before investing
|
|
355
|
+
- **Risk Warning**: All investments carry risk. Past performance doesn't guarantee future results
|
|
356
|
+
- **Delayed Data**: Politician trades are disclosed 45 days after execution
|
|
357
|
+
- **No Guarantees**: ML predictions are probabilistic, not certainties
|
|
358
|
+
- **Paper Trading**: Practice with virtual money before risking real capital
|
|
359
|
+
|
|
360
|
+
**Legal Note**: All data comes from public sources. This dashboard aggregates
|
|
361
|
+
publicly disclosed information under the STOCK Act and is compliant with all regulations.
|
|
362
|
+
""")
|
|
363
|
+
|
|
364
|
+
vertical_space(1)
|
|
365
|
+
|
|
366
|
+
# Footer
|
|
367
|
+
st.markdown("""
|
|
368
|
+
<div style='text-align: center; color: #666; padding: 2rem 0;'>
|
|
369
|
+
<p>Built with ❤️ for transparent government and informed investing</p>
|
|
370
|
+
<p style='font-size: 0.9rem;'>
|
|
371
|
+
Data sources: Senate.gov • House.gov • Senate Stock Watcher • Yahoo Finance
|
|
372
|
+
</p>
|
|
373
|
+
</div>
|
|
374
|
+
""", unsafe_allow_html=True)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
if __name__ == "__main__":
|
|
378
|
+
show_overview()
|
mcli/ml/dashboard/pages/cicd.py
CHANGED
|
@@ -121,12 +121,12 @@ def show_cicd_dashboard():
|
|
|
121
121
|
if st.button("🔄 Refresh"):
|
|
122
122
|
st.rerun()
|
|
123
123
|
with col2:
|
|
124
|
-
auto_refresh = st.checkbox("Auto-refresh", value=False)
|
|
124
|
+
auto_refresh = st.checkbox("Auto-refresh (30s)", value=False)
|
|
125
125
|
|
|
126
126
|
if auto_refresh:
|
|
127
|
-
import
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
from streamlit_autorefresh import st_autorefresh
|
|
128
|
+
# Auto-refresh every 30 seconds
|
|
129
|
+
st_autorefresh(interval=30000, key="cicd_refresh")
|
|
130
130
|
|
|
131
131
|
st.divider()
|
|
132
132
|
|