File size: 3,295 Bytes
7169bc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d7d1b9
7169bc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""
Gradio interfaces module for Financial Market Data MCP Server.
Creates all Gradio UI interfaces.
"""

import gradio as gr
from .stock_quote import get_stock_quote
from .historical_data import get_historical_data
from .technical_analysis import get_technical_analysis
from .portfolio import analyze_portfolio, compare_stocks
from .market import get_market_overview
from .rate_limiter import rate_limiter
from .error_handler import handle_errors


# Stock Quote Interface
stock_quote_interface = gr.Interface(
    fn=get_stock_quote,
    inputs=gr.Textbox(label="Ticker Symbol", placeholder="AAPL"),
    outputs=gr.JSON(label="Stock Quote"),
    title="πŸ“ˆ Real-Time Stock Quote",
    description="Get current price, volume, and key metrics for any stock",
    examples=[["AAPL"], ["TSLA"], ["MSFT"], ["GOOGL"], ["NVDA"]]
)

# Historical Data Interface
historical_interface = gr.Interface(
    fn=get_historical_data,
    inputs=[
        gr.Textbox(label="Ticker Symbol", placeholder="AAPL"),
        gr.Dropdown(
            choices=["1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y"],
            value="1mo",
            label="Period"
        ),
        gr.Dropdown(
            choices=["1m", "5m", "15m", "1h", "1d"],
            value="1d",
            label="Interval"
        )
    ],
    outputs=gr.JSON(label="Historical Data"),
    title="πŸ“Š Historical Price Data",
    description="Get historical OHLCV data for any period and interval"
)

# Technical Analysis Interface
technical_interface = gr.Interface(
    fn=get_technical_analysis,
    inputs=[
        gr.Textbox(label="Ticker Symbol", placeholder="AAPL"),
        gr.Dropdown(
            choices=["3mo", "6mo", "1y"],
            value="3mo",
            label="Analysis Period"
        )
    ],
    outputs=gr.JSON(label="Technical Analysis"),
    title="πŸ” Technical Analysis",
    description="Comprehensive technical analysis with RSI, MACD, Bollinger Bands, and trading signals",
    examples=[["AAPL", "3mo"], ["TSLA", "6mo"]]
)

# Portfolio Analysis Interface
portfolio_interface = gr.Interface(
    fn=analyze_portfolio,
    inputs=gr.Textbox(
        label="Portfolio Holdings (JSON)",
        placeholder='{"AAPL": {"shares": 10, "cost_basis": 150}, "TSLA": {"shares": 5, "cost_basis": 200}}',
        lines=5
    ),
    outputs=gr.JSON(label="Portfolio Analysis"),
    title="πŸ’Ό Portfolio Analyzer",
    description="Analyze your portfolio with current values, gains/losses, and allocation"
)

# Stock Comparison Interface
comparison_interface = gr.Interface(
    fn=compare_stocks,
    inputs=[
        gr.Textbox(label="Ticker Symbols (comma-separated)", placeholder="AAPL,MSFT,GOOGL"),
        gr.Dropdown(
            choices=["performance", "valuation", "volatility"],
            value="performance",
            label="Comparison Metric"
        )
    ],
    outputs=gr.JSON(label="Stock Comparison"),
    title="βš–οΈ Stock Comparison",
    description="Compare multiple stocks across performance, valuation, or volatility"
)

# Market Overview Interface
market_interface = gr.Interface(
    fn=get_market_overview,
    inputs=[],
    outputs=gr.JSON(label="Market Overview"),
    title="🌍 Market Overview",
    description="Current status of major market indices and overall sentiment"
)