feat: Enhance AI analysis capabilities and UI

Refactor AI analysis to support different modes (Technical, Fundamental, Hybrid) and introduce richer data points in the `Signal` and `AnalysisResponse` interfaces. This improves the granularity and detail of the AI's market insights.

Remove the `MarketTicker` component from the main layout and simplify the `Navbar` by removing the 'Plans' tab. These changes streamline the user interface.
This commit is contained in:
desartstudio95
2026-05-03 12:02:27 +02:00
parent c336df2746
commit c95af0e973
9 changed files with 168 additions and 162 deletions
+48 -43
View File
@@ -3,26 +3,47 @@ import { AnalysisResponse, SignalType } from "../types";
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY || '' });
export const analyzeForexChart = async (imageBase64: string, userNotes?: string): Promise<AnalysisResponse> => {
export const analyzeForexChart = async (imageBase64: string, userNotes?: string, preferredMode?: 'Técnico' | 'Fundamental' | 'Híbrido'): Promise<AnalysisResponse> => {
const model = "gemini-3-flash-preview";
const systemInstruction = `
Você é um Analista Institucional de Forex com IA adaptativa, especializado em Fluxo de Ordens, Liquidez e Comportamento Institucional (PRO Logic).
Sua função é analisar o gráfico fornecido e identificar oportunidades de alta probabilidade instantaneamente.
Você é o QuantScan IA, um sistema avançado de análise de mercado financeiro com inteligência institucional.
Analise a imagem detalhadamente em busca de:
1. LIQUIDITY SWEEP + TRAP DETECTION: Detectar Stop Hunts, Falsos rompimentos, Equal highs/lows e Rejeições.
2. MOMENTUM + ENTRY TIMING: Avaliar força dos candles e rejeições.
3. ZONAS IMPORTANTES: Oferta/Demanda e Níveis psicológicos.
Especializações: Smart Money Concepts (SMC), Liquidez, Momentum, Análise Fundamental macro, Aprendizado contínuo.
Detecte automaticamente o Timeframe e o Par de Moedas.
Seja breve, preciso e ultrarrápido na resposta.
Sua função é gerar decisões de trading com alta precisão, explicação clara e score de probabilidade baseado na análise de imagem do gráfico e no input técnico/fundamental.
MODOS DE ANÁLISE:
- Técnico: Foco em Timing, Estrutura e Execução.
- Fundamental: Foco em Macro, Notícias, Força de moedas.
- Híbrido: Combinação de Técnico e Fundamental (Recomendado).
DETECÇÃO AUTOMÁTICA: Timeframe (M1-D1), Par de moeda, Estrutura.
FORMATO DE SAÍDA (Obrigatório em JSON):
{
"mode": "Técnico" | "Fundamental" | "Híbrido",
"analiseGeral": "string",
"timeframe": "string",
"estrutura": "string",
"tecnica": "string", // Detalhada (SMC+Liquidez+Momentum)
"fundamental": "string", // Resumo macro
"decision": "BUY" | "SELL" | "WAIT",
"entry": "string",
"stopLoss": "string",
"takeProfit": "string",
"score": number, // 0-100
"justification": "string",
"alerta": "string",
"pair": "string"
}
`;
const prompt = `
Analise este gráfico de Forex sob a óptica institucional. ${userNotes ? `Notas do usuário: ${userNotes}` : ''}
Retorne a análise seguindo estritamente o esquema JSON fornecido.
Analise este gráfico sob a óptica do QuantScan IA.
${preferredMode ? `Use estritamente o modo de análise: ${preferredMode}.` : 'Detecte o melhor modo automaticamente.'}
${userNotes ? `Notas do usuário: ${userNotes}` : ''}
Detecte modo, timeframe e par se não fornecidos. Retorne JSON estrito.
`;
const response = await ai.models.generateContent({
@@ -41,38 +62,22 @@ export const analyzeForexChart = async (imageBase64: string, userNotes?: string)
responseSchema: {
type: Type.OBJECT,
properties: {
pair: { type: Type.STRING, description: "Par de moedas detectado (ex: EURUSD)" },
timeframe: { type: Type.STRING, description: "Timeframe detectado (ex: H1)" },
structure: { type: Type.STRING, description: "Resumo da estrutura de mercado" },
conceptsDetected: {
type: Type.ARRAY,
items: { type: Type.STRING },
description: "Lista de conceitos identificados"
},
decision: {
type: Type.STRING,
enum: ["BUY", "SELL", "WAIT"],
description: "Decisão final de trading"
},
entry: { type: Type.STRING, description: "Preço ou zona de entrada" },
stopLoss: { type: Type.STRING, description: "Preço de Stop Loss" },
takeProfit: { type: Type.STRING, description: "Preço de Take Profit" },
score: { type: Type.NUMBER, description: "Score de probabilidade de 0 a 100" },
justification: { type: Type.STRING, description: "Explicação técnica para o score" },
liquiditySweep: { type: Type.STRING, description: "Descrição do sweep de liquidez detectado ou armadilhas" },
momentum: { type: Type.STRING, description: "Análise do momentum e timing de entrada" },
keyZones: {
type: Type.ARRAY,
items: { type: Type.STRING },
description: "Zonas importantes detectadas"
},
institutionalContext: {
type: Type.STRING,
enum: ["Accumulation", "Manipulation", "Distribution", "None"],
description: "Fase do ciclo institucional"
}
mode: { type: Type.STRING, enum: ['Técnico', 'Fundamental', 'Híbrido'] },
analiseGeral: { type: Type.STRING },
pair: { type: Type.STRING },
timeframe: { type: Type.STRING },
estrutura: { type: Type.STRING },
tecnica: { type: Type.STRING },
fundamental: { type: Type.STRING },
decision: { type: Type.STRING, enum: ["BUY", "SELL", "WAIT"] },
entry: { type: Type.STRING },
stopLoss: { type: Type.STRING },
takeProfit: { type: Type.STRING },
score: { type: Type.NUMBER },
justification: { type: Type.STRING },
alerta: { type: Type.STRING }
},
required: ["pair", "timeframe", "structure", "conceptsDetected", "decision", "entry", "stopLoss", "takeProfit", "score", "justification", "liquiditySweep", "momentum", "keyZones", "institutionalContext"]
required: ["mode", "analiseGeral", "pair", "timeframe", "estrutura", "tecnica", "fundamental", "decision", "entry", "stopLoss", "takeProfit", "score", "justification", "alerta"]
}
}
});