Benjamin Consolvo commited on
Commit
8889d78
Β·
1 Parent(s): 9ac7c93

markdown for description

Browse files
Files changed (1) hide show
  1. app.py +20 -18
app.py CHANGED
@@ -553,7 +553,8 @@ def get_market_times(alpaca_api):
553
  return None, None, None, None
554
 
555
  def main():
556
- st.title("Stock Trading Application")
 
557
 
558
  if not st.secrets['ALPACA_API_KEY'] or not st.secrets['NEWS_API_KEY']:
559
  st.error("Please configure your API keys in secrets.toml")
@@ -568,24 +569,8 @@ def main():
568
  # Create two columns for market status and portfolio holdings
569
  col1, col2 = st.columns([1, 1])
570
 
571
- # Column 1: Market status
572
  with col1:
573
- is_open, now, next_open, next_close = get_market_times(app.alpaca.alpaca)
574
- market_status = "🟒 Market is OPEN" if is_open else "πŸ”΄ Market is CLOSED"
575
- st.markdown(f"### {market_status}")
576
- if now is not None:
577
- st.markdown(f"**Current time (ET):** {now.strftime('%Y-%m-%d %H:%M:%S')}")
578
- if is_open and next_close is not None:
579
- st.markdown(f"**Market closes at:** {next_close.strftime('%Y-%m-%d %H:%M:%S')} ET")
580
- seconds_left = int((next_close - now).total_seconds())
581
- st.markdown(f"**Time until close:** {pd.to_timedelta(seconds_left, unit='s')}")
582
- elif not is_open and next_open is not None:
583
- st.markdown(f"**Market opens at:** {next_open.strftime('%Y-%m-%d %H:%M:%S')} ET")
584
- seconds_left = int((next_open - now).total_seconds())
585
- st.markdown(f"**Time until open:** {pd.to_timedelta(seconds_left, unit='s')}")
586
-
587
- # Column 2: Portfolio holdings bar chart
588
- with col2:
589
  st.subheader("Portfolio Holdings")
590
  holdings_container = st.empty() # Create a container for dynamic updates
591
  def update_holdings():
@@ -627,6 +612,23 @@ def main():
627
  else:
628
  st.info("No holdings to display.")
629
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
630
  # Initialize auto trade log in session state if needed
631
  if AUTO_TRADE_LOG_KEY not in st.session_state:
632
  st.session_state[AUTO_TRADE_LOG_KEY] = []
 
553
  return None, None, None, None
554
 
555
  def main():
556
+ st.title("Ben's Stock Trading Application")
557
+ st.markdown("This is a fun stock trading application that uses Alpaca API for trading and News API for sentiment analysis. Come and trade my money! Well, it's a paper account, so it's not real money. But still, have fun!")
558
 
559
  if not st.secrets['ALPACA_API_KEY'] or not st.secrets['NEWS_API_KEY']:
560
  st.error("Please configure your API keys in secrets.toml")
 
569
  # Create two columns for market status and portfolio holdings
570
  col1, col2 = st.columns([1, 1])
571
 
572
+ # Column 1: Portfolio holdings bar chart
573
  with col1:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  st.subheader("Portfolio Holdings")
575
  holdings_container = st.empty() # Create a container for dynamic updates
576
  def update_holdings():
 
612
  else:
613
  st.info("No holdings to display.")
614
 
615
+ # Column 2: Market status
616
+ with col2:
617
+ is_open, now, next_open, next_close = get_market_times(app.alpaca.alpaca)
618
+ market_status = "🟒 Market is OPEN" if is_open else "πŸ”΄ Market is CLOSED"
619
+ st.markdown(f"### {market_status}")
620
+ if now is not None:
621
+ st.markdown(f"**Current time (ET):** {now.strftime('%Y-%m-%d %H:%M:%S')}")
622
+ if is_open and next_close is not None:
623
+ st.markdown(f"**Market closes at:** {next_close.strftime('%Y-%m-%d %H:%M:%S')} ET")
624
+ seconds_left = int((next_close - now).total_seconds())
625
+ st.markdown(f"**Time until close:** {pd.to_timedelta(seconds_left, unit='s')}")
626
+ elif not is_open and next_open is not None:
627
+ st.markdown(f"**Market opens at:** {next_open.strftime('%Y-%m-%d %H:%M:%S')} ET")
628
+ seconds_left = int((next_open - now).total_seconds())
629
+ st.markdown(f"**Time until open:** {pd.to_timedelta(seconds_left, unit='s')}")
630
+
631
+
632
  # Initialize auto trade log in session state if needed
633
  if AUTO_TRADE_LOG_KEY not in st.session_state:
634
  st.session_state[AUTO_TRADE_LOG_KEY] = []