Reorganize UI for external trading workflow with manual trade logging

- Restructure tabs to analysis-focused workflow:
  * Analysis Hub: AI analysis, risk management, manual trade logger
  * Daily Prep: Market summary, alerts, checklist, news, trading plan
  * Journal & Review: Trading journal, habit tracker, advanced analytics
  * Live Charts: Technical analysis with streaming charts

- Add ManualTradeLogger component for logging trades from MT5/TradingView/cTrader
- Remove execution-focused components (TradeControls, PortfolioTracker)
- Update XAU/USD price to realistic ,084.99
- Add indicator preferences and AI plan service
- Add comprehensive documentation on decision coverage and implementation
This commit is contained in:
Krikorios
2025-11-16 07:50:00 +02:00
parent 73a26ea9b7
commit b5e2b02cb8
20 changed files with 4347 additions and 29 deletions
+60
View File
@@ -135,5 +135,65 @@ Respond in JSON format:
risk_level=RiskLevel(analysis_data.get("risk_level", "MEDIUM")),
)
async def generate_trading_plan(self, prompt: str) -> dict:
"""
Generate a comprehensive trading plan using AI
Args:
prompt: Detailed prompt with market data and user preferences
Returns:
Dictionary with trading plan data
"""
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json",
"HTTP-Referer": settings.OPENROUTER_SITE_URL,
"X-Title": settings.OPENROUTER_SITE_NAME,
}
payload = {
"model": self.model,
"messages": [
{
"role": "system",
"content": "You are an expert gold (XAU/USD) trading analyst. Always respond with valid JSON only, no additional text or explanations.",
},
{"role": "user", "content": prompt},
],
"temperature": 0.7,
"max_tokens": 2000,
}
async with httpx.AsyncClient(timeout=90.0) as client:
response = await client.post(
f"{self.base_url}/chat/completions",
headers=headers,
json=payload,
)
response.raise_for_status()
data = response.json()
# Extract AI response
ai_content = data["choices"][0]["message"]["content"]
# Parse JSON response
try:
# Try to extract JSON from markdown code blocks if present
if "```json" in ai_content:
json_start = ai_content.find("```json") + 7
json_end = ai_content.find("```", json_start)
ai_content = ai_content[json_start:json_end].strip()
elif "```" in ai_content:
json_start = ai_content.find("```") + 3
json_end = ai_content.find("```", json_start)
ai_content = ai_content[json_start:json_end].strip()
plan_data = json.loads(ai_content)
return plan_data
except json.JSONDecodeError as e:
raise Exception(f"Failed to parse AI trading plan response: {str(e)}")
openrouter_service = OpenRouterService()