Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,9 @@ __marimo__/
*.db-wal
*.db-shm
*.sqlite
*.sqlite3
*.sqlite3

# Downloads
*csv
*xlsx
*xls
21 changes: 14 additions & 7 deletions python/configs/agent_cards/trading_agents.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
"streaming": true,
"push_notifications": false
},
"metadata": {
"version": "1.0.0",
"author": "ValueCell Team",
"tags": ["trading", "analysis", "multi-agent", "stocks", "finance"],
"supported_tickers": ["AAPL", "GOOGL", "MSFT", "NVDA", "TSLA", "AMZN", "META", "NFLX", "SPY"],
"supported_analysts": ["market", "social", "news", "fundamentals"],
"supported_llm_providers": ["openai", "anthropic", "google", "ollama", "openrouter"]
"skills": [{
"id": "trading_agents",
"name": "Trading Agents",
"description": "Trading Agents - Multi-agent trading analysis system with market, sentiment, news and fundamentals analysis",
"examples": [
"Analyze APPL using all analysts",
"Analyze NVDA using market and fundamentals analysts",
"Analyze TSLA using all analysts, date 2024-01-15, enable debug mode"
],
"tags": ["analysis", "multi-agent", "stocks", "US market"]
}],
"provider": {
"organization": "Tauric",
"url": "https://arxiv.org/abs/2412.20138"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 15 additions & 9 deletions python/third_party/TradingAgents/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
# Get your key from: https://platform.openai.com/api-keys
OPENAI_API_KEY=your_openai_api_key_here

# OpenAI Embeddings API Key - IMPORTANT for Memory Functionality
# Finnhub API Key - Required for financial news and insider trading data
# Get your free key from: https://finnhub.io/register
FINNHUB_API_KEY=your_finnhub_api_key_here


# Embeddings API Key - IMPORTANT for Memory Functionality
# This is needed when using non-OpenAI providers (OpenRouter, Anthropic, Google)
# because they don't support OpenAI's embeddings API
# If not set, the system will try to use OPENAI_API_KEY for embeddings
# Get your key from: https://platform.openai.com/api-keys
OPENAI_EMBEDDINGS_API_KEY=your_openai_embeddings_key_here
EMBEDDINGS_API_KEY=your_openai_embeddings_key_here
# Default embedding URL is OpenAI
EMBEDDINGS_BACKEND_URL=your_embedding_model_backend_url_here
# Default embedding model
EMBEDDINGS_MODEL=text-embedding-3-small

# Finnhub API Key - Required for financial news and insider trading data
# Get your free key from: https://finnhub.io/register
FINNHUB_API_KEY=your_finnhub_api_key_here

# =============================================================================
# OPTIONAL API KEYS (Only needed if using specific providers)
Expand Down Expand Up @@ -112,7 +118,7 @@ TRADINGAGENTS_ONLINE_TOOLS=true
# OpenRouter does not support OpenAI's embeddings API, which is required for
# the memory functionality in TradingAgents. You MUST set both:
# OPENAI_API_KEY=sk-or-v1-your-openrouter-key-here (for chat models)
# OPENAI_EMBEDDINGS_API_KEY=sk-your-real-openai-key-here (for embeddings)
# EMBEDDINGS_API_KEY=sk-your-real-openai-key-here (for embeddings)

# For Azure OpenAI
# TRADINGAGENTS_LLM_PROVIDER=azure
Expand All @@ -130,15 +136,15 @@ TRADINGAGENTS_ONLINE_TOOLS=true

# Solution 1 - Use dedicated OpenAI key for embeddings (RECOMMENDED):
# OPENAI_API_KEY=sk-or-v1-your-openrouter-key-here
# OPENAI_EMBEDDINGS_API_KEY=sk-your-real-openai-key-here
# EMBEDDINGS_API_KEY=sk-your-real-openai-key-here

# Solution 2 - Switch to Ollama for fully local processing:
# TRADINGAGENTS_LLM_PROVIDER=ollama
# TRADINGAGENTS_BACKEND_URL=http://localhost:11434/v1
# Then run: ollama pull llama3.1 && ollama pull nomic-embed-text

# Solution 3 - Accept limited memory functionality:
# If you don't set OPENAI_EMBEDDINGS_API_KEY, the system will use dummy
# If you don't set EMBEDDINGS_API_KEY, the system will use dummy
# embeddings and continue running, but memory features will be limited.

# Affected providers that need separate embeddings key:
Expand All @@ -156,6 +162,6 @@ TRADINGAGENTS_ONLINE_TOOLS=true
# 1. Copy this file to .env: cp .env.example .env
# 2. Fill in your actual API keys and configuration values
# 3. Make sure .env is in your .gitignore to keep your keys private
# 4. For OpenRouter users: Set both OPENAI_API_KEY and OPENAI_EMBEDDINGS_API_KEY
# 4. For OpenRouter users: Set both OPENAI_API_KEY and EMBEDDINGS_API_KEY
# 5. For Ollama users: Run 'ollama pull nomic-embed-text' for embeddings support
# 6. Run the application: python main.py or python -m cli.main
1 change: 1 addition & 0 deletions python/third_party/TradingAgents/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Environment variables
.env
.env.backup
.env.local
.env.*.local

Expand Down
1 change: 0 additions & 1 deletion python/third_party/TradingAgents/adapter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime, date
from typing import List, Dict, Any, Optional
import re
import json

from langchain_core.messages import HumanMessage
from langchain_openai import ChatOpenAI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,12 @@

class FinancialSituationMemory:
def __init__(self, name, config):
if config["backend_url"] == "http://localhost:11434/v1":
self.embedding = "nomic-embed-text"
self.client = OpenAI(base_url=config["backend_url"])
else:
self.embedding = "text-embedding-3-small"
# For embeddings, handle different providers appropriately
# Many providers like OpenRouter, Anthropic, Google don't support embeddings API
if "openrouter.ai" in config["backend_url"] or "anthropic.com" in config["backend_url"] or "generativelanguage.googleapis.com" in config["backend_url"]:
# Use a dedicated OpenAI API key for embeddings, or fall back to the main key
embeddings_api_key = os.getenv("OPENAI_EMBEDDINGS_API_KEY") or os.getenv("OPENAI_API_KEY")

# Check if the API key is from OpenRouter (starts with sk-or-v1-)
if embeddings_api_key and embeddings_api_key.startswith("sk-or-v1-"):
print("⚠️ Warning: OpenRouter API key detected for embeddings.")
print("💡 OpenRouter doesn't support embeddings API. Please set OPENAI_EMBEDDINGS_API_KEY")
print(" with a real OpenAI API key, or the memory functionality will be disabled.")
# Try to use it anyway, but it will likely fail and trigger fallback

self.client = OpenAI(api_key=embeddings_api_key)
else:
self.client = OpenAI(base_url=config["backend_url"])
self.embedding = config["embeddings_model"]
self.client = OpenAI(base_url=config["embeddings_backend_url"])
if "localhost" not in config["embeddings_backend_url"]:
embeddings_api_key = os.getenv("EMBEDDINGS_API_KEY") or os.getenv("OPENAI_API_KEY")
self.client = OpenAI(api_key=embeddings_api_key, base_url=config["embeddings_backend_url"])

self.chroma_client = chromadb.Client(Settings(allow_reset=True))
try:
self.situation_collection = self.chroma_client.create_collection(name=name)
Expand All @@ -49,20 +34,8 @@ def get_embedding(self, text):
# try alternative approaches
print(f"⚠️ Embedding request failed with current provider: {str(e)}")

# Try with a dedicated embeddings API key
embeddings_key = os.getenv("OPENAI_EMBEDDINGS_API_KEY")
if embeddings_key and not embeddings_key.startswith("sk-or-v1-"):
print("🔄 Trying with dedicated OPENAI_EMBEDDINGS_API_KEY...")
try:
fallback_client = OpenAI(api_key=embeddings_key)
response = fallback_client.embeddings.create(
model="text-embedding-3-small", input=text
)
return response.data[0].embedding
except Exception as fallback_error:
print(f"❌ Dedicated embeddings key also failed: {str(fallback_error)}")

# Return a dummy embedding vector of the expected dimension (1536 for text-embedding-3-small)
print("Using dummy embeddings as fallback...")
import random
return [random.random() for _ in range(1536)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def str_to_bool(value):
"deep_think_llm": os.getenv("TRADINGAGENTS_DEEP_THINK_LLM", "o4-mini"),
"quick_think_llm": os.getenv("TRADINGAGENTS_QUICK_THINK_LLM", "gpt-4o-mini"),
"backend_url": os.getenv("TRADINGAGENTS_BACKEND_URL", "https://api.openai.com/v1"),
# Embeddings settings
"embeddings_backend_url": os.getenv("EMBEDDINGS_BACKEND_URL", "https://api.openai.com/v1"),
"embeddings_model": os.getenv("EMBEDDINGS_MODEL", "text-embedding-3-small"),
# Debate and discussion settings
"max_debate_rounds": int(os.getenv("TRADINGAGENTS_MAX_DEBATE_ROUNDS", "1")),
"max_risk_discuss_rounds": int(os.getenv("TRADINGAGENTS_MAX_RISK_DISCUSS_ROUNDS", "1")),
Expand Down
Loading