Hi,
i have a program that does something like that:
@st.cache_data
def histo_fonds(numero)::
# Load data from internet
return df
def info_fonds(numero):
# load data from internet
return df
# select funds
fonds = st.selectbox("Choix du fonds",
list_fonds.sort_values().unique()
)
numero_fonds = df.query("Nom==@fonds")['ID_Produit'].squeeze()
# information on the fund
try:
info = info_fonds(numero_fonds)
info
exept:
pass
# Dates selection
dt_min, dt_max = date_fonds(numero_fonds)
col = st.columns(2)
start_date = pd.to_datetime(col[0].date_input("Date de début:",
format="DD/MM/YYYY",
value=dt_min,
min_value=dt_min,
max_value=dt_max
)
)
end_date = pd.to_datetime(col[1].date_input("Date de fin:",
format="DD/MM/YYYY",
value=dt_max,
max_value=dt_max
)
)
try:
histo = histo_fonds(numero_fonds, start_date=start_date.strftime("%Y-%m-%d")).dropna()
histo = 100*histo.loc[:end_date]/histo.loc[start_date]
histo
except:
"Pas d'historique pour ce fonds"
What I would like is:
- the info_fonds() function won’t be change except if I change the fonds variable in
st.selectbox()
. It will print info variable (if it exists) as I don’t change thenumero_fonds
variable - that
histo_fonds()
function won’t go to the internet if start_date > dt_min else it will charge the data from internet with histo_fonds()
How should I do to get this ? I hope it is enough clear. Let me know if it is not the case.
Thx for your help.