Files
TradingAgents/test_smoke.py
T
小钰 51d057e2c9
CI / tests (py3.10) (push) Has been cancelled
CI / tests (py3.11) (push) Has been cancelled
CI / tests (py3.12) (push) Has been cancelled
CI / tests (py3.13) (push) Has been cancelled
CI / clean-install smoke (push) Has been cancelled
CI / ruff (strict, full repo) (push) Has been cancelled
feat: Yahoo Finance SSH proxy + Xiaomi MiMo LLM support
- Add SSH proxy via foreign server for Yahoo Finance bypass
- Add fallback in load_ohlcv and get_YFin_data_online
- Add LLM JSON decode retry (3 attempts) in NormalizedChatOpenAI
- Add yahoo_proxy.py utility module
- Add test_smoke.py and patches/
2026-07-07 15:30:20 +08:00

67 lines
2.2 KiB
Python

"""Quick smoke test for TradingAgents deployment.
Uses OpenRouter + free Gemini model to minimize cost.
"""
import os
import json
# Load OpenRouter API key from openclaw config
with open(os.path.expanduser("~/.openclaw/openclaw.json")) as f:
oc_config = json.load(f)
openrouter_key = oc_config.get("env", {}).get("OPENROUTER_API_KEY", "")
if not openrouter_key:
raise RuntimeError("OPENROUTER_API_KEY not found in openclaw.json")
os.environ["OPENROUTER_API_KEY"] = openrouter_key
os.environ["ALPHA_VANTAGE_API_KEY"] = "W5PTA2J5OB16W02L"
os.environ["OPENAI_API_KEY"] = "tp-ce6eaqg1gh1uev46i4oexh4sahloyfo2hfpxuc2n9m7yl9dd"
os.environ["OPENAI_API_BASE"] = "https://token-plan-cn.xiaomimimo.com/v1"
# Import after env var is set
from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG
# Configure: OpenRouter + Gemini (free/cheap model)
config = DEFAULT_CONFIG.copy()
config["llm_provider"] = "openai"
config["deep_think_llm"] = "mimo-v2.5-pro"
config["quick_think_llm"] = "mimo-v2.5"
config["llm_max_retries"] = 6
config["temperature"] = 0.1 # Lower temperature for more stable output
config["data_vendors"] = {
"core_stock_apis": "yfinance",
"technical_indicators": "yfinance",
"fundamental_data": "alpha_vantage",
"news_data": "yfinance",
"macro_data": "fred",
"prediction_markets": "polymarket",
}
config["max_debate_rounds"] = 1
config["max_risk_discuss_rounds"] = 1
config["output_language"] = "Chinese"
print("=" * 60)
print("TradingAgents Smoke Test")
print(f"Provider: {config['llm_provider']}")
print(f"Deep Model: {config['deep_think_llm']}")
print(f"Quick Model: {config['quick_think_llm']}")
print("=" * 60)
# Test with a simple A-share ticker
ta = TradingAgentsGraph(debug=True, config=config)
print("\nRunning analysis for 600519.SS (Kweichow Moutai) on 2026-01-15...")
print("(This will take several minutes due to multiple LLM calls)\n")
try:
_, decision = ta.propagate("AAPL", "2026-01-15")
print("\n" + "=" * 60)
print("DECISION RESULT:")
print("=" * 60)
print(decision)
print("\n✅ Smoke test PASSED!")
except Exception as e:
print(f"\n❌ Smoke test FAILED: {e}")
import traceback
traceback.print_exc()