Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
from datetime import datetime
|
|
|
|
| 5 |
|
| 6 |
# Hard-coded API key for demonstration purposes
|
| 7 |
API_KEY = "QR8F9B7T6R2SWTAT"
|
|
@@ -25,6 +26,9 @@ def main():
|
|
| 25 |
# Use the hard-coded API key
|
| 26 |
api_key = API_KEY
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
# Continuously fetch and display real-time data
|
| 29 |
while True:
|
| 30 |
# Fetch Alpha Vantage data
|
|
@@ -33,7 +37,10 @@ def main():
|
|
| 33 |
# Extract relevant data from Alpha Vantage response
|
| 34 |
alpha_vantage_quote = alpha_vantage_data.get('Global Quote', {})
|
| 35 |
df = pd.DataFrame([alpha_vantage_quote])
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
df = df.dropna(axis=0)
|
| 38 |
|
| 39 |
# Display the real-time data
|
|
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
from datetime import datetime
|
| 5 |
+
import pytz
|
| 6 |
|
| 7 |
# Hard-coded API key for demonstration purposes
|
| 8 |
API_KEY = "QR8F9B7T6R2SWTAT"
|
|
|
|
| 26 |
# Use the hard-coded API key
|
| 27 |
api_key = API_KEY
|
| 28 |
|
| 29 |
+
# Set the desired time zone (e.g., 'US/Eastern')
|
| 30 |
+
desired_time_zone = 'US/Eastern'
|
| 31 |
+
|
| 32 |
# Continuously fetch and display real-time data
|
| 33 |
while True:
|
| 34 |
# Fetch Alpha Vantage data
|
|
|
|
| 37 |
# Extract relevant data from Alpha Vantage response
|
| 38 |
alpha_vantage_quote = alpha_vantage_data.get('Global Quote', {})
|
| 39 |
df = pd.DataFrame([alpha_vantage_quote])
|
| 40 |
+
|
| 41 |
+
# Convert the timestamp to the desired time zone
|
| 42 |
+
df.index = [datetime.now(pytz.timezone(desired_time_zone))]
|
| 43 |
+
|
| 44 |
df = df.dropna(axis=0)
|
| 45 |
|
| 46 |
# Display the real-time data
|