Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
import streamlit as st
|
2 |
-
from thronetrader import StrategicSignals
|
3 |
import requests
|
4 |
-
from Pandas_Market_Predictor import Pandas_Market_Predictor
|
5 |
import pandas as pd
|
6 |
|
7 |
-
|
8 |
# Hard-coded API key for demonstration purposes
|
9 |
API_KEY = "QR8F9B7T6R2SWTAT"
|
10 |
|
11 |
def fetch_alpha_vantage_data(api_key, symbol):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def main():
|
18 |
st.title("Stock Trend Predictor")
|
@@ -30,15 +32,16 @@ def main():
|
|
30 |
# Fetch Alpha Vantage data
|
31 |
alpha_vantage_data = fetch_alpha_vantage_data(api_key, symbol)
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
|
43 |
if __name__ == "__main__":
|
44 |
-
main()
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import requests
|
|
|
3 |
import pandas as pd
|
4 |
|
|
|
5 |
# Hard-coded API key for demonstration purposes
|
6 |
API_KEY = "QR8F9B7T6R2SWTAT"
|
7 |
|
8 |
def fetch_alpha_vantage_data(api_key, symbol):
|
9 |
+
try:
|
10 |
+
url = f'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol={symbol}&interval=5min&apikey={api_key}'
|
11 |
+
response = requests.get(url)
|
12 |
+
response.raise_for_status() # Raise an error for bad responses
|
13 |
+
alpha_vantage_data = response.json()
|
14 |
+
return alpha_vantage_data
|
15 |
+
except requests.RequestException as e:
|
16 |
+
st.error(f"Error fetching data: {e}")
|
17 |
+
return None
|
18 |
|
19 |
def main():
|
20 |
st.title("Stock Trend Predictor")
|
|
|
32 |
# Fetch Alpha Vantage data
|
33 |
alpha_vantage_data = fetch_alpha_vantage_data(api_key, symbol)
|
34 |
|
35 |
+
if alpha_vantage_data:
|
36 |
+
# Extract relevant data from Alpha Vantage response
|
37 |
+
alpha_vantage_time_series = alpha_vantage_data.get('Time Series (5min)', {})
|
38 |
+
df = pd.DataFrame(alpha_vantage_time_series).T
|
39 |
+
df.index = pd.to_datetime(df.index)
|
40 |
+
df = df.dropna(axis=0)
|
41 |
|
42 |
+
# Display the raw data
|
43 |
+
st.subheader("Raw Data:")
|
44 |
+
st.write(df)
|
45 |
|
46 |
if __name__ == "__main__":
|
47 |
+
main()
|