The Models API manages ML model definitions and exposes the full training pipeline. A model definition records theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/najmulhossainnj/Hedge-fund-backend/llms.txt
Use this file to discover all available pages before exploring further.
model_type, family, and parameters; the training endpoints drive time-series cross-validation using rolling or expanding window splits, Optuna hyperparameter search across configurable trial budgets, and multi-candidate AutoML evaluation that produces a ranked leaderboard — all backed by S3/MinIO artifact storage and MLflow experiment tracking via mlflow_run_id. Model families span statistical (arima, garch), machine learning (xgboost, lightgbm, catboost, random_forest), deep learning (lstm), and ensemble methods.
Model CRUD
Create a Model Definition
/api/v1/models
Request Body
Human-readable name, e.g.
"XGBoost v1". Maximum 255 characters.Algorithm identifier, e.g.
"xgboost", "lstm", "arima". This is the sub-type within the family.Model family. One of:
"statistical", "machine_learning", "deep_learning", "ensemble".Initial hyperparameters passed to the model plugin constructor, e.g.
{"n_estimators": 100, "max_depth": 5}. Defaults to {}.Response — ModelRead
Unique model identifier.
Model name.
Algorithm sub-type.
Model family.
Stored hyperparameters.
Optimistic-lock version counter, incremented on each update.
MLflow run ID linked after training.
null before first train.S3 URI to the serialized model artifact.
null before first train.Latest CV metric summary dict stored after training. Empty before first train.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
List Model Definitions
/api/v1/models
Query Parameters
Number of records to skip. Default
0.Maximum records to return. Default
100.ModelRead objects.
Get a Model Definition
/api/v1/models/{model_id}
UUID of the model to retrieve.
ModelRead object.
Errors: 404 Model not found.
Update a Model Definition
/api/v1/models/{model_id}
Request Body (all optional)
Updated name.
Updated algorithm type.
Updated model family.
Replacement hyperparameter dict (full replace, not merge).
Link or update the MLflow run ID.
Override the S3 artifact URI.
Override the stored metrics dict.
ModelRead object.
Errors: 404 Model not found.
Delete a Model Definition
/api/v1/models/{model_id}
204 No Content
Errors: 404 Model not found.
Training
Train with Time-Series Cross-Validation
/api/v1/models/{model_id}/train
FeatureDataset records, aligns them to a forward-return target at target_horizon bars, runs time-series cross-validation, serializes the fitted model to S3, and records the MLflow run. The call is synchronous and blocks until training completes.
Path Parameter
UUID of the model definition to train.
Request Body — TrainRequest
Response — TrainResponse
UUID of the trained model (same as path parameter).
S3 path to the serialized model artifact written after training.
Fold-level and aggregate cross-validation metrics, including per-fold MSE, MAE, and directional accuracy, plus summary statistics (mean, std).
Total number of aligned rows in the assembled training frame (after feature warm-up period and target shift).
Ordered list of column names in the feature matrix
X, useful for reproducing the exact input schema.404 Model not foundor404 Unknown feature id(s)— if the model or any feature ID is missing.422 Unprocessable Entity— if fewer than 30 aligned rows remain after feature warm-up and target alignment.
Train Asynchronously
/api/v1/models/{model_id}/train/async
GET /api/v1/tasks/{task_id}.
Request Body: Identical to POST /api/v1/models/{model_id}/train.
Response:
404 Model not found.
Hyperparameter Tuning
Run an Optuna Tuning Study
/api/v1/models/tune
param_space. Each trial trains the plugin with a sampled configuration and evaluates it under the same CV protocol as the training endpoint. Returns the best parameters found within n_trials.
Request Body — TuneRequest
Plugin to tune, e.g.
"ml.xgboost". Does not need to be associated with an existing model definition.Same
DatasetSpec structure as the training endpoint.Dictionary mapping parameter names to
ParamSpec objects.Number of Optuna trials to run. Default
30.Cross-validation configuration (same structure as training). Default: rolling, 5 splits, test_size 0.15.
Optimization direction:
"minimize" or "maximize". Default "minimize".Metric to optimize. Common values:
"mean_mse", "mean_mae", "directional_accuracy". Default "mean_mse".Response — TuneResponse
Hyperparameter dict from the best-scoring trial.
Metric value achieved by the best trial.
Number of trials actually completed (may be less than requested if early stopping occurs).
Run Tuning Asynchronously
/api/v1/models/tune/async
task_id.
Request Body: Identical to POST /api/v1/models/tune.
Response:
AutoML
Run AutoML Leaderboard
/api/v1/models/automl
Request Body — AutoMLRequest
Same
DatasetSpec structure as the training endpoint.Mapping of
plugin_key → fixed params dict. Each key–value pair is one candidate to evaluate, e.g. {"ml.xgboost": {"max_depth": 6}, "ml.lightgbm": {"num_leaves": 64}}.Cross-validation configuration shared across all candidates.
Ranking metric. Default
"mean_mse".Response — AutoMLResponse
score according to the chosen metric direction (ascending for error metrics).
Plugin Discovery
List Available Model Plugins
/api/v1/models/plugins/available
Get Default Hyperparameter Search Spaces
/api/v1/models/plugins/search-spaces
search_spaces.py. The Model Builder UI reads these to pre-populate the tuning configuration form, ensuring the frontend and tuner always use the same bounds.
These are the platform-default search spaces. You can override any parameter range or add new parameters in your
TuneRequest.param_space — the tuner uses your supplied spec in full.