class_docstr: OnlineStrategy is working with `Online Manager <#Online Manager>`_, responding to how the tasks are generated, the models are updated and signals are prepared.
class_docstr_tok: ["OnlineStrategy","is","working","with","`","Online","Manager","<","#","Online","Manager",">","`","_",",","responding","to","how","the","tasks","are","generated",",","the","models","are","updated","and","signals","are","prepared","."]
docstr: Select some models from trained models and set them to online models.
  This is a typical implementation to online all trained models, you can override it to implement the complex method.
  You can find the last online models by OnlineTool.online_models if you still need them.
  
  NOTE: Reset all online models to trained models. If there are no trained models, then do nothing.
  
  **NOTE**:
      Current implementation is very naive. Here is a more complex situation which is more closer to the
      practical scenarios.
      1. Train new models at the day before `test_start` (at time stamp `T`)
      2. Switch models at the `test_start` (at time timestamp `T + 1` typically)
  
  Args:
      models (list): a list of models.
      cur_time (pd.Dataframe): current time from OnlineManger. None for the latest.
  
  Returns:
      List[object]: a list of online models.
docstr_tok: ["Select","some","models","from","trained","models","and","set","them","to","online","models",".","This","is","a","typical","implementation","to","online","all","trained","models",",","you","can","override","it","to","implement","the","complex","method",".","You","can","find","the","last","online","models","by","OnlineTool.online_models","if","you","still","need","them",".","NOTE",":","Reset","all","online","models","to","trained","models",".","If","there","are","no","trained","models",",","then","do","nothing",".","*","*","NOTE","*","*",":","Current","implementation","is","very","naive",".","Here","is","a","more","complex","situation","which","is","more","closer","to","the","practical","scenarios",".","1",".","Train","new","models","at","the","day","before","`","test_start","`","(","at","time","stamp","`","T","`",")","2",".","Switch","models","at","the","`","test_start","`","(","at","time","timestamp","`","T","+","1","`","typically",")","Args",":","models","(","list",")",":","a","list","of","models",".","cur_time","(","pd.Dataframe",")",":","current","time","from","OnlineManger",".","None","for","the","latest",".","Returns",":","List","[","object","]",":","a","list","of","online","models","."]
code: def prepare_online_models(
      self, trained_models, cur_time=None
  ) -> List[object]:
      """
      Select some models from trained models and set them to online models.
      This is a typical implementation to online all trained models, you can override it to implement the complex method.
      You can find the last online models by OnlineTool.online_models if you still need them.
  
      NOTE: Reset all online models to trained models. If there are no trained models, then do nothing.
  
      **NOTE**:
          Current implementation is very naive. Here is a more complex situation which is more closer to the
          practical scenarios.
          1. Train new models at the day before `test_start` (at time stamp `T`)
          2. Switch models at the `test_start` (at time timestamp `T + 1` typically)
  
      Args:
          models (list): a list of models.
          cur_time (pd.Dataframe): current time from OnlineManger. None for the latest.
  
      Returns:
          List[object]: a list of online models.
      """
      if not trained_models:
          return self.tool.online_models()
      self.tool.reset_online_tag(trained_models)
      return trained_models
  
imports: from typing import List, Union
  from qlib.log import get_module_logger
  from qlib.model.ens.group import RollingGroup
  from qlib.utils import transform_end_date
  from qlib.workflow.online.utils import OnlineTool, OnlineToolR
  from qlib.workflow.recorder import Recorder
  from qlib.workflow.task.collect import Collector, RecorderCollector
  from qlib.workflow.task.gen import RollingGen, task_generator
  from qlib.workflow.task.utils import TimeAdjuster
label_desc: Use image node_id 3 for calling the OnlineStrategy obj's underlying member method code with example usage: obj.prepare_online_models(trained_models, cur_time) and returns: trained_models, self