-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
36 lines (32 loc) · 1.15 KB
/
app.py
File metadata and controls
36 lines (32 loc) · 1.15 KB
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
import streamlit as st
import yfinance as yf
import pandas as pd
# Set the page title
st.set_page_config(page_title='Stock Tracker', page_icon=':chart_with_upwards_trend:')
st.title("Stock Tracker")
st.markdown(
f"""
<style>
.stApp {{
background-image: url("https://4kwallpapers.com/images/wallpapers/dark-background-abstract-background-network-3d-background-2560x1440-8324.png");
background-attachment: fixed;
background-size: cover
}}
</style>
""",
unsafe_allow_html=True
)
# Define a function to get the stock data
@st.cache_data
def get_stock_data(ticker):
stock_data = yf.download(ticker)
return stock_data
# Create a text input for the user to enter a stock ticker
ticker_input = st.sidebar.text_input('Enter a stock ticker (e.g. AAPL,INTC)', 'AAPL')
st.markdown(f"<h3>Visualization for {ticker_input}</h3>",unsafe_allow_html=True)
# Get the stock data for the entered ticker
stock_data = get_stock_data(ticker_input)
# Display the stock data in a line chart
st.line_chart(stock_data['Close'])
# Display the stock data in a table
st.write(stock_data)