Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,12 +27,16 @@ tickers = ['TSLA', 'MSFT', 'PG', 'META', 'AMZN', 'GOOG', 'AMD', 'AAPL', 'NFLX',
|
|
27 |
start_date = (datetime.today() - pd.DateOffset(years=1)).strftime('%Y-%m-%d')
|
28 |
end_date = datetime.today().strftime('%Y-%m-%d')
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
stock_data = st.session_state[
|
36 |
|
37 |
|
38 |
# Perform sentiment analysis on tweets (assuming you still have your tweets data)
|
|
|
27 |
start_date = (datetime.today() - pd.DateOffset(years=1)).strftime('%Y-%m-%d')
|
28 |
end_date = datetime.today().strftime('%Y-%m-%d')
|
29 |
|
30 |
+
# Cache stock data for 1 day using st.cache_data
|
31 |
+
@st.cache_data(ttl=86400)
|
32 |
+
def load_and_cache_stock_data():
|
33 |
+
return load_stock_data(tickers, start_date, end_date)
|
34 |
+
|
35 |
+
# Initialize stock_data once at app startup
|
36 |
+
if "stock_data" not in st.session_state:
|
37 |
+
st.session_state["stock_data"] = load_and_cache_stock_data()
|
38 |
|
39 |
+
stock_data = st.session_state["stock_data"]
|
40 |
|
41 |
|
42 |
# Perform sentiment analysis on tweets (assuming you still have your tweets data)
|