Geek7 commited on
Commit
8675d66
·
verified ·
1 Parent(s): 087ef0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -3,11 +3,15 @@ from thronetrader import StrategicSignals
3
  import requests
4
  import pandas as pd
5
 
 
 
 
 
6
  # Hard-coded API key for demonstration purposes
7
  API_KEY = "QR8F9B7T6R2SWTAT"
8
 
9
- def fetch_alpha_vantage_data(api_key):
10
- url = f'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=IBM&interval=5min&apikey={api_key}'
11
  response = requests.get(url)
12
  alpha_vantage_data = response.json()
13
  return alpha_vantage_data
@@ -15,11 +19,18 @@ def fetch_alpha_vantage_data(api_key):
15
  def main():
16
  st.title("Stock Trend Predictor")
17
 
 
 
 
 
 
 
 
18
  # Use the hard-coded API key
19
  api_key = API_KEY
20
 
21
  # Fetch Alpha Vantage data
22
- alpha_vantage_data = fetch_alpha_vantage_data(api_key)
23
 
24
  # Extract relevant data from Alpha Vantage response
25
  alpha_vantage_time_series = alpha_vantage_data.get('Time Series (5min)', {})
@@ -27,15 +38,13 @@ def main():
27
  df.index = pd.to_datetime(df.index)
28
  df = df.dropna(axis=0)
29
 
30
- # Print DataFrame for observation
31
  st.subheader("Raw Data:")
32
  st.write(df)
33
 
34
- # Uncomment the next line if you want to stop the execution here to observe the data
35
- # st.stop()
36
-
37
  if __name__ == "__main__":
38
  main()
 
39
  def main():
40
  st.title("Strategic Trading Signals")
41
 
 
3
  import requests
4
  import pandas as pd
5
 
6
+ import streamlit as st
7
+ import requests
8
+ import pandas as pd
9
+
10
  # Hard-coded API key for demonstration purposes
11
  API_KEY = "QR8F9B7T6R2SWTAT"
12
 
13
+ def fetch_alpha_vantage_data(api_key, symbol):
14
+ url = f'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol={symbol}&interval=5min&apikey={api_key}'
15
  response = requests.get(url)
16
  alpha_vantage_data = response.json()
17
  return alpha_vantage_data
 
19
  def main():
20
  st.title("Stock Trend Predictor")
21
 
22
+ # User input for stock symbol
23
+ symbol = st.text_input("Enter Stock Symbol (e.g., IBM):")
24
+
25
+ if not symbol:
26
+ st.warning("Please enter a valid stock symbol.")
27
+ st.stop()
28
+
29
  # Use the hard-coded API key
30
  api_key = API_KEY
31
 
32
  # Fetch Alpha Vantage data
33
+ alpha_vantage_data = fetch_alpha_vantage_data(api_key, symbol)
34
 
35
  # Extract relevant data from Alpha Vantage response
36
  alpha_vantage_time_series = alpha_vantage_data.get('Time Series (5min)', {})
 
38
  df.index = pd.to_datetime(df.index)
39
  df = df.dropna(axis=0)
40
 
41
+ # Display the raw data
42
  st.subheader("Raw Data:")
43
  st.write(df)
44
 
 
 
 
45
  if __name__ == "__main__":
46
  main()
47
+
48
  def main():
49
  st.title("Strategic Trading Signals")
50