This repository contains code for a simple stock tracker web application built with Python and Streamlit. The application allows users to track the stock prices of various companies using the yfinance
library and visualizes the data using line charts and tables.
To run the stock tracker application locally, follow these steps:
-
Clone the repository:
git clone https://github.com/<username>/<repository>.git
-
Navigate to the project directory:
cd <repository>
-
Install the required dependencies using pip:
pip install -r requirements.txt
-
Run the application:
streamlit run app.py
The application will be accessible at http://localhost:8501 in your web browser.
-
Open the application in your web browser.
-
Enter the stock ticker symbol in the text input box (e.g., AAPL for Apple Inc., INTC for Intel Corporation).
-
Press Enter or click outside the input box to update the visualization.
-
The application will display a line chart representing the closing prices of the stock over time.
-
Additionally, a table containing the stock data will be displayed below the chart.
The main code file app.py
contains the following components:
- Importing the required libraries:
streamlit
,yfinance
, andpandas
. - Setting the page title and background image using Streamlit's
set_page_config
andmarkdown
functions. - Defining a function
get_stock_data
that uses theyf.download
function fromyfinance
to retrieve stock data for a given ticker symbol. - Using Streamlit's
sidebar
andtext_input
functions to allow users to input a stock ticker. - Calling the
get_stock_data
function to retrieve the stock data for the entered ticker. - Displaying the stock data in a line chart using Streamlit's
line_chart
function. - Displaying the stock data in a table using Streamlit's
write
function.
The stock tracker application is deployed using Streamlit and can be accessed online at Stock Tracker App.
For more information about Streamlit, refer to the Streamlit documentation.
Contributions to the repository are welcome. If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.