Skip to content

How to create a PostgreSQL stock database using Python

Notifications You must be signed in to change notification settings

whyrv/Stock-Database

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to create a PostgreSQL stock database using Python

This code example will help you create your own stock pricing database using PostgreSQL and Python. The code will create two separate tables:

daily_prices: A table containing daily OHLCV stock pricing information (pkey: symbol, date)

tickers: A table containing detailed information on each ticker/symbol in the daily_prices table (pkey: symbol)

Note: The database password is stored as an environmental variable.

Database Requirements

Download and install PostgreSQL

Download and install pgAdmin

Create a new database instance in pgAdmin, name the new database 'stockdata'

Python Requirements

Download and install Anaconda

Create a new virtual environment

$ conda create --name polyenv python=3.8

Activate the new virtual environment

$ conda activate polyenv

Install packages

$ pip install -r requirements.txt

Alternatively, you can take a look at the requirements.txt file and install what you need.

Note, I'm using VS Code with the ipykernel (Jupyter Notebook) capability to run in a notebook like experience. You can certainly also run this without this.

Additional instructions on my YouTube channel

About

How to create a PostgreSQL stock database using Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%