"""
Main Streamlit app entry point for the Trading Agents Dashboard.
Dark terminal-inspired trading interface with sidebar navigation.
"""
from datetime import datetime
import streamlit as st
from tradingagents.ui import pages
from tradingagents.ui.theme import COLORS, GLOBAL_CSS
from tradingagents.ui.utils import load_quick_stats
def setup_page_config():
"""Configure the Streamlit page settings."""
st.set_page_config(
page_title="Trading Agents",
page_icon="",
layout="wide",
initial_sidebar_state="expanded",
)
def render_sidebar():
"""Render the sidebar with navigation and quick stats."""
with st.sidebar:
# Brand header
st.markdown(
f"""
TRADINGAGENTS
v2.0 — {datetime.now().strftime('%b %d, %Y')}
""",
unsafe_allow_html=True,
)
st.markdown(
f"""""",
unsafe_allow_html=True,
)
# Navigation
page = st.radio(
"Navigation",
options=["Overview", "Signals", "Portfolio", "Performance", "Config"],
label_visibility="collapsed",
)
st.markdown(
f"""""",
unsafe_allow_html=True,
)
# Quick stats
try:
open_positions, win_rate = load_quick_stats()
st.markdown(
f"""
""",
unsafe_allow_html=True,
)
except Exception:
pass
return page
def route_page(page):
"""Route to the appropriate page based on selection."""
page_map = {
"Overview": pages.home,
"Signals": pages.todays_picks,
"Portfolio": pages.portfolio,
"Performance": pages.performance,
"Config": pages.settings,
}
module = page_map.get(page)
if module is None:
st.error(f"Unknown page: {page}")
return
try:
module.render()
except Exception as exc:
st.error(f"Error rendering {page}: {exc}")
import traceback
st.code(traceback.format_exc(), language="python")
def main():
"""Main entry point for the Streamlit app."""
setup_page_config()
# Inject global theme CSS
st.markdown(GLOBAL_CSS, unsafe_allow_html=True)
# Render sidebar and get selected page
selected_page = render_sidebar()
# Route to selected page
route_page(selected_page)
if __name__ == "__main__":
main()