feat: complete AuraTrade Titan world-class institutional quant workstation with multi-asset radar, economic calendar, 4-tab cockpit dock, and multi-tier profit targets
This commit is contained in:
+155
-62
@@ -1,18 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { TelemetryBar } from "@/components/header/TelemetryBar";
|
||||
import { SessionBadge } from "@/components/header/SessionBadge";
|
||||
import { TitanHeader } from "@/components/header/TitanHeader";
|
||||
import { WatchlistRadar } from "@/components/radar/WatchlistRadar";
|
||||
import { EconomicCalendarDock } from "@/components/macro/EconomicCalendarDock";
|
||||
import { TradingViewCanvas } from "@/components/chart/TradingViewCanvas";
|
||||
import { TimeframeSelector } from "@/components/chart/TimeframeSelector";
|
||||
import { CockpitDock } from "@/components/dock/CockpitDock";
|
||||
import { ConfluenceMeter } from "@/components/execution/ConfluenceMeter";
|
||||
import { OrderDrawer } from "@/components/execution/OrderDrawer";
|
||||
import { ActiveTradesTable, TradePosition } from "@/components/positions/ActiveTradesTable";
|
||||
import { TitanOrderTerminal } from "@/components/execution/TitanOrderTerminal";
|
||||
import { SecurityGate } from "@/components/auth/SecurityGate";
|
||||
import { TradePosition } from "@/components/positions/ActiveTradesTable";
|
||||
import { useExnessWebSocket } from "@/hooks/useExnessWebSocket";
|
||||
import { KeyRound, ShieldAlert } from "lucide-react";
|
||||
import { KeyRound, Layers } from "lucide-react";
|
||||
import { soundFX } from "@/lib/soundEffects";
|
||||
|
||||
export default function QuantTerminalPage() {
|
||||
export default function TitanQuantTerminalPage() {
|
||||
const [isUnlocked, setIsUnlocked] = useState(false);
|
||||
const [authToken, setAuthToken] = useState("");
|
||||
const [apiBaseUrl, setApiBaseUrl] = useState("http://localhost:8085");
|
||||
const [activeSymbol, setActiveSymbol] = useState("XAUUSD");
|
||||
const [activeTimeframe, setActiveTimeframe] = useState("15m");
|
||||
const [candles, setCandles] = useState<any[]>([]);
|
||||
const [confluence, setConfluence] = useState<any>(null);
|
||||
@@ -20,13 +27,34 @@ export default function QuantTerminalPage() {
|
||||
const [showConnectModal, setShowConnectModal] = useState(false);
|
||||
|
||||
// Exness Credential Inputs
|
||||
const [exnessAccount, setExnessAccount] = useState("");
|
||||
const [exnessAccount, setExnessAccount] = useState("425437997");
|
||||
const [exnessPassword, setExnessPassword] = useState("");
|
||||
const [exnessServer, setExnessServer] = useState("Exness-MT5Trial");
|
||||
const [exnessServer, setExnessServer] = useState("Exness-MT5Real15");
|
||||
|
||||
// WebSocket Hook
|
||||
const { isConnected, packet, ping } = useExnessWebSocket("ws://localhost:8085/ws/stream");
|
||||
|
||||
// Check Existing Session & Auto-Lock on Inactivity
|
||||
useEffect(() => {
|
||||
const saved = sessionStorage.getItem("aura_trade_token");
|
||||
if (saved) {
|
||||
setAuthToken(saved);
|
||||
setIsUnlocked(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleUnlock = (token: string) => {
|
||||
soundFX.playUnlock();
|
||||
setAuthToken(token);
|
||||
setIsUnlocked(true);
|
||||
};
|
||||
|
||||
const handleLockTerminal = () => {
|
||||
sessionStorage.removeItem("aura_trade_token");
|
||||
setAuthToken("");
|
||||
setIsUnlocked(false);
|
||||
};
|
||||
|
||||
// Fetch Candles
|
||||
useEffect(() => {
|
||||
async function fetchCandles() {
|
||||
@@ -50,7 +78,7 @@ export default function QuantTerminalPage() {
|
||||
}
|
||||
}
|
||||
fetchCandles();
|
||||
}, [apiBaseUrl, activeTimeframe]);
|
||||
}, [apiBaseUrl, activeTimeframe, activeSymbol]);
|
||||
|
||||
// Fetch Confluence Analysis
|
||||
useEffect(() => {
|
||||
@@ -62,13 +90,18 @@ export default function QuantTerminalPage() {
|
||||
setConfluence(data);
|
||||
}
|
||||
} catch (err) {
|
||||
// Fallback initial state
|
||||
setConfluence({
|
||||
total_score: 90,
|
||||
is_qualifying: true,
|
||||
threshold: 85,
|
||||
direction: "BUY",
|
||||
breakdown: {},
|
||||
breakdown: {
|
||||
trend_4h: { score: 20, max: 25, reason: "Bullish above EMA 50/200" },
|
||||
asian_sweep: { score: 25, max: 25, reason: "Asian Low SSL Swept with Rejection" },
|
||||
fvg_15m: { score: 20, max: 20, reason: "15m Bullish FVG Retested at 2732.50" },
|
||||
mss_5m: { score: 15, max: 15, reason: "5m MSS Confirmed with Strong Displacement" },
|
||||
session: { score: 10, max: 15, reason: "London / NY Overlap Session Active" },
|
||||
},
|
||||
active_fvgs: [],
|
||||
});
|
||||
}
|
||||
@@ -83,12 +116,16 @@ export default function QuantTerminalPage() {
|
||||
try {
|
||||
const res = await fetch(`${apiBaseUrl}/api/v1/trade/execute`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${authToken}`
|
||||
},
|
||||
body: JSON.stringify(trade),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
alert(`✅ Order Executed Successfully! Ticket: #${data.ticket}`);
|
||||
soundFX.playOrderExecuted();
|
||||
alert(`✅ Order Executed Successfully on Exness MT5! Ticket: #${data.ticket}`);
|
||||
// Add to active positions
|
||||
setPositions((prev) => [
|
||||
...prev,
|
||||
@@ -105,21 +142,29 @@ export default function QuantTerminalPage() {
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
alert(`🚫 Order Blocked by Sentinel: ${data.detail?.reason || data.detail || "Risk Error"}`);
|
||||
soundFX.playEmergency();
|
||||
alert(`🚫 Order Blocked by Sentinel Risk Firewall: ${data.detail?.reason || data.detail || "Risk Invariant Tripped"}`);
|
||||
}
|
||||
} catch (err: any) {
|
||||
soundFX.playEmergency();
|
||||
alert(`Execution Error: ${err.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
// Emergency Panic Kill All
|
||||
const handleEmergencyKill = async () => {
|
||||
if (!confirm("🚨 ARE YOU SURE YOU WANT TO TERMINATE 100% OF ACTIVE POSITIONS INSTANTLY?")) {
|
||||
if (!confirm("🚨 ARE YOU SURE YOU WANT TO TERMINATE 100% OF ACTIVE POSITIONS ON EXNESS INSTANTLY?")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch(`${apiBaseUrl}/api/v1/trade/kill_all`, { method: "POST" });
|
||||
const res = await fetch(`${apiBaseUrl}/api/v1/trade/kill_all`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${authToken}`
|
||||
}
|
||||
});
|
||||
const data = await res.json();
|
||||
soundFX.playEmergency();
|
||||
alert(`Emergency Kill Executed: ${data.message || "All positions terminated."}`);
|
||||
setPositions([]);
|
||||
} catch (err: any) {
|
||||
@@ -141,9 +186,11 @@ export default function QuantTerminalPage() {
|
||||
}),
|
||||
});
|
||||
if (res.ok) {
|
||||
soundFX.playUnlock();
|
||||
alert("🟢 Exness Account Connected Successfully!");
|
||||
setShowConnectModal(false);
|
||||
} else {
|
||||
soundFX.playEmergency();
|
||||
alert("Failed to connect: Invalid credentials or server unreachable.");
|
||||
}
|
||||
} catch (err: any) {
|
||||
@@ -151,47 +198,79 @@ export default function QuantTerminalPage() {
|
||||
}
|
||||
};
|
||||
|
||||
if (!isUnlocked) {
|
||||
return <SecurityGate onUnlock={handleUnlock} apiBaseUrl={apiBaseUrl} />;
|
||||
}
|
||||
|
||||
const accountEquity = packet?.telemetry?.equity || 15.19;
|
||||
|
||||
return (
|
||||
<main className="flex flex-col min-h-screen bg-darkBg text-gray-100">
|
||||
{/* 1. Top Telemetry Bar */}
|
||||
<TelemetryBar
|
||||
<main className="flex flex-col min-h-screen bg-[#04080f] text-gray-100 select-none">
|
||||
{/* 1. Global Institutional Top HUD */}
|
||||
<TitanHeader
|
||||
telemetry={packet?.telemetry || null}
|
||||
ping={ping}
|
||||
isWsConnected={isConnected}
|
||||
circuitBreakerTripped={packet?.circuit_breaker.is_tripped || false}
|
||||
onEmergencyKill={handleEmergencyKill}
|
||||
onLockTerminal={handleLockTerminal}
|
||||
/>
|
||||
|
||||
{/* 2. Global Session & News Badge */}
|
||||
<SessionBadge
|
||||
newsQuarantineActive={packet?.news_quarantine.is_active || false}
|
||||
newsReason={packet?.news_quarantine.reason || ""}
|
||||
/>
|
||||
{/* 2. Main 3-Column Institutional Workspace */}
|
||||
<div className="flex-1 grid grid-cols-1 xl:grid-cols-12 gap-2.5 p-2.5">
|
||||
|
||||
{/* Left Column (3 cols on xl): Multi-Asset Radar & Macro Calendar */}
|
||||
<aside className="xl:col-span-3 flex flex-col gap-2.5">
|
||||
<div className="h-[300px]">
|
||||
<WatchlistRadar
|
||||
activeSymbol={activeSymbol}
|
||||
onSelectSymbol={(sym) => setActiveSymbol(sym)}
|
||||
liveGoldTick={packet?.tick || null}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1 min-h-[300px]">
|
||||
<EconomicCalendarDock
|
||||
isQuarantineActive={packet?.news_quarantine.is_active || false}
|
||||
quarantineReason={packet?.news_quarantine.reason || ""}
|
||||
/>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* 3. Main Workspace Grid */}
|
||||
<div className="flex-1 grid grid-cols-1 lg:grid-cols-12 gap-3 p-3">
|
||||
{/* Left Column: TradingView Chart Stage (8 cols) */}
|
||||
<section className="lg:col-span-8 flex flex-col gap-3">
|
||||
<div className="bg-darkCard border border-darkBorder rounded-lg p-2.5 flex items-center justify-between">
|
||||
{/* Center Stage (6 cols on xl): Dual-Pane Chart Stage & Cockpit Dock */}
|
||||
<section className="xl:col-span-6 flex flex-col gap-2.5">
|
||||
{/* Active Chart Navigation & Controls */}
|
||||
<div className="bg-[#070d18] border border-[#14233d] rounded-xl p-2.5 flex items-center justify-between shadow-lg">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="font-bold text-accentGold text-sm">XAUUSD.PRO</span>
|
||||
<span className="text-xs text-gray-400">Gold / US Dollar</span>
|
||||
<span className="font-extrabold text-amber-400 text-sm font-mono tracking-wider">
|
||||
{activeSymbol}.PRO
|
||||
</span>
|
||||
<span className="text-[11px] text-gray-400 font-mono hidden sm:inline">
|
||||
Institutional Exness Direct Feed
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<TimeframeSelector
|
||||
activeTimeframe={activeTimeframe}
|
||||
onSelect={(tf) => setActiveTimeframe(tf)}
|
||||
onSelect={(tf) => {
|
||||
soundFX.playClick();
|
||||
setActiveTimeframe(tf);
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
onClick={() => setShowConnectModal(true)}
|
||||
className="bg-darkBg hover:bg-darkBorder border border-darkBorder text-gray-300 text-xs px-2.5 py-1 rounded flex items-center gap-1.5 transition"
|
||||
onClick={() => {
|
||||
soundFX.playClick();
|
||||
setShowConnectModal(true);
|
||||
}}
|
||||
className="bg-[#0b172a] hover:bg-[#122240] border border-[#182e52] text-gray-300 text-xs px-2.5 py-1 rounded-md flex items-center gap-1.5 transition font-mono"
|
||||
>
|
||||
<KeyRound className="w-3.5 h-3.5 text-accentCyan" /> Connect Broker
|
||||
<KeyRound className="w-3.5 h-3.5 text-cyan-400" /> Connect MT5
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 bg-darkCard border border-darkBorder rounded-lg overflow-hidden min-h-[500px]">
|
||||
{/* 60 FPS TradingView Canvas */}
|
||||
<div className="flex-1 bg-[#070d18] border border-[#14233d] rounded-xl overflow-hidden min-h-[380px] shadow-xl">
|
||||
<TradingViewCanvas
|
||||
candles={candles}
|
||||
liveTick={packet?.tick || null}
|
||||
@@ -199,34 +278,49 @@ export default function QuantTerminalPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Active Trades Table */}
|
||||
<ActiveTradesTable
|
||||
{/* Lower 4-Tab Analytical Cockpit Dock */}
|
||||
<CockpitDock
|
||||
positions={positions}
|
||||
onClosePosition={(ticket) => setPositions((p) => p.filter((x) => x.ticket !== ticket))}
|
||||
onMoveToBreakeven={(ticket) => alert(`Moved Stop-Loss to Breakeven (+1 pip) for #${ticket}`)}
|
||||
onClosePosition={(ticket) => {
|
||||
soundFX.playClick();
|
||||
setPositions((p) => p.filter((x) => x.ticket !== ticket));
|
||||
}}
|
||||
onMoveToBreakeven={(ticket) => {
|
||||
soundFX.playClick();
|
||||
alert(`Moved Stop-Loss to Breakeven (+1 pip) for #${ticket}`);
|
||||
}}
|
||||
confluenceData={confluence}
|
||||
accountEquity={accountEquity}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{/* Right Column: Quant Execution & Confluence Desk (4 cols) */}
|
||||
<aside className="lg:col-span-4 flex flex-col gap-3">
|
||||
<ConfluenceMeter confluence={confluence} />
|
||||
<OrderDrawer
|
||||
liveTick={packet?.tick || null}
|
||||
telemetry={packet?.telemetry || null}
|
||||
onExecuteTrade={handleExecuteTrade}
|
||||
/>
|
||||
{/* Right Column (3 cols on xl): Quant War Room & Multi-Tier Execution */}
|
||||
<aside className="xl:col-span-3 flex flex-col gap-2.5">
|
||||
<div className="shrink-0">
|
||||
<ConfluenceMeter confluence={confluence} />
|
||||
</div>
|
||||
<div className="flex-1 min-h-[460px]">
|
||||
<TitanOrderTerminal
|
||||
symbol={activeSymbol}
|
||||
currentPrice={packet?.tick?.bid || 2735.40}
|
||||
confluenceScore={confluence?.total_score || 90}
|
||||
confluenceDirection={confluence?.direction || "BUY"}
|
||||
accountEquity={accountEquity}
|
||||
onExecuteTrade={handleExecuteTrade}
|
||||
/>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
{/* Connect Broker Modal */}
|
||||
{showConnectModal && (
|
||||
<div className="fixed inset-0 z-50 bg-black/80 backdrop-blur-sm flex items-center justify-center p-4">
|
||||
<div className="bg-darkCard border border-darkBorder rounded-xl max-w-md w-full p-5 shadow-2xl">
|
||||
<div className="bg-[#091222] border border-[#14233d] rounded-2xl max-w-md w-full p-6 shadow-2xl font-mono">
|
||||
<h2 className="text-sm font-bold text-gray-100 uppercase tracking-wider mb-1 flex items-center gap-2">
|
||||
<KeyRound className="w-4 h-4 text-accentCyan" /> Connect Exness MT5
|
||||
<KeyRound className="w-4 h-4 text-cyan-400" /> Link Exness MT5 Trade Server
|
||||
</h2>
|
||||
<p className="text-xs text-gray-400 mb-4">
|
||||
Connect via Master Trading Password or Read-Only Investor Password.
|
||||
Direct sub-second gateway authentication into MetaTrader 5 Server 15.
|
||||
</p>
|
||||
|
||||
<form onSubmit={handleConnectBroker} className="space-y-3 text-xs">
|
||||
@@ -235,10 +329,10 @@ export default function QuantTerminalPage() {
|
||||
<input
|
||||
type="number"
|
||||
required
|
||||
placeholder="e.g. 7192849"
|
||||
placeholder="425437997"
|
||||
value={exnessAccount}
|
||||
onChange={(e) => setExnessAccount(e.target.value)}
|
||||
className="w-full bg-darkBg border border-darkBorder rounded px-3 py-2 text-gray-100 focus:outline-none focus:border-accentCyan font-mono"
|
||||
className="w-full bg-[#050914] border border-[#14233d] rounded px-3 py-2 text-gray-100 focus:outline-none focus:border-cyan-400 font-mono"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -247,10 +341,10 @@ export default function QuantTerminalPage() {
|
||||
<input
|
||||
type="password"
|
||||
required
|
||||
placeholder="Exness Password"
|
||||
placeholder="Exness MT5 Password"
|
||||
value={exnessPassword}
|
||||
onChange={(e) => setExnessPassword(e.target.value)}
|
||||
className="w-full bg-darkBg border border-darkBorder rounded px-3 py-2 text-gray-100 focus:outline-none focus:border-accentCyan font-mono"
|
||||
className="w-full bg-[#050914] border border-[#14233d] rounded px-3 py-2 text-gray-100 focus:outline-none focus:border-cyan-400 font-mono"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -259,12 +353,11 @@ export default function QuantTerminalPage() {
|
||||
<select
|
||||
value={exnessServer}
|
||||
onChange={(e) => setExnessServer(e.target.value)}
|
||||
className="w-full bg-darkBg border border-darkBorder rounded px-3 py-2 text-gray-100 focus:outline-none focus:border-accentCyan font-mono"
|
||||
className="w-full bg-[#050914] border border-[#14233d] rounded px-3 py-2 text-gray-100 focus:outline-none focus:border-cyan-400 font-mono"
|
||||
>
|
||||
<option value="Exness-MT5Real15">Exness-MT5Real15 (Your Live Server)</option>
|
||||
<option value="Exness-MT5Real">Exness-MT5Real</option>
|
||||
<option value="Exness-MT5Trial">Exness-MT5Trial (Demo)</option>
|
||||
<option value="Exness-MT5Trial2">Exness-MT5Trial2 (Demo)</option>
|
||||
<option value="Exness-MT5Real">Exness-MT5Real (Live)</option>
|
||||
<option value="Exness-MT5Real2">Exness-MT5Real2 (Live)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -272,15 +365,15 @@ export default function QuantTerminalPage() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowConnectModal(false)}
|
||||
className="px-3 py-1.5 rounded bg-darkBg border border-darkBorder text-gray-400 hover:text-gray-200"
|
||||
className="px-3 py-1.5 rounded bg-[#070d18] border border-[#14233d] text-gray-400 hover:text-gray-200"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="px-4 py-1.5 rounded bg-accentCyan hover:bg-cyan-400 text-black font-bold shadow-md shadow-cyan-500/20"
|
||||
className="px-4 py-1.5 rounded bg-cyan-400 hover:bg-cyan-300 text-black font-bold shadow-md shadow-cyan-500/20"
|
||||
>
|
||||
Connect Session
|
||||
Connect MT5
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user