Skip to content

Commit

Permalink
[931] Remove mutable default argument. (microsoft#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiahungTai authored Feb 28, 2022
1 parent ec8969a commit 4dc6693
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions qlib/workflow/record_temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,26 +359,7 @@ class PortAnaRecord(ACRecordTemp):
def __init__(
self,
recorder,
config: dict = { # Default config for daily trading
"strategy": {
"class": "TopkDropoutStrategy",
"module_path": "qlib.contrib.strategy",
"kwargs": {"signal": "<PRED>", "topk": 50, "n_drop": 5},
},
"backtest": {
"start_time": None,
"end_time": None,
"account": 100000000,
"benchmark": "SH000300",
"exchange_kwargs": {
"limit_threshold": 0.095,
"deal_price": "close",
"open_cost": 0.0005,
"close_cost": 0.0015,
"min_cost": 5,
},
},
},
config=None,
risk_analysis_freq: Union[List, str] = None,
indicator_analysis_freq: Union[List, str] = None,
indicator_analysis_method=None,
Expand All @@ -401,6 +382,27 @@ def __init__(
"""
super().__init__(recorder=recorder, skip_existing=skip_existing, **kwargs)

if config is None:
config = { # Default config for daily trading
"strategy": {
"class": "TopkDropoutStrategy",
"module_path": "qlib.contrib.strategy",
"kwargs": {"signal": "<PRED>", "topk": 50, "n_drop": 5},
},
"backtest": {
"start_time": None,
"end_time": None,
"account": 100000000,
"benchmark": "SH000300",
"exchange_kwargs": {
"limit_threshold": 0.095,
"deal_price": "close",
"open_cost": 0.0005,
"close_cost": 0.0015,
"min_cost": 5,
},
},
}
# We only deepcopy_basic_type because
# - We don't want to affect the config outside.
# - We don't want to deepcopy complex object to avoid overhead
Expand Down

0 comments on commit 4dc6693

Please sign in to comment.