Last active
June 11, 2025 20:29
-
-
Save parthi2929/ddd518bf683fe427ef386cb0aadc34aa to your computer and use it in GitHub Desktop.
Script created to calculate DCF methods for Axon control engineering valuation..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
# Inputs | |
initial_revenue = 12498748 | |
growth_rate = 0.50 | |
cogs_pct = 0.50 | |
opex_pct = 0.08 | |
depreciation = 50000 | |
capex = 200000 | |
wc_pct = 0.02 | |
tax_rate = 0.30 | |
wacc = 0.12 | |
terminal_growth = 0.03 | |
years = 5 | |
# Lists for storing yearly data | |
revenues = [] | |
cogs_list = [] | |
gross_profit_list = [] | |
opex_list = [] | |
ebitda_list = [] | |
tax_list = [] | |
nopat_list = [] | |
wc_list = [] | |
fcf_list = [] | |
df_list = [] | |
pv_fcf_list = [] | |
revenue = initial_revenue | |
for t in range(1, years + 1): | |
revenues.append(revenue) | |
cogs = revenue * cogs_pct | |
cogs_list.append(cogs) | |
gross_profit = revenue - cogs | |
gross_profit_list.append(gross_profit) | |
opex = revenue * opex_pct | |
opex_list.append(opex) | |
ebitda = revenue - cogs - opex | |
ebitda_list.append(ebitda) | |
tax_val = ebitda * tax_rate | |
tax_list.append(tax_val) | |
nopat = ebitda - tax_val | |
nopat_list.append(nopat) | |
wc = revenue * wc_pct | |
wc_list.append(wc) | |
fcf = nopat + depreciation - capex - wc | |
fcf_list.append(fcf) | |
df = 1 / ((1 + wacc) ** t) | |
df_list.append(df) | |
pv_fcf = fcf * df | |
pv_fcf_list.append(pv_fcf) | |
revenue *= (1 + growth_rate) | |
total_pv_fcf = sum(pv_fcf_list) | |
last_fcf = fcf_list[-1] | |
# Terminal Value Calculation Breakdown | |
# terminal_value = (last_fcf * (1 + terminal_growth)) / (wacc - terminal_growth) | |
terminal_value = (last_fcf * (1 + terminal_growth)) / (wacc - terminal_growth) | |
df_year5 = df_list[-1] | |
pv_terminal_value = terminal_value * df_year5 | |
enterprise_value = total_pv_fcf + pv_terminal_value | |
# Print results in markdown format | |
print("# DCF Valuation Report\n") | |
print("**Assumptions**") | |
print(f"- **Initial Revenue (Year 1):** INR {initial_revenue:,}") | |
print(f"- **Revenue Growth Rate:** {growth_rate*100:.0f}% per annum") | |
print(f"- **COGS:** {cogs_pct*100:.0f}% of Revenue") | |
print(f"- **Operating Expenses (OPEX):** {opex_pct*100:.0f}% of Revenue") | |
print(f"- **Depreciation:** INR {depreciation:,} per year") | |
print(f"- **Capital Expenditure (CapEx):** INR {capex:,} per year") | |
print(f"- **Working Capital:** {wc_pct*100:.0f}% of Revenue") | |
print(f"- **Tax Rate:** {tax_rate*100:.0f}% on EBITDA") | |
print(f"- **Discount Rate (WACC):** {wacc*100:.0f}%") | |
print(f"- **Terminal Growth Rate:** {terminal_growth*100:.0f}%") | |
print(f"- **Projection Period:** {years} Years\n") | |
print("## Yearly Projections\n") | |
header = ( | |
"| Year | Revenue (INR) | COGS (INR) | Gross Profit (INR) | OPEX (INR) | EBITDA (INR) | " | |
"Taxes (INR) | NOPAT (INR) | Depreciation (INR) | CapEx (INR) | Working Capital (INR) | " | |
"FCF (INR) | Discount Factor | PV of FCF (INR) |" | |
) | |
separator = ( | |
"|:---:|--------------:|-----------:|-------------------:|-----------:|-------------:|" | |
"------------:|------------:|-------------------:|------------:|----------------------:|" | |
"-----------:|----------------:|-----------------:|" | |
) | |
print(header) | |
print(separator) | |
for i in range(years): | |
print( | |
f"| {i+1} " | |
f"| {revenues[i]:,.2f} " | |
f"| {cogs_list[i]:,.2f} " | |
f"| {gross_profit_list[i]:,.2f} " | |
f"| {opex_list[i]:,.2f} " | |
f"| {ebitda_list[i]:,.2f} " | |
f"| {tax_list[i]:,.2f} " | |
f"| {nopat_list[i]:,.2f} " | |
f"| {depreciation:,.2f} " | |
f"| {capex:,.2f} " | |
f"| {wc_list[i]:,.2f} " | |
f"| {fcf_list[i]:,.2f} " | |
f"| {df_list[i]:.4f} " | |
f"| {pv_fcf_list[i]:,.2f} |" | |
) | |
print("\n## DCF Summary\n") | |
print(f"- **Total PV of FCF (Years 1–{years}):** INR {total_pv_fcf:,.2f}") | |
# Terminal Value explanation line | |
print(f"- **Terminal Value:** (({last_fcf:,.2f} * (1 + {terminal_growth})) / ({wacc} - {terminal_growth})) = INR {terminal_value:,.2f}") | |
print(f"- **Discount Factor for Year {years} (1/(1+WACC)^{years}):** {df_year5:.4f}") | |
print(f"- **PV of Terminal Value:** {terminal_value:,.2f} * {df_year5:.4f} = INR {pv_terminal_value:,.2f}") | |
print(f"- **Enterprise Value (EV):** INR {total_pv_fcf:,.2f} + INR {pv_terminal_value:,.2f} = INR {enterprise_value:,.2f}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment