Setting Up Automatic Retraining of a Trading Model on LightGBM

A trading model loses accuracy when the market changes, and updates rely on manual runs. We set up automatic retraining turnkey: monitor quality, trigger updates by schedule or event, and return the model to a working state. This reduces update preparation time by about 60% and removes routine work from the team.

AI Development Areas

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Why a trading model degrades without automatic retraining

Any trading model is a snapshot of patterns taken over a specific segment of history. The market changes regime: liquidity flows between instruments, volatility changes, some features stop carrying signal.

Within a few weeks after training, this snapshot diverges from reality, and forecast quality declines without a single change in code.

Model degradation manifests as data drift in two forms. First is a shift in feature distribution: the same inputs begin arriving with different frequencies and ranges than during training.

Second is a change in the relationship between features and target: the dependency the model relied on weakens.

Validation on a holdout segment of history shows the usual metrics, while on live trades accuracy and ROC-AUC drop — the divergence between these two pictures is an early sign of drift.

Manual model updates add a second layer of the problem. Until retraining is launched manually, outdated data enters the training sample: the model continues to reproduce the logic of the market's past regime.

Between launches, quality reaches a plateau, then slides, and decisions are made based on forecasts that no longer reflect the current structure of supply and demand.

Especially unpleasant is that a failure doesn't look like a failure: there's no error, forecasts arrive, their value just quietly melts.

Below we break down how this is closed — from drift detection to scheduled retraining of gradient boosting on LightGBM, launched by schedule and by quality trigger, not by someone's memory.

Effect of regular trading model updates

Regular model updates change not so much the peak metric as its behavior over time. One-time tuning gives a good result on a historical segment and gradually diverges from the market: quality holds, then falls, then recovers again — a "sawtooth" instead of a flat line.

With a scheduled cycle, the stability of quality metrics is checked at each update and on the holdout period, so degradation is visible in advance, not after a drawdown in results.

Time to react to drift is the main measurable effect. We monitor divergence in input feature distributions and quality on a fresh data window; the trigger threshold is set in advance.

While the shift is within norm, the model is retrained on schedule; when the threshold is crossed, training starts out of turn — reaction time drops from weeks of manual diagnosis to several hours.

The model update pipeline is assembled as a reproducible process: export and validation of the data schema, training on a sliding window, validation on a holdout period, comparison with the running model, and publication only upon confirmed superiority.

If the new model is worse, it is not rolled out, and the current one remains in prod — rollback requires no manual actions.

We separately track the share of outdated data in the sample: too long a history drags along obsolete dependencies, too short makes the metric noisy. The balance is selected by measurement — which horizon gives the best result on fresh data. We train on LightGBM: fast runs allow retraining the model more often and not skimping on checks.

This mode turns the model from a one-time artifact into a maintained service: metrics are predictable, reaction to market shifts is measured in hours, and outdated data does not accumulate unnoticed in the sample.

Model update approaches: full cycle, incremental training, event-based

There is no universally "correct" update method: full training cycle, model incremental training, and event-based updates solve different problems and tolerate failures differently.

The selection criterion is how stable the input data distribution is and how expensive an outdated model is.

In practice, a combination is more often used: regular incremental training keeps the model sharp, while full rebuild by event provides backup during sharp shifts.

Option When it fits Limitations
Full training cycle Feature set changed, a large volume of new data accumulated, distribution diverged Slow: hours for training and validation, requires a full historical slice
Model incremental training Data is homogeneous, frequent and fast updates are needed Accumulates bias, gradually "forgets" old regimes, requires periodic full rebuild
Scheduled updates Regime changes smoothly, quality is predictable Between launches, the model runs on outdated weights and does not react to shifts
Event-based updates Participant behavior changes in jumps Requires established telemetry and protection from false triggers, rollback is harder

What to consider when choosing

Choosing an update strategy comes down to three questions: how quickly quality degrades, whether there is a reliable metric for the trigger, and how long rollback to the previous version takes.

Where the metric is captured reliably, event-based updates provide better freshness at lower resource consumption; where signals are noisy, a scheduled full cycle is more predictable.

How we build automatic retraining

Automatic retraining is not a single button but a closed loop: schedule, reproducible sample, quality control, and predictable rollback.

First we examine how the LightGBM model is trained now — where data comes from, who launches training manually and when, what happens to the version if metrics drop.

Then we assemble the process so it runs without human involvement but leaves a trail by which every version can be explained.

  1. Reviewing the current loop. We look at data sources, the sample formation scheme, and manual steps around training. We record which of them are actually needed and which remain a habit.
  2. Training launch scheme. We determine what triggers retraining: a schedule or accumulation of a new data volume, less often a metric falling below threshold. We block parallel launches so that two versions are not written to the same place.
  3. Preparing data for training. We assemble features as of the event time, without looking into the future, and apply the same transformations in training and in production. A discrepancy here is the main reason a model is "good on paper and weak in prod."
  4. Training and version fixation. The run follows a fixed configuration; the output is a model artifact, metadata, and metrics tied to a specific sample. Any version can be reproduced and compared with neighboring ones.
  5. Validating the model on history. We run the new version on a holdout period it has not seen and compare it with the current running one. If the improvement is below threshold, the version is not rolled out and training is considered unsuccessful.
  6. Handover and scheduled launch. Switching happens according to the regulation, with notifications and simple rollback to the previous version with one command. After that, the loop runs itself, and we support it on an agreed rhythm.

Configurations, schemas, and regulations at handover

Automatic retraining is not one script but a set of artifacts that must work without us: launch configurations, data flow schema, access rules, and a regulation for reacting to quality drops.

All of this is handed over to the customer's repository with change history, so that the team's engineer can reproduce any run, change parameters, and relaunch training on their own without contacting us.

  • Launch configurations — files describing the training window, feature set, retraining start conditions, and rejection thresholds. Edited without code changes.
  • Data flow schema — where the historical slice comes from, where it is de-identified, in what form it enters training, and where the candidate model goes.
  • Access separation for models — roles separately for reading metrics, separately for launching retraining, and separately for publishing to the production loop. Publication does not coincide with development rights.
  • Run logs — for each iteration, quality metrics, data version, configuration, and a link to the artifact are saved. They show what changed and when.
  • Degradation response regulation — which metrics count as a signal, who receives the alert, in what time and by what scenario the model returns to the previous version.
  • Versioning and rollback — storage of several latest model and data versions so that rollback takes one step and does not require retraining.
  • Documentation and acceptance — instructions for local reproduction of a run, a pre-publication checklist, and incident review together with the customer's team.

We separately fix the boundary of responsibility: what we maintain and what remains on the customer's side. This removes disputes at the first metric divergence.

Case: data drift and restoring model quality

The trading model was retrained manually: an analyst once every few weeks exported fresh data, started training, and handed the new version over to production.

While the market behaved as usual, quality held, and no one tracked how much the input features had diverged from those the model was trained on.

The model is built on LightGBM — gradient boosting over decision trees, which captures nonlinear relationships between features well.

The turning point came with a change in volatility regime: the distributions of key features shifted, while the model continued to confidently forecast based on outdated dependencies.

Quality on live data dropped from 0.78 to 0.64, the share of correct signals almost halved — and this was noticed from a drawdown in results, not from drift.

What was changed

We began calculating a stability index and a distribution divergence test on a sliding window for each feature.

Retraining was decoupled from the calendar: the cycle is launched by a divergence threshold and runs without manual steps — feature rebuilding, training, validation on a holdout period, comparison with the running version.

A new model goes into production only with better quality; otherwise an alert remains; for the first day it runs in shadow mode alongside the old one, and rollback is one command.

Metrics before and after

The path from detecting the shift to a working model was reduced from eleven days to four hours. Quality returned to 0.77 and no longer drops below 0.72: the cycle manages to retrain before the divergence reaches the result.

There are no manual steps left in the process — the analyst gets involved only in anomaly review and feature edits.

How is incremental training different from full model update?

Incremental training continues the already built ensemble of trees: the model sees only the fresh data slice and adjusts existing dependencies without rebuilding the structure from scratch.

Full training builds the model anew on all available history — with repeated feature preparation and stability validation across several time windows.

The difference is primarily in the data. Incremental training needs only the latest periods, so the cycle is short and fits into a daily update: the model adapts to slow drift while preserving previously learned patterns. Full training needs all history, but it does not inherit past biases.

The main risk of incremental training is error accumulation. Each cycle relies on the previous state, and gradual data drift becomes fixed in the model: it confidently reproduces outdated relationships, while quality on new data quietly falls.

A short window worsens the effect — it is easy to overfit to a one-off spike. Full training removes accumulation but is more expensive and can "forget" rare segments if the fresh history does not contain them.

The choice is this: incremental training is appropriate with a stable feature set and smooth drift; full training is appropriate when the data regime changes, the feature schema changes, or when the divergence of metrics on a fresh window exceeds a given threshold.

In automatic retraining, we link both approaches: regular incremental training and a trigger for a full rebuild based on metrics, with a canary run on a historical window and rollback to the previous version if quality on new data dropped.

What engineers usually clarify before start

Before start, we fix what we consider quality: one target metric on a time-based holdout period, so the model does not peek into the future.

This determines both the amount of history and the frequency of automatic retraining — usually it runs on schedule plus by trigger, when the input data distribution noticeably deviates from the training one.

The second question is infrastructure and environment separation. Retraining should not run on the same capacity as request serving: feature preparation and training consume compute resources, and without isolation response time drops exactly at launch time.

That is why the loops are separated, and the finished model is a versioned object in the registry that can be substituted with a single pointer change.

Is the current hardware sufficient?

Yes, if features are precomputed and stored materialized — then training fits into the nightly window and does not compete with production traffic. We calculate the load profile on your history and show where headroom is needed.

How much data is needed at the input?

At minimum, several full business cycles, including seasonal spikes and holidays. If there is less history, we train on a reduced feature set and honestly note which metrics it is too early to trust.

How are environments separated?

Three loops: development, validation, production. A new version passes validation on a holdout period and only then enters the production loop — comparison with the current model runs on the same data.

What if quality dropped after retraining?

The previous version remains in the registry, so rollback is a pointer change, without a rebuild. Additionally, we set a threshold: if the metric on the control period is worse than the current one, the version is not published automatically.

Let's discuss the task and come back with an estimate and plan

To estimate automatic retraining of a model on gradient boosting, you do not need to prepare a technical specification — it is enough to describe how the process is structured today. The list below removes the main uncertainty at the review stage.

  • How the model is updated now: manual launch, scheduled regulation, script based on data accumulation — and who makes the rollout decision.
  • Where training data comes from: a data mart, an event stream, an export — and how labels get into it.
  • The amount of history and the rate of new examples arriving: how many observations accumulate between two retrainings.
  • Production metrics and the degradation threshold: which metric is primary, on what window it is calculated, at what deviation it is time to change the version.
  • Who approves the new version and whether there is a window in which an update is acceptable without quality loss for consumers.
  • What already exists in the infrastructure: training code in the repository, model version registry, checks, rollback method.
  • What is critical not to break: response time requirements, data volume limits, external model consumers.

From this we assemble an implementation plan: first a shadow run, when the new version computes but does not affect the decision, then automatic rollout with a rollback rule.

We fix acceptance criteria before work begins — the share of retrainings without manual intervention, the time from fresh data appearing to the version in production, and reproducibility of the result from the pair "data and configuration."

Describe the task as it stands now — we will come back with an estimate and plan.