Capturing Stock Prices into a Local Database
Goal
Tools and Services used
- SQL Server 2019
- Visual Studio Code
- SQL Server Database Project
- Python 3.9
- Jupyter plugin in Visual Studio Code
- SQL Server Management Studio 18
- IEX Cloud / Apperate
API Service Chosen
API Call Response Structure
"close": 0.99,
"fclose": 0.99,
"fhigh": 0.99,
"flow": 0.99,
"fopen": 0.99,
"fvolume": 0,
"high": 0.99,
"low": 0.99,
"open": 0.99,
"priceDate": "2023-01-12",
"symbol": "BTG-AO",
"uclose": 0.99,
"uhigh": 0.99,
"ulow": 0.99,
"uopen": 0.99,
"uvolume": 0,
"volume": 0,
"id": "HISTORICAL_PRICES",
"key": "BTG-AO",
"subkey": "",
"date": 1673481600000,
"updated": 1673503202000
}
]
Database Table Structure
Some things to take a note of.
- The schema APPERATE is created because that is the name of service the data is coming from putting grouping all tables and procedures used in association with that service under the same schema allows for easy convention structure to quickly know about those database objects.
- All the incoming data from the API Call is stored as strings so that it reduces the chances of running into an error when loading in the data into the database.
- This is only the first step of loading in the data. It will be converted into the actual data types like Dates and Decimals in another step.
- The other columns that are for keeping meta data about the data being loaded.
Loading Data with Python
Next is the Python file to do the API call then do some slight transformation and load into the SQL Database.
Comments
Post a Comment