fix: add missing json import, complete risk_manager rename, use curr_date param
- Add missing import json at module level in bright_data.py (removed inline but never added to top) - Rename reflect_portfolio_manager -> reflect_risk_manager in reflection.py to match trading_graph.py - Use curr_date parameter in get_social_sentiment search query - Remove unused company_name variable in social_media_analyst.py
This commit is contained in:
parent
1bdbc7918f
commit
5028018624
|
|
@ -8,7 +8,6 @@ def create_social_media_analyst(llm):
|
||||||
def social_media_analyst_node(state):
|
def social_media_analyst_node(state):
|
||||||
current_date = state["trade_date"]
|
current_date = state["trade_date"]
|
||||||
ticker = state["company_of_interest"]
|
ticker = state["company_of_interest"]
|
||||||
company_name = state["company_of_interest"]
|
|
||||||
|
|
||||||
# Check if bright_data vendor is configured for social sentiment
|
# Check if bright_data vendor is configured for social sentiment
|
||||||
config = get_config()
|
config = get_config()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ in clean markdown format. No HTML parsing needed.
|
||||||
- Web Unlocker docs: https://docs.brightdata.com/scraping-automation/web-unlocker/introduction
|
- Web Unlocker docs: https://docs.brightdata.com/scraping-automation/web-unlocker/introduction
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
@ -294,8 +295,11 @@ def get_social_sentiment(ticker: str, curr_date: str = "") -> str:
|
||||||
Formatted string containing social media sentiment data.
|
Formatted string containing social media sentiment data.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
query = f"{ticker} stock reddit wallstreetbets sentiment discussion"
|
||||||
|
if curr_date:
|
||||||
|
query += f" {curr_date}"
|
||||||
results = _search_and_fetch(
|
results = _search_and_fetch(
|
||||||
query=f"{ticker} stock reddit wallstreetbets sentiment discussion",
|
query=query,
|
||||||
num_results=5,
|
num_results=5,
|
||||||
fetch_content=True,
|
fetch_content=True,
|
||||||
max_content_length=3000,
|
max_content_length=3000,
|
||||||
|
|
|
||||||
|
|
@ -110,12 +110,12 @@ Adhere strictly to these instructions, and ensure your output is detailed, accur
|
||||||
)
|
)
|
||||||
invest_judge_memory.add_situations([(situation, result)])
|
invest_judge_memory.add_situations([(situation, result)])
|
||||||
|
|
||||||
def reflect_portfolio_manager(self, current_state, returns_losses, portfolio_manager_memory):
|
def reflect_risk_manager(self, current_state, returns_losses, risk_manager_memory):
|
||||||
"""Reflect on portfolio manager's decision and update memory."""
|
"""Reflect on risk manager's decision and update memory."""
|
||||||
situation = self._extract_current_situation(current_state)
|
situation = self._extract_current_situation(current_state)
|
||||||
judge_decision = current_state["risk_debate_state"]["judge_decision"]
|
judge_decision = current_state["risk_debate_state"]["judge_decision"]
|
||||||
|
|
||||||
result = self._reflect_on_component(
|
result = self._reflect_on_component(
|
||||||
"PORTFOLIO MANAGER", judge_decision, situation, returns_losses
|
"RISK MANAGER", judge_decision, situation, returns_losses
|
||||||
)
|
)
|
||||||
portfolio_manager_memory.add_situations([(situation, result)])
|
risk_manager_memory.add_situations([(situation, result)])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue