'use client'; import React, { useState, useEffect } from 'react'; import WhaleMathModal from './WhaleMathModal'; import { Compass, ArrowUpRight, ArrowDownRight, Minus, BookOpen, AlertCircle, RefreshCw, Layers, DollarSign, Calendar, TrendingUp } from 'lucide-react'; interface WhaleProfile { name: string; cik: string; aum: number; holdingsCount: number; topSector: string; filingDate: string; } interface PositionDelta { manager: string; symbol: string; name: string; currentWeight: number; prevWeight: number; vocDelta: number; shares: number; value: number; } export default function WhaleScreener() { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [profiles, setProfiles] = useState([]); const [positions, setPositions] = useState([]); const [isShieldActive, setIsShieldActive] = useState(false); const [isMathModalOpen, setIsMathModalOpen] = useState(false); const [refreshKey, setRefreshKey] = useState(0); useEffect(() => { const fetchWhaleData = async () => { setLoading(true); setError(null); try { const response = await fetch('/api/whale/screener'); if (response.ok) { const data = await response.json(); setProfiles(data.whales || []); setPositions(data.positions || []); setIsShieldActive(!!data.isShieldActive); } else { setError('Failed to fetch institutional whale screener data.'); } } catch (err) { console.error('Fetch whale data error:', err); setError('Network error loading Whale Satellite Screener data.'); } finally { setLoading(false); } }; fetchWhaleData(); }, [refreshKey]); if (loading) { return (
Extracting SEC Form 13F filing dates & holding logs...
); } if (error) { return (
{error}
); } return (
{/* ⚠️ Dynamic Rate-Limit Fallback Banner */} {isShieldActive && (
[🔒 Offline-Shield Active - Cached Archive Ingested] Iterative development protection is active (`DEV_MODE`). The system is rendering high-fidelity baseline 13F deltas to maintain zero outbound FMP API calls.
)} {/* HEADER PANEL */}
Whale Satellite-Screener

Whale Institutional Screener {isShieldActive ? ( DEV-ARCHIV AKTIV (0 CALLS) ) : ( LIVE-API ENDPUNKT (FMP CORPO) )}

Tracks smart money allocation pivots by analyzing quarterly CIK portfolio shifts. Calculates the conviction velocity of boutique value and small-cap managers.

{/* 2-COLUMN WORKSTATION LAYOUT */}
{/* LEFT COLUMN: WHALE PROFILE CARDS */}

Tracked Institutional Managers

{profiles.map((profile) => (

{profile.name}

CIK: {profile.cik}
Estimated AUM ${profile.aum >= 1e9 ? `${(profile.aum / 1e9).toFixed(2)}B` : `${(profile.aum / 1e6).toFixed(1)}M`}
Top Sector Focus {profile.topSector}
Holdings: {profile.holdingsCount} Filing: {profile.filingDate}
))}
{/* RIGHT COLUMN: HIGH-CONVICTION BUY/SELL TABLE */}

High-Conviction Portfolio Shifts

Position weights delta compared to prior 13F report

{positions.length} Positions
{positions.map((pos, idx) => { const isPositive = pos.vocDelta > 0; const isZero = pos.vocDelta === 0; const deltaColor = isPositive ? 'text-emerald-400 bg-emerald-500/10 border-emerald-500/25' : (isZero ? 'text-slate-400 bg-slate-900 border-slate-800' : 'text-rose-400 bg-rose-500/10 border-rose-500/25'); const deltaIcon = isPositive ? : (isZero ? : ); return ( ); })}
Manager Ticker Company Name Prev Weight Current Weight VoC Delta
{pos.manager.split(' (')[0]} {pos.symbol} {pos.name} {pos.prevWeight.toFixed(2)}% {pos.currentWeight.toFixed(2)}% {deltaIcon} {isPositive ? '+' : ''}{pos.vocDelta.toFixed(2)}%
setIsMathModalOpen(false)} />
); }