How xingwudao/ferric-alpha works
Ferric Alpha is a Rust/Polars factor-analysis library with Rust and Python APIs and native tear-sheet rendering. The main workflow accepts long-form factor data, prepares and analyzes it, assembles serializable report data, then renders HTML, SVG, or PNG. Python plotting also offers an optional Matplotlib route. The graph reflects README capabilities and sampled API/rendering code; unsampled implementation wiring is shown only where documented, so some internal calls are intentionally omitted.
Main entry points: lib.rs PyO3 Bridge · tears.py Python API · _rendered.py Rendered Tear Sheet · mod.rs Tear-Sheet Data
Components 27
User APIs
- Python API
python/ferric_alpha/tears.py - Input Validation
python/ferric_alpha/_validation.py - PyO3 Bridge
crates/ferric-alpha-py/src/lib.rs - Performance API
python/ferric_alpha/performance.py
Factor Preparation
- Factor Data
crates/ferric-alpha/src/data.rs - Data Cleaning
crates/ferric-alpha/src/clean.rs - Forward Returns
crates/ferric-alpha/src/forward_returns.rs - Quantile Assignment
crates/ferric-alpha/src/quantiles.rs
Factor Analytics
- Information Coefficient
crates/ferric-alpha/src/performance/ic.rs - Quantile Returns
crates/ferric-alpha/src/performance/quantiles.rs - Portfolio Metrics
crates/ferric-alpha/src/performance/portfolio.rs - Return Metrics
crates/ferric-alpha/src/performance/returns.rs - Alpha and Beta
crates/ferric-alpha/src/performance/alpha_beta.rs - Turnover
crates/ferric-alpha/src/performance/turnover.rs - Event Studies
crates/ferric-alpha/src/performance/events.rs
Reports and Rendering
- Tear-Sheet Data
crates/ferric-alpha/src/report/mod.rs - Report Context
crates/ferric-alpha/src/report/context.rs - Report Serialization
crates/ferric-alpha/src/report/serialization.rs - Python Plotting
python/ferric_alpha/plotting/__init__.py - Render Planning
crates/ferric-alpha-render/src/plan/mod.rs - Chart Rendering
crates/ferric-alpha-render/src/charts - HTML Backend
crates/ferric-alpha-render/src/backend/html.rs - SVG Backend
crates/ferric-alpha-render/src/backend/svg.rs - PNG Backend
crates/ferric-alpha-render/src/backend/png.rs - Matplotlib Backend
python/ferric_alpha/plotting/_matplotlib.py - Rendered Tear Sheet
python/ferric_alpha/plotting/_rendered.py
Other components
- Researcher
Connections 31
- Researcher → Python API: submits data
- Python API → Input Validation: validates input
- Python API → PyO3 Bridge: calls API
- Performance API → PyO3 Bridge: calls metrics
- PyO3 Bridge → Factor Data: validates frame
- PyO3 Bridge → Data Cleaning: cleans data
- PyO3 Bridge → Forward Returns: computes returns
- PyO3 Bridge → Quantile Assignment: assigns quantiles
- PyO3 Bridge → Information Coefficient: computes IC
- PyO3 Bridge → Quantile Returns: computes metrics
- PyO3 Bridge → Portfolio Metrics: computes portfolio
- PyO3 Bridge → Return Metrics: computes returns
- PyO3 Bridge → Alpha and Beta: computes alpha beta
- PyO3 Bridge → Turnover: computes turnover
- PyO3 Bridge → Event Studies: computes events
- Python API → PyO3 Bridge: builds report
- PyO3 Bridge → Tear-Sheet Data: returns report data
- Tear-Sheet Data → Report Context: prepares report
- Tear-Sheet Data → Report Serialization: serializes report
- Researcher → Python Plotting: requests rendering
- Python Plotting → PyO3 Bridge: requests native output
- PyO3 Bridge → Render Planning: plans panels
- Render Planning → Chart Rendering: dispatches panels
- PyO3 Bridge → HTML Backend: renders HTML
- PyO3 Bridge → SVG Backend: renders SVG
- PyO3 Bridge → PNG Backend: renders PNG
- Python Plotting → Matplotlib Backend: selects backend
- HTML Backend → Rendered Tear Sheet: returns output
- SVG Backend → Rendered Tear Sheet: returns output
- PNG Backend → Rendered Tear Sheet: returns output
- Matplotlib Backend → Rendered Tear Sheet: returns figure