File size: 2,521 Bytes
5935af9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import plotly.graph_objects as go
import plotly.express as px
import streamlit as st


def pie_chart_company_asset_weights(company_asset_weights):

    # Define custom colors
    custom_colors = px.colors.qualitative.Pastel

    explode_dist = [0.03] * len(company_asset_weights)

    fig = go.Figure(
        data=[
            go.Pie(
                labels=company_asset_weights["Name"],
                values=company_asset_weights["Allocation"],
                pull=explode_dist,
                marker=dict(colors=custom_colors),
                textposition="inside",
                hoverinfo="label+percent",
                textinfo="percent+label",
            )
        ]
    )

    fig.update_layout(
        title="Asset Allocation",
        showlegend=True,
        legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
        autosize=True,
        width=700,
        height=700,
        font=dict(
            family="League Spartan",
        ),
        plot_bgcolor="white",  # Set background color
    )

    fig.update_traces(
        textfont=dict(size=12),  # Adjust text font size
    )

    st.plotly_chart(fig, use_container_width=True)


def plot_annual_returns(annual_portfolio_returns):
    # Plot annual returns using Plotly
    annual_returns_fig = go.Figure(
        data=[
            go.Bar(
                x=annual_portfolio_returns.index.year,
                y=annual_portfolio_returns.values,
                marker_color="skyblue",
                opacity=0.7,
            )
        ]
    )
    annual_returns_fig.update_layout(
        title="Annual Returns of Portfolio",
        xaxis_title="Year",
        yaxis_title="Return",
        xaxis=dict(tickmode="linear"),
        yaxis=dict(tickformat=".2%"),
    )

    st.plotly_chart(annual_returns_fig, use_container_width=True)


def plot_cummulative_returns(cumulative_returns):
    # Plot cumulative returns using Plotly
    cumulative_returns_fig = go.Figure(
        data=go.Scatter(
            x=cumulative_returns.index,
            y=cumulative_returns.values,
            mode="lines",
            marker=dict(color="skyblue"),
        )
    )
    cumulative_returns_fig.update_layout(
        title="Cumulative Returns of Portfolio",
        xaxis_title="Date",
        yaxis_title="Value (Rupees)",
        xaxis=dict(rangeslider=dict(visible=True)),
        yaxis=dict(tickformat=".2f"),
    )

    # Display both plots
    st.plotly_chart(cumulative_returns_fig, use_container_width=True)