sohoso commited on
Commit
17fced7
1 Parent(s): f2fdaa2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -12,15 +12,12 @@ from tensorflow.keras.layers import Activation, Dense, Dropout, LSTM
12
  from datetime import date, datetime, timedelta
13
  from stocknews import StockNews
14
 
15
-
16
-
17
  # --- SIDEBAR CODE
18
- ticker = st.sidebar.selectbox('Select your Crypto', ["BTC-USD", "ETH-USD", "BNB-USD","XRP-USD","ADA-USD","DOT-USD","DOGE-USD","SOL-USD"])
19
 
20
  start_date = st.sidebar.date_input('Start Date', date.today() - timedelta(days=365))
21
  end_date = st.sidebar.date_input('End Date')
22
 
23
-
24
  # --- MAIN PAGE
25
  st.header('Cryptocurrency Prediction')
26
 
@@ -28,11 +25,10 @@ col1, col2, = st.columns([1,9])
28
  with col1:
29
  st.image('icons/'+ ticker +'.png', width=75)
30
  with col2:
31
- st.write(f" ## { ticker}")
32
 
33
  ticker_obj = yf.Ticker(ticker)
34
 
35
-
36
  # --- CODE
37
 
38
  model_data = ticker_obj.history(interval='1h', start=start_date, end=end_date)
@@ -60,7 +56,6 @@ def build_lstm_model(input_data, output_size, neurons, activ_func='linear', drop
60
 
61
  return model
62
 
63
-
64
  # Hyperparameters
65
  np.random.seed(245)
66
  window_len = 10
@@ -83,7 +78,6 @@ def extract_window_data(input_data, target_data, window_len):
83
 
84
  X, y = extract_window_data(input_data_normalized, target_data_normalized, window_len)
85
 
86
-
87
  # Split the data into training and testing sets
88
  split_ratio = 0.8 # Ratio of training set to total data
89
  split_index = int(split_ratio * len(X))
@@ -126,7 +120,6 @@ fig.update_layout(
126
  legend_title=" ")
127
  st.write(fig)
128
 
129
-
130
  # --- INFO BUBBLE
131
 
132
  about_data, news = st.tabs(["About", "News"])
@@ -153,7 +146,6 @@ with about_data:
153
  history_data.sort_values(by='Date', ascending=False, inplace=True)
154
  st.write(history_data)
155
 
156
-
157
  with news:
158
  sNews = StockNews(ticker, save_news=False)
159
  sNews_df = sNews.read_rss()
@@ -163,4 +155,4 @@ with news:
163
  st.subheader(f"{i+1} - {sNews_df['title'][i]}")
164
  st.write(sNews_df['summary'][i])
165
  date_object = datetime.strptime(sNews_df['published'][i], '%a, %d %b %Y %H:%M:%S %z')
166
- st.write(f"_{date_object.strftime('%A')}, {date_object.date()}_")
 
12
  from datetime import date, datetime, timedelta
13
  from stocknews import StockNews
14
 
 
 
15
  # --- SIDEBAR CODE
16
+ ticker = st.sidebar.selectbox('Select your Crypto', ["BTC-USD", "ETH-USD", "BNB-USD", "XRP-USD", "ADA-USD", "DOT-USD", "DOGE-USD", "SOL-USD"])
17
 
18
  start_date = st.sidebar.date_input('Start Date', date.today() - timedelta(days=365))
19
  end_date = st.sidebar.date_input('End Date')
20
 
 
21
  # --- MAIN PAGE
22
  st.header('Cryptocurrency Prediction')
23
 
 
25
  with col1:
26
  st.image('icons/'+ ticker +'.png', width=75)
27
  with col2:
28
+ st.write(f" ## {ticker}")
29
 
30
  ticker_obj = yf.Ticker(ticker)
31
 
 
32
  # --- CODE
33
 
34
  model_data = ticker_obj.history(interval='1h', start=start_date, end=end_date)
 
56
 
57
  return model
58
 
 
59
  # Hyperparameters
60
  np.random.seed(245)
61
  window_len = 10
 
78
 
79
  X, y = extract_window_data(input_data_normalized, target_data_normalized, window_len)
80
 
 
81
  # Split the data into training and testing sets
82
  split_ratio = 0.8 # Ratio of training set to total data
83
  split_index = int(split_ratio * len(X))
 
120
  legend_title=" ")
121
  st.write(fig)
122
 
 
123
  # --- INFO BUBBLE
124
 
125
  about_data, news = st.tabs(["About", "News"])
 
146
  history_data.sort_values(by='Date', ascending=False, inplace=True)
147
  st.write(history_data)
148
 
 
149
  with news:
150
  sNews = StockNews(ticker, save_news=False)
151
  sNews_df = sNews.read_rss()
 
155
  st.subheader(f"{i+1} - {sNews_df['title'][i]}")
156
  st.write(sNews_df['summary'][i])
157
  date_object = datetime.strptime(sNews_df['published'][i], '%a, %d %b %Y %H:%M:%S %z')
158
+ st.write(f"_{date_object.strftime('%A')}, {date_object.date()}_")