import React,{useState,useEffect,useRef,useMemo} from 'react';
import {Zap,Activity,BarChart3,ReceiptText,Network,FileJson,ArrowUpRight,Upload,ArrowRight,Play,CheckCircle2,AlertCircle,Download,RefreshCw,ChevronRight,Info} from 'lucide-react';
import Papa from 'papaparse';
import AnalysisPanel,{AuditDatasets} from './AnalysisPanel.jsx';
import LiveWorkspace from './LiveWorkspace.jsx';
import EnergyIntro from './EnergyIntro.jsx';
import ChallengePanel from './ChallengePanel.jsx';
import './live.css';
const markets={PT:{name:'Portugal',scope:'Mainland grid',currency:'EUR',region:'PT-mainland',flag:'🇵🇹'},DE:{name:'Germany',scope:'National grid load',currency:'EUR',region:'DE-local-grid',flag:'🇩🇪'},AU:{name:'Australia',scope:'NEM · five regions',currency:'AUD',region:'NSW1',flag:'🇦🇺'}};
const nav=[['live','Analyze now',Zap],['atlas','Grid Atlas',Activity],['quotes','Quote explorer',Zap],['bills','Your bill profile',ReceiptText],['analysis','Import bills & swaps',Network],['benchmark','Forecast lab',Activity],['challenge','LLM challenge',BarChart3],['models','Model evidence',BarChart3],['sources','Official feeds',Network],['api','API & methods',FileJson]];
async function request(path,payload){let r=await fetch(path,{signal:AbortSignal.timeout(path==='/api/benchmark'?240000:120000),method:payload===undefined?'GET':'POST',headers:payload===undefined?{}:{'Content-Type':'application/json'},body:payload===undefined?undefined:JSON.stringify(payload)});if(!r.headers.get('content-type')?.includes('application/json'))throw Error(`Service returned HTTP ${r.status} instead of JSON. Retry the connection.`);let data=await r.json();if(!r.ok)throw Error(data.detail||'Request failed');return data;}
const num=(n,d=0)=>Number(n).toLocaleString(undefined,{maximumFractionDigits:d});
function Json({value}){return
{JSON.stringify(value,null,2)} }
function Notice({children}){return }
function Table({rows,columns}){if(!rows?.length)return No records to show yet.
;return {columns.map(([key,label])=>{label} )} {rows.map((row,i)=>{columns.map(([key])=>{typeof row[key]==='number'?num(row[key],2):typeof row[key]==='boolean'?(row[key]?'Yes':'—'):String(row[key]??'—')} )} )}
}
function Chart({series,unit='GWh',labels=[]}){let arrays=series.filter(s=>s.values?.length);let all=arrays.flatMap(s=>s.values);if(!all.length)return null;let lo=Math.min(...all),hi=Math.max(...all);let pad=(hi-lo)*.15||1;lo-=pad;hi+=pad;const w=780,h=220,left=55,right=18,top=12,bottom=36;const xy=(v,i,n)=>[left+i*(w-left-right)/Math.max(n-1,1),h-bottom-(v-lo)/(hi-lo)*(h-top-bottom)];return {[0,1,2,3].map(i=>{let y=top+i*(h-top-bottom)/3;return {num(hi-i*(hi-lo)/3)} })}{arrays.map((s,k)=>{let pts=s.values.map((v,i)=>xy(v,i,s.values.length).join(',')).join(' ');return {k===0&&arrays.length===1&& } })}{[0,Math.floor(labels.length/2),labels.length-1].filter((x,i,a)=>x>=0&&a.indexOf(x)===i).map(i=>{String(labels[i]||'').slice(0,7)} )}{arrays.map(s=>{s.name} )}{unit}
}
function CsvUpload({label,onData,onError,help}){return {label} {help||'CSV · maximum 2 MB'} {let f=e.target.files[0];if(!f)return;if(f.size>2000000){onError('CSV limit is 2 MB.');return;}Papa.parse(f,{header:true,skipEmptyLines:true,complete:r=>{if(r.errors.length){onError(r.errors[0].message);return;}onData(r.data);},error:e=>onError(e.message)});e.target.value='';}}/> }
function Field({label,children}){return {label} {children} }
function download(value,name){let url=URL.createObjectURL(new Blob([JSON.stringify(value,null,2)],{type:'application/json'}));let a=document.createElement('a');a.href=url;a.download=name;a.click();URL.revokeObjectURL(url);}
const atlasMonthLabels = Array.from({length: 12}, (_, month) =>
new Intl.DateTimeFormat('en', {month: 'short', timeZone: 'UTC'}).format(Date.UTC(2024, month))
);
const gridDemandStops = [
[69, 184, 126],
[240, 211, 94],
[248, 160, 76],
[231, 98, 91]
];
function gridDemandColor(fraction) {
const position = Math.max(0, Math.min(1, fraction)) * (gridDemandStops.length - 1);
const lower = Math.floor(position);
const mix = position - lower;
const start = gridDemandStops[lower];
const end = gridDemandStops[Math.ceil(position)];
return `rgb(${start.map((value, index) => Math.round(value + (end[index] - value) * mix)).join(', ')})`;
}
function AtlasWheel({points, selection, onSelect, low, high}) {
const canvas = useRef(null);
const hitTargets = useRef([]);
const drag = useRef(null);
const [angle, setAngle] = useState(-0.52);
useEffect(() => {
const element = canvas.current;
function draw() {
const width = element.clientWidth;
const height = element.clientHeight;
if (!width || !height) return;
const scale = window.devicePixelRatio || 1;
element.width = Math.round(width * scale);
element.height = Math.round(height * scale);
const ctx = element.getContext('2d');
ctx.scale(scale, scale);
const radius = Math.min(width * .31, height * .40);
const firstYear = points[0].year;
const lastYear = points.at(-1).year;
const vertical = height * .52;
function project(month, year, factor) {
const phase = angle + month * Math.PI / 6;
const depth = Math.sin(phase) * radius * factor;
const level = (year - firstYear) / Math.max(lastYear - firstYear, 1);
return {
x: width / 2 + Math.cos(phase) * radius * factor,
y: height * .76 - (lastYear === firstYear ? .5 : level) * vertical + depth * .40,
depth
};
}
function line(nodes, color, weight = 1) {
ctx.beginPath();
nodes.forEach((p, index) => index ? ctx.lineTo(p.x, p.y) : ctx.moveTo(p.x, p.y));
ctx.strokeStyle = color;
ctx.lineWidth = weight;
ctx.stroke();
}
const yearStep = Math.max(1, Math.ceil((lastYear - firstYear) / 7));
for (let year = firstYear; year <= lastYear; year += yearStep) {
const ring = Array.from({length: 73}, (_, index) => project(index / 6, year, 1.08));
line(ring, '#b5ced23b');
ctx.font = '11px system-ui';
ctx.fillStyle = '#b9cbd0';
ctx.fillText(year, Math.min(width - 33, width / 2 + radius * 1.12), ring[0].y);
}
for (let month = 0; month < 12; month += 3) {
const start = project(month, firstYear, 1.08);
const end = project(month, lastYear, 1.08);
line([start, end], '#b5ced23b');
ctx.font = '11px system-ui';
ctx.fillStyle = '#b9cbd0';
ctx.fillText(atlasMonthLabels[month], start.x - 9, start.y + 20 + (lastYear === firstYear ? 4 : 0));
}
const nodes = points.map(point => {
const fraction = (point.value - low) / (high - low || 1);
return {...project(point.month, point.year, .31 + .69 * fraction), point, fraction};
});
for (let i = 1; i < nodes.length; i++) {
const before = nodes[i - 1];
const after = nodes[i];
if (after.point.index - before.point.index === 1) line([before, after], '#90b7ba78', 1.6);
}
hitTargets.current = [...nodes].sort((a, b) => a.depth - b.depth);
for (const node of hitTargets.current) {
const active = node.point.key === selection;
ctx.beginPath();
ctx.arc(node.x, node.y, active ? 8 : 3.4 + node.fraction * 1.2, 0, Math.PI * 2);
ctx.fillStyle = gridDemandColor(node.fraction);
ctx.fill();
if (active) {
ctx.strokeStyle = '#ffffff';
ctx.lineWidth = 2.5;
ctx.stroke();
}
}
}
const observer = new ResizeObserver(draw);
observer.observe(element);
draw();
return () => observer.disconnect();
}, [points, selection, angle, low, high]);
function endDrag(event) {
const start = drag.current;
drag.current = null;
if (!start || start.moved) return;
const bounds = event.currentTarget.getBoundingClientRect();
const x = event.clientX - bounds.left;
const y = event.clientY - bounds.top;
const nearest = hitTargets.current.reduce((best, point) => {
const distance = Math.hypot(point.x - x, point.y - y);
return distance <= best.distance ? {distance, point} : best;
}, {distance: 16});
if (nearest.point) onSelect(nearest.point.point.key);
}
return
{
drag.current = {x: event.clientX, angle, moved: false};
event.currentTarget.setPointerCapture(event.pointerId);
}}
onPointerMove={event => {
if (!drag.current) return;
const delta = event.clientX - drag.current.x;
drag.current.moved ||= Math.abs(delta) > 5;
if (drag.current.moved) setAngle(drag.current.angle + delta / 115);
}}
onPointerUp={endDrag} onPointerCancel={() => {drag.current = null;}} />
setAngle(value => value - .45)}>←
setAngle(-.52)}>Reset view
setAngle(value => value + .45)}>→
;
}
function GridAtlas({history, market, source, loaded}) {
const [mode, setMode] = useState('wheel');
const [windowSize, setWindowSize] = useState('5');
const [selectedKey, setSelectedKey] = useState(null);
const all = useMemo(() => {
const unique = new Map();
for (const row of history) {
const stamp = typeof row.timestamp === 'string' ? row.timestamp : '';
const match = /^(\d{4})-(0[1-9]|1[0-2])/.exec(stamp || '');
if (!match || row.value == null || !Number.isFinite(Number(row.value))) continue;
const year = Number(match[1]);
const month = Number(match[2]) - 1;
const key = match[0];
unique.set(key, {year, month, key, index: year * 12 + month, value: Number(row.value), coverage: row.coverage});
}
return [...unique.values()].sort((a, b) => a.index - b.index);
}, [history]);
const latest = all.at(-1);
const points = useMemo(() => {
if (!latest || windowSize === 'all') return all;
return all.filter(point => point.year > latest.year - Number(windowSize));
}, [all, latest, windowSize]);
if (!latest) return {loaded ? 'No published monthly grid data for this market.' : 'Loading the published grid snapshot…'}
;
const selected = points.find(point => point.key === selectedKey) || latest;
const previous = all.find(point => point.index === selected.index - 12);
const delta = previous?.value ? (selected.value - previous.value) / previous.value * 100 : null;
const low = Math.min(...points.map(point => point.value));
const high = Math.max(...points.map(point => point.value));
const years = [...new Set(points.map(point => point.year))].reverse();
const byDate = new Map(points.map(point => [point.year * 12 + point.month, point]));
const position = points.indexOf(selected);
const publisher = source?.publisher || 'Published';
return
{publisher} grid history
Grid Atlas {market.scope} · {points[0].key} to {latest.key}
setMode('wheel')}>Seasonal orbit
setMode('calendar')}>Calendar
{mode === 'wheel' ?
:
Year {atlasMonthLabels.map(label => {label} )}
{years.map(year =>
{year}
{atlasMonthLabels.map((label, month) => {
const point = byDate.get(year * 12 + month);
const amount = point ? (point.value - low) / (high - low || 1) : 0;
return point ? setSelectedKey(point.key)} /> :
— ;
})}
)}
}
{mode === 'wheel' ? 'One turn per year. Distance from the centre shows demand. Drag to rotate.' : 'Select a month to inspect demand. A dash marks a gap in the record.'}
{num(low)}
gridDemandColor(index / (gridDemandStops.length - 1))).join(', ')})`}} />
{num(high)} GWh
History range setWindowSize(event.target.value)}>
Last 3 calendar years Last 5 calendar years All available years
{atlasMonthLabels[selected.month]} {selected.year}
{num(selected.value, 1)} GWh
{Number.isFinite(selected.coverage)&&selected.coverage<1&&
{num(selected.coverage*100,1)}% source coverage
}
{delta === null ? 'Same month last year unavailable' : `${delta > 0 ? '+' : ''}${num(delta, 1)}% vs the same month last year`}
Month setSelectedKey(points[Number(event.target.value)].key)} />
{source?.link&&
Open {publisher} source ↗ }
;
}
const gridAtlasStyles = `
.grid-atlas{color:#1b2e37}
.atlas-heading,.atlas-modes,.atlas-camera,.atlas-scale{display:flex;align-items:center;gap:8px}
.atlas-heading{justify-content:space-between;flex-wrap:wrap;margin-bottom:18px}
.atlas-heading h2{font-size:clamp(23px,3.6vw,33px);letter-spacing:-.045em;margin:0;line-height:1.08}
.atlas-heading p{margin:6px 0 0;color:#52666a;font-size:12px}
.atlas-heading .atlas-kicker{color:#306f5e;font-size:10px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;margin:0 0 6px}
.atlas-modes{padding:4px;gap:3px;border-radius:9px;background:#e9efec}
.atlas-modes button,.atlas-camera button{border-radius:6px;padding:7px 11px;cursor:pointer;font-size:11px;font-weight:700}
.atlas-modes button{color:#526761;background:transparent}
.atlas-modes button[aria-pressed=true]{background:#fff;color:#234d3d;box-shadow:0 2px 6px #18332b14}
.atlas-modes button:hover{color:#1b4f41}
.atlas-body{display:grid;grid-template-columns:minmax(0,1fr) minmax(175px,.36fr);gap:16px}
.atlas-visual{min-width:0}
.atlas-wheel{overflow:hidden;position:relative;border-radius:10px;background:radial-gradient(ellipse at 47% 43%,#203947,#13212e 78%);border:1px solid #233746}
.atlas-wheel canvas{display:block;width:100%;height:clamp(285px,43vw,430px);touch-action:pan-y;cursor:grab}
.atlas-wheel canvas:active{cursor:grabbing}
.atlas-camera{position:absolute;bottom:10px;left:50%;transform:translateX(-50%);white-space:nowrap}
.atlas-camera button{background:#1f3540;color:#e3eeef;border:1px solid #55717a}
.atlas-camera button:hover{background:#2c4b52}
.atlas-detail{display:grid;align-content:start;gap:17px;background:#f5f8f7;border:1px solid #e2e9e6;border-radius:10px;padding:15px}
.atlas-detail label{display:grid;gap:6px;font-size:12px;font-weight:700;color:#3b5651}
.atlas-detail select{width:100%;border-radius:7px;padding:7px;background:#fff;color:#1b2e37;border:1px solid #ccdad5}
.atlas-detail input{width:100%;min-width:0;accent-color:#238b70}
.atlas-detail a{font-size:12px;font-weight:700;color:#176653;text-underline-offset:3px}
.atlas-readout span,.atlas-readout p{font-size:12px;color:#52666a;margin:4px 0}
.atlas-readout strong{display:block;font-size:clamp(25px,4vw,38px);letter-spacing:-.05em;line-height:1.15;overflow-wrap:anywhere}
.atlas-readout small{font-size:13px;letter-spacing:0}
.atlas-scale{justify-content:space-between;flex-wrap:wrap;color:#52666a;font-size:12px;margin:8px 0 0}
.atlas-scale p{margin:0}
.atlas-demand-key{display:flex;align-items:center;gap:6px;white-space:nowrap;font-variant-numeric:tabular-nums}
.atlas-demand-ramp{display:block;width:clamp(66px,10vw,108px);height:7px;border-radius:99px}
.atlas-calendar{overflow:auto;max-height:430px;border:1px solid #e2e9e6;border-radius:10px;padding:10px;background:#f5f8f7}
.atlas-calendar-row{min-width:430px;display:grid;grid-template-columns:45px repeat(12,minmax(25px,1fr));gap:4px;align-items:center;text-align:center;color:#42595a;font-size:10px;padding:3px 0}
.atlas-calendar-row button,.atlas-gap{height:23px;border:1px solid transparent;border-radius:4px}
.atlas-calendar-row button{cursor:pointer}
.atlas-calendar-row button[aria-pressed=true]{border:2px solid #13212e;box-shadow:inset 0 0 0 1px #fff}
.grid-atlas button:focus-visible,.grid-atlas select:focus-visible,.grid-atlas input:focus-visible,.grid-atlas a:focus-visible{outline:2px solid #1b7d65;outline-offset:2px}
.atlas-camera button:focus-visible{outline-color:#d9efea}
@media(max-width:820px){.atlas-body{grid-template-columns:minmax(0,1fr)}}
`;
export default function App(){
const [boot,setBoot]=useState(null),[country,setCountry]=useState('PT'),[tab,setTab]=useState(()=>nav.find(([id])=>window.location.hash==='#'+id)?.[0]||'live'),[error,setError]=useState(''),[busy,setBusy]=useState(false);
const [usage,setUsage]=useState(''),[bill,setBill]=useState(''),[region,setRegion]=useState('PT-mainland'),[meter,setMeter]=useState('standard'),[peak,setPeak]=useState(.5),[powerKva,setPowerKva]=useState(''),[profileSource,setProfileSource]=useState('annual_user_input'),[demo,setDemo]=useState(false),[quotes,setQuotes]=useState(null),[bills,setBills]=useState(null),[accepted,setAccepted]=useState(''),[comparison,setComparison]=useState(null);
const [kind,setKind]=useState('demand'),[monthly,setMonthly]=useState(null),[provider,setProvider]=useState(''),[bench,setBench]=useState(null),[evidence,setEvidence]=useState(null);
const [runtime,setRuntime]=useState(null),[runtimeError,setRuntimeError]=useState(''),[liveBusy,setLiveBusy]=useState(false);
const analysisStartRef=useRef(null);
const focusAnalysis=()=>requestAnimationFrame(()=>{analysisStartRef.current?.focus({preventScroll:true});analysisStartRef.current?.scrollIntoView({behavior:window.matchMedia('(prefers-reduced-motion: reduce)').matches?'auto':'smooth',block:'start'});});
const [month,setMonth]=useState(''),[nemRegion,setNemRegion]=useState('NSW1'),[live,setLive]=useState(null),[brand,setBrand]=useState('agl'),[postcode,setPostcode]=useState(''),[plans,setPlans]=useState(null),[planId,setPlanId]=useState(''),[plan,setPlan]=useState(null);
const [jsonInput,setJsonInput]=useState(''),[apiType,setApiType]=useState('consumer_compare'),[apiOutput,setApiOutput]=useState(null);
useEffect(()=>{let cancelled=false;request('/api/runtime').then(d=>{if(!cancelled){setRuntime(d);setMonth(d.latest_complete_month||d.latest_month||'')}}).catch(e=>{if(!cancelled)setRuntimeError(e.message)});return()=>{cancelled=true}},[]);
useEffect(()=>{if(tab==='live'||boot)return;let cancelled=false;request('/api/bootstrap').then(d=>{if(!cancelled){setBoot(d);setMonth(d.latest_month)}}).catch(e=>{if(!cancelled)setError(e.message)});return()=>{cancelled=true}},[tab,boot]);
useEffect(()=>{if(tab!=='models')return;setEvidence(null);let cancel=false;request('/api/model_evidence',{country}).then(d=>{if(!cancel)setEvidence(d)}).catch(e=>setError(e.message));return()=>{cancel=true}},[country,tab]);
const market=markets[country];const history=boot?.histories[country]||[];
const payload=()=>{let p={country,region,profile_source:profileSource,meter_type:meter,peak_share:Number(peak),allow_illustrative:demo,offers:quotes||(demo?boot.example_quotes.filter(q=>q.country===country):[]),accepted_conditions:accepted.split(',').map(x=>x.trim()).filter(Boolean)};if(powerKva)p.contracted_power_kva=Number(powerKva);if(bills){p.billing_months=bills;if(bills.every(x=>'peak_kwh'in x))delete p.peak_share;}else{p.annual_kwh=Number(usage);p.current_annual_bill=Number(bill)}return p};
const run=async(fn)=>{setError('');setBusy(true);try{await fn()}catch(e){setError(e.message)}finally{setBusy(false)}};
const changeMarket=c=>{if(liveBusy)return;setCountry(c);setRegion(markets[c].region);setComparison(null);setBench(null);setBills(null);setPowerKva('');setProfileSource('annual_user_input');setQuotes(null);setLive(null);setError('')};
const best=comparison?.ranked_offers?.[0];
let billingUsage=bills?bills.reduce((s,r)=>s+Number(r.kwh||0),0):Number(usage);let billingTotal=bills?bills.reduce((s,r)=>s+Number(r.billed_total||0),0):Number(bill);
return
ELECTRICITY, WITH THE EVIDENCE ATTACHED
{tab==='live'?'Your data. A fresh analysis.':tab==='atlas'?'Explore grid demand.':tab==='quotes'?'More clarity. Less bill shock.':tab==='bills'?'Your year, in kilowatt-hours.':tab==='analysis'?'From billing archive to scenario.':tab==='benchmark'?'Challenge the forecast.':tab==='challenge'?'Put our model to the test.':tab==='models'?'Every model earns its place.':tab==='sources'?'Go straight to the source.':'The engine behind XenoWAttz.'} {tab==='live'?'Run a forecast, compare supplied offers, and check the market when you need it.':tab==='atlas'?'Follow seasonal demand through the published monthly series for Portugal, Germany and Australia.':tab==='quotes'?'Compare the offers you can actually use, with every supplied cost included.':tab==='bills'?'A complete bill profile makes a better starting point than a national average.':tab==='analysis'?'Import compressed bills, inspect tariffs, and compare constrained provider plans.':tab==='benchmark'?'Chronological calibration, validation and test. Complexity gets no free pass.':tab==='challenge'?'Portable prompts, matched predictions and fine-tuning files.':tab==='models'?'TSF, transformers and Astra — inspect the versions and the measured evidence.':tab==='sources'?'Published demand, wholesale prices and Australian retailer plan data.':'React on the surface. Reproducible Python underneath.'}
{Object.entries(markets).map(([c,m])=>changeMarket(c)}>{m.flag} {c} )}
{error&&
}
{tab!=='live'&&tab!=='atlas'&&
SELECTED MARKET {market.name}{market.flag} {market.scope}
YOUR CONSUMPTION SCENARIO {bills||usage!==''?num(billingUsage):'—'}kWh / year {bills?'From uploaded monthly bills':profileSource==='annual_user_input'?(usage!==''?'From your annual input':'Enter your consumption'):'Reviewed annualized invoice estimate'}
YOUR CURRENT BILL {bills||bill!==''?num(billingTotal,2):'—'}{market.currency} / year {bills?`${bills.length} supplied monthly records`:bill!==''?'Full electricity cost, tax included':'Enter your electricity cost'}
}
setTab('analysis')}/>
{tab!=='live'&&!boot&&
Loading this workspace {error||'Retrieving the archive and source registry…'}
{error&&{setError('');request('/api/bootstrap').then(setBoot).catch(e=>setError(e.message))}}>Retry }}
{boot&&<>
{setCountry(p.country);setRegion(p.region);setUsage(p.annual_kwh);setBill(p.current_annual_bill);setMeter(p.meter_type);setPowerKva(p.contracted_power_kva??'');setProfileSource(p.profile_source);setBills(null);setComparison(null);setTab('quotes')}}/>
{tab==='quotes'&&<>
ARCHIVED MARKET CONTEXT
{market.name} · grid demand {country==='PT'?'REN':country==='DE'?'SMARD':'AEMO'} x.value)}]} labels={history.map(x=>x.timestamp)}/>{history.length} archived monthly records · {String(history[0]?.timestamp||'').slice(0,7)}–{String(history.at(-1)?.timestamp||'').slice(0,7)}GWh
Grid demand provides context. It does not describe an individual retailer or predict your bill.
The whole quoted cost. Energy + supply charges + annual fees + switching costs − guaranteed credits.
Tax included Eligibility checked Dated evidence
{comparison&&
{demo?'ILLUSTRATIVE SCENARIO':'SUPPLIED QUOTE SCENARIO'}
{best?`${best.provider} · lowest supplied first-year cost`:'No eligible quotes'} {best&&
{num(best.first_year_cost,2)} {market.currency} }
{best&&Estimated difference from your supplied annual bill: {num(best.estimated_saving,2)} {market.currency} . {best.price_basis}.
}{comparison.excluded_offers.length>0&&Excluded quotes and reasons ({comparison.excluded_offers.length}) }Calculation evidence }Quotes must be complete and tax inclusive. The comparison covers eligible supplied offers; it is not a whole-market promise. Complex indexed, tiered, demand-charge or export tariffs need a complete scoped quote. >}
{tab==='bills'&&<>A complete latest-year profile Twelve complete months before the current month.
setTab('analysis')}>Import ZIP / PDF billing archives {setBills(d);setComparison(null);setError('')}} onError={setError}/>Use actual tax-inclusive electricity charges, not bank-payment instalments. Remove names, addresses and account numbers. Each month must appear once, in the selected market currency. setTab('quotes')}>Compare using this profile {bills&&{setBills(null);setComparison(null)}}>Clear monthly profile } What your data can tell us 01 Consumption and current cost Your latest-year totals replace the manual annual fields.
02 Peak and off-peak allocation Supply peak_kwh for every month, or supply your measured peak share separately.
03 A starting scenario, not a model winner Twelve monthly bills cover only one annual cycle. The grid-model leaderboard cannot select a reliable household forecaster.
{bills&&Supplied monthly profile Number(x.kwh))}]} labels={bills.map(x=>x.month)} unit="kWh"/> }>}
{tab==='atlas'&&entry.market===market.name)} loaded={!!boot}/>}
{tab==='benchmark'&&<>The forecast laboratory Same series. Same origins. Validation chooses; test measures.
PROTOCOL V2 {setMonthly(d);setBench(null)}} onError={setError}/>{monthly&&{setMonthly(null);setBench(null)}}>Use bundled grid snapshot instead }1. Training prefix2. Calibration3. Validation4. Testrun(async()=>setBench(await request('/api/benchmark',{country,kind,records:monthly,provider})))}>{busy?:}Run CPU benchmark Seasonal baselines · SARIMA · Grokked · SARIMAX · GARCH {!bench&&
Published historical context {market.scope} {kind==='demand'?x.value)}]} labels={history.map(x=>x.timestamp)}/>:Wholesale history is not bundled. Upload a complete monthly price series to run a pricing benchmark.
} }{bench&&VALIDATION-SELECTED
{bench.selected_model} {bench.series_scope} · held-out test starts {bench.test_start}
download(bench,'electrocheap-benchmark.json')}>Evidence JSON p.split==='test'&&p.model==='Seasonal naive').map(p=>p.timestamp)} series={[{name:'Actual',values:bench.predictions.filter(p=>p.split==='test'&&p.model==='Seasonal naive').map(p=>p.actual),color:'#243344'},{name:bench.selected_model,values:bench.predictions.filter(p=>p.split==='test'&&p.model===bench.selected_model).map(p=>p.forecast),color:'#18a184'},{name:'Seasonal naive',values:bench.predictions.filter(p=>p.split==='test'&&p.model==='Seasonal naive').map(p=>p.forecast),color:'#e59b39',dashed:true}]}/>s.split==='test')} columns={[["model","Model"],["MAE","MAE"],["RMSE","RMSE"],["MASE","MASE"],["selected_on_validation","Selected"]]}/>Residual GARCH volatility and protocol }At least 72 consecutive complete months. No interpolation. Bias is frozen after calibration; a candidate needs 5% better validation MAE to replace the baseline. GARCH estimates residual volatility and keeps the SARIMAX mean unchanged. Tests are retrospective and descriptive. >}
{tab==='challenge'&&}
{tab==='models'&&<>The full recorded model family Archived grid-demand evidence · 24 test targets · six-month forecasts
2026-10-09 ARCHIVE LIVE CPU CANDIDATES
Statistical & Grokked Seasonal baselines, SARIMA, the explicit 80/20 Grokked blend, calendar SARIMAX and residual GARCH.
Runnable in Forecast lab PINNED TRANSFORMERS
TimesFM 2.5 · Chronos-2 Exact checkpoint revisions and Python package versions preserved from the measured archived runs.
Cached measured evidence HOSTED MODEL DIAGNOSTICS
Astra · Sol Archived delegated test diagnostics. No separately authenticated customer inference API is configured.
Diagnostic only A separate Super Grokked implementation and the original KMLAIOps SARIMAX-GARCHX source are unavailable. Newly written adapters are not presented under those identities. Grid scores do not establish household accuracy or bill savings. Inspect exact versions, source commits and availability >}
{tab==='sources'&&<>{live&&Fetched market data [k,k])}/>Showing up to 100 of {live.records.length} source records.
Source, retrieval time and completeness download(live,'electrocheap-live-feed.json')}>Download full response }{plans&&Published retailer plans [k,k])}/> setPlanId(e.target.value)} placeholder="Copy from the plan table"/>run(async()=>setPlan(await request('/api/aer_detail',{brand,plan_id:planId})))}>Inspect full plan
Plan list metadata {plan&&}}Source registry [k,k])}/>Australia covers the NEM, excluding WA and NT. Portugal is mainland only. German live data validates every hourly observation across the complete local month, including daylight-saving changes. Wholesale prices are not retail bills; national grids do not reveal retailer-level customer demand. >}
{tab==='api'&&<>live_analysisRun customer or NGO forecasts with dated market and news context.
market_newsRead SerpApi electricity news with source dates and cache metadata.
consumer_compareOne household or site. Annual totals or the latest 12 monthly bills.
ngo_compareUp to 100 anonymous profiles. Totals stay separate by currency.
model_evidenceArchived grid-demand scores and exact implementation versions.
setApiType(e.target.value)}>live_analysis market_news consumer_compare ngo_compare model_evidence {let p=payload();if(['model_evidence','market_news'].includes(apiType))p={country};if(apiType==='live_analysis')p={role:'customer',country,include_news:true,include_market:true,series:[],horizon_months:12,models:['seasonal_naive']};if(apiType==='ngo_compare')p={offers:p.offers,allow_illustrative:p.allow_illustrative,profiles:[{...p,profile_id:'anonymous-001'}]};setJsonInput(JSON.stringify(p,null,2))}}>Use current profile
run(async()=>setApiOutput(await request('/api/'+apiType,JSON.parse(jsonInput))))}>Run API request {apiOutput&&}MCP connection for XenoWAttz Keep the decision honest First-year quote cost = annual kWh × rate + 365 × daily charge + annual fees + switching cost − guaranteed credit. A two-period tariff uses the supplied peak/off-peak allocation. The quote must include taxes and all mandatory fees.
Unknown eligibility, incomplete tariff structures and stale quotes are excluded. Model selection is separate from tariff arithmetic. Forecast accuracy alone does not demonstrate financial savings.
This public research API has no customer billing, tenant isolation, contracting or automatic switching. Inputs are processed in memory. Do not submit personal identifiers. React uploads are parsed in your browser; the normalized data is sent to the API only when you run a request. >}
>}
Electrocheap · XenoWAttz × Bhor Bohr Evidence before savings. Always. ;
}