|
|
""" |
|
|
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 = 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_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_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_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" |
|
|
) |
|
|
|
|
|
|
|
|
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_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" |
|
|
) |
|
|
|
|
|
|