Skip to content

Commit

Permalink
Being compatible with previous Qlib version
Browse files Browse the repository at this point in the history
  • Loading branch information
you-n-g committed Oct 15, 2021
1 parent 052aad7 commit 1e54eb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -14,9 +14,8 @@ port_analysis_config: &port_analysis_config
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal:
- <MODEL>
- <DATASET>
model: <MODEL>
dataset: <DATASET>
topk: 50
n_drop: 5
backtest:
Expand Down
10 changes: 9 additions & 1 deletion qlib/contrib/strategy/signal_strategy.py
Expand Up @@ -27,7 +27,7 @@ def __init__(
*,
topk,
n_drop,
signal: Union[Signal, Tuple[BaseModel, Dataset], List, Dict, Text, pd.Series, pd.DataFrame],
signal: Union[Signal, Tuple[BaseModel, Dataset], List, Dict, Text, pd.Series, pd.DataFrame]=None,
method_sell="bottom",
method_buy="top",
risk_degree=0.95,
Expand All @@ -36,6 +36,8 @@ def __init__(
trade_exchange=None,
level_infra=None,
common_infra=None,
model=None,
dataset=None,
**kwargs,
):
"""
Expand Down Expand Up @@ -82,6 +84,12 @@ def __init__(
self.risk_degree = risk_degree
self.hold_thresh = hold_thresh
self.only_tradable = only_tradable

# This is trying to be compatible with previous version of qlib task config
if model is not None and dataset is not None:
warnings.warn("`model` `dataset` is deprecated; use `signal`.", DeprecationWarning)
signal = model, dataset

self.signal: Signal = create_signal_from(signal)

def get_risk_degree(self, trade_step=None):
Expand Down

0 comments on commit 1e54eb0

Please sign in to comment.