mr601s commited on
Commit
10976c8
Β·
verified Β·
1 Parent(s): 8f182cb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -0
app.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from utils.sec_utils import SECUtils
3
+ from utils.news_utils import NewsUtils
4
+ from utils.finance_utils import FinanceUtils
5
+ from utils.chart_utils import ChartUtils
6
+
7
+ # Initialize utility classes
8
+ sec_utils = SECUtils()
9
+ news_utils = NewsUtils()
10
+ finance_utils = FinanceUtils()
11
+ chart_utils = ChartUtils()
12
+
13
+ def update_stock_info(ticker):
14
+ """Update all sections when ticker changes"""
15
+ if not ticker:
16
+ empty_msg = "Enter a ticker symbol to see data"
17
+ return empty_msg, empty_msg, empty_msg, empty_msg, None
18
+
19
+ ticker = ticker.upper().strip()
20
+
21
+ # Get data for each section
22
+ quote_data = finance_utils.get_stock_quote(ticker)
23
+ news_data = news_utils.get_yahoo_news(ticker)
24
+ filings_data = sec_utils.get_recent_filings(ticker)
25
+ financial_data = finance_utils.get_financial_summary(ticker)
26
+ chart = chart_utils.create_price_chart(ticker)
27
+
28
+ return quote_data, news_data, filings_data, financial_data, chart
29
+
30
+ # Custom CSS
31
+ css = """
32
+ .gradio-container {
33
+ font-family: 'Arial', sans-serif;
34
+ }
35
+ .tab-nav button {
36
+ font-size: 16px;
37
+ font-weight: bold;
38
+ }
39
+ """
40
+
41
+ # Create Gradio interface
42
+ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
43
+ gr.Markdown("""
44
+ # πŸ“ˆ Stock Research Platform MVP
45
+ Enter a stock ticker symbol to explore comprehensive information, news, SEC filings, and financial data.
46
+ """)
47
+
48
+ with gr.Row():
49
+ ticker_input = gr.Textbox(
50
+ label="Stock Ticker",
51
+ placeholder="Enter ticker (e.g., AAPL, TSLA, MSFT)",
52
+ value="AAPL"
53
+ )
54
+ refresh_btn = gr.Button("πŸ”„ Refresh Data", variant="primary")
55
+
56
+ with gr.Tabs():
57
+ with gr.TabItem("πŸ’° Quote & Overview"):
58
+ quote_output = gr.Markdown(value="Enter a ticker to see stock quote")
59
+
60
+ with gr.TabItem("πŸ“° News"):
61
+ news_output = gr.Markdown(value="Enter a ticker to see latest news")
62
+
63
+ with gr.TabItem("πŸ“„ SEC Filings"):
64
+ filings_output = gr.Markdown(value="Enter a ticker to see SEC filings")
65
+
66
+ with gr.TabItem("πŸ“Š Financial Summary"):
67
+ financial_output = gr.Markdown(value="Enter a ticker to see financial summary")
68
+
69
+ with gr.TabItem("πŸ“ˆ Price Chart"):
70
+ chart_output = gr.Plot(value=None)
71
+
72
+ # Event handlers
73
+ ticker_input.change(
74
+ fn=update_stock_info,
75
+ inputs=[ticker_input],
76
+ outputs=[quote_output, news_output, filings_output, financial_output, chart_output]
77
+ )
78
+
79
+ refresh_btn.click(
80
+ fn=update_stock_info,
81
+ inputs=[ticker_input],
82
+ outputs=[quote_output, news_output, filings_output, financial_output, chart_output]
83
+ )
84
+
85
+ # Launch the app
86
+ if __name__ == "__main__":
87
+ demo.launch()