Module Reference Index
This is the canonical index of every OpenQuant module: one page each, with purpose, APIs, formulas, examples, and implementation notes. It lists the same 42 modules twice over — by subject, and by the language surface they are reachable through — because those are the two questions readers arrive with. For the AFML chapter each module implements, see By AFML Chapter.
By subject
Section titled “By subject”Data Ingestion and Quality
Section titled “Data Ingestion and Quality”adapters— Polars DataFrame adapters for signals, events, weights, backtest curves, and streaming buffers.data— Fetching daily OHLCV through a cache, content hashes for run manifests, and OHLCV loading, cleaning, calendar alignment and quality reporting.
Event-Driven Data and Labeling
Section titled “Event-Driven Data and Labeling”data_structures— Time, tick, volume, dollar, run and imbalance bars built from a stream of trades.filters— The symmetric CUSUM filter and a rolling z-score filter for event-based sampling.labeling— Triple-barrier labels and meta-labels, with barriers in units of volatility at the event.sample_weights— Training weights for overlapping labels: return attribution and time decay.
Market Microstructure, Dependence and Regime Detection
Section titled “Market Microstructure, Dependence and Regime Detection”codependence— Correlation distances, distance correlation, mutual information and variation of information.fracdiff— Fractional differentiation: stationarity with as much memory as possible.microstructural_features— Spread, price-impact, order-flow and entropy features from bars or trades.structural_breaks— SADF for explosive behaviour, a Chow-type Dickey-Fuller test, and the CSW CUSUM test.util::fast_ewma— Fast EWMA primitive shared across feature and volatility routines.util::volatility— Volatility estimators used across labeling and risk workflows.
Portfolio Construction and Risk
Section titled “Portfolio Construction and Risk”backtest_statistics— Probabilistic and deflated Sharpe ratios, minimum track record, drawdown and concentration.cla— The Critical Line Algorithm: the exact long-only efficient frontier as a sequence of turning points.hcaa— Hierarchical allocation down the cluster tree, cut at a chosen number of clusters, with a choice of risk measure.hrp— Hierarchical Risk Parity: weights from a clustering of the correlation matrix, with no inversion.onc— Optimal Number of Clusters: k-means over a correlation matrix, with the count chosen by silhouette quality.portfolio_optimization— Mean-variance allocation with weight bounds: inverse variance, minimum volatility, maximum Sharpe, target return.risk_metrics— Historical value at risk, expected shortfall, conditional drawdown at risk and portfolio variance.strategy_risk— The precision and bet frequency a target Sharpe ratio requires, and the probability of falling short.
Position Sizing and Trade Construction
Section titled “Position Sizing and Trade Construction”bet_sizing— From a probability or a price forecast to a position size, averaged over live bets and discretised.etf_trick— A rebalanced futures basket, or one rolled contract, as a single continuous value series.
Research Workflows
Section titled “Research Workflows”data_processing— Rust OHLCV deduplication, gap diagnostics and regular-grid alignment through row, column and DataFrame interfaces.evaluation— PSR, deflated Sharpe and minimum track record from a returns series, with a trial registry that persists the count DSR deflates by.pipeline— End-to-end AFML research pipeline: events → signals → portfolio → risk → backtest, with ordering checks.research— Synthetic dataset generation and flywheel research iteration with cost modeling and promotion gates.viz— Visualization payload builders for feature importance, drawdown, regime, frontier, and cluster charts.
Sampling, Validation and ML Diagnostics
Section titled “Sampling, Validation and ML Diagnostics”backtesting_engine— Walk-forward, purged CV and combinatorial purged CV splits, with CPCV’s out-of-sample paths.cross_validation— Purged k-fold cross-validation with an embargo, for overlapping labels.ef3m— EF3M: a mixture of two Gaussians fitted by matching its first four or five moments exactly.ensemble_methods— Diagnostics for bagged ensembles: variance reduction given estimator correlation.feature_diagnostics— Python importance reports on purged folds, with a substitution-effect report and a feature screen.feature_importance— MDI, MDA and SFI feature importance, and a PCA cross-check, on purged folds.fingerprint— Linear, non-linear and pairwise-interaction effects of each feature in a fitted model.hyperparameter_tuning— Grid and randomised search on purged k-fold splits, scored with sample weights.sampling— Label concurrency, average uniqueness and the sequential bootstrap.sb_bagging— A bagging ensemble that draws each estimator’s sample with the sequential bootstrap, around a one-feature base learner.synthetic_backtesting— Profit-taking and stop-loss levels chosen on simulated paths of a fitted mean-reverting process.
Scaling, HPC and Infrastructure
Section titled “Scaling, HPC and Infrastructure”combinatorial_optimization— Exhaustive search over small integer problems and single-instrument trading paths, as an exact baseline.dynamic_allocation— AFML Chapter 21’s multi-asset allocation trajectories, enumerated exactly with square-root trading costs and a bounded search.hpc_parallel— AFML’s atoms and molecules: equal-work partitions of a job, run in serial or on threads, outputs in order.streaming_hpc— VPIN and a venue-concentration HHI updated event by event in constant memory, with a joint alert.
By language surface
Section titled “By language surface”Rust core
Section titled “Rust core”backtest_statistics— Probabilistic and deflated Sharpe ratios, minimum track record, drawdown and concentration.backtesting_engine— Walk-forward, purged CV and combinatorial purged CV splits, with CPCV’s out-of-sample paths.bet_sizing— From a probability or a price forecast to a position size, averaged over live bets and discretised.cla— The Critical Line Algorithm: the exact long-only efficient frontier as a sequence of turning points.codependence— Correlation distances, distance correlation, mutual information and variation of information.combinatorial_optimization— Exhaustive search over small integer problems and single-instrument trading paths, as an exact baseline.cross_validation— Purged k-fold cross-validation with an embargo, for overlapping labels.data— Fetching daily OHLCV through a cache, content hashes for run manifests, and OHLCV loading, cleaning, calendar alignment and quality reporting.data_processing— Rust OHLCV deduplication, gap diagnostics and regular-grid alignment through row, column and DataFrame interfaces.data_structures— Time, tick, volume, dollar, run and imbalance bars built from a stream of trades.dynamic_allocation— AFML Chapter 21’s multi-asset allocation trajectories, enumerated exactly with square-root trading costs and a bounded search.ef3m— EF3M: a mixture of two Gaussians fitted by matching its first four or five moments exactly.ensemble_methods— Diagnostics for bagged ensembles: variance reduction given estimator correlation.etf_trick— A rebalanced futures basket, or one rolled contract, as a single continuous value series.feature_importance— MDI, MDA and SFI feature importance, and a PCA cross-check, on purged folds.filters— The symmetric CUSUM filter and a rolling z-score filter for event-based sampling.fingerprint— Linear, non-linear and pairwise-interaction effects of each feature in a fitted model.fracdiff— Fractional differentiation: stationarity with as much memory as possible.hcaa— Hierarchical allocation down the cluster tree, cut at a chosen number of clusters, with a choice of risk measure.hpc_parallel— AFML’s atoms and molecules: equal-work partitions of a job, run in serial or on threads, outputs in order.hrp— Hierarchical Risk Parity: weights from a clustering of the correlation matrix, with no inversion.hyperparameter_tuning— Grid and randomised search on purged k-fold splits, scored with sample weights.labeling— Triple-barrier labels and meta-labels, with barriers in units of volatility at the event.microstructural_features— Spread, price-impact, order-flow and entropy features from bars or trades.onc— Optimal Number of Clusters: k-means over a correlation matrix, with the count chosen by silhouette quality.pipeline— End-to-end AFML research pipeline: events → signals → portfolio → risk → backtest, with ordering checks.portfolio_optimization— Mean-variance allocation with weight bounds: inverse variance, minimum volatility, maximum Sharpe, target return.risk_metrics— Historical value at risk, expected shortfall, conditional drawdown at risk and portfolio variance.sample_weights— Training weights for overlapping labels: return attribution and time decay.sampling— Label concurrency, average uniqueness and the sequential bootstrap.sb_bagging— A bagging ensemble that draws each estimator’s sample with the sequential bootstrap, around a one-feature base learner.strategy_risk— The precision and bet frequency a target Sharpe ratio requires, and the probability of falling short.streaming_hpc— VPIN and a venue-concentration HHI updated event by event in constant memory, with a joint alert.structural_breaks— SADF for explosive behaviour, a Chow-type Dickey-Fuller test, and the CSW CUSUM test.synthetic_backtesting— Profit-taking and stop-loss levels chosen on simulated paths of a fitted mean-reverting process.util::fast_ewma— Fast EWMA primitive shared across feature and volatility routines.util::volatility— Volatility estimators used across labeling and risk workflows.
Python namespaces
Section titled “Python namespaces”adapters—to_polars_signal_frame,to_polars_event_frame,to_polars_backtest_frame,to_polars_weights_frame,to_polars_indicator_matrix,to_polars_frontier_frame,SignalStreamBuffer,to_pandasbacktest_stats—sharpe_ratio,information_ratio,probabilistic_sharpe_ratio,deflated_sharpe_ratio,minimum_track_record_length,timing_of_flattening_and_flips,average_holding_period,bets_concentration,all_bets_concentration,drawdown_and_time_under_waterbacktesting_engine—cpcv_path_count,run_cpcv,assemble_cpcv_pathsbars—build_time_bars,build_tick_bars,build_volume_bars,build_dollar_bars,bar_diagnosticsbet_sizing—get_signal,discrete_signal,bet_size,bet_size_sigmoid,bet_size_power,inv_price,inv_price_sigmoid,inv_price_power,get_w,get_w_sigmoid,get_w_power,get_target_pos,get_target_pos_sigmoid,get_target_pos_power,limit_price,limit_price_sigmoid,limit_price_power,avg_active_signals,bet_size_dynamic,cdf_mixture,single_bet_size_mixed,get_concurrent_sides,bet_size_budget,bet_size_probability,mp_avg_active_signals,bet_size_reserve,bet_size_reserve_with_fit,bet_size_reserve_fullcla—allocate_clacodependence—angular_distance,absolute_angular_distance,squared_angular_distance,distance_correlation,get_optimal_number_of_bins,get_mutual_info,variation_of_information_scorecross_validation—purged_kfold_splits,split_with_diagnostics,cpcv_splits,cpcv_paths,naive_kfold_splits,count_train_test_overlaps,walk_forward_splits,walk_forward_split_with_diagnostics,null_score_distribution,null_p_value,bootstrap_returnsdata—fetch,dataset_hash,record_dataset_hash,quality_failures,default_cache_dir,DataSource,LocalSampleSource,LocalFileSource,CallableSource,CacheMissError,load_ohlcv,clean_ohlcv,align_calendar,data_quality_reportdynamic_allocation—pigeonhole_partitions,all_weights,transaction_costs,trajectory_sharpe_ratio,dynamic_optimal_portfolioef3m—centered_moment,raw_moment,most_likely_parameters,fit_m2nensemble—bias_variance_noise,bootstrap_sample_indices,sequential_bootstrap_sample_indices,aggregate_regression_mean,aggregate_classification_vote,aggregate_classification_probability_mean,average_pairwise_prediction_correlation,bagging_ensemble_variance,recommend_bagging_vs_boostingevaluation—return_moments,probabilistic_sharpe_ratio,deflated_sharpe_ratio,expected_max_sharpe,minimum_track_record_length,meta_label_metrics,strategy_failure_probability,config_hash,TrialRegistryfast_ewma—ewmafeature_diagnostics—mdi_importance,mda_importance,sfi_importance,orthogonalize_features_pca,substitution_effect_reportfeature_importance—mean_decrease_impurity,mean_decrease_accuracy,single_feature_importance,mda_from_probabilities,sfi_from_probabilitiesfilters—cusum_filter_indices,cusum_filter_timestamps,z_score_filter_indices,z_score_filter_timestampsfracdiff—get_weights,get_weights_ffd,frac_diff,frac_diff_ffdhcaa—allocate_hcaahrp—allocate_hrphyperparameter_tuning—expand_param_grid,sample_param_sets,classification_score,purged_searchlabeling—triple_barrier_labels,triple_barrier_events,meta_labels,add_vertical_barrier,get_events,get_bins,drop_labelsmicrostructural—get_roll_measure,get_roll_impact,get_corwin_schultz_estimator,get_bekker_parkinson_vol,get_bar_based_kyle_lambda,get_bar_based_amihud_lambda,get_bar_based_hasbrouck_lambda,get_trades_based_kyle_lambda,get_trades_based_amihud_lambda,get_trades_based_hasbrouck_lambda,vwap,get_avg_tick_size,get_vpin,get_bvc_buy_volume,encode_tick_rule_array,quantile_mapping,sigma_mapping,encode_array,get_shannon_entropy,get_lempel_ziv_entropy,get_plug_in_entropy,get_konto_entropyonc—get_onc_clusterspipeline—run_mid_frequency_pipeline,run_mid_frequency_pipeline_frames,summarize_pipeline,infer_periods_per_yearportfolio—allocate_inverse_variance,allocate_min_vol,allocate_max_sharpe,allocate_efficient_risk,allocate_with_solution,allocate_from_inputsresearch—make_synthetic_futures_dataset,run_flywheel_iteration,run_flywheel_grid,research_run_manifest,ResearchDatasetrisk—calculate_value_at_risk,calculate_expected_shortfall,calculate_conditional_drawdown_risk,calculate_variance,calculate_value_at_risk_from_matrix,calculate_expected_shortfall_from_matrix,calculate_conditional_drawdown_risk_from_matrixsample_weights—get_weights_by_return,get_weights_by_time_decaysampling—get_ind_matrix,seq_bootstrap,get_ind_mat_average_uniqueness,get_ind_mat_label_uniqueness,bootstrap_loop_run,get_av_uniqueness_from_triple_barrier,num_concurrent_eventssb_bagging—fit_predict_sb_classifier,fit_predict_sb_regressor,SequentiallyBootstrappedBaggingClassifierstrategy_risk—sharpe_symmetric,implied_precision_symmetric,implied_frequency_symmetric,sharpe_asymmetric,implied_precision_asymmetric,implied_frequency_asymmetric,estimate_strategy_failure_probabilitystreaming_hpc—run_streaming_pipeline,generate_synthetic_flash_crash_streamstructural_breaks—get_chow_type_stat,get_chu_stinchcombe_white_statistics,get_sadfsynthetic_bt—calibrate_ou_params,generate_ou_paths,evaluate_rule_on_paths,detect_no_stable_optimum,run_synthetic_otr_workflow,search_optimal_trading_ruleviz—prepare_feature_importance_payload,prepare_feature_importance_comparison_payload,prepare_drawdown_payload,prepare_regime_payload,prepare_frontier_payload,prepare_cluster_payloadvolatility—get_daily_vol,get_parkinson_vol,get_garman_class_vol,get_yang_zhang_vol