- Add advanced metrics dashboard with trade analytics - Add new trading components (EntryTypeAnalysis, MultiDayPositionTracker, NewsEventTracker, etc.) - Add strategy mode selector and trend confirmation - Add risk automation panel and slippage correlation analysis - Add daily trading plan enhancements with modal components - Add custom hooks (useApi, useLocalStorage, useAdvancedTradeMetrics) - Add broker service integration and trading API - Add test setup and vitest configuration - Include parquet data files for live market data - Add comprehensive documentation in docs/ folder
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify OpenRouter API is working correctly
|
|
"""
|
|
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.dirname(__file__))
|
|
|
|
from app.services.openrouter import openrouter_service
|
|
|
|
|
|
async def test_openrouter_connection():
|
|
"""Test basic OpenRouter API connection"""
|
|
print("🔍 Testing OpenRouter API Connection...")
|
|
print(f"Base URL: {openrouter_service.base_url}")
|
|
print(f"Model: {openrouter_service.model}")
|
|
print(f"API Key: {'✓ Set' if openrouter_service.api_key else '✗ Not Set'}")
|
|
print()
|
|
|
|
if not openrouter_service.api_key:
|
|
print("❌ ERROR: OPENROUTER_API_KEY not set in environment")
|
|
return False
|
|
|
|
# Test with a simple trading plan generation
|
|
test_prompt = """Analyze the current gold (XAU/USD) market conditions and provide a brief trading recommendation.
|
|
|
|
Current Price: $2,050.00
|
|
Market Context: Gold has been consolidating in a range between $2,030 and $2,060.
|
|
|
|
Respond in JSON format with:
|
|
{
|
|
"recommendation": "BUY|SELL|HOLD",
|
|
"confidence": 75,
|
|
"reasoning": "Brief explanation"
|
|
}
|
|
"""
|
|
|
|
try:
|
|
print("📡 Sending test request to OpenRouter...")
|
|
response = await openrouter_service.generate_trading_plan(test_prompt)
|
|
print("✅ SUCCESS! OpenRouter API is working")
|
|
print()
|
|
print("Response received:")
|
|
print("-" * 60)
|
|
import json
|
|
print(json.dumps(response, indent=2))
|
|
print("-" * 60)
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ ERROR: {str(e)}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
success = asyncio.run(test_openrouter_connection())
|
|
sys.exit(0 if success else 1)
|