-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add news data analysis to trading strategies #20
Conversation
Related to #2 Incorporate news data analysis into futures and options trading strategies. * **Futures Strategy (`strategies/futures_strategy.py`)** - Import `NewsDataFetcher` from `data/news_data_fetcher.py`. - Initialize `NewsDataFetcher` in the `__init__` method. - Add `_analyze_news_data` method to analyze news data. - Update `generate_signal` method to incorporate news data analysis. * **Options Strategy (`strategies/options_strategy.py`)** - Import `NewsDataFetcher` from `data/news_data_fetcher.py`. - Initialize `NewsDataFetcher` in the `__init__` method. - Add `_analyze_news_data` method to analyze news data. - Update `generate_signal` method to incorporate news data analysis.
WalkthroughThe pull request introduces news data integration into trading signal generation for both Changes
Sequence DiagramsequenceDiagram
participant Strategy
participant NewsDataFetcher
participant NewsAnalyzer
Strategy->>NewsDataFetcher: Fetch news data
NewsDataFetcher-->>Strategy: Return news articles
Strategy->>NewsAnalyzer: Analyze news sentiment
NewsAnalyzer-->>Strategy: Compute news score
Strategy->>Strategy: Integrate news score with other signals
Possibly related PRs
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (6)
strategies/futures_strategy.py (3)
29-32
: Initialize the news fetcher with graceful fallback.
If the API key or endpoint is missing or invalid, consider logging a warning or falling back to a no-op fetcher.
70-71
: Confirm weighting logic.
You are combining multiple scores equally. If news data is less reliable, consider assigning a lower weight or a dynamic weighting approach.
144-165
: Evaluate duplication across strategies.
These lines match the_analyze_news_data
approach inOptionsStrategy
. Consider refactoring into a shared utility to maintain DRY principles.Would you like help creating a shared helper for analyzing news data?
strategies/options_strategy.py (3)
63-66
: Handle fetch errors.
Like with the futures strategy, consider adding error handling around the asynchronous news fetch call.
71-72
: Weighing the signals.
Integration of the news signal is done similarly to the futures strategy. Verify if uniform weighting is appropriate for options data, or if you need a different weighting approach.
183-204
: Refactor repeated logic.
As seen infutures_strategy.py
,_analyze_news_data
is identical. Moving this to a shared helper or base class would reduce duplication and promote consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
strategies/futures_strategy.py
(4 hunks)strategies/options_strategy.py
(4 hunks)
🔇 Additional comments (6)
strategies/futures_strategy.py (4)
8-8
: Consider verifying the fetcher configuration.
By instantiatingNewsDataFetcher
directly, you're assuming the config keys exist. You might want to validate the presence or correctness ofnews_api_key
andnews_api_endpoint
before usage.
12-12
: Docstring update looks great.
The inclusion of “news data” in the docstring properly reflects the updated functionality.
36-36
: Docstring alignment.
The method description now references news data. This ensures clarity for developers.
61-64
: 🛠️ Refactor suggestionCheck for potential network errors.
When callingfetch_news_data
, there could be network or API failures. Consider wrapping this in atry/except
block or verifying the data attributes before processing.strategies/options_strategy.py (2)
6-6
: ImportingNewsDataFetcher
Import statement is consistent with the futures strategy. Well done.
28-31
: Validate config for news fetcher.
Similar to the futures strategy, ensure thatconfig["api"]["news_api_key"]
andconfig["api"]["news_api_endpoint"]
are present and valid prior to initialization.
Related to #2
Incorporate news data analysis into futures and options trading strategies.
Futures Strategy (
strategies/futures_strategy.py
)NewsDataFetcher
fromdata/news_data_fetcher.py
.NewsDataFetcher
in the__init__
method._analyze_news_data
method to analyze news data.generate_signal
method to incorporate news data analysis.Options Strategy (
strategies/options_strategy.py
)NewsDataFetcher
fromdata/news_data_fetcher.py
.NewsDataFetcher
in the__init__
method._analyze_news_data
method to analyze news data.generate_signal
method to incorporate news data analysis.Summary by CodeRabbit
New Features
Improvements