import React, { useMemo } from 'react'; import { motion } from 'framer-motion'; const buildPath = (points, width, height) => { if (!points.length) { return ''; } const prices = points.map((point) => point.price); const min = Math.min(...prices); const max = Math.max(...prices); const range = max - min || 1; return points .map((point, index) => { const x = (index / Math.max(points.length - 1, 1)) * width; const y = height - ((point.price - min) / range) * height; return `${index === 0 ? 'M' : 'L'} ${x.toFixed(2)} ${y.toFixed(2)}`; }) .join(' '); }; export const MarketPanel = ({ chart, history, trade, engine, lastPriceDelta }) => { const path = useMemo(() => buildPath(history || [], 250, 90), [history]); const priceTone = lastPriceDelta < 0 ? '#d95d5d' : '#52b788'; return (
Live Execution

Market tape

{engine?.policy_active ? 'SLM live' : 'Fallback'}
Price {lastPriceDelta >= 0 ? '+' : ''} {lastPriceDelta.toFixed(2)}
${chart?.price?.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
Last side
{trade?.side || 'HOLD'}
Notional
${trade?.notional?.toLocaleString(undefined, { maximumFractionDigits: 0 })}
Decision reason
{trade?.reason || 'Waiting for the desk to move.'}
); };