File size: 1,808 Bytes
a9384ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from datetime import date
import json
import plotly
from re import sub
from plotly import graph_objects as go

import streamlit as st

st.set_page_config(layout="wide")

from subs.access_backend import get_tickerlist
from subs.access_backend import get_plot

tickerTable = get_tickerlist().set_index("Ticker")

PrimeStandardSector = "Prime Standard Sector"
sectors = tickerTable[PrimeStandardSector].unique()
sectors.sort()
sector = st.selectbox(
    label="Select a Sector. Remark: This sets the default for the selected stocks",
    options=sectors,
)

default_index = tickerTable[PrimeStandardSector] == sector

default = tickerTable[default_index]

selections = st.multiselect(
    label="Dax Constituents",
    options=list(tickerTable.index),
    format_func=lambda x: tickerTable.at[x, "Company"],
    default=list(default.index),
)

for selection in selections:

    try:

        fig_scatter = get_plot(selection, "scatter")
        fig_returns = get_plot(selection, "returns")
        fig_histogram = get_plot(selection, "histogram")

        st.header(tickerTable.at[selection, "Company"])
        c1, _, c2, _, c3 = st.columns((10, 1, 10, 1, 10))

        c1.plotly_chart(fig_scatter, use_container_width=True)
        c2.plotly_chart(fig_returns, use_container_width=True)
        c3.plotly_chart(fig_histogram, use_container_width=True)

    except Exception as e:
        st.header(tickerTable.at[selection, "Company"])
        st.markdown(
            f"Data for {tickerTable.at[selection, 'Company']} not available",
            unsafe_allow_html=False,
        )
        # print(selection)
        # print(e)

if __name__ == "__main__":
    print(tickerTable)
    print(tickerTable.index[:3])

    print(sectors)
    print(tickerTable["Prime Standard Sector"] == sector)
    print(default)