Spaces:
Runtime error
Runtime error
Commit
·
30d86e6
1
Parent(s):
c1bdfd2
Update app.py
Browse files
app.py
CHANGED
@@ -27,12 +27,12 @@ Shown is the stock prediction of the next working day taking into account the la
|
|
27 |
|
28 |
model = keras.models.load_model('model_stock_prices.h5')
|
29 |
|
30 |
-
working_days = st.sidebar.slider("Working days to take into account in the prediction", min_value = 10, max_value=
|
31 |
working_days = int(working_days)
|
32 |
# downloading the last 10 days to make the prediction
|
33 |
|
34 |
today = date.today()
|
35 |
-
days_ago = today - timedelta(days=
|
36 |
|
37 |
# we get the last 20 days and keep just the last 10 working days, which have prices
|
38 |
nasdaq = yf.Ticker("^IXIC")
|
@@ -40,7 +40,7 @@ hist = nasdaq.history(start=days_ago, end=today)
|
|
40 |
hist = hist.drop(columns=['Dividends', 'Stock Splits'])
|
41 |
|
42 |
# keeping the last 10 data points
|
43 |
-
hist = hist[-
|
44 |
|
45 |
|
46 |
inflation = []
|
@@ -75,7 +75,7 @@ inp = scaler.transform(hist.to_numpy())
|
|
75 |
df = inp
|
76 |
temp_df = pd.DataFrame(inp, columns = ['Open','High','Low','Close','Volume','Inflation', 'CPI', 'Quarter_end'])
|
77 |
ds = []
|
78 |
-
ds.append(temp_df[0:
|
79 |
ds = np.array(ds)
|
80 |
|
81 |
|
@@ -103,11 +103,22 @@ prediction.append(final_prediction)
|
|
103 |
print(prediction)
|
104 |
plt.figure(figsize = (20,10))
|
105 |
plt.plot(prediction, label="Prediction")
|
106 |
-
plt.plot(hist['Close'].to_list()[-
|
107 |
plt.ylabel('Price US$', fontsize = 15 )
|
108 |
plt.xlabel('Working Days', fontsize = 15 )
|
109 |
plt.title("NASDAQ Stock Prediction", fontsize = 20)
|
110 |
plt.legend()
|
111 |
plt.grid()
|
112 |
|
113 |
-
st.pyplot(plt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
model = keras.models.load_model('model_stock_prices.h5')
|
29 |
|
30 |
+
working_days = st.sidebar.slider("Working days to take into account in the prediction", min_value = 10, max_value=20)
|
31 |
working_days = int(working_days)
|
32 |
# downloading the last 10 days to make the prediction
|
33 |
|
34 |
today = date.today()
|
35 |
+
days_ago = today - timedelta(days=20)
|
36 |
|
37 |
# we get the last 20 days and keep just the last 10 working days, which have prices
|
38 |
nasdaq = yf.Ticker("^IXIC")
|
|
|
40 |
hist = hist.drop(columns=['Dividends', 'Stock Splits'])
|
41 |
|
42 |
# keeping the last 10 data points
|
43 |
+
hist = hist[-10:]
|
44 |
|
45 |
|
46 |
inflation = []
|
|
|
75 |
df = inp
|
76 |
temp_df = pd.DataFrame(inp, columns = ['Open','High','Low','Close','Volume','Inflation', 'CPI', 'Quarter_end'])
|
77 |
ds = []
|
78 |
+
ds.append(temp_df[0:10])
|
79 |
ds = np.array(ds)
|
80 |
|
81 |
|
|
|
103 |
print(prediction)
|
104 |
plt.figure(figsize = (20,10))
|
105 |
plt.plot(prediction, label="Prediction")
|
106 |
+
plt.plot(hist['Close'].to_list()[-10:], label="Previous")
|
107 |
plt.ylabel('Price US$', fontsize = 15 )
|
108 |
plt.xlabel('Working Days', fontsize = 15 )
|
109 |
plt.title("NASDAQ Stock Prediction", fontsize = 20)
|
110 |
plt.legend()
|
111 |
plt.grid()
|
112 |
|
113 |
+
st.pyplot(plt)
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
st.write("""
|
119 |
+
# Historical prices data
|
120 |
+
Shown is the historical data of the prices (can be adapted with the values from the sidebar)
|
121 |
+
""")
|
122 |
+
|
123 |
+
temp_df
|
124 |
+
|