This document covers Meta Models, an advanced meta-learning system for dynamic strategy selection and classification in the Systematica framework.
Meta Models use machine learning classifiers to determine which trading strategy to apply at any given time based on market state representations and historical strategy performance.
Overview
The Meta Model system implements a hierarchical classification approach where multiple trading strategies compete for selection based on their historical performance. The system consists of state representation engines, reward calculation modules, and classification models that together determine optimal strategy allocation. Meta models operate through a multi-stage process:- Feature Collection: Executes multiple base models and calculates rolling metrics
- State Representation: Generates input features from market data
- Target Generation: Creates categorical labels from best-performing strategies
- Classification: Trains ML model to predict optimal strategy
- Signal Generation: Converts predictions to trading signals
use_neptune: Load models from Neptune experiments vs. local configsklearn.Pipeline: Custom ML pipeline componentswindow_in_days: Rolling metric calculation windowtraining_window/testing_window: Cross-validation parameters
Architecture
System Overview
API & Core Components
Key Integration Points
Config & State Management
Signal Generation
Meta-Learning Functionality
Foundation
TheBaseMetaModel class provides the foundation for meta-learning functionality, handling feature processing, category management, and classifier training.
Steps
Model Creation and Data Sources
Meta Models can be created from two primary data sources: model registries for local configurations or Neptune experiments for cloud-based model tracking.- From Model Registry: The
from_model_config()method creates meta models using local feature configurations stored inModelRegistry. - From Neptune Experiments: The
from_neptune()method creates meta models using cloud-based feature configurations stored inNeptuneAIRegistry.
Classification and Cross-Validation
The classification engine uses time series cross-validation to train models that predict which trading strategy should be active based on current market conditions.Performance Evaluation
The system provides comprehensive model evaluation tools including accuracy metrics, classification reports, and confusion matrices.State Representation
State representation converts market data into feature vectors suitable for machine learning classification. TheState class processes multiple data sources to create comprehensive market state descriptions.
Signal Generation and Trading
Meta Models generate trading signals by converting classifier predictions into actionable buy/sell decisions for the optimal strategy at each time period.Signal Generation Pipeline
Portfolio Execution Pipeline
MetaModel
MetaModel is a class for cross-validation of meta models.
It allows for the evaluation of different model configurations and
the generation of trading signals based on the results. The class is designed
to work with various classifiers and preprocessors, and it supports custom
data splitting strategies for training and testing.
Method generated by attrs for class MetaModel.
Ancestors
systematica.models.base.BaseStatArbabc.ABC
Instance variables
-
custom_splitter: str | None: Custom splitter to use for data partitioning. Defaults toNone. If set, it should be a string that matches a custom splitter function. -
custom_splitter_kwargs: Dict[str, Any]: Additional keyword arguments for the custom splitter. Defaults toNone. Ifcustom_splitteris set, this should contain any necessary parameters for the custom splitter function. -
downsample: str: Resample data before state representation computation use to speed up the process. Upsampling and ffill is performed straight after. IfNone, no resampling is performed. Defaults to1d(daily). -
estimator: sklearn.base.BaseEstimator: Classifier model. IfNone, defaults toLogisticRegression(akalogit,MaxEnt) classifier fromsklearn. Defaults toNone. -
metrics: str: Metric(s) to calculate the reward. Defaults tosharpe_ratio. -
minp: int: Minimum number of observations required. Defaults toNone. -
model_registry: List[systematica.registries.base.Register]: Config of models to use for metric calculation. Defaults tomodel_registry. -
n_steps: int: Number of periods to shift backward bynpositions. This operation intentionally looks ahead to train the model! Must be positive. Default to1. -
neptune_registry: List[systematica.registries.base.Register]: Config of models to use for metric calculation whenuse_neptuneis set to True. Defaults toneptune_registry. -
preprocessor: sklearn.base.BaseEstimator: Standardize features. If None, defaults to StandardScaler. Defaults toNone. -
splitter: str: Default splitter to be used if custom_splitter is not passed. Choices arefrom_rolling,from_custom_rolling,from_expanding,from_custom_expanding. Defaults to “from_custom_rolling”. -
state_registry: systematica.registries.base.Register: State representation config. ifNone, usesStateRegistry. Defaults toNone. -
testing_window: int: The size of the testing window. Defaults to60. -
training_window: int: The size of the training window. Defaults to365. -
use_neptune: bool: UseneptuneifTrue,configotherwise. Defaults toFalse. -
window_in_days: int: The size of the rolling window in days. Defaults to365. This is the window size used for calculating both rolling metrics and state representations.
Methods
get_signals
Returns:

