Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qlib/backtest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def create_account_instance(
position_dict=position_dict,
pos_type=pos_type,
benchmark_config=(
{}
{"benchmark": None}
if benchmark is None
else {
"benchmark": benchmark,
Expand Down
15 changes: 15 additions & 0 deletions tests/backtest/test_benchmark_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from qlib.backtest import create_account_instance


def test_create_account_instance_disables_benchmark_when_none():
account = create_account_instance(
start_time="2020-01-01",
end_time="2020-01-02",
benchmark=None,
account=100000,
)

assert account.benchmark_config["benchmark"] is None
assert "start_time" not in account.benchmark_config
assert "end_time" not in account.benchmark_config
assert account.portfolio_metrics.bench is None