Qlib Online Serving for Live Model Predictions
Summary
The document introduces Qlib’s online-serving components for applying trained models to current market data. It describes a workflow that can produce predictions in live conditions and support real trading based on those predictions. The named components are an online manager, strategy, utility tools, and updater; examples also connect these capabilities to task-management components such as trainers and collectors.
The page emphasizes that online serving depends on keeping the underlying data source current, and mentions scripts for updating daily Yahoo Finance data. Its stated limitation is that daily predictions for the next trading day are supported, but generating orders for that day is not, due to constraints in public data. The text is an overview and API reference entry point rather than an explanation of model design or evidence of trading performance; it provides no performance results or detailed implementation guidance.
Key ideas
- Qlib online serving applies models to recently updated data for predictions in live market conditions.
- Its modules include an online manager, strategy, utilities, and updater.
- Examples use task-management components to coordinate models and related tasks.
- The data source must be kept current for online predictions to work.
- The documented setup supports next-day predictions but not next-day order generation.
Tags
Full text
# online
.. _online_serving:
==============
Online Serving
==============
.. currentmodule:: qlib
Introduction
============
.. image:: ../_static/img/online_serving.png
:align: center
In addition to backtesting, one way to test a model is effective is to make predictions in real market conditions or even do real trading based on those predictions.
``Online Serving`` is a set of modules for online models using the latest data,
which including `Online Manager <#Online Manager>`_, `Online Strategy <#Online Strategy>`_, `Online Tool <#Online Tool>`_, `Updater <#Updater>`_.
`Here <https://github.com/microsoft/qlib/tree/main/examples/online_srv>`_ are several examples for reference, which demonstrate different features of ``Online Serving``.
If you have many models or `task` needs to be managed, please consider `Task Management <../advanced/task_management.html>`_.
The `examples <https://github.com/microsoft/qlib/tree/main/examples/online_srv>`_ are based on some components in `Task Management <../advanced/task_management.html>`_ such as ``TrainerRM`` or ``Collector``.
**NOTE**: User should keep his data source updated to support online serving. For example, Qlib provides `a batch of scripts <https://github.com/microsoft/qlib/blob/main/scripts/data_collector/yahoo/README.md#automatic-update-of-daily-frequency-datafrom-yahoo-finance>`_ to help users update Yahoo daily data.
Known limitations currently
- Currently, the daily updating prediction for the next trading day is supported. But generating orders for the next trading day is not supported due to the `limitations of public data <https://github.com/microsoft/qlib/issues/215#issuecomment-766293563>_`
Recorder artifact trust
=======================
Online updates may reload executable model, dataset and task objects from recorders.
The default is restricted loading. After verifying the artifact writer and the
store's write permissions, opt in with ``trusted=True`` on each
``RollingStrategy`` or on a directly constructed ``OnlineToolR``/updater.
``RollingStrategy`` forwards this setting through its online tool and updater;
prediction, label and numerical-report reads remain restricted.
``OnlineManager`` does not grant trust globally. Configure newly added strategies
as well as initial strategies, and configure ``DelayTrainerR`` or ``DelayTrainerRM``
separately if used. A supplied trainer keeps its caller-selected trust policy.
Local serialized manager files must also be independently trusted; restoring one
retains the settings saved in it, rather than applying a new manager-wide grant.
Legacy components without a saved flag default to restricted loading. Explicitly
reconfigure or recreate each strategy, its ``strategy.tool``, and any delayed
trainer as needed; an example constructor flag does not override a subsequently
loaded manager.
See :ref:`artifact_loading_migration` for supported data, refusal handling and custom
loader migration, and the
`example commands <https://github.com/microsoft/qlib/blob/main/examples/README.md#recorder-artifact-trust>`_
for the default-off ``--trusted=True`` CLI option.
Online Manager
==============
.. automodule:: qlib.workflow.online.manager
:members:
:noindex:
Online Strategy
===============
.. automodule:: qlib.workflow.online.strategy
:members:
:noindex:
Online Tool
===========
.. automodule:: qlib.workflow.online.utils
:members:
:noindex:
Updater
=======
.. automodule:: qlib.workflow.online.update
:members:
:noindex:Shown in full with attribution under the source's licence. Licence: MIT
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.