Skip to main content

OptunaTuner

Method generated by attrs for class OptunaTuner.

Static methods

get_all_metrics

Get a list of metric keys from the registry that have a valid rolling_func. Optionally include non-tunable metrics based on user choice. Parameters: Returns:

Instance variables

  • target_names: List[str]: Normalize metric names.
  • create_study_kwargs: Dict[str, Any]: Additional optuna study parameters.
  • cross_validate: bool: Whether to use cross-validation analytics through run_report, wrapping BaseReportCV or BaseRollingReport instead of using run_pipeline alone. If True, optimize using cross validation. Otherwise, uses data history as a whole. Defaults to False.
  • direction: str | List[str]: Optimization direction for Optuna (default: ‘maximize’). If list, direction is modified to “directions” internally.
  • gc_after_trial: bool: Flag to determine whether to automatically run garbage collection after each trial. Set to True to run the garbage collection, False otherwise. It runs a full collection by internally calling gc.collect. If you see an increase in memory consumption over several trials, try setting this flag to True.
  • metric_registry_kwargs: Dict[str, Any]: Additional arguments for metric registry. Parameters such as window of minp for rolling metrics should be specified at this level.
  • metrics: str | List[str]: Performance metrics to compute (default: ‘sharpe_ratio’).
  • n_completed_trials: int: Number of trials to complete before stopping (default: None).
  • n_jobs: int: Parallel jobs for Optuna (default: -1).
  • n_trials: int: Number of optimization trials for Optuna (default: 100).
  • optimize_kwargs: Dict[str, Any]: Additional arguments for Optuna optimization.
  • pruner: optuna.pruners._base.BasePruner: Pruner. Defaults to Asynchronous Successive Halving Algorithm.
  • reduce_func: Callable: Reduce function when using cross_validate. If None, defaults to vbt.nb.nanmedian_nb. Defaults to None.
  • sampler: optuna.samplers._base.BaseSampler: Sampler. Defaults to TPE (Tree-structured Parzen Estimator) algorithm.
  • tracker: systematica.portfolio.trackers.base.BaseTracker: Log and monitor the Optuna hyperparameter using tracker integration.
  • use_rolling: bool: Flag to use rolling method via BaseRollingReport. Note that both rolling and cv models can be passed. Defaults to False.
  • verbose: bool: Enable verbose output (default: True).

Methods

check_direction

Validate optimization directions. Parameters: Raises:

check_metrics

Validate metrics Parameters: Raises:

create_objective

Creates an optimized objective function for Optuna by separating fixed and tunable parameters once. Parameters: Returns:

run_feature

Run feature config. Parameters: Returns:

run

Run optuna study or tracker. Parameters: Returns:

run_tracker

Run tracker. Parameters: Returns:

run_optuna

Run optuna. Parameters: Returns: