Fix the bollinger band strategy#286
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #286 +/- ##
==========================================
+ Coverage 91.73% 91.79% +0.05%
==========================================
Files 191 191
Lines 6797 6797
==========================================
+ Hits 6235 6239 +4
+ Misses 497 494 -3
+ Partials 65 64 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughThe BollingerBandsStrategy.Compute function updates the action mapping: price closing above the upper band now yields Sell, and price closing below the lower band now yields Buy. All other logic, including inputs, idle-period handling, and action shifting, remains unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Market as Market Data
participant BB as BollingerBandsStrategy.Compute
participant Mapper as Action Mapper
participant Out as Actions
Market->>BB: close, upper, lower
BB->>Mapper: Evaluate band-cross conditions
alt close > upper
note over Mapper: CHANGED: map to Sell
Mapper-->>Out: Action = Sell
else close < lower
note over Mapper: CHANGED: map to Buy
Mapper-->>Out: Action = Buy
else within bands
Mapper-->>Out: Action = Hold/None
end
BB->>Out: Apply IdlePeriod skip and Shift (unchanged)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
strategy/volatility/bollinger_bands_strategy.go (1)
15-16: Doc comment contradicts code and has typos — update to mean-reversion wordingReplace the header in strategy/volatility/bollinger_bands_strategy.go with the diff below; also fix spelling in strategy/volatility/super_trend_strategy.go ('suggets' → 'suggests', 'indivates' → 'indicates').
-// BollingerBandsStrategy represents the configuration parameters for calculating the Bollinger Bands strategy. -// A closing value crossing above the upper band suggets a Buy signal, while crossing below the lower band -// indivates a Sell signal. +// BollingerBandsStrategy represents the configuration parameters for calculating the Bollinger Bands strategy. +// Mean-reversion variant: a close above the upper band suggests a Sell signal (overbought), +// while a close below the lower band suggests a Buy signal (oversold).
🧹 Nitpick comments (2)
strategy/volatility/bollinger_bands_strategy.go (2)
51-53: Nit: preferclosing < lowerfor readability/consistency.Reads more naturally alongside the upper-band check.
Apply this diff:
- if lower > closing { + if closing < lower { return strategy.Buy }
47-53: Boundary condition: should equality trigger a signal?Decide whether closes exactly on a band should count (>= / <=) or remain strict. If inclusive is desired, change to
closing >= upperandclosing <= lowerand note this in docs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
strategy/volatility/testdata/bollinger_bands_strategy.csvis excluded by!**/*.csv
📒 Files selected for processing (1)
strategy/volatility/bollinger_bands_strategy.go(1 hunks)
🔇 Additional comments (1)
strategy/volatility/bollinger_bands_strategy.go (1)
46-53: Signal inversion looks correct (mean‑reversion).Mapping close > upper → Sell and close < lower → Buy aligns with the reported issue and typical mean‑reversion BB usage.
|
Thank you! |
Describe Request
As mentioned in #269 the strategy seems to be invers
Fixed #269
Change Type
correction for the signal actions
Summary by CodeRabbit