File size: 1,248 Bytes
558d330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.path.insert(0, '.')
from pipeline.resolver import resolve
from pipeline.fetcher import fetch_all
from pipeline.calculator import calculate

meta = resolve('TCS', log_fn=lambda m: print(m))
data = fetch_all(meta, years=5, force_refresh=True, log_fn=lambda m: print(m))
data = calculate(data, meta.to_dict())

print()
print("=== SCALED DATA ===")
inc = data['income_statement']
yr  = data['years']
units_label = data.get('units_label', data.get('units', '?'))
print("Units label:", units_label)
print()
for y, r, n, e in zip(yr, inc['revenue'], inc['net_income'], inc['ebitda']):
    r_s = f"{r:,.0f} Cr" if r else "N/A"
    n_s = f"{n:,.0f} Cr" if n else "N/A"
    e_s = f"{e:,.0f} Cr" if e else "N/A"
    print(f"  {y} | Rev: {r_s:>15} | NetInc: {n_s:>12} | EBITDA: {e_s:>12}")

print()
rat = data['ratios']
print("Ratios (latest year):")
print(f"  Operating Margin: {(rat['operating_margin'][-1] or 0)*100:.1f}%")
print(f"  Net Margin:       {(rat['net_margin'][-1] or 0)*100:.1f}%")
print(f"  ROE:              {(rat['roe'][-1] or 0)*100:.1f}%")
print(f"  Current Ratio:    {rat['current_ratio'][-1]}")
print()
print("Data looks correct - ready for reports!")