Conversation
📝 WalkthroughWalkthroughThis PR implements the Elder-Ray Index indicator in the momentum package, a generic type that calculates Bull Power (High−EMA) and Bear Power (Low−EMA) using a configurable exponential moving average. Includes implementation, tests, and documentation updates. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ElderRay as ElderRay[T]
participant EMA as EMA
participant Helper as Helper Utils
Client->>ElderRay: Compute(highs, lows, closings)
activate ElderRay
ElderRay->>EMA: NewEmaWithPeriod(closings)
activate EMA
EMA-->>ElderRay: ema channel
deactivate EMA
ElderRay->>Helper: Duplicate(ema) → [ema[0], ema[1]]
activate Helper
Helper-->>ElderRay: two ema channels
deactivate Helper
ElderRay->>Helper: Skip(highs, IdlePeriod)
Helper-->>ElderRay: skipped highs
ElderRay->>Helper: Skip(lows, IdlePeriod)
Helper-->>ElderRay: skipped lows
ElderRay->>ElderRay: Compute bullPower = highs - ema[0]
ElderRay->>ElderRay: Compute bearPower = lows - ema[1]
ElderRay-->>Client: (bullPower channel, bearPower channel)
deactivate ElderRay
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (88.93%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #329 +/- ##
==========================================
- Coverage 89.04% 88.93% -0.11%
==========================================
Files 207 208 +1
Lines 5822 5839 +17
==========================================
+ Hits 5184 5193 +9
- Misses 566 572 +6
- Partials 72 74 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@momentum/elder_ray.go`:
- Around line 41-44: The constructor NewElderRayWithPeriod currently allows
period <= 0 which can produce invalid idle periods; update NewElderRayWithPeriod
to validate the input and either return a sensible normalized value or reject
invalid input: check the `period` parameter at the start of
NewElderRayWithPeriod and if <= 0 set it to a safe default (e.g., 1 or a
package-constant DefaultPeriod) or panic/return an error per project
conventions, then assign the validated value to the ElderRay.Period field so
downstream EMA logic always sees a positive period; reference
NewElderRayWithPeriod and the ElderRay.Period field when making the change.
In `@momentum/README.md`:
- Around line 493-500: The README contains untyped fenced code blocks (the
blocks around the "Bull Power = High - n-period EMA / Bear Power = Low -
n-period EMA" snippet and the subsequent Example block) causing MD040; update
the source/template comments that emit those fences to include explicit language
tags (e.g., use "text" for plain snippets and "go" for Go examples) so the
generated Markdown has typed fences, then regenerate the docs so the lint
warning is resolved.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
momentum/testdata/elder_ray.csvis excluded by!**/*.csv
📒 Files selected for processing (5)
README.mdissues.txtmomentum/README.mdmomentum/elder_ray.gomomentum/elder_ray_test.go
| func NewElderRayWithPeriod[T helper.Number](period int) *ElderRay[T] { | ||
| return &ElderRay[T]{ | ||
| Period: period, | ||
| } |
There was a problem hiding this comment.
Guard invalid period values in constructor.
NewElderRayWithPeriod accepts period <= 0, which can produce an invalid idle period and undefined EMA behavior. Please validate or normalize the value at construction time.
Suggested fix
func NewElderRayWithPeriod[T helper.Number](period int) *ElderRay[T] {
+ if period < 1 {
+ period = DefaultElderRayPeriod
+ }
return &ElderRay[T]{
Period: period,
}
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@momentum/elder_ray.go` around lines 41 - 44, The constructor
NewElderRayWithPeriod currently allows period <= 0 which can produce invalid
idle periods; update NewElderRayWithPeriod to validate the input and either
return a sensible normalized value or reject invalid input: check the `period`
parameter at the start of NewElderRayWithPeriod and if <= 0 set it to a safe
default (e.g., 1 or a package-constant DefaultPeriod) or panic/return an error
per project conventions, then assign the validated value to the ElderRay.Period
field so downstream EMA logic always sees a positive period; reference
NewElderRayWithPeriod and the ElderRay.Period field when making the change.
| ``` | ||
| Bull Power = High - n-period EMA | ||
| Bear Power = Low - n-period EMA | ||
| ``` | ||
|
|
||
| Example: | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Add language tags to new fenced code blocks (lint warning).
Lines 493 and 500 introduce fenced blocks without a language, which triggers MD040. Because this file is generated, please adjust the source comments/template and regenerate docs so the fences are emitted as typed blocks (e.g., text and go).
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 493-493: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
[warning] 500-500: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@momentum/README.md` around lines 493 - 500, The README contains untyped
fenced code blocks (the blocks around the "Bull Power = High - n-period EMA /
Bear Power = Low - n-period EMA" snippet and the subsequent Example block)
causing MD040; update the source/template comments that emit those fences to
include explicit language tags (e.g., use "text" for plain snippets and "go" for
Go examples) so the generated Markdown has typed fences, then regenerate the
docs so the lint warning is resolved.
Describe Request
Elder-Ray Index is added.
Fixed #303
Change Type
New indicator.
Summary by CodeRabbit
New Features
Documentation
Tests
Chores