Skip to content

Repository files navigation

BankLab: JPM vs Morgan Stanley Analytics Platform

CIPython 3.11+License: MIT

A reproducible research platform for comparative analysis of JPMorgan Chase (JPM) and Morgan Stanley (MS) using public data sources.

Overview

BankLab provides a clean, professional pipeline for:

  • Fundamentals: SEC EDGAR XBRL company facts (10-K/10-Q filings)
  • Market Data: Daily prices and returns from public sources
  • Factor Models: Fama-French 5-factor daily returns
  • Macro Context: FRED economic indicators

Quick Start

# Clone and setup
git clone https://github.com/Leotaby/banklab.git
cd banklab
pip install -e ".[dev]"# Set FRED API key (get free key at https://fred.stlouisfed.org/docs/api/api_key.html)export FRED_API_KEY="your_key_here"# Download and process all data
make data
# Run tests
make test# Build full report
make report

Data Sources

SourceDescriptionUpdate Frequency
SEC EDGARCompany facts, filings metadataQuarterly
StooqDaily stock pricesDaily
Fama-French5-factor model returnsDaily
FREDFed Funds Rate, Treasury yields, GDPVarious

Project Structure

banklab/
├── src/banklab/ # Main package
│ ├── ingest/ # Data downloaders
│ │ ├── sec.py # SEC EDGAR API
│ │ ├── market.py # Stock prices
│ │ ├── factors.py # Fama-French factors
│ │ └── macro.py # FRED macro series
│ ├── process/ # Data transformations
│ │ └── pipeline.py # Processing pipeline
│ ├── utils/ # Shared utilities
│ │ ├── cache.py # Caching + manifest
│ │ └── http.py # Polite HTTP client
│ └── run.py # CLI entry point
├── tests/ # pytest test suite
├── data/
│ ├── raw/ # Cached downloads (gitignored)
│ └── processed/ # Output parquet files
├── notebooks/ # Jupyter analysis notebooks
├── docs/ # Documentation
└── data_manifest.yml # Data provenance log

Output Schemas

prices_daily.parquet

ColumnTypeDescription
datedateTrading date
tickerstringStock ticker (JPM, MS)
closefloat64Adjusted close price
retfloat64Daily return

factors_daily.parquet

ColumnTypeDescription
datedateTrading date
mktrffloat64Market excess return
smbfloat64Size factor
hmlfloat64Value factor
rmwfloat64Profitability factor
cmafloat64Investment factor
rffloat64Risk-free rate

macro_monthly.parquet

ColumnTypeDescription
datedateObservation date
series_idstringFRED series identifier
valuefloat64Observation value

fundamentals_raw_facts.parquet

ColumnTypeDescription
datedateFiling/period end date
cikstringSEC CIK identifier
tickerstringStock ticker
tagstringXBRL taxonomy tag
valuefloat64Reported value
unitstringUnit of measure
fpstringFiscal period (FY, Q1-Q4)
fyint64Fiscal year
formstringFiling form type

Makefile Commands

make data # Download and process all data
make build # Install package in dev mode
make test# Run pytest suite
make lint # Run ruff linter
make report # Generate analysis report
make clean # Remove cached data
make all # Full pipeline: build → data → test → report

Configuration

Environment Variables

VariableRequiredDescription
FRED_API_KEYYesFRED API key for macro data
BANKLAB_DATA_DIRNoOverride default data directory

Rate Limiting

The SEC requires polite access with proper User-Agent headers. BankLab implements:

  • 10 requests/second max to SEC EDGAR
  • Exponential backoff on 429 responses
  • Persistent caching to minimize repeated requests

Development

# Install with dev dependencies
pip install -e ".[dev]"# Run linter
ruff check src/ tests/
# Run tests with coverage
pytest --cov=banklab --cov-report=term-missing
# Format code
ruff format src/ tests/

License

MIT License - see LICENSE for details.

Citation

If you use this platform in research, please cite:

@software{banklab2025,
author = {Hatef Tabbakhian},
title = {BankLab: JPM vs Morgan Stanley Analytics Platform},
year = {2025},
url = {https://github.com/Leotaby/banklab}
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages