-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
151 lines (139 loc) · 5.15 KB
/
Copy pathapp.py
File metadata and controls
151 lines (139 loc) · 5.15 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import streamlit as st
import polars as pl
import subprocess
from src.app.app_tables import tab_gb_cotation, prepare_table, table_global
from src.app.app_plot import (
graph_repartition_type,
grap_repartition_titre,
graph_invest_month,
graph_portefeuille_brut,
graph_portefeuille_variation,
graph_invest_carte,
graph_frais_moyen,
graph_coupon_temps
)
from src.scrap.yf import get_list_isin, df_evolution_portefeuille, df_creata_all_cotation
from src.app.app_function import remove_white_space, css_button, css_tabs
from src.app.app_data import (
dataframe_frais,
nombre_versement,
nombre_delta_titre,
nombre_performance_titre,
nombre_total_dividende,
nombre_total_titre,
nombre_total_achat,
nombre_total_portefeuille)
df_ordres = pl.read_parquet("./data/parquet/ordres.parquet")
df_releves = pl.read_parquet("./data/parquet/releves.parquet")
df_cotation = pl.read_parquet("./data/parquet/cotation.parquet")
df_infos = pl.read_parquet("./data/parquet/infos.parquet")
infos = df_infos.select("isin", "ticker")
df_frais = dataframe_frais(df_ordres)
df_coupon = df_releves.filter(pl.col("type").str.starts_with("COUPON"))
df_ordres_gb = tab_gb_cotation(df_ordres, df_cotation,df_infos)
df_resume = prepare_table(df_releves, df_ordres_gb)
list_isin = get_list_isin()
datoum = df_evolution_portefeuille(list_isin)
total_titre = nombre_total_titre(df_resume)
total_div = nombre_total_dividende(df_releves)
total_achat = nombre_total_achat(df_resume)
versement = nombre_versement(df_releves)
total_port = nombre_total_portefeuille(versement, total_titre, total_achat, total_div)
delta_titre = nombre_delta_titre(df_resume)
perf_titre = nombre_performance_titre(df_resume)
st.set_page_config(
page_title="Bourse",
page_icon="🔮",
layout="centered"
)
def main():
remove_white_space()
css_button()
css_tabs()
with st.sidebar:
st.write("# Configuration")
st.divider()
st.write("### Actualisation")
if st.button("PDF Scraping", type="primary"):
subprocess.call(["python", "src/scrap/trigger.py"])
if st.button("MàJ Cotation", type = "primary"):
liste_isin = get_list_isin()
df_creata_all_cotation(liste_isin)
st.divider()
st.write("### Versement total")
st.write("Facultatif : utile si un versement a été fait depuis le dernier relevé d'espèces.")
versement = st.number_input("Versement",
value=nombre_versement(df_releves),
step=100.)
total_port = nombre_total_portefeuille(versement, total_titre, total_achat, total_div)
col1, col2 = st.columns([2, 1])
with col1:
st.write("## Portefeuille boursier 🧭 ")
with col2:
st.metric(
label="Total Portefeuille",
value=str(round(total_port,2)) + " €",
delta=str(round(100 * (total_port - versement)
/ versement, 2))
+ " % ("
+ str(round(total_port - versement, 2))
+ "€)",
)
tab1, tab2, tab3 , tab4, tab5= st.tabs(
["🔍 Composition", "👑 Performance", "🐣 Investissement", "💰 Dividende", "💸 Frais"]
)
with tab1:
st.subheader("Vue d'ensemble")
col1, col2 = st.columns([1, 1])
with col1:
st.metric(
label="Titres",
value=str(total_titre) + " €",
delta=str(delta_titre) + " % (" + str(perf_titre) + "€)",
delta_color="off",
)
with col2:
st.metric(label="Espèces", value=str(round(versement - total_achat + total_div,2)) + " €")
table_global(df_resume)
st.divider()
on = st.toggle("Graphique par type d'actif")
if on:
graph_repartition_type(df_resume)
else:
grap_repartition_titre(df_resume)
with tab3:
st.subheader("Temporalité des achats")
on = st.toggle("Mois / Années")
if on:
graph_invest_month(df_ordres, temps="Années")
else:
graph_invest_month(df_ordres, temps="Mois")
st.divider()
graph_invest_carte(df_ordres)
with tab2:
st.subheader("Performance")
graph_portefeuille_brut(datoum)
st.divider()
on = st.toggle("% ou €")
if on:
graph_portefeuille_variation(datoum, "variation_eur")
else:
graph_portefeuille_variation(datoum, "variation")
with tab4:
col1, col2 = st.columns([2,1])
with col1:
st.subheader("Dividendes versés")
with col2:
st.metric("Dividende",
str(round(df_coupon.select("montant").sum().item(),2)) + " €")
graph_coupon_temps(df_releves,df_ordres, infos)
with tab5:
col1, col2 = st.columns([2,1])
with col1:
st.subheader("Prélévements des ordres")
with col2:
st.metric("Prélévement",
str(round(df_frais.select("ponction").sum().item(),2)) + " €")
graph_frais_moyen(df_ordres)
if __name__ == "__main__":
main()