
    ̣%j(                       d Z ddlmZ ddlZddlmZ  ee      j                         j                  Z	e	dz  Z
e	dz  Ze	dz  Zg dZd	Zd
Zg dZddZddZddZddZddZddZddZddZddZddZedk(  r e        yy) zSDerive capacity_timeseries.csv and company_gw_chart.html from forecast_vintage.csv.    )annotationsN)Pathzforecast_vintage.csvzcapacity_timeseries.csvzcompany_gw_chart.html)	z
FY2024-FQ1z
FY2024-FQ2z
FY2024-FQ3
FY2024-FQ4z
FY2025-FQ1z
FY2025-FQ2z
FY2025-FQ3
FY2025-FQ4z
FY2026-FQ1r   FY2026companytickerfiscal_quarter	actual_gwlatest_forecast_gworiginal_forecast_gwunder_construction_gwcapex_actual_usd_bcapex_guidance_latest_usd_bcapex_guidance_original_usd_bcapex_actual_metriccapex_actual_is_derivedcaveatc                `    t        | dd       }t        | j                  d      d         }||fS )N      z-FQ   )intsplit)pfyfqs      m/home/dev/research_loop/runs/gw-forecast-production-001-loop06/artifacts/production/GOOGL/build_timeseries.py
period_keyr    .   s1    	QqVB	QWWU^A	B8O    c                     t         j                  d      5 } t        t        j                  |             cd d d        S # 1 sw Y   y xY w)Nutf-8encoding)VINTAGEopenlistcsv
DictReader)fs    r   load_vintager,   4   s8    	w	' '1CNN1%&' ' 's	   ?Ac                    g }| D ]:  }|d   dk(  s|d   t         k(  s|j                  |d   t        |d         f       < t        |d       S )Nmetric_namecapex_guidancetarget_periodas_of_period	raw_valuec                    t        | d         S )Nr   )r    )xs    r   <lambda>z#guidance_vintages.<locals>.<lambda>A   s    Z!%5 r!   )key)GUIDANCE_TARGETappendfloatsorted)rowsoutrows      r   guidance_vintagesr>   9   sc    #%C G"22O$7JJN+U3{3C-DEFG #566r!   c                    | t        |       k(  rt        t        |             S | dj                  d      j                  d      S )Nz.3f0.)r   strrstrip)values    r   	fmt_usd_brE   D   s<    E
3u:C[  %,,S11r!   c                h    t        |       }d}|D ]  \  }}t        |      |k  st        |      }! |S )N )r    rE   )quartervintagesqklatestperiodrD   s         r   guidance_as_ofrM   J   sB    	G	BF! &f#u%F& Mr!   c                b    t        |       t        t              k  ry|syt        |d   d         S )NrG   r   r   )r    GUIDANCE_ORIGIN_QUARTERrE   )rH   rI   s     r   original_guidance_as_ofrP   S   s1    'Z(?@@Xa[^$$r!   c                ,   |D ])  }|d   | k(  s|d   dk(  s|d   | k(  s|d   d|d   fc S  | dk(  r.|D ])  }|d   | k(  s|d   dk(  s|d   dk(  s|d   d	|d   fc S  | d
k(  r.|D ])  }|d   | k(  s|d   dk(  s|d   d
k(  s|d   d|d   fc S  y)Nr1   r.   capex_actualr0   r2   
is_derivedr   FY2024capex_actual_fyr   )rG   rG   rG    )rH   r;   r=   s      r   capex_actual_for_quarterrW   [   s	    G7*M"n4O$/{#^S5FFFG , 	NCN#w.&.8(H4;'):C<MMM	N , 	KCN#w.&.8(L8;'\9JJJ	K r!   c                    t        |       }dt         dt         d}g }t        D ]E  }t	        ||       \  }}}|j                  dd|dddd|t        ||      t        ||      |||d       G |S )NzAlphabet/Google Cloud does not disclose data-center MW/GW; GW columns blank. capex_*_usd_b are USD billions proxies from SEC/IR primary sources. FY2024-FQ4 capex_actual is full-year FY2024 (not quarterly-comparable). z# guidance vintages apply only from z onward.AlphabetGOOGLrG   r   )r>   r7   rO   QUARTERSrW   r8   rM   rP   )r;   guidancer   r<   rH   capexmetricderiveds           r   build_timeseriesr`   y   s     &H	S 
>?V>WW_	a  !#C 
!9'4!Hvw

%!")&((*)+&+/=gx/P1HRZ1['-+2 	

& Jr!   c                   | D cg c]  }|d   	 c}| D cg c]  }|d   rt        |d         nd  }}| D cg c]  }|d   rt        |d         nd  }}| D cg c]  }|d   rt        |d         nd  }}t        | |      D cg c]  \  }}|d   dk(  rd n| }}}t        d t        |       D        d       }d\  }}	}
|z
  |	z
  z
  |
z
  c||z   |z   D cg c]  }||	 }}|||   |j	                  ||          |rt        |      d	z  nd
dd;fdd<fdd=fd}d}|R||   M |       ||         }}d|dd|dz
  dd|dz   dd|dd|dd|dz   dd|dz
  dd|dd|dd|dz
  dd}g }dk  rdndk  rdnd}t        dt              dz   |      D ]O  } |      }|j	                  d d |dd!||	z
   d"|dd#	       |j	                  d$d%z
   d|d&z   dd'| d(       Q dj                  fd)t              D              }dj                  g d*| d+ d,| d d- d d. d+ d/dj                  |       d0d1z  z   d2dd3z
   d4d1z  z   d2d5 ||d6       d7 ||d8       d7 ||d9       d7| d7| d:      S c c}w c c}w c c}w c c}w c c}}w c c}w )>Nr   r   r   r   r   rU   c              3  8   K   | ]  \  }}|d    dk(  s|  yw)r   rU   NrV   ).0irs      r   	<genexpr>zsvg_chart.<locals>.<genexpr>   s"     Xtq!!,A*BFW*WXs   )i  i  F      rg   Z   g?   r   c                F    | t        t              dz
  d      z  z  z   S )Nr   )maxlen)rd   labelsmlpws    r   r4   zsvg_chart.<locals>.x   s'    QS[1_a00B666r!   c                ,    z   | z
  z
  z  z  z
  S )NrV   )vmtphymaxymins    r   yzsvg_chart.<locals>.y   s$    Bw1t8t4:::r!   c                    g }t        |       D ],  \  }}|	|j                   |      dd |      d       . t        |      dk  ryd| ddj                  |       dS )	N.1f,r   rG   z<polyline fill="none" stroke="z" stroke-width="2.5" points=" z"/>)	enumerater8   rm   join)valscolorptsrd   rr   r4   rw   s        r   polylinezsvg_chart.<locals>.polyline   s|    dO 	5DAq}

ad3Zq1c
34	5 s8a</w6STWT\T\]`TaSbbeffr!   rG   z<polygon points="ry   rz   r   r{      z=" fill="#1d4ed8" stroke="#1e3a8a" stroke-width="1"/><text x="" y="   zH" text-anchor="middle" font-size="9" fill="#1e3a8a">FY2024 annual</text>2   
   d      r   z
<line x1="z" y1="z" x2="z" y2="z" stroke="#e5e7eb"/>	<text x="      z2" text-anchor="end" font-size="11" fill="#6b7280"></text>c              3  p   K   | ]-  \  }}d  |      dddz
   d |      dddz
   d| d / yw)	r   ry   r   r   zH" text-anchor="end" font-size="10" fill="#374151" transform="rotate(-35 r{   z)">r   NrV   )rc   rd   labhr4   s      r   rf   zsvg_chart.<locals>.<genexpr>   s[       As AaD:U1R4& )!!"1c
!AbD6SE	Bs   36u  <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8"/>
  <title>GOOGL — Capex Actual vs FY2026 Guidance Vintages (GW Proxy)</title>
  <style>
    body { font-family: system-ui, sans-serif; margin: 24px; background: #fafafa; color: #111; }
    .banner { background: #fef3c7; border: 1px solid #f59e0b; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
    h1 { font-size: 20px; margin: 0 0 8px; }
    .legend { display: flex; gap: 20px; margin-top: 12px; font-size: 13px; flex-wrap: wrap; }
    .swatch { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; }
    .diamond { display: inline-block; width: 10px; height: 10px; background: #1d4ed8; transform: rotate(45deg); margin-right: 6px; vertical-align: middle; }
  </style>
</head>
<body>
  <div class="banner">
    <strong>GW-proxy caveat:</strong> Alphabet/Google Cloud does not disclose data-center MW/GW capacity.
    This chart plots <em>USD billions</em> quarterly capex actuals (SEC cash-flow purchases of
    property and equipment) vs full-year FY2026 capex guidance vintages applied <em>as-of</em> each
    quarter (~$180B midpoint from FY2025-FQ4 SEC 8-K; revised to ~$185B at FY2026-FQ1). FY2024-FQ4 is
    shown as a separate <strong>annual</strong> anchor (diamond), not on the quarterly line. Not convertible to GW.
  </div>
  <h1>Alphabet (GOOGL) — Infrastructure Spend Proxy: Actual vs Guidance</h1>
  <svg width="z
" height="z" viewBox="0 0 z:" role="img" aria-label="GOOGL capex chart">
    <rect x="z	" width="z%" fill="#fff" stroke="#d1d5db"/>
    z
    <text x="r   z.0f   zu" text-anchor="middle" font-size="12" fill="#374151">Fiscal quarter (as-of)</text>
    <text transform="translate(18 zh) rotate(-90)" text-anchor="middle" font-size="12" fill="#374151">USD billions (capex proxy)</text>
    z#2563ebz
    z#16a34az#dc2626a  
  </svg>
  <div class="legend">
    <span><span class="swatch" style="background:#2563eb"></span>Capex actual (quarterly proxy)</span>
    <span><span class="diamond"></span>FY2024 full-year actual (annual anchor)</span>
    <span><span class="swatch" style="background:#16a34a"></span>Latest FY2026 capex guidance vintage (as-of)</span>
    <span><span class="swatch" style="background:#dc2626"></span>Original FY2026 capex guidance (~$180B midpoint, from FY2025-FQ4)</span>
  </div>
</body>
</html>
)rd   r   returnr9   )rr   r9   r   r9   )r~   zlist[float | None]r   rB   r   rB   )	r9   zipnextr|   r8   rl   ranger   r}   )r;   re   
raw_actualrK   originalrr   quarterly_actualannual_anchor_idxwmrmball_valsr   annual_markeraxaygridsteptickyyxlabelsr   rn   ro   rs   rt   rp   r4   rw   ru   rv   s                        @@@@@@@@@@r   	svg_chartr      s	   +/0aa !0F_cdZ[A6J4K%./0QUUdJdmqrhi;X9YeA345_ccrFr  677V5Wa/01]aaH  j)Aq '(,==1D  XyX
 4Aq"b"bVb[!b&2+FB+f4x?Qa1=QHQ$4E)F)R
#456"*3x=3DD7; ;g M$4E)F)R$%q4E)F'GB3xqAc
!BqD:Qr#ha3xqQSTUQUVYPZZ[!tCj"S "3xuRU3K 0#$ 	 D2"DaTQ- 
tWjF2c(&2fRHL`ab1vU2a4*,^_c^ddkl	

 gg   ' G* *  *. c/*. /*. 3/*. ./*. /0S/*. 12/*. 34/*.5/*0 T1*0 1*0 d1*0 $1*0 %'41*0 (21*0 351*061*2 WWT]O3*23*4 2a4i_5*4 "5*4 #$B$5*4(#5*6 $&19S/7*627*8 	*+9*8,9*: fi !;*:";*< h	"#=*<$=*> O?*>?*@ IA*@
A* *C 1dr
 Rs(   KKK&K$K),K/4K/c                    t               } t        |       }t        j                  ddd      5 }t	        j
                  |t              }|j                          |j                  |       d d d        t        j                  t        |      d       t        dt        |       dt                t        d	t                y # 1 sw Y   ZxY w)
Nr   rG   r#   )newliner%   )
fieldnamesr$   zWrote z	 rows to zWrote chart to )r,   r`   
TIMESERIESr'   r)   
DictWriterFIELDSwriteheader	writerowsCHART
write_textr   printrm   )vintagetsr+   writers       r   mainr     s    nG	'	"B	b7	; qf5 
Yr]W5	F3r7)9ZL
12	OE7
#$ s   =CC__main__)r   rB   r   ztuple[int, int])r   list[dict[str, str]])r;   r   r   list[tuple[str, float]])rD   r9   r   rB   )rH   rB   rI   r   r   rB   )rH   rB   r;   r   r   ztuple[str, str, str])r;   r   r   r   )r;   r   r   rB   )r   None)__doc__
__future__r   r)   pathlibr   __file__resolveparentBASEr&   r   r   r[   rO   r7   r   r    r,   r>   rE   rM   rP   rW   r`   r   r   __name__rV   r!   r   <module>r      s    Y " 
 H~&&
'
'--
&&
 ' 
"'
72%<>l^	% zF r!   