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

Negative Volume Index Strategy is added. #237

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

cinar
Copy link
Owner

@cinar cinar commented Oct 17, 2024

Describe Request

Negative Volume Index Stratey is added.

Change Type

New strategy.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced the Negative Volume Index Strategy for enhanced trading decisions.
    • Comprehensive updates to the documentation, including installation instructions and a new section on backtesting functionality.
    • Added support for fully configurable indicators and strategies, enhancing user flexibility.
  • Bug Fixes

    • Improved clarity in licensing information and contributing guidelines.
  • Documentation

    • Expanded lists of indicators and strategies with detailed descriptions and links.

@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 96.82540% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.93%. Comparing base (3e0fce2) to head (5340f09).

Files with missing lines Patch % Lines
strategy/volume/negative_volume_index_strategy.go 98.38% 1 Missing ⚠️
strategy/volume/volume.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #237      +/-   ##
==========================================
+ Coverage   92.87%   92.93%   +0.05%     
==========================================
  Files         168      169       +1     
  Lines        4353     4416      +63     
==========================================
+ Hits         4043     4104      +61     
- Misses        251      253       +2     
  Partials       59       59              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

coderabbitai bot commented Oct 17, 2024

Walkthrough

The pull request introduces significant updates to the Indicator Go module, primarily reflected in the README.md and the addition of the NegativeVolumeIndexStrategy. The README.md now includes details on major improvements, configurable indicators, generics support, expanded strategy lists, and new backtesting functionality. The NegativeVolumeIndexStrategy is implemented in the volume package with associated methods for instantiation and computation. Unit tests for this strategy have also been added to ensure functionality and reporting accuracy.

Changes

File Change Summary
README.md Updated to include major improvements, configurable indicators, generics support, expanded strategy lists, backtesting functionality, usage instructions, contributing guidelines, and license information.
strategy/volume/README.md Introduced NegativeVolumeIndexStrategy, including methods for instantiation and functionality.
strategy/volume/negative_volume_index_strategy.go Added NegativeVolumeIndexStrategy type with methods for computation and reporting.
strategy/volume/negative_volume_index_strategy_test.go Introduced unit tests for NegativeVolumeIndexStrategy, validating functionality and report generation.
strategy/volume/volume.go Updated AllStrategies function to include NewNegativeVolumeIndexStrategy().

Possibly related PRs

🐇 In the meadow, where numbers play,
A new strategy hops in, brightening the day.
With volumes dancing, and tests to run,
The Negative Volume Index has finally begun!
So gather your data, let trading commence,
With insights and metrics, it's all so intense! 📈✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 3

🧹 Outside diff range and nitpick comments (4)
strategy/volume/negative_volume_index_strategy_test.go (2)

17-37: LGTM: Well-structured test function with a minor suggestion.

The test function is well-organized, using separate CSV files for input data and expected results. Error handling is properly implemented, and helper functions are utilized effectively.

Consider adding a comment explaining the choice of 12 as the parameter for NewNegativeVolumeIndexStrategyWith. This would provide context for future maintainers:

+ // Initialize strategy with a period of 12, which is a common choice for NVI
 nvis := volume.NewNegativeVolumeIndexStrategyWith(12)

39-55: LGTM: Well-structured test function with suggestions for improvement.

The test function for the strategy report is well-organized and follows similar patterns to the previous test, which is good for consistency. The use of defer for cleanup is a good practice.

Consider the following improvements:

  1. Add a check to verify the content of the generated HTML file:
content, err := os.ReadFile(fileName)
if err != nil {
    t.Fatal(err)
}
if len(content) == 0 {
    t.Fatal("Generated report is empty")
}
  1. Use a temporary directory for the output file to avoid potential conflicts:
tempDir, err := os.MkdirTemp("", "test")
if err != nil {
    t.Fatal(err)
}
defer os.RemoveAll(tempDir)
fileName := filepath.Join(tempDir, "negative_volume_index_strategy.html")
  1. Add a comment explaining why the strategy is initialized without parameters in this test, as it differs from the previous test:
// Initialize strategy without parameters to test the default configuration
nvis := volume.NewNegativeVolumeIndexStrategy()
strategy/volume/README.md (1)

219-223: Minor grammatical fix needed

There's a small grammatical issue in the description of the NewNegativeVolumeIndexStrategy function.

Please update the description as follows:

-NewNegativeVolumeIndexStrategy function initializes a new Negative Volume Index strategy instance with the default parameters.
+The NewNegativeVolumeIndexStrategy function initializes a new Negative Volume Index strategy instance with the default parameters.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~222-~222: Possible missing article found.
Context: ...egy() *NegativeVolumeIndexStrategy ``` NewNegativeVolumeIndexStrategy function initializes a new Negative Vol...

(AI_HYDRA_LEO_MISSING_THE)

README.md (1)

144-144: Great addition, but please fix the indentation.

The addition of the Negative Volume Index Strategy is a valuable contribution to the list of Volume Strategies. However, there's a minor formatting issue:

Please replace the hard tab with spaces to maintain consistency with the rest of the file. You can apply this diff:

-	[Negative Volume Index Strategy](strategy/volume/README.md#type-negativevolumeindexstrategy)
+    [Negative Volume Index Strategy](strategy/volume/README.md#type-negativevolumeindexstrategy)

This change will ensure that the indentation is consistent with the other items in the list.

🧰 Tools
🪛 Markdownlint

144-144: Column: 2
Hard tabs

(MD010, no-hard-tabs)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3e0fce2 and 5340f09.

⛔ Files ignored due to path filters (1)
  • strategy/volume/testdata/negative_volume_index_strategy.csv is excluded by !**/*.csv
📒 Files selected for processing (5)
  • README.md (1 hunks)
  • strategy/volume/README.md (3 hunks)
  • strategy/volume/negative_volume_index_strategy.go (1 hunks)
  • strategy/volume/negative_volume_index_strategy_test.go (1 hunks)
  • strategy/volume/volume.go (1 hunks)
🧰 Additional context used
🪛 Markdownlint
README.md

144-144: Column: 2
Hard tabs

(MD010, no-hard-tabs)

🪛 LanguageTool
strategy/volume/README.md

[uncategorized] ~222-~222: Possible missing article found.
Context: ...egy() *NegativeVolumeIndexStrategy ``` NewNegativeVolumeIndexStrategy function initializes a new Negative Vol...

(AI_HYDRA_LEO_MISSING_THE)

🔇 Additional comments (4)
strategy/volume/negative_volume_index_strategy_test.go (1)

7-15: LGTM: Appropriate imports for testing.

The import statements are well-organized and include all necessary packages for testing the NegativeVolumeIndexStrategy. Using the versioned import github.com/cinar/indicator/v2 is a good practice for maintaining compatibility.

strategy/volume/README.md (3)

41-46: LGTM: Index section updated correctly

The new entries for NegativeVolumeIndexStrategy have been added to the index section, following the established pattern for other strategies. This ensures consistency and makes it easy for users to find information about the new strategy.


63-70: LGTM: New constant properly defined and documented

The new constant DefaultNegativeVolumeIndexStrategyEmaPeriod is correctly defined with a value of 255 and is accompanied by an appropriate comment explaining its purpose. This follows the established pattern for constant definitions in the file.


201-260: LGTM: NegativeVolumeIndexStrategy documentation added

The documentation for NegativeVolumeIndexStrategy and its methods has been added successfully. The structure and content are consistent with the documentation of other strategies in the file, providing clear information about the new strategy's purpose and usage.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~222-~222: Possible missing article found.
Context: ...egy() *NegativeVolumeIndexStrategy ``` NewNegativeVolumeIndexStrategy function initializes a new Negative Vol...

(AI_HYDRA_LEO_MISSING_THE)

strategy/volume/volume.go Show resolved Hide resolved
@cinar cinar merged commit 467323d into master Oct 17, 2024
6 checks passed
@cinar cinar deleted the negative-volume-index-strategy branch October 17, 2024 01:20
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2024
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.

2 participants