mirror of
https://github.com/microsoft/qlib.git
synced 2026-06-06 05:51:17 +08:00
Fix the Errors/Warnings when building Qlib's documentation (#1381)
* Fix the Errors/Warnings when building Qlib's documentation * Fix * Fix * Empty * Test CI * Add doc compiling checking to CI * Fix * Tries to be consistent with Makefile Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
This commit is contained in:
2
.github/workflows/test_qlib_from_source.yml
vendored
2
.github/workflows/test_qlib_from_source.yml
vendored
@@ -60,7 +60,7 @@ jobs:
|
||||
- name: Make html with sphinx
|
||||
run: |
|
||||
cd docs
|
||||
sphinx-build -b html . build
|
||||
sphinx-build -W --keep-going -b html . _build
|
||||
cd ..
|
||||
|
||||
# Check Qlib with pylint
|
||||
|
||||
@@ -17,4 +17,5 @@ help:
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
pip install -r requirements.txt
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
@@ -117,7 +117,7 @@ Model
|
||||
Strategy
|
||||
--------
|
||||
|
||||
.. automodule:: qlib.contrib.strategy.strategy
|
||||
.. automodule:: qlib.contrib.strategy
|
||||
:members:
|
||||
|
||||
Evaluate
|
||||
@@ -255,7 +255,7 @@ Utils
|
||||
Serializable
|
||||
------------
|
||||
|
||||
.. automodule:: qlib.utils.serial.Serializable
|
||||
.. automodule:: qlib.utils.serial
|
||||
:members:
|
||||
|
||||
RL
|
||||
|
||||
@@ -4,3 +4,4 @@ numpy
|
||||
scipy
|
||||
scikit-learn
|
||||
pandas
|
||||
tianshou
|
||||
|
||||
@@ -96,9 +96,11 @@ def indicator_analysis(df, method="mean"):
|
||||
index: Index(datetime)
|
||||
method : str, optional
|
||||
statistics method of pa/ffr, by default "mean"
|
||||
|
||||
- if method is 'mean', count the mean statistical value of each trade indicator
|
||||
- if method is 'amount_weighted', count the deal_amount weighted mean statistical value of each trade indicator
|
||||
- if method is 'value_weighted', count the value weighted mean statistical value of each trade indicator
|
||||
|
||||
Note: statistics method of pos is always "mean"
|
||||
|
||||
Returns
|
||||
@@ -154,6 +156,7 @@ def backtest_daily(
|
||||
E.g.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# dict
|
||||
strategy = {
|
||||
"class": "TopkDropoutStrategy",
|
||||
@@ -180,7 +183,6 @@ def backtest_daily(
|
||||
# 3) specify module path with class name
|
||||
# - "a.b.c.ClassName" getattr(<a.b.c.module>, "ClassName")() will be used.
|
||||
|
||||
|
||||
executor : Union[str, dict, BaseExecutor]
|
||||
for initializing the outermost executor.
|
||||
benchmark: str
|
||||
|
||||
@@ -276,8 +276,8 @@ def model_performance_graph(
|
||||
) -> [list, tuple]:
|
||||
"""Model performance
|
||||
|
||||
:param pred_label: index is **pd.MultiIndex**, index name is **[instrument, datetime]**; columns names is **[score,
|
||||
label]**. It is usually same as the label of model training(e.g. "Ref($close, -2)/Ref($close, -1) - 1").
|
||||
:param pred_label: index is **pd.MultiIndex**, index name is **[instrument, datetime]**; columns names is **[score, label]**.
|
||||
It is usually same as the label of model training(e.g. "Ref($close, -2)/Ref($close, -1) - 1").
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -218,6 +218,7 @@ def cumulative_return_graph(
|
||||
|
||||
|
||||
Graph desc:
|
||||
|
||||
- Axis X: Trading day.
|
||||
- Axis Y:
|
||||
- Above axis Y: `(((Ref($close, -1)/$close - 1) * weight).sum() / weight.sum()).cumsum()`.
|
||||
@@ -242,7 +243,8 @@ def cumulative_return_graph(
|
||||
|
||||
|
||||
:param label_data: `D.features` result; index is `pd.MultiIndex`, index name is [`instrument`, `datetime`]; columns names is [`label`].
|
||||
**The label T is the change from T to T+1**, it is recommended to use ``close``, example: `D.features(D.instruments('csi500'), ['Ref($close, -1)/$close-1'])`
|
||||
|
||||
**The label T is the change from T to T+1**, it is recommended to use ``close``, example: `D.features(D.instruments('csi500'), ['Ref($close, -1)/$close-1'])`
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -99,7 +99,8 @@ def rank_label_graph(
|
||||
|
||||
:param position: position data; **qlib.backtest.backtest** result.
|
||||
:param label_data: **D.features** result; index is **pd.MultiIndex**, index name is **[instrument, datetime]**; columns names is **[label]**.
|
||||
**The label T is the change from T to T+1**, it is recommended to use ``close``, example: `D.features(D.instruments('csi500'), ['Ref($close, -1)/$close-1'])`.
|
||||
|
||||
**The label T is the change from T to T+1**, it is recommended to use ``close``, example: `D.features(D.instruments('csi500'), ['Ref($close, -1)/$close-1'])`.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -25,12 +25,14 @@ class SoftTopkStrategy(WeightStrategyBase):
|
||||
common_infra=None,
|
||||
**kwargs,
|
||||
):
|
||||
"""Parameter
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
topk : int
|
||||
top-N stocks to buy
|
||||
risk_degree : float
|
||||
position percentage of total value
|
||||
buy_method :
|
||||
position percentage of total value buy_method:
|
||||
|
||||
rank_fill: assign the weight stocks that rank high first(1/topk max)
|
||||
average_fill: assign the weight to the stocks rank high averagely.
|
||||
"""
|
||||
@@ -51,12 +53,19 @@ class SoftTopkStrategy(WeightStrategyBase):
|
||||
return self.risk_degree
|
||||
|
||||
def generate_target_weight_position(self, score, current, trade_start_time, trade_end_time):
|
||||
"""Parameter:
|
||||
score : pred score for this trade date, pd.Series, index is stock_id, contain 'score' column
|
||||
current : current position, use Position() class
|
||||
trade_date : trade date
|
||||
generate target position from score for this date and the current position
|
||||
The cache is not considered in the position
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
score:
|
||||
pred score for this trade date, pd.Series, index is stock_id, contain 'score' column
|
||||
current:
|
||||
current position, use Position() class
|
||||
trade_date:
|
||||
trade date
|
||||
|
||||
generate target position from score for this date and the current position
|
||||
|
||||
The cache is not considered in the position
|
||||
"""
|
||||
# TODO:
|
||||
# If the current stock list is more than topk(eg. The weights are modified
|
||||
|
||||
@@ -103,9 +103,13 @@ class TopkDropoutStrategy(BaseSignalStrategy):
|
||||
before sell stock , will check current.get_stock_count(order.stock_id) >= self.hold_thresh.
|
||||
only_tradable : bool
|
||||
will the strategy only consider the tradable stock when buying and selling.
|
||||
|
||||
if only_tradable:
|
||||
|
||||
strategy will make decision with the tradable state of the stock info and avoid buy and sell them.
|
||||
|
||||
else:
|
||||
|
||||
strategy will make buy sell decision without checking the tradable state of the stock.
|
||||
"""
|
||||
super().__init__(**kwargs)
|
||||
@@ -287,9 +291,11 @@ class WeightStrategyBase(BaseSignalStrategy):
|
||||
the decision of the strategy will base on the given signal
|
||||
trade_exchange : Exchange
|
||||
exchange that provides market info, used to deal order and generate report
|
||||
|
||||
- If `trade_exchange` is None, self.trade_exchange will be set with common_infra
|
||||
- It allowes different trade_exchanges is used in different executions.
|
||||
- For example:
|
||||
|
||||
- In daily execution, both daily exchange and minutely are usable, but the daily exchange is recommended because it run faster.
|
||||
- In minutely execution, the daily exchange is not usable, only the minutely exchange is recommended.
|
||||
"""
|
||||
@@ -303,6 +309,7 @@ class WeightStrategyBase(BaseSignalStrategy):
|
||||
def generate_target_weight_position(self, score, current, trade_start_time, trade_end_time):
|
||||
"""
|
||||
Generate target position from score for this date and the current position.The cash is not considered in the position
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
score : pd.Series
|
||||
@@ -355,12 +362,14 @@ class EnhancedIndexingStrategy(WeightStrategyBase):
|
||||
|
||||
Users need to prepare their risk model data like below:
|
||||
|
||||
├── /path/to/riskmodel
|
||||
├──── 20210101
|
||||
├────── factor_exp.{csv|pkl|h5}
|
||||
├────── factor_cov.{csv|pkl|h5}
|
||||
├────── specific_risk.{csv|pkl|h5}
|
||||
├────── blacklist.{csv|pkl|h5} # optional
|
||||
.. code-block:: text
|
||||
|
||||
├── /path/to/riskmodel
|
||||
├──── 20210101
|
||||
├────── factor_exp.{csv|pkl|h5}
|
||||
├────── factor_cov.{csv|pkl|h5}
|
||||
├────── specific_risk.{csv|pkl|h5}
|
||||
├────── blacklist.{csv|pkl|h5} # optional
|
||||
|
||||
The risk model data can be obtained from risk data provider. You can also use
|
||||
`qlib.model.riskmodel.structured.StructuredCovEstimator` to prepare these data.
|
||||
|
||||
@@ -141,8 +141,10 @@ class MemCache:
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mem_cache_size_limit: cache max size.
|
||||
limit_type: length or sizeof; length(call fun: len), size(call fun: sys.getsizeof).
|
||||
mem_cache_size_limit:
|
||||
cache max size.
|
||||
limit_type:
|
||||
length or sizeof; length(call fun: len), size(call fun: sys.getsizeof).
|
||||
"""
|
||||
|
||||
size_limit = C.mem_cache_size_limit if mem_cache_size_limit is None else mem_cache_size_limit
|
||||
@@ -858,7 +860,7 @@ class DiskDatasetCache(DatasetCache):
|
||||
"""gen_dataset_cache
|
||||
|
||||
.. note:: This function does not consider the cache read write lock. Please
|
||||
Acquire the lock outside this function
|
||||
acquire the lock outside this function
|
||||
|
||||
The format the cache contains 3 parts(followed by typical filename).
|
||||
|
||||
@@ -874,10 +876,10 @@ class DiskDatasetCache(DatasetCache):
|
||||
1999-11-12 00:00:00 2 3
|
||||
...
|
||||
|
||||
.. note:: The start is closed. The end is open!!!!!
|
||||
.. note:: The start is closed. The end is open!!!!!
|
||||
|
||||
- Each line contains two element <start_index, end_index> with a timestamp as its index.
|
||||
- It indicates the `start_index`(included) and `end_index`(excluded) of the data for `timestamp`
|
||||
- It indicates the `start_index` (included) and `end_index` (excluded) of the data for `timestamp`
|
||||
|
||||
- meta data: cache/d41366901e25de3ec47297f12e2ba11d.meta
|
||||
|
||||
|
||||
@@ -220,7 +220,8 @@ class InstrumentProvider(abc.ABC):
|
||||
----------
|
||||
dict: if isinstance(market, str)
|
||||
dict of stockpool config.
|
||||
{`market`=>base market name, `filter_pipe`=>list of filters}
|
||||
|
||||
{`market` => base market name, `filter_pipe` => list of filters}
|
||||
|
||||
example :
|
||||
|
||||
@@ -432,9 +433,12 @@ class ExpressionProvider(abc.ABC):
|
||||
data of a certain expression
|
||||
|
||||
The data has two types of format
|
||||
|
||||
1) expression with datetime index
|
||||
|
||||
2) expression with integer index
|
||||
- because the datetime is not as good as
|
||||
|
||||
- because the datetime is not as good as
|
||||
"""
|
||||
raise NotImplementedError("Subclass of ExpressionProvider must implement `Expression` method")
|
||||
|
||||
@@ -890,6 +894,7 @@ class LocalDatasetProvider(DatasetProvider):
|
||||
Will we align the time to calendar
|
||||
the frequency is flexible in some dataset and can't be aligned.
|
||||
For the data with fixed frequency with a shared calendar, the align data to the calendar will provides following benefits
|
||||
|
||||
- Align queries to the same parameters, so the cache can be shared.
|
||||
"""
|
||||
super().__init__()
|
||||
@@ -1167,11 +1172,12 @@ class BaseProvider:
|
||||
inst_processors=[],
|
||||
):
|
||||
"""
|
||||
Parameters:
|
||||
-----------
|
||||
Parameters
|
||||
----------
|
||||
disk_cache : int
|
||||
whether to skip(0)/use(1)/replace(2) disk_cache
|
||||
|
||||
|
||||
This function will try to use cache method which has a keyword `disk_cache`,
|
||||
and will use provider method if a type error is raised because the DatasetD instance
|
||||
is a provider class.
|
||||
@@ -1221,10 +1227,12 @@ class ClientProvider(BaseProvider):
|
||||
"""Client Provider
|
||||
|
||||
Requesting data from server as a client. Can propose requests:
|
||||
|
||||
- Calendar : Directly respond a list of calendars
|
||||
- Instruments (without filter): Directly respond a list/dict of instruments
|
||||
- Instruments (with filters): Respond a list/dict of instruments
|
||||
- Features : Respond a cache uri
|
||||
|
||||
The general workflow is described as follows:
|
||||
When the user use client provider to propose a request, the client provider will connect the server and send the request. The client will start to wait for the response. The response will be made instantly indicating whether the cache is available. The waiting procedure will terminate only when the client get the response saying `feature_available` is true.
|
||||
`BUG` : Everytime we make request for certain data we need to connect to the server, wait for the response and disconnect from it. We can't make a sequence of requests within one connection. You can refer to https://python-socketio.readthedocs.io/en/latest/client.html for documentation of python-socketIO client.
|
||||
|
||||
@@ -35,7 +35,7 @@ class DataHandler(Serializable):
|
||||
Example of the data:
|
||||
The multi-index of the columns is optional.
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: text
|
||||
|
||||
feature label
|
||||
$close $volume Ref($close, 1) Mean($close, 3) $high-$low LABEL0
|
||||
@@ -671,6 +671,7 @@ class DataHandlerLP(DataHandler):
|
||||
def cast(cls, handler: "DataHandlerLP") -> "DataHandlerLP":
|
||||
"""
|
||||
Motivation
|
||||
|
||||
- A user creates a datahandler in his customized package. Then he wants to share the processed handler to
|
||||
other users without introduce the package dependency and complicated data processing logic.
|
||||
- This class make it possible by casting the class to DataHandlerLP and only keep the processed data
|
||||
|
||||
@@ -27,7 +27,7 @@ class DataLoader(abc.ABC):
|
||||
|
||||
Example of the data (The multi-index of the columns is optional.):
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: text
|
||||
|
||||
feature label
|
||||
$close $volume Ref($close, 1) Mean($close, 3) $high-$low LABEL0
|
||||
|
||||
@@ -272,8 +272,8 @@ class NameDFilter(SeriesDFilter):
|
||||
def __init__(self, name_rule_re, fstart_time=None, fend_time=None):
|
||||
"""Init function for name filter class
|
||||
|
||||
params:
|
||||
------
|
||||
Parameters
|
||||
----------
|
||||
name_rule_re: str
|
||||
regular expression for the name rule.
|
||||
"""
|
||||
@@ -325,8 +325,8 @@ class ExpressionDFilter(SeriesDFilter):
|
||||
def __init__(self, rule_expression, fstart_time=None, fend_time=None, keep=False):
|
||||
"""Init function for expression filter class
|
||||
|
||||
params:
|
||||
------
|
||||
Parameters
|
||||
----------
|
||||
fstart_time: str
|
||||
filter the feature starting from this time.
|
||||
fend_time: str
|
||||
|
||||
@@ -1530,6 +1530,7 @@ class TResample(ElemOperator):
|
||||
"""
|
||||
Resampling the data to target frequency.
|
||||
The resample function of pandas is used.
|
||||
|
||||
- the timestamp will be at the start of the time span after resample.
|
||||
|
||||
Parameters
|
||||
@@ -1632,10 +1633,14 @@ class OpsWrapper:
|
||||
ops_list : List[Union[Type[ExpressionOps], dict]]
|
||||
- if type(ops_list) is List[Type[ExpressionOps]], each element of ops_list represents the operator class, which should be the subclass of `ExpressionOps`.
|
||||
- if type(ops_list) is List[dict], each element of ops_list represents the config of operator, which has the following format:
|
||||
{
|
||||
"class": class_name,
|
||||
"module_path": path,
|
||||
}
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
{
|
||||
"class": class_name,
|
||||
"module_path": path,
|
||||
}
|
||||
|
||||
Note: `class` should be the class name of operator, `module_path` should be a python module or path of file.
|
||||
"""
|
||||
for _operator in ops_list:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
"""
|
||||
The Trainer will train a list of tasks and return a list of model recorders.
|
||||
There are two steps in each Trainer including ``train``(make model recorder) and ``end_train``(modify model recorder).
|
||||
There are two steps in each Trainer including ``train`` (make model recorder) and ``end_train`` (modify model recorder).
|
||||
|
||||
This is a concept called ``DelayTrainer``, which can be used in online simulating for parallel training.
|
||||
In ``DelayTrainer``, the first step is only to save some necessary info to model recorders, and the second step which will be finished in the end can do some concurrent and time-consuming operations such as model fitting.
|
||||
@@ -242,7 +242,7 @@ class TrainerR(Trainer):
|
||||
|
||||
def train(self, tasks: list, train_func: Callable = None, experiment_name: str = None, **kwargs) -> List[Recorder]:
|
||||
"""
|
||||
Given a list of `task`s and return a list of trained Recorder. The order can be guaranteed.
|
||||
Given a list of `tasks` and return a list of trained Recorder. The order can be guaranteed.
|
||||
|
||||
Args:
|
||||
tasks (list): a list of definitions based on `task` dict
|
||||
@@ -315,7 +315,7 @@ class DelayTrainerR(TrainerR):
|
||||
|
||||
Args:
|
||||
models (list): a list of Recorder, the tasks have been saved to them
|
||||
end_train_func (Callable, optional): the end_train method which needs at least `recorder`s and `experiment_name`. Defaults to None for using self.end_train_func.
|
||||
end_train_func (Callable, optional): the end_train method which needs at least `recorders` and `experiment_name`. Defaults to None for using self.end_train_func.
|
||||
experiment_name (str): the experiment name, None for use default name.
|
||||
kwargs: the params for end_train_func.
|
||||
|
||||
@@ -390,14 +390,14 @@ class TrainerRM(Trainer):
|
||||
**kwargs,
|
||||
) -> List[Recorder]:
|
||||
"""
|
||||
Given a list of `task`s and return a list of trained Recorder. The order can be guaranteed.
|
||||
Given a list of `tasks` and return a list of trained Recorder. The order can be guaranteed.
|
||||
|
||||
This method defaults to a single process, but TaskManager offered a great way to parallel training.
|
||||
Users can customize their train_func to realize multiple processes or even multiple machines.
|
||||
|
||||
Args:
|
||||
tasks (list): a list of definitions based on `task` dict
|
||||
train_func (Callable): the training method which needs at least `task`s and `experiment_name`. None for the default training method.
|
||||
train_func (Callable): the training method which needs at least `tasks` and `experiment_name`. None for the default training method.
|
||||
experiment_name (str): the experiment name, None for use default name.
|
||||
before_status (str): the tasks in before_status will be fetched and trained. Can be STATUS_WAITING, STATUS_PART_DONE.
|
||||
after_status (str): the tasks after trained will become after_status. Can be STATUS_WAITING, STATUS_PART_DONE.
|
||||
@@ -470,7 +470,7 @@ class TrainerRM(Trainer):
|
||||
The multiprocessing method for `train`. It can share a same task_pool with `train` and can run in other progress or other machines.
|
||||
|
||||
Args:
|
||||
train_func (Callable): the training method which needs at least `task`s and `experiment_name`. None for the default training method.
|
||||
train_func (Callable): the training method which needs at least `tasks` and `experiment_name`. None for the default training method.
|
||||
experiment_name (str): the experiment name, None for use default name.
|
||||
"""
|
||||
if train_func is None:
|
||||
@@ -525,7 +525,7 @@ class DelayTrainerRM(TrainerRM):
|
||||
|
||||
Args:
|
||||
tasks (list): a list of definition based on `task` dict
|
||||
train_func (Callable): the train method which need at least `task`s and `experiment_name`. Defaults to None for using self.train_func.
|
||||
train_func (Callable): the train method which need at least `tasks` and `experiment_name`. Defaults to None for using self.train_func.
|
||||
experiment_name (str): the experiment name, None for use default name.
|
||||
|
||||
Returns:
|
||||
@@ -554,7 +554,7 @@ class DelayTrainerRM(TrainerRM):
|
||||
|
||||
Args:
|
||||
recs (list): a list of Recorder, the tasks have been saved to them.
|
||||
end_train_func (Callable, optional): the end_train method which need at least `recorder`s and `experiment_name`. Defaults to None for using self.end_train_func.
|
||||
end_train_func (Callable, optional): the end_train method which need at least `recorders` and `experiment_name`. Defaults to None for using self.end_train_func.
|
||||
experiment_name (str): the experiment name, None for use default name.
|
||||
kwargs: the params for end_train_func.
|
||||
|
||||
@@ -596,7 +596,7 @@ class DelayTrainerRM(TrainerRM):
|
||||
The multiprocessing method for `end_train`. It can share a same task_pool with `end_train` and can run in other progress or other machines.
|
||||
|
||||
Args:
|
||||
end_train_func (Callable, optional): the end_train method which need at least `recorder`s and `experiment_name`. Defaults to None for using self.end_train_func.
|
||||
end_train_func (Callable, optional): the end_train method which need at least `recorders` and `experiment_name`. Defaults to None for using self.end_train_func.
|
||||
experiment_name (str): the experiment name, None for use default name.
|
||||
"""
|
||||
if end_train_func is None:
|
||||
|
||||
@@ -321,7 +321,7 @@ class LogBuffer(LogWriter):
|
||||
|
||||
- on_episode: Whether it's called at the end of an episode
|
||||
- on_collect: Whether it's called at the end of a collect
|
||||
- log_buffer: the :class:`LogBbuffer`object
|
||||
- log_buffer: the :class:`LogBbuffer` object
|
||||
|
||||
No return value is expected.
|
||||
"""
|
||||
|
||||
@@ -47,6 +47,7 @@ class QlibRecorder:
|
||||
with R.start(experiment_name='test', recorder_name='recorder_1', resume=True): # if users want to resume recorder, they have to specify the exact same name for experiment and recorder.
|
||||
... # further operations
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
experiment_id : str
|
||||
@@ -204,7 +205,7 @@ class QlibRecorder:
|
||||
If user doesn't provide the id or name of the experiment, this method will try to retrieve the default experiment and
|
||||
list all the recorders of the default experiment. If the default experiment doesn't exist, the method will first
|
||||
create the default experiment, and then create a new recorder under it. (More information about the default experiment
|
||||
can be found `here <../component/recorder.html#qlib.workflow.exp.Experiment>`_).
|
||||
can be found `here <../component/recorder.html#qlib.workflow.exp.Experiment>`__).
|
||||
|
||||
Here is the example code:
|
||||
|
||||
@@ -249,7 +250,7 @@ class QlibRecorder:
|
||||
|
||||
- Else If '`create`' is False:
|
||||
|
||||
- If ``active experiment` exists:
|
||||
- If `active experiment` exists:
|
||||
|
||||
- no id or name specified, return the active experiment.
|
||||
|
||||
@@ -294,7 +295,7 @@ class QlibRecorder:
|
||||
according to user's specification if the experiment hasn't been created before.
|
||||
start : bool
|
||||
when start is True,
|
||||
if the experiment has not started(not activated), it will start
|
||||
if the experiment has not started(not activated), it will start
|
||||
It is designed for R.log_params to auto start experiments
|
||||
|
||||
Returns
|
||||
|
||||
@@ -21,13 +21,14 @@ logger = get_module_logger("workflow")
|
||||
|
||||
class ExpManager:
|
||||
"""
|
||||
This is the `ExpManager` class for managing experiments. The API is designed similar to mlflow.
|
||||
(The link: https://mlflow.org/docs/latest/python_api/mlflow.html)
|
||||
This is the `ExpManager` class for managing experiments. The API is designed similar to mlflow.
|
||||
(The link: https://mlflow.org/docs/latest/python_api/mlflow.html)
|
||||
|
||||
The `ExpManager` is expected to be a singleton (btw, we can have multiple `Experiment`s with different uri. user can get different experiments from different uri, and then compare records of them). Global Config (i.e. `C`) is also a singleton.
|
||||
|
||||
The `ExpManager` is expected to be a singleton (btw, we can have multiple `Experiment`s with different uri. user can get different experiments from different uri, and then compare records of them). Global Config (i.e. `C`) is also a singleton.
|
||||
So we try to align them together. They share the same variable, which is called **default uri**. Please refer to `ExpManager.default_uri` for details of variable sharing.
|
||||
|
||||
When the user starts an experiment, the user may want to set the uri to a specific uri (it will override **default uri** during this period), and then unset the **specific uri** and fallback to the **default uri**. `ExpManager._active_exp_uri` is that **specific uri**.
|
||||
When the user starts an experiment, the user may want to set the uri to a specific uri (it will override **default uri** during this period), and then unset the **specific uri** and fallback to the **default uri**. `ExpManager._active_exp_uri` is that **specific uri**.
|
||||
"""
|
||||
|
||||
active_experiment: Optional[Experiment]
|
||||
|
||||
@@ -121,7 +121,7 @@ class OnlineManager(Serializable):
|
||||
Args:
|
||||
strategies (Union[OnlineStrategy, List[OnlineStrategy]]): an instance of OnlineStrategy or a list of OnlineStrategy
|
||||
begin_time (Union[str,pd.Timestamp], optional): the OnlineManager will begin at this time. Defaults to None for using the latest date.
|
||||
trainer (Trainer): the trainer to train task. None for using TrainerR.
|
||||
trainer (qlib.model.trainer.Trainer): the trainer to train task. None for using TrainerR.
|
||||
freq (str, optional): data frequency. Defaults to "day".
|
||||
"""
|
||||
self.logger = get_module_logger(self.__class__.__name__)
|
||||
|
||||
@@ -24,11 +24,11 @@ class OnlineStrategy:
|
||||
def __init__(self, name_id: str):
|
||||
"""
|
||||
Init OnlineStrategy.
|
||||
This module **MUST** use `Trainer <../reference/api.html#Trainer>`_ to finishing model training.
|
||||
This module **MUST** use `Trainer <../reference/api.html#qlib.model.trainer.Trainer>`_ to finishing model training.
|
||||
|
||||
Args:
|
||||
name_id (str): a unique name or id.
|
||||
trainer (Trainer, optional): a instance of Trainer. Defaults to None.
|
||||
trainer (qlib.model.trainer.Trainer, optional): a instance of Trainer. Defaults to None.
|
||||
"""
|
||||
self.name_id = name_id
|
||||
self.logger = get_module_logger(self.__class__.__name__)
|
||||
|
||||
@@ -118,6 +118,7 @@ class RecordTemp:
|
||||
"""
|
||||
Check if the records is properly generated and saved.
|
||||
It is useful in following examples
|
||||
|
||||
- checking if the depended files complete before generating new things.
|
||||
- checking if the final files is completed
|
||||
|
||||
@@ -131,7 +132,7 @@ class RecordTemp:
|
||||
Raise
|
||||
------
|
||||
FileNotFoundError
|
||||
: whether the records are stored properly.
|
||||
whether the records are stored properly.
|
||||
"""
|
||||
if include_self:
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class Collector(Serializable):
|
||||
|
||||
{"IC": {"Xgboost": pd.Series, "LSTM": pd.Series}}
|
||||
|
||||
......
|
||||
...
|
||||
"""
|
||||
raise NotImplementedError(f"Please implement the `collect` method.")
|
||||
|
||||
@@ -58,7 +58,7 @@ class Collector(Serializable):
|
||||
Args:
|
||||
collected_dict (dict): the dict return by `collect`
|
||||
process_list (list or Callable): the list of processors or the instance of a processor to process dict.
|
||||
The processor order is the same as the list order.
|
||||
The processor order is the same as the list order.
|
||||
For example: [Group1(..., Ensemble1()), Group2(..., Ensemble2())]
|
||||
|
||||
Returns:
|
||||
@@ -97,7 +97,7 @@ class MergeCollector(Collector):
|
||||
A can collect {"prediction": pd.Series} and B can collect {"IC": {"Xgboost": pd.Series, "LSTM": pd.Series}}.
|
||||
Then after this class's collect, we can collect {"A_prediction": pd.Series, "B_IC": {"Xgboost": pd.Series, "LSTM": pd.Series}}
|
||||
|
||||
......
|
||||
...
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -489,7 +489,7 @@ def run_task(
|
||||
after_status: str = TaskManager.STATUS_DONE,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
r"""
|
||||
While the task pool is not empty (has WAITING tasks), use task_func to fetch and run tasks in task_pool
|
||||
|
||||
After running this method, here are 4 situations (before_status -> after_status):
|
||||
@@ -505,8 +505,9 @@ def run_task(
|
||||
Parameters
|
||||
----------
|
||||
task_func : Callable
|
||||
def (task_def, **kwargs) -> <res which will be committed>
|
||||
the function to run the task
|
||||
def (task_def, \**kwargs) -> <res which will be committed>
|
||||
|
||||
the function to run the task
|
||||
task_pool : str
|
||||
the name of the task pool (Collection in MongoDB)
|
||||
query: dict
|
||||
|
||||
@@ -25,18 +25,22 @@ def get_mongodb() -> Database:
|
||||
|
||||
Using qlib.init():
|
||||
|
||||
mongo_conf = {
|
||||
"task_url": task_url, # your MongoDB url
|
||||
"task_db_name": task_db_name, # database name
|
||||
}
|
||||
qlib.init(..., mongo=mongo_conf)
|
||||
.. code-block:: python
|
||||
|
||||
mongo_conf = {
|
||||
"task_url": task_url, # your MongoDB url
|
||||
"task_db_name": task_db_name, # database name
|
||||
}
|
||||
qlib.init(..., mongo=mongo_conf)
|
||||
|
||||
After qlib.init():
|
||||
|
||||
C["mongo"] = {
|
||||
"task_url" : "mongodb://localhost:27017/",
|
||||
"task_db_name" : "rolling_db"
|
||||
}
|
||||
.. code-block:: python
|
||||
|
||||
C["mongo"] = {
|
||||
"task_url" : "mongodb://localhost:27017/",
|
||||
"task_db_name" : "rolling_db"
|
||||
}
|
||||
|
||||
Returns:
|
||||
Database: the Database instance
|
||||
|
||||
Reference in New Issue
Block a user