import json, math, datetime, csv, xml.etree.ElementTree as ET from pathlib import Path p = Path(__file__).resolve().parent x=json.load(open(p/'yahoo-iren.json'))['chart']['result'][0]; q=x['indicators']['quote'][0] rows=[dict(date=str(datetime.datetime.fromtimestamp(t,datetime.UTC).date()),**{k:q[k][i] for k in ('open','high','low','close','volume')}) for i,t in enumerate(x['timestamp']) if all(q[k][i] is not None for k in ('high','low','close','volume'))][-60:] price=rows[-1]['close']; edges=list(range(16,74,2)); raw=[0.]*(len(edges)-1); recent=raw.copy() for age,r in enumerate(reversed(rows)): lo,hi=r['low'],r['high']; assert hi>=lo and r['volume']>=0 for j,(a,b) in enumerate(zip(edges,edges[1:])): share=max(0,min(hi,b)-max(lo,a))/(hi-lo) if hi>lo else float(a<=loprice],key=lambda z:-z[1])[:5]} json.dump(s,open(p/'summary.json','w'),indent=2) W,H=1000,730 parts=[f'','','','IREN | Where did recent trading concentrate?',f'{rows[0]["date"]} to {rows[-1]["date"]} · 60 sessions · latest close ${price:.2f}'] # Two independently scaled percentage distributions, same price scale. for cx,values,title,color in [(95,raw,'Historical volume share','#557a9b'),(550,recent,'Recent-weighted share (20-session half-life)','#ac7258')]: total=sum(values);maxpct=max(values)/total*100 parts.append(f'{title}') for j,(a,b,v) in enumerate(zip(edges,edges[1:],values)): y=125+j*17; width=v/total*100/25*310 parts.append(f'{a}–{b}{v/total*100:.1f}%') for tick in [0,5,10,15,20,25]: xx=cx+tick/25*310 parts.append(f'{tick}%') parts+=['Price bands: USD 2. Each daily volume is distributed uniformly between that day’s low and high.','Repeated turnover is counted. Percentages describe traded volume, not shareholders or selling probability.','Source: Yahoo Finance daily OHLCV. Time decay is an illustrative assumption, not a holdings estimate.',''] (p/'iren-profile.svg').write_text('\n'.join(parts));ET.parse(p/'iren-profile.svg') print(json.dumps(s));print('Checks passed: 60 valid sessions; volume conserved; SVG parses. No build or compilation run.')