Skip to main content
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.
Meta models implement machine learning approaches for dynamic strategy selection, using features from multiple base models to predict optimal strategies.

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
Key configuration options:
  • use_neptune: Load models from Neptune experiments vs. local config
  • sklearn.Pipeline: Custom ML pipeline components
  • window_in_days: Rolling metric calculation window
  • training_window/testing_window: Cross-validation parameters

Architecture

System Overview

API & Core Components

Key Integration Points

Config & State Management

Signal Generation

Meta-Learning Functionality

Foundation

The BaseMetaModel 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 in ModelRegistry.
  • From Neptune Experiments: The from_neptune() method creates meta models using cloud-based feature configurations stored in NeptuneAIRegistry.

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. The State 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.BaseStatArb
  • abc.ABC

Instance variables

  • custom_splitter: str | None: Custom splitter to use for data partitioning. Defaults to None. 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 to None. If custom_splitter is 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. If None, no resampling is performed. Defaults to 1d (daily).
  • estimator: sklearn.base.BaseEstimator: Classifier model. If None, defaults to LogisticRegression (aka logit, MaxEnt) classifier from sklearn. Defaults to None.
  • metrics: str: Metric(s) to calculate the reward. Defaults to sharpe_ratio.
  • minp: int: Minimum number of observations required. Defaults to None.
  • model_registry: List[systematica.registries.base.Register]: Config of models to use for metric calculation. Defaults to model_registry.
  • n_steps: int: Number of periods to shift backward by n positions. This operation intentionally looks ahead to train the model! Must be positive. Default to 1.
  • neptune_registry: List[systematica.registries.base.Register]: Config of models to use for metric calculation when use_neptune is set to True. Defaults to neptune_registry.
  • preprocessor: sklearn.base.BaseEstimator: Standardize features. If None, defaults to StandardScaler. Defaults to None.
  • splitter: str: Default splitter to be used if custom_splitter is not passed. Choices are from_rolling, from_custom_rolling, from_expanding, from_custom_expanding. Defaults to “from_custom_rolling”.
  • state_registry: systematica.registries.base.Register: State representation config. if None, uses StateRegistry. Defaults to None.
  • testing_window: int: The size of the testing window. Defaults to 60.
  • training_window: int: The size of the training window. Defaults to 365.
  • use_neptune: bool: Use neptune if True, config otherwise. Defaults to False.
  • window_in_days: int: The size of the rolling window in days. Defaults to 365. This is the window size used for calculating both rolling metrics and state representations.

Methods

get_signals

Generate trading signals based on scores. See BaseStatArb.get_signals Parameters: Returns: