File size: 1,252 Bytes
a5ca742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import plotly.graph_objects as go
import pandas as pd

def create_stock_chart(stock_data, symbol):
    """Create an interactive stock price chart"""
    fig = go.Figure()
    
    fig.add_trace(
        go.Candlestick(
            x=stock_data.index,
            open=stock_data['Open'],
            high=stock_data['High'],
            low=stock_data['Low'],
            close=stock_data['Close'],
            name=symbol
        )
    )
    
    fig.update_layout(
        title=f"{symbol} Stock Price",
        yaxis_title="Price (USD)",
        template="plotly_dark",
        xaxis_rangeslider_visible=False
    )
    
    return fig

def create_metrics_table(company_info):
    """Create a table of key financial metrics"""
    metrics = {
        'Metric': [
            'Market Cap', 'P/E Ratio', 'Forward P/E',
            'PEG Ratio', 'Dividend Yield', 'Beta'
        ],
        'Value': [
            company_info.get('marketCap', 'N/A'),
            company_info.get('trailingPE', 'N/A'),
            company_info.get('forwardPE', 'N/A'),
            company_info.get('pegRatio', 'N/A'),
            company_info.get('dividendYield', 'N/A'),
            company_info.get('beta', 'N/A')
        ]
    }
    
    return pd.DataFrame(metrics)