A simple stock viewing web app built in python, html, css, and javascript. Django framework was used as structure for the site, Bootstrap to style and Chart.js to generate the graphs. Stock data is retrieved from Alpha Vantage using a free license. The app is deployed and live - prospective employers can get in touch if they would like to try the demo (the link is not shared publicly since this is not a commercial version, and the free API licence only handles a very limited amount of calls.)
- Display at a strategic glance fundamental stock data in a pleasing visualization
- Control API calls
- Database storage with automatic updating when data is older than a set parameter (1 day in this case)
Since API keys may have limited calls (as in this case), the app uses local cache memory to set a timeout when the API is called. This prevents more calls on the API than is allowed for, avoiding faulty data to be stored in the database. However, the app stores previous successful data and will first attempt to retrieve the data from the database if the ticker symbol already exists. The app will also check the timestamp of the existing record and if the data is older than the set parameter, the app will call the API (unless its function is on the cache timeout). If the user agent inputs within the timeout range, they will be sent to an request denied page. And if the user agent inputs a faulty or non-existent ticker symbol, the app will detect this in the data retrieved from the API provider and send the user agent to a ticker invalid page. These routes are intended to prevent the app from crashing.
A second API source (with preset endpoints) is called for index data with which to compare the current stock. This data will also be stored in the database with a refresh window when data has become stale. This API call is "optional", such that if the call runs into errors, the main data should still load and everything else in the app should still work without it. The graph where this is relevant will simply not display the comparison data.
Preliminary Setup
First make sure to get an API key from Alpha Vantage and add this as an environmental variable on your system. Or, alternatively, hardcode it into the APIKEY
variable at the top of the /visualizer/av.py
file.
Clone the Repository
- Open your favorite terminal/command prompt.
- Navigate to the directory you want to store the project. E.g.
C:\Users\username\dev
- Run the following command to clone the repository code:
git clone https://github.com/Firgrep/vstock.git
Set up Virtual Environment
-
Change into the project directory:
cd vstock
-
Create a virtual environment:
- On MacOS and Linux:
python3 -m venv .venv
- On Windows:
python -m venv .venv
- On MacOS and Linux:
-
Activate the virtual environment:
- On MacOS and Linux:
source .venv/bin/activate
- On Windows (PowerShell):
& "./.venv/Scripts/Activate.ps1"
- On MacOS and Linux:
Install Dependencies and Database Setup
-
With the virtual environment activated, install the necessary dependencies using pip:
pip install -r requirements.txt
-
Create the database tables:
python manage.py migrate
Run the Development Server
- Start the development server
python manage.py runserver
- Open your web browser and go to http://127.0.0.1:8000/ to see the app in action!
- Punch in the ticker symbol of your choice and explore the stats!
This project is lincensed under the Apache License Version 2.0, January 2004 license.