This project offers users the possibility to request stock data via the publicly available Yahoo Finance API and visualize the data in a candlestick chart using the plotly package. The application is hosted on http://thestockticker.pythonanywhere.com/ using the flask package.
Follow these steps to set up and run the project:
-
Install the required packages listed in the
requirements.txt
file. -
Create the main python file and name it
app.py
. -
Specify the stock symbols and names for the pull down select in the
tickers.txt
. -
Create the HTML files that will host the web visualization generated by your Python files.
4.1 Create a file named
home.html
which will be the landing page for the user where the stock symbol can be selected.4.2 Create a file named
response.html
where the data of the requested stock symbol is retrieved and visualized.4.3. Create a file name
error.html
which will offer an error message in case the api response is empty. -
Create a free user account on PythonAnywhere.
5.1. Create a new file named
requirements.txt
and enter the required packages.5.2. Sign up for a Beginner account, which is free. Choose a username that fits the application you want to host, as it will be part of the URL (e.g., username "TheStockTicker" results in http://thestockticker.pythonanywhere.com/).
5.3. Create a web app by clicking on the "Add a new web app" button.
5.4. Select your Python web framework and choose Python Version 3.10.
5.5. Create a file named
app.py
inside the newly created folder/mysite
and copy the contents of yourapp.py
file into it.5.6. Create a folder called
templates
within the/mysite
folder. Name the HTML fileindex.html
and copy the contents of yourindex.html
file into it.5.7. Save the
requirements.txt
file in the/mysite
folder and install all the listed packages by executing the following command in the bash console within the/mysite
directory:pip3 install -r requirements.txt --user
.5.8. Configure the root file by opening the WSGI configuration file:
/var/www/thestockticker_pythonanywhere_com_wsgi.py
in the Web tab. Change the import statement for Flask tofrom app import app as application
. This is necessary to define the correct location of your Python file.5.9. Run the web application, reload the URL, access it, and have fun!
Feel free to explore the visualization of stock data.