Add watchlist screener page#25
Add watchlist screener page#25felipeimpieri wants to merge 1 commit intocodex/clean-repo-and-fix-keyerror-close-kyrlsofrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| prev_pos = pos.shift(1).fillna(0.0) | ||
| entries = (pos != 0.0) & (pos != prev_pos) | ||
| # shift trade ids so the flip bar's return stays with the trade that held it | ||
| trade_ids = entries.shift(1).cumsum() | ||
| trade_ids = trade_ids.where(pos != 0.0) |
There was a problem hiding this comment.
Drop exit-bar returns when closing to flat
run_backtest groups trade P&L using entries.shift(1).cumsum() and then discards bars where pos is 0 (trade_ids = trade_ids.where(pos != 0.0)). Any time a position is closed to flat, the last bar’s return is still calculated using pos.shift(1) but is filtered out, so that trade’s P&L and win/loss status exclude the exit move. For example signals [1,1,0,0,1,1,0] yield trade returns of about +1.0% and +0.96% instead of ~+1.99% and ~0% because the returns on the bars where the position was exited are dropped. This understates losses and overstates win rate/average trade return for any strategy that ever goes flat.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task