python Copy code
import pandas as pd
import numpy as np
try:
from tabulate import tabulate
except ImportError:
print("Install tabulate: pip install tabulate")
exit(1)
class DividendPolicySimulator:
def __init__(self):
# Policy Parameters (customizable)
self.payout_min = 0.20
self.payout_target = 0.40
self.payout_max = 0.60
self.max_leverage = 3.0 # Max Net Debt / EBITDA (x)
self.max_rating_score = 4 # BBB = 4, higher score = worse rating
self.min_runway_months = 6.0
self.years = 5
# Financials (set later)
self.debt_gross = None
self.cash_init = None
self.ebitda_init = None
self.ni_init = None
self.fcf_init = None
self.opex_annual = None
def set_params(self, payout_min=None, payout_target=None, payout_max=None,
max_leverage=None, max_rating_score=None, min_runway_months=None, years=None):
if payout_min is not None: self.payout_min = payout_min
if payout_target is not None: self.payout_target = payout_target
if payout_max is not None: self.payout_max = payout_max
if max_leverage is not None: self.max_leverage = max_leverage
if max_rating_score is not None: self.max_rating_score = max_rating_score
if min_runway_months is not None: self.min_runway_months = min_runway_months
if years is not None: self.years = years
def set_initial_financials(self, debt_gross, cash_init, ebitda_init, ni_init, fcf_init, opex_annual):
self.debt_gross = debt_gross
self.cash_init = cash_init
self.ebitda_init = ebitda_init
self.ni_init = ni_init
self.fcf_init = fcf_init
self.opex_annual = opex_annual
def get_rating_score(self, lev):
if lev <= 1.5: return 1 # AAA
elif lev <= 2.0: return 2 # AA
elif lev <= 2.75: return 3 # A
elif lev <= 3.5: return 4 # BBB
elif lev <= 5.0: return 5 # BB
else: return 6 # B-
def rating_from_leverage(self, lev):
score = self.get_rating_score(lev)
ratings = {1: 'AAA', 2: 'AA', 3: 'A', 4: 'BBB', 5: 'BB', 6: 'B-'}
return ratings.get(score, 'NR')
def can_pay_dividend(self, lev_pre, rating_score, runway_pre, fcf):
return (lev_pre <= self.max_leverage and
rating_score <= self.max_rating_score and
runway_pre >= self.min_runway_months and
fcf >= 0)
def run_scenario(self, name, ni_growth, ebitda_growth, fcf_growth, opex_growth=0.03):
if self.debt_gross is None:
raise ValueError("Set initial financials first!")
df = pd.DataFrame(index=range(self.years + 1),
columns=['EBITDA', 'NI', 'FCF', 'Cash_pre', 'NetDebt_pre', 'Leverage_pre',
'Runway_pre', 'Rating_pre', 'CanPay', 'TargetPayoutRatio',
'Rec_Dividend', 'Cash_post', 'NetDebt_post', 'Leverage_post'])
# Year 0: Current
y = 0
cash_pre = self.cash_init
df.at[y, 'EBITDA'] = self.ebitda_init
df.at[y, 'NI'] = self.ni_init
df.at[y, 'FCF'] = self.fcf_init
df.at[y, 'Cash_pre'] = cash_pre
netdebt_pre = max(self.debt_gross - cash_pre, 0)
df.at[y, 'NetDebt_pre'] = netdebt_pre
lev_pre = netdebt_pre / self.ebitda_init if self.ebitda_init > 0 else 0
df.at[y, 'Leverage_pre'] = lev_pre
monthly_burn = self.opex_annual / 12
runway_pre = cash_pre / monthly_burn if monthly_burn > 0 else float('inf')
df.at[y, 'Runway_pre'] = runway_pre
rating_pre = self.rating_from_leverage(lev_pre)
rating_score = self.get_rating_score(lev_pre)
df.at[y, 'Rating_pre'] = rating_pre
can_pay = self.can_pay_dividend(lev_pre, rating_score, runway_pre, self.fcf_init)
df.at[y, 'CanPay'] = can_pay
rec_div = 0
target_payout = self.payout_target
if self.ni_init > 0 and can_pay:
if lev_pre < 2.0:
target_payout = self.payout_max
elif lev_pre > self.max_leverage * 0.8:
target_payout = self.payout_min
df.at[y, 'TargetPayoutRatio'] = target_payout
div_cand = self.ni_init * target_payout
rec_div = min(div_cand, self.fcf_init)
rec_div = max(self.ni_init * self.payout_min, rec_div)
rec_div = min(self.ni_init * self.payout_max, rec_div)
else:
df.at[y, 'TargetPayoutRatio'] = 0.0
df.at[y, 'Rec_Dividend'] = rec_div
cash_post = max(cash_pre - rec_div, 0)
df.at[y, 'Cash_post'] = cash_post
netdebt_post = max(self.debt_gross - cash_post, 0)
df.at[y, 'NetDebt_post'] = netdebt_post
lev_post = netdebt_post / self.ebitda_init if self.ebitda_init > 0 else 0
df.at[y, 'Leverage_post'] = lev_post
# Projections
cash_post_current = cash_post
opex_current = self.opex_annual
for y in range(1, self.years + 1):
df.at[y, 'EBITDA'] = df.at[y-1, 'EBITDA'] * (1 + ebitda_growth)
df.at[y, 'NI'] = df.at[y-1, 'NI'] * (1 + ni_growth)
df.at[y, 'FCF'] = df.at[y-1, 'FCF'] * (1 + fcf_growth)
cash_pre = cash_post_current + df.at[y, 'FCF']
df.at[y, 'Cash_pre'] = cash_pre
netdebt_pre = max(self.debt_gross - cash_pre, 0)
df.at[y, 'NetDebt_pre'] = netdebt_pre
lev_pre = netdebt_pre / df.at[y, 'EBITDA'] if df.at[y, 'EBITDA'] > 0 else 0
df.at[y, 'Leverage_pre'] = lev_pre
opex_current *= (1 + opex_growth)
monthly_burn = opex_current / 12
runway_pre = cash_pre / monthly_burn if monthly_burn > 0 else float('inf')
df.at[y, 'Runway_pre'] = runway_pre
rating_pre = self.rating_from_leverage(lev_pre)
rating_score = self.get_rating_score(lev_pre)
df.at[y, 'Rating_pre'] = rating_pre
can_pay = self.can_pay_dividend(lev_pre, rating_score, runway_pre, df.at[y, 'FCF'])
df.at[y, 'CanPay'] = can_pay
rec_div = 0
target_payout = self.payout_target
if df.at[y, 'NI'] > 0 and can_pay:
if lev_pre < 2.0:
target_payout = self.payout_max
elif lev_pre > self.max_leverage * 0.8:
target_payout = self.payout_min
df.at[y, 'TargetPayoutRatio'] = target_payout
div_cand = df.at[y, 'NI'] * target_payout
rec_div = min(div_cand, df.at[y, 'FCF'])
rec_div = max(df.at[y, 'NI'] * self.payout_min, rec_div)
rec_div = min(df.at[y, 'NI'] * self.payout_max, rec_div)
else:
df.at[y, 'TargetPayoutRatio'] = 0.0
df.at[y, 'Rec_Dividend'] = rec_div
cash_post = max(cash_pre - rec_div, 0)
df.at[y, 'Cash_post'] = cash_post
netdebt_post = max(self.debt_gross - cash_post, 0)
df.at[y, 'NetDebt_post'] = netdebt_post
lev_post = netdebt_post / df.at[y, 'EBITDA'] if df.at[y, 'EBITDA'] > 0 else 0
df.at[y, 'Leverage_post'] = lev_post
cash_post_current = cash_post
df.index.name = 'Year'
return df
def generate_decision_pack(self, scenarios):
"""Generate CFO/Board decision pack summary."""
print("\n" + "="*80)
print("CFO / BOARD DECISION PACK: DIVIDEND POLICY RECOMMENDATION")
print("="*80)
# Current year rec
current_year = 0
current_rec_div = self.dfs[0].at[current_year, 'Rec_Dividend'] # Assumes dfs set
current_ni = self.dfs[0].at[current_year, 'NI']
current_payout = (current_rec_div / current_ni * 100) if current_ni > 0 else 0
print(f"\nIMMEDIATE RECOMMENDATION (Year 0):")
print(f" - Recommended Dividend: ${current_rec_div:,.0f}M")
print(f" - Payout Ratio: {current_payout:.1f}% of NI (${current_ni:,.0f}M)")
print(f" - Leverage Pre-Div: {self.dfs[0].at[current_year, 'Leverage_pre']:.2f}x (Rating: {self.dfs[0].at[current_year, 'Rating_pre']})")
print(f" - Cash Runway Pre-Div: {self.dfs[0].at[current_year, 'Runway_pre']:.1f} months")
print(f" - Can Pay: {'YES' if self.dfs[0].at[current_year, 'CanPay'] else 'NO (Guardrail Hit)'}")
print("\nSCENARIO COMPARISON (5-Year Horizon):")
summary_data = []
for i, (name, df) in enumerate(self.dfs.items()):
total_div = df['Rec_Dividend'].sum()
avg_payout = (df.loc[1:, df['NI'] > 0, 'Rec_Dividend'] / df.loc[1:, df['NI'] > 0, 'NI']).mean() * 100 if len(df.loc[1:, df['NI'] > 0]) > 0 else 0
peak_lev = df['Leverage_post'].max()
min_runway = df['Runway_pre'].min()
no_div_years = (~df['CanPay']).sum()
summary_data.append([name, f"${total_div:,.0f}M", f"{avg_payout:.1f}%", f"{peak_lev:.2f}x", f"{min_runway:.1f}mo", no_div_years])
summary_df = pd.DataFrame(summary_data, columns=['Scenario', 'Total Div (5Y)', 'Avg Payout %', 'Peak Lev Post', 'Min Runway Pre', 'No-Div Years'])
print(tabulate(summary_df, headers='keys', tablefmt='grid'))
print("\nKEY INSIGHTS:")
print(" - Policy respects payout targets, leverage/rating guardrails (BBB+ min, 3.0x max), and 6mo cash runway.")
print(" - Dynamic payout: Higher if low leverage (<2x), lower near guardrails.")
print(" - Debt assumed fixed (no new issuance/mandatory paydown). FCF builds cash / deleverages when no div.")
print("Approve Year 0 dividend if Base case aligns with Board risk appetite.")
def main():
sim = DividendPolicySimulator()
print("DIVIDEND POLICY SIMULATOR")
print("Enter current financials ($M, TTM):")
debt_gross = float(input("Gross Debt (default 5000): ") or 5000)
cash_init = float(input("Cash & Equiv (default 1000): ") or 1000)
ebitda_init = float(input("EBITDA (default 2000): ") or 2000)
ni_init = float(input("Net Income (default 1000): ") or 1000)
fcf_init = float(input("Free Cash Flow (default 800): ") or 800)
opex_annual = float(input("Annual OpEx (default 5000): ") or 5000)
sim.set_initial_financials(debt_gross, cash_init, ebitda_init, ni_init, fcf_init, opex_annual)
print("\nPolicy params (enter to keep default):")
sim.set_params(
payout_min=float(input("Payout min (default 0.20): ") or 0.20),
payout_target=float(input("Payout target (default 0.40): ") or 0.40),
payout_max=float(input("Payout max (default 0.60): ") or 0.60),
max_leverage=float(input("Max leverage x (default 3.0): ") or 3.0),
min_runway_months=float(input("Min runway months (default 6): ") or 6)
)
scenarios = {
'Base': {'ni_growth': 0.05, 'ebitda_growth': 0.05, 'fcf_growth': 0.05, 'opex_growth': 0.03},
'Bear': {'ni_growth': 0.00, 'ebitda_growth': 0.00, 'fcf_growth': -0.02, 'opex_growth': 0.02},
'Bull': {'ni_growth': 0.10, 'ebitda_growth': 0.08, 'fcf_growth': 0.12, 'opex_growth': 0.04}
}
sim.dfs = {} # Store for decision pack
print("\nRunning simulations...")
for name, gs in scenarios.items():
df = sim.run_scenario(name, **gs)
sim.dfs[name] = df
print(f"\n=== {name} Scenario ===")
display_df = df[['EBITDA', 'NI', 'FCF', 'Leverage_pre', 'Runway_pre', 'Rating_pre', 'CanPay', 'TargetPayoutRatio', 'Rec_Dividend', 'Leverage_post']].round(2)
display_df['TargetPayoutRatio'] = (display_df['TargetPayoutRatio'] * 100).round(1).astype(str) + '%'
display_df['CanPay'] = display_df['CanPay'].map({True: 'YES', False: 'NO'})
print(tabulate(display_df, headers='keys', tablefmt='grid', floatfmt='.1f'))
print(f"Total Dividends (Years 0-{sim.years}): ${df['Rec_Dividend'].sum():,.0f}M")
sim.generate_decision_pack(scenarios)
print("\nRerun with custom growth? Edit scenarios dict and call sim.run_scenario()")
if __name__ == "__main__":
main()
Example output includes pro forma tables, totals, peaks/mins, and board-ready rec. Perfect for modeling dividend sustainability! Adjust scenarios for custom stress tests.