Skip to content

Elder-Ray Index is added.#329

Merged
cinar merged 2 commits intomasterfrom
feature/elder-ray
Feb 25, 2026
Merged

Elder-Ray Index is added.#329
cinar merged 2 commits intomasterfrom
feature/elder-ray

Conversation

@cinar
Copy link
Owner

@cinar cinar commented Feb 25, 2026

Describe Request

Elder-Ray Index is added.

Fixed #303

Change Type

New indicator.

Summary by CodeRabbit

  • New Features

    • Added Elder-Ray Index indicator to the momentum analysis toolkit with configurable period support
  • Documentation

    • Updated indicator documentation to include the new Elder-Ray Index
  • Tests

    • Added comprehensive test suite for Elder-Ray Index calculations
  • Chores

    • Added 30 issue tracking entries for feature requests and enhancements

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Documentation and Issue Tracking
README.md, issues.txt
Updated README with Elder-Ray Index reference; added 30 new tracked issues in issues.txt.
Elder-Ray Index Implementation
momentum/elder_ray.go, momentum/elder_ray_test.go
Implemented ElderRay[T] generic type with Compute method that synchronizes highs, lows, and EMA streams to produce separate Bull Power and Bear Power channels. Includes NewElderRay, NewElderRayWithPeriod constructors, IdlePeriod, and String methods. Comprehensive test validates computation against CSV data.
API Documentation
momentum/README.md
Added documentation for ElderRay type, its constructors, methods (Compute, IdlePeriod, String), and DefaultElderRayPeriod constant.

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
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A new index hops into the fold,
Elder-Ray brings bull power and bear!
With channels that flow and helpers so bold,
The momentum shines bright in the air.
Thirteen bars of EMA's care. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Elder-Ray Index is added.' clearly summarizes the main change - adding a new Elder-Ray Index indicator to the codebase.
Description check ✅ Passed The description follows the template with 'Describe Request', 'Fixed #303', and 'Change Type' sections properly filled out.
Linked Issues check ✅ Passed The implementation fully addresses issue #303: creates ElderRay type with configurable period, uses EMA, computes Bull/Bear Power, and respects EMA's idle period.
Out of Scope Changes check ✅ Passed All changes are in-scope: Elder-Ray implementation in momentum package, documentation updates in README files, test file, and issue tracking in issues.txt.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/elder-ray

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.93%. Comparing base (855cb96) to head (c31f980).

Files with missing lines Patch % Lines
momentum/elder_ray.go 88.23% 2 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 855cb96 and c145402.

⛔ Files ignored due to path filters (1)
  • momentum/testdata/elder_ray.csv is excluded by !**/*.csv
📒 Files selected for processing (5)
  • README.md
  • issues.txt
  • momentum/README.md
  • momentum/elder_ray.go
  • momentum/elder_ray_test.go

Comment on lines +41 to +44
func NewElderRayWithPeriod[T helper.Number](period int) *ElderRay[T] {
return &ElderRay[T]{
Period: period,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

Comment on lines +493 to +500
```
Bull Power = High - n-period EMA
Bear Power = Low - n-period EMA
```

Example:

```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

@cinar cinar merged commit 673ad0c into master Feb 25, 2026
6 checks passed
@cinar cinar deleted the feature/elder-ray branch February 25, 2026 06:34
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Elder-Ray Index

2 participants