Victorlopo21 commited on
Commit
c1bdfd2
·
1 Parent(s): 178a799

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -28,13 +28,11 @@ Shown is the stock prediction of the next working day taking into account the la
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=30)
31
-
32
-
33
-
34
  # downloading the last 10 days to make the prediction
35
 
36
  today = date.today()
37
- days_ago = today - timedelta(days=20)
38
 
39
  # we get the last 20 days and keep just the last 10 working days, which have prices
40
  nasdaq = yf.Ticker("^IXIC")
@@ -42,7 +40,7 @@ hist = nasdaq.history(start=days_ago, end=today)
42
  hist = hist.drop(columns=['Dividends', 'Stock Splits'])
43
 
44
  # keeping the last 10 data points
45
- hist = hist[-10:]
46
 
47
 
48
  inflation = []
@@ -77,7 +75,7 @@ inp = scaler.transform(hist.to_numpy())
77
  df = inp
78
  temp_df = pd.DataFrame(inp, columns = ['Open','High','Low','Close','Volume','Inflation', 'CPI', 'Quarter_end'])
79
  ds = []
80
- ds.append(temp_df[0:10])
81
  ds = np.array(ds)
82
 
83
 
@@ -105,7 +103,7 @@ prediction.append(final_prediction)
105
  print(prediction)
106
  plt.figure(figsize = (20,10))
107
  plt.plot(prediction, label="Prediction")
108
- plt.plot(hist['Close'].to_list()[-10:], label="Previous")
109
  plt.ylabel('Price US$', fontsize = 15 )
110
  plt.xlabel('Working Days', fontsize = 15 )
111
  plt.title("NASDAQ Stock Prediction", fontsize = 20)
 
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=30)
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=30)
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[-working_days:]
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:working_days])
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()[-working_days:], label="Previous")
107
  plt.ylabel('Price US$', fontsize = 15 )
108
  plt.xlabel('Working Days', fontsize = 15 )
109
  plt.title("NASDAQ Stock Prediction", fontsize = 20)