finance-data-mcp / src /interfaces.py
dlrklc's picture
Update README and app files
3d7d1b9
"""
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"
)