This project implements a robust and automated ETL pipeline to ingest end-of-day (EOD) financial data using the EOD Historical Data API, parse and enrich it with currency mappings, and store the results in a Microsoft SQL Server database.
The pipeline automates the following tasks:
- Authenticates and queries the EODHD API for daily EOD data per exchange.
- Applies ticker and exchange-specific currency enrichment.
- Transforms the raw EOD JSON into structured tabular data.
- Inserts the final output into SQL Server tables.
This system is designed for financial analysts, portfolio managers, and data engineers who require reliable and up-to-date daily price data for instruments traded across multiple exchanges.
Data is retrieved from the official EOD Historical Data API:
- Endpoint used:
eod-bulk-last-day/{exchange}
- Format: JSON with optional
"extended"
fieldset - Authentication: Token-based (passed as query parameter)
Note: The pipeline defaults to retrieving data for yesterday in CET time zone to ensure alignment with close-of-market hours globally.
Execution begins in main.py
and follows these stages:
-
Load Metadata:
- Queries the database for tickers and exchange/currency mappings.
-
Initialize Engine:
- Instantiates a custom
Engine
to manage API interactions and data normalization.
- Instantiates a custom
-
Fetch EOD Data:
- For each exchange, retrieves EOD data using the
eod-bulk-last-day
endpoint.
- For each exchange, retrieves EOD data using the
-
Enrich Data:
- Adds currency based on ticker and exchange mapping.
- Skips tickers with missing or malformed symbols.
-
Transform and Save:
- A
transformer.Agent
module shapes the parsed JSON into SQL-ready tables. - Uses bulk insertion via SQLAlchemy to persist results.
- A
eodhd-eod-main/
├── client/ # API client and ETL engine
│ ├── engine.py # Orchestrates data fetch and parsing
│ └── eodhd.py # Low-level EODHD API wrapper
├── config/ # Logging and settings handler
├── database/ # MSSQL DB helpers
├── transformer/ # Data frame preparation logic
├── main.py # Primary entrypoint
├── .env.sample # Sample environment variable configuration
├── Dockerfile # Docker setup
Create a .env
file using .env.sample
. Key variables:
Variable | Description |
---|---|
TOKEN |
EODHD API token |
EXCHANGES_DB_QUERY |
SQL query to pull exchange/currency mappings |
TICKERS_DB_QUERY |
SQL query to retrieve instrument tickers |
OUTPUT_TABLE |
Target SQL Server table for insert |
MSSQL_* |
Connection settings for SQL Server |
INSERTER_MAX_RETRIES |
Retry logic for insertions |
REQUEST_MAX_RETRIES , REQUEST_BACKOFF_FACTOR |
API request resilience |
Build and run this ETL pipeline in a containerized environment.
docker build -t eodhd-eod .
docker run --env-file .env eodhd-eod
Install Python dependencies:
pip install -r requirements.txt
Core packages:
pandas
: Data handlingrequests
: HTTP requestsSQLAlchemy
+pyodbc
: Database accessfast-to-sql
: Efficient batch insertionpython-decouple
: Environment variable parsing
Ensure all environment variables are correctly configured, then run:
python main.py
Logging will confirm:
- Exchanges and tickers loaded
- Data fetched from EODHD API
- Data inserted into the database
This project is MIT licensed. Use of the EODHD API must comply with the service's terms and conditions.