File size: 1,084 Bytes
3f96245
 
 
 
dd448e5
 
 
3f96245
 
 
 
 
 
 
 
 
dd448e5
 
3f96245
 
dd448e5
 
 
 
 
 
 
 
67bdd5a
 
 
dd448e5
67bdd5a
 
3f96245
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
import requests
import pandas as pd

# Hard-coded API key for demonstration purposes
API_KEY = "QR8F9B7T6R2SWTAT"

def fetch_alpha_vantage_data(api_key):
    url = f'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=IBM&interval=5min&apikey={api_key}'
    response = requests.get(url)
    alpha_vantage_data = response.json()
    return alpha_vantage_data

def main():
    st.title("Stock Trend Predictor")

    # Use the hard-coded API key
    api_key = API_KEY

    # Fetch Alpha Vantage data
    alpha_vantage_data = fetch_alpha_vantage_data(api_key)

    # Extract relevant data from Alpha Vantage response
    alpha_vantage_time_series = alpha_vantage_data.get('Time Series (5min)', {})
    df = pd.DataFrame(alpha_vantage_time_series).T
    df.index = pd.to_datetime(df.index)
    df = df.dropna(axis=0)

    # Print DataFrame for observation
    st.subheader("Raw Data:")
    st.write(df)

    # Uncomment the next line if you want to stop the execution here to observe the data
    # st.stop()

if __name__ == "__main__":
    main()