-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
55 lines (42 loc) · 1.59 KB
/
Copy pathapp.py
File metadata and controls
55 lines (42 loc) · 1.59 KB
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
import streamlit as st
from analyzer import StockSentimentAnalyzer
from ui_components import UIComponents
from config import Config
def main():
# Initialize configuration
config = Config()
# Set page configuration
st.set_page_config(
page_title="tradeo",
layout="wide",
initial_sidebar_state="collapsed"
)
# Apply custom CSS
UIComponents.apply_custom_css()
# Render header
UIComponents.render_header()
# Render search section
ticker, analyze_button = UIComponents.render_search_section()
# Main analysis logic
if analyze_button and ticker:
# Validate API keys
keys_valid, missing_keys = config.validate_api_keys()
if not keys_valid:
UIComponents.render_error("Configuration", f"Missing API keys: {', '.join(missing_keys)}")
return
try:
# Initialize analyzer
analyzer = StockSentimentAnalyzer(config.perplexity_api_key)
# Show loading spinner and perform analysis
with UIComponents.render_loading_spinner("Analyzing..."):
analysis, stock_data = analyzer.analyze_sentiment(ticker)
# Render metrics if available
UIComponents.render_metrics(stock_data)
# Render analysis report
UIComponents.render_analysis(analysis)
except Exception as e:
UIComponents.render_error(ticker, str(e))
# Render footer
UIComponents.render_footer()
if __name__ == "__main__":
main()