merge upstream main into crypto-analysis-mvp
This commit is contained in:
commit
99ec63f966
52 files changed
+1170
-669
No files matched your search
@@ -1,10 +1,6 @@
|
||||
from typing import Annotated, Sequence
|
||||
from datetime import date, timedelta, datetime
|
||||
from typing_extensions import TypedDict, Optional
|
||||
from langchain_openai import ChatOpenAI
|
||||
from tradingagents.agents import *
|
||||
from langgraph.prebuilt import ToolNode
|
||||
from langgraph.graph import END, StateGraph, START, MessagesState
|
||||
from typing import Annotated
|
||||
from typing_extensions import TypedDict
|
||||
from langgraph.graph import MessagesState
|
||||
|
||||
|
||||
# Researcher team state
|
||||
|
||||
@@ -19,6 +19,36 @@ from tradingagents.agents.utils.news_data_tools import (
|
||||
get_global_news
|
||||
)
|
||||
|
||||
|
||||
def get_language_instruction() -> str:
|
||||
"""Return a prompt instruction for the configured output language.
|
||||
|
||||
Returns empty string when English (default), so no extra tokens are used.
|
||||
Only applied to user-facing agents (analysts, portfolio manager).
|
||||
Internal debate agents stay in English for reasoning quality.
|
||||
"""
|
||||
from tradingagents.dataflows.config import get_config
|
||||
lang = get_config().get("output_language", "English")
|
||||
if lang.strip().lower() == "english":
|
||||
return ""
|
||||
return f" Write your entire response in {lang}."
|
||||
|
||||
|
||||
def build_instrument_context(ticker: str, asset_type: str = "stock") -> str:
|
||||
"""Describe the exact instrument so agents preserve exchange-qualified tickers."""
|
||||
instrument_label = "asset" if asset_type == "crypto" else "instrument"
|
||||
extra_hint = (
|
||||
" Treat it as a crypto asset rather than a company, and do not assume company fundamentals are available."
|
||||
if asset_type == "crypto"
|
||||
else ""
|
||||
)
|
||||
return (
|
||||
f"The {instrument_label} to analyze is `{ticker}`. "
|
||||
"Use this exact ticker in every tool call, report, and recommendation, "
|
||||
"preserving any exchange suffix (e.g. `.TO`, `.L`, `.HK`, `.T`, `-USD`)."
|
||||
+ extra_hint
|
||||
)
|
||||
|
||||
def create_msg_delete():
|
||||
def delete_messages(state):
|
||||
"""Clear messages and add placeholder for Anthropic compatibility"""
|
||||
@@ -35,4 +65,4 @@ def create_msg_delete():
|
||||
return delete_messages
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class FinancialSituationMemory:
|
||||
|
||||
# Build results
|
||||
results = []
|
||||
max_score = max(scores) if max(scores) > 0 else 1 # Normalize scores
|
||||
max_score = float(scores.max()) if len(scores) > 0 and scores.max() > 0 else 1.0
|
||||
|
||||
for idx in top_indices:
|
||||
# Normalize score to 0-1 range for consistency
|
||||
|
||||
@@ -22,10 +22,11 @@ def get_indicators(
|
||||
"""
|
||||
# LLMs sometimes pass multiple indicators as a comma-separated string;
|
||||
# split and process each individually.
|
||||
indicators = [i.strip() for i in indicator.split(",") if i.strip()]
|
||||
if len(indicators) > 1:
|
||||
results = []
|
||||
for ind in indicators:
|
||||
indicators = [i.strip().lower() for i in indicator.split(",") if i.strip()]
|
||||
results = []
|
||||
for ind in indicators:
|
||||
try:
|
||||
results.append(route_to_vendor("get_indicators", symbol, ind, curr_date, look_back_days))
|
||||
return "\n\n".join(results)
|
||||
return route_to_vendor("get_indicators", symbol, indicator.strip(), curr_date, look_back_days)
|
||||
except ValueError as e:
|
||||
results.append(str(e))
|
||||
return "\n\n".join(results)
|
||||
Reference in new issue
Block a user