| Crates.io | factors |
| lib.rs | factors |
| version | 0.2.1 |
| created_at | 2025-12-25 14:15:30.14301+00 |
| updated_at | 2025-12-25 15:47:25.466252+00 |
| description | Unified factor library for alpha and risk models |
| homepage | https://github.com/factordynamics/factors |
| repository | https://github.com/factordynamics/factors |
| max_upload_size | |
| id | 2004587 |
| size | 533,192 |
Unified factor library for quantitative finance, serving both alpha generation (tarifa) and risk modeling (perth) use cases.
factors/
├── traits.rs # Core Factor trait definition
├── registry.rs # Factor discovery and introspection
├── standardize.rs # Cross-sectional z-scoring utilities
├── momentum/ # Trend persistence factors
├── value/ # Relative valuation factors
├── quality/ # Profitability and leverage factors
├── size/ # Market capitalization factors
├── volatility/ # Risk and beta factors
├── growth/ # Growth rate factors
└── liquidity/ # Trading volume factors
use factors::{Factor, FactorRegistry, FactorCategory};
// Create registry with all default factors
let registry = FactorRegistry::with_defaults();
// Get all momentum factors
let momentum = registry.by_category(FactorCategory::Momentum);
// Compute a specific factor
let short_momentum = registry.get("short_term_momentum").unwrap();
let result = short_momentum.compute(&data, date)?;
All factors implement the core Factor trait:
pub trait Factor: Send + Sync {
fn name(&self) -> &str;
fn description(&self) -> &str;
fn category(&self) -> FactorCategory;
fn required_columns(&self) -> &[&str];
fn lookback(&self) -> usize;
fn compute_raw(&self, data: &LazyFrame, date: NaiveDate) -> Result<DataFrame>;
fn compute(&self, data: &LazyFrame, date: NaiveDate) -> Result<DataFrame>;
}
All factors support cross-sectional standardization:
cross_sectional_standardize: Z-score normalization per datewinsorize: Clip extreme values to percentilesrobust_standardize: MAD-based standardization for outlier robustnessMIT License - see LICENSE.