Skip to content

Commit f68c4b9

Browse files
authored
[931] Remove mutable default argument. (microsoft#932)
1 parent 1f7390a commit f68c4b9

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

qlib/workflow/record_temp.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -359,26 +359,7 @@ class PortAnaRecord(ACRecordTemp):
359359
def __init__(
360360
self,
361361
recorder,
362-
config: dict = { # Default config for daily trading
363-
"strategy": {
364-
"class": "TopkDropoutStrategy",
365-
"module_path": "qlib.contrib.strategy",
366-
"kwargs": {"signal": "<PRED>", "topk": 50, "n_drop": 5},
367-
},
368-
"backtest": {
369-
"start_time": None,
370-
"end_time": None,
371-
"account": 100000000,
372-
"benchmark": "SH000300",
373-
"exchange_kwargs": {
374-
"limit_threshold": 0.095,
375-
"deal_price": "close",
376-
"open_cost": 0.0005,
377-
"close_cost": 0.0015,
378-
"min_cost": 5,
379-
},
380-
},
381-
},
362+
config=None,
382363
risk_analysis_freq: Union[List, str] = None,
383364
indicator_analysis_freq: Union[List, str] = None,
384365
indicator_analysis_method=None,
@@ -401,6 +382,27 @@ def __init__(
401382
"""
402383
super().__init__(recorder=recorder, skip_existing=skip_existing, **kwargs)
403384

385+
if config is None:
386+
config = { # Default config for daily trading
387+
"strategy": {
388+
"class": "TopkDropoutStrategy",
389+
"module_path": "qlib.contrib.strategy",
390+
"kwargs": {"signal": "<PRED>", "topk": 50, "n_drop": 5},
391+
},
392+
"backtest": {
393+
"start_time": None,
394+
"end_time": None,
395+
"account": 100000000,
396+
"benchmark": "SH000300",
397+
"exchange_kwargs": {
398+
"limit_threshold": 0.095,
399+
"deal_price": "close",
400+
"open_cost": 0.0005,
401+
"close_cost": 0.0015,
402+
"min_cost": 5,
403+
},
404+
},
405+
}
404406
# We only deepcopy_basic_type because
405407
# - We don't want to affect the config outside.
406408
# - We don't want to deepcopy complex object to avoid overhead

0 commit comments

Comments
 (0)