Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.py #1435

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion qlib/backtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ def finished(self) -> bool:
- If self.trade_step >= self.self.trade_len, it means the trading is finished
- If self.trade_step < self.self.trade_len, it means the number of trading step finished is self.trade_step
"""
return self.trade_step >= self.trade_len
"""
In /contrib/strategy/signal_strategy.py,
it comments
"get the number of trading step finished, trade_step can be [0, 1, 2, ..., trade_len - 1]"
If set finished == self.trade_step >= self.trade_len it will raise IndexError: index X is out of bounds for axis 0 with size X.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tell me which script will raise the IndexError error you mentioned here?

I think change self.trade_len = _end_index - _start_index + 1 to self.trade_len = _end_index - _start_index maybe better, but it may
result other errors.
"""
return self.trade_step >= self.trade_len - 1

def step(self) -> None:
if self.finished():
Expand Down