For this project, my purpose is to create a stock infomation database for all the stock in s&p 500. Through SQL language to retrieve information from the database, I can apply some basic stock price data visulization methods: pricing plot through a certain time window, and correlation table for chosen stocks. And I also developed a web running on the local server. User can select the stock they are interested in and get more infomation from the stock open high low close price for most recent 3 month.
- Download or clone the repo into a local pc.
- Open Terminal (OSX or Unix), set the current folder to be the final project folder.
- If you are a anaconda user you can type
conda create --name myenv
, if not you can use pip to create the environment. - Activate the environment by typing
source active myenv
. - Install all the required package by typing
pip install -r requirements.txt
.
- Assume you are a PostgreSQL user, Edit config.py by including the database name and user/password required to connect to the database. An example is as follow:
db_name = 'finalProject'
db_user = 'lee'
db_password = ' '
- Start the database server, for example:
pg_ctl -D /usr/local/var/postgres start
, check if the server is running. - Start running the SI507F17_finalproject.py file:
python SI507F17_finalproject.py
, this program will construct the database on the caching data(using all the csv file under the stock_dfs folder). - If you want to update the caching data, you can open SI507F17_finalproject.py file and follow the instruction for dataBaseConstuct() function. If you want to cache the new data from the web, please be patient, because this may take up to 4 minutes, since there are 3 month data for 505 stocks. You can keep track of the process in the command window output.
- After successfully ran the program, you can get an correlation_table.html file, you can use the web browser to open the file and you get something like this:
- In the terminal, typing
python webApp.py runserver
to start the web application. - Once the web server is runing, go the browser and go to the default local server address http://localhost:5000/, you should see something like this: