How quantopian/empyrical works
Project type and purpose
• This is a Python library (“empyrical”) providing common financial risk and performance metrics (drawdown, alpha/beta, capture ratios, etc.).
• It’s intended for import as a dependency in other Python projects, not a standalone web or desktop application.
File structure
• Top-level packaging and configuration:
• setup.py, setup.cfg, versioneer.py – package metadata and version management
• MANIFEST.in, LICENSE – packaging and legal files
• .gitignore, .gitattributes, .travis.yml – VCS and CI configuration
• runtests.py – test harness
• Core source code directory: empyrical/
• __init__.py – package entry point (version import)
• _version.py – auto-generated version stub
• stats.py, perf_attrib.py, periods.py, deprecate.py – main algorithm modules
• utils.py – deprecated data-loading utilities
• Documentation: docs/ (Sphinx)
• Test suite: empyrical/tests/ with sample CSVs under test_data/
README for additional insights
• Dependencies: numpy, pandas (optional), nose, parameterized
• Features: simple and rolling measures, pandas support
• Deprecation notice: data‐reading utilities are deprecated
a. Main components
• Core Library Modules (empyrical package)
• External Dependencies (numpy, pandas)
• Test Suite
• Documentation Build
• Packaging & Release Tooling
b. Relationships and interactions
• Core modules import numpy (and pandas for Series support)
• perf_attrib, stats, periods call shared utility functions
• utils (deprecated) stand apart but still import pandas-datareader (indicate deprecation)
• tests import core modules and sample CSVs, run via runtests.py
• docs reference the core modules, built with Sphinx (docs/conf.py, Makefile)
• setup.py pulls in versioneer.py for version stamping; produces a PyPI artifact
c. Architectural patterns / design principles
• Modular decomposition by functionality (statistics vs performance attribution vs period calculations)
• Clear separation of concerns: core algorithms vs I/O utilities vs testing vs docs
• Deprecation path indicated in deprecate.py and utils.py
d. Key technologies & frameworks
• Python packaging: setuptools (setup.py), versioneer
• Testing: nose, parameterized
• Documentation: Sphinx (conf.py, Makefile)
• CI: Travis CI (.travis.yml)