Spaces:
Sleeping
Sleeping
import gradio as gr | |
import math | |
# Equity Dilution Calculator | |
def calculate_equity_dilution(pre_money_valuation, investment_amount, current_ownership): | |
if not all([pre_money_valuation, investment_amount, current_ownership]) or any(x <= 0 for x in [pre_money_valuation, investment_amount, current_ownership]): | |
return "Please enter valid positive values" | |
if current_ownership > 100: | |
return "Current ownership cannot exceed 100%" | |
post_money_valuation = pre_money_valuation + investment_amount | |
dilution_factor = pre_money_valuation / post_money_valuation | |
new_ownership = (current_ownership / 100) * dilution_factor * 100 | |
dilution_percentage = current_ownership - new_ownership | |
investor_ownership = (investment_amount / post_money_valuation) * 100 | |
return f""" | |
π° EQUITY DILUTION RESULTS | |
π Pre-money Valuation: ${pre_money_valuation:,.0f} | |
π΅ Investment Amount: ${investment_amount:,.0f} | |
π Post-money Valuation: ${post_money_valuation:,.0f} | |
π₯ Ownership Changes: | |
β’ Your ownership before: {current_ownership:.2f}% | |
β’ Your ownership after: {new_ownership:.2f}% | |
β’ Dilution: {dilution_percentage:.2f}% | |
β’ Investor ownership: {investor_ownership:.2f}% | |
π Key Insights: | |
β’ You retain {new_ownership:.1f}% of the company | |
β’ Investor gets {investor_ownership:.1f}% for ${investment_amount:,.0f} | |
β’ Your stake is diluted by {dilution_percentage:.1f} percentage points | |
""" | |
# Runway Calculator | |
def calculate_runway(current_cash, monthly_burn, monthly_revenue=0): | |
if not all([current_cash, monthly_burn]) or current_cash <= 0 or monthly_burn <= 0: | |
return "Please enter valid positive values for cash and burn rate" | |
net_burn = monthly_burn - monthly_revenue | |
if net_burn <= 0: | |
return f""" | |
π CONGRATULATIONS! YOU'RE PROFITABLE | |
π° Current Cash: ${current_cash:,.0f} | |
π Monthly Revenue: ${monthly_revenue:,.0f} | |
πΈ Monthly Burn: ${monthly_burn:,.0f} | |
π Net Cash Flow: +${abs(net_burn):,.0f}/month | |
π You're generating positive cash flow! | |
Your business is sustainable and growing. | |
""" | |
runway_months = current_cash / net_burn | |
runway_days = runway_months * 30 | |
# Calculate when cash runs out | |
import datetime | |
today = datetime.date.today() | |
cash_out_date = today + datetime.timedelta(days=runway_days) | |
# Runway status | |
if runway_months < 3: | |
status = "π΄ CRITICAL" | |
advice = "Immediate action required! Consider emergency fundraising or cost cuts." | |
elif runway_months < 6: | |
status = "π‘ WARNING" | |
advice = "Start fundraising now. Typical fundraising takes 3-6 months." | |
elif runway_months < 12: | |
status = "π’ HEALTHY" | |
advice = "Good runway. Plan your next fundraising round." | |
else: | |
status = "π EXCELLENT" | |
advice = "Strong position. Focus on growth and product development." | |
return f""" | |
β° RUNWAY CALCULATION | |
π° Current Cash: ${current_cash:,.0f} | |
π Monthly Revenue: ${monthly_revenue:,.0f} | |
πΈ Monthly Burn: ${monthly_burn:,.0f} | |
π Net Burn: ${net_burn:,.0f}/month | |
π― Runway Results: | |
β’ Runway: {runway_months:.1f} months ({runway_days:.0f} days) | |
β’ Cash depletes on: {cash_out_date.strftime('%B %d, %Y')} | |
β’ Status: {status} | |
π‘ Recommendation: {advice} | |
π Burn Rate Optimization: | |
β’ To extend runway to 12 months: Reduce burn to ${current_cash/12:,.0f}/month | |
β’ To extend runway to 18 months: Reduce burn to ${current_cash/18:,.0f}/month | |
""" | |
# Startup Valuation Calculator (Berkus Method) | |
def calculate_berkus_valuation(idea_score, prototype_score, team_score, market_score, revenue_score): | |
if not all(isinstance(x, (int, float)) and 0 <= x <= 5 for x in [idea_score, prototype_score, team_score, market_score, revenue_score]): | |
return "Please rate all factors from 0 to 5" | |
# Berkus Method scoring | |
factors = { | |
"Sound Idea": idea_score, | |
"Prototype": prototype_score, | |
"Quality Management Team": team_score, | |
"Strategic Relationships": market_score, | |
"Product Rollout/Sales": revenue_score | |
} | |
# Each factor can add up to $500K in valuation | |
max_per_factor = 500000 | |
total_valuation = sum(score * max_per_factor for score in factors.values()) | |
# Calculate weighted score | |
total_score = sum(factors.values()) | |
avg_score = total_score / 5 | |
# Risk assessment | |
if avg_score >= 4: | |
risk_level = "π’ LOW RISK" | |
investment_advice = "Strong investment candidate" | |
elif avg_score >= 3: | |
risk_level = "π‘ MEDIUM RISK" | |
investment_advice = "Promising with some concerns" | |
elif avg_score >= 2: | |
risk_level = "π HIGH RISK" | |
investment_advice = "Significant risks present" | |
else: | |
risk_level = "π΄ VERY HIGH RISK" | |
investment_advice = "Major concerns across multiple areas" | |
breakdown = "\n".join([f"β’ {factor}: {score}/5 β ${score * max_per_factor:,.0f}" | |
for factor, score in factors.items()]) | |
return f""" | |
π BERKUS METHOD VALUATION | |
{breakdown} | |
π° Total Valuation: ${total_valuation:,.0f} | |
π Average Score: {avg_score:.1f}/5 | |
β οΈ Risk Level: {risk_level} | |
π‘ Investment Advice: {investment_advice} | |
π Valuation Breakdown: | |
β’ Maximum possible: $2,500,000 (5/5 on all factors) | |
β’ Your valuation: ${total_valuation:,.0f} ({total_score}/25 points) | |
β’ Percentile: {(total_valuation/2500000)*100:.1f}% of maximum | |
π Note: Berkus Method is ideal for pre-revenue startups. | |
Consider other methods (DCF, Market Multiple) for revenue-generating companies. | |
""" | |
# Investment Return Calculator | |
def calculate_investment_returns(investment_amount, exit_valuation, ownership_percentage, years_to_exit): | |
if not all([investment_amount, exit_valuation, ownership_percentage, years_to_exit]) or any(x <= 0 for x in [investment_amount, exit_valuation, ownership_percentage, years_to_exit]): | |
return "Please enter valid positive values" | |
if ownership_percentage > 100: | |
return "Ownership percentage cannot exceed 100%" | |
exit_value = (ownership_percentage / 100) * exit_valuation | |
total_return = exit_value - investment_amount | |
roi_percentage = (total_return / investment_amount) * 100 | |
multiple = exit_value / investment_amount | |
# Calculate IRR (Internal Rate of Return) | |
irr = ((exit_value / investment_amount) ** (1/years_to_exit) - 1) * 100 | |
# Performance assessment | |
if multiple >= 10: | |
performance = "π EXCEPTIONAL" | |
grade = "A+" | |
elif multiple >= 5: | |
performance = "π EXCELLENT" | |
grade = "A" | |
elif multiple >= 3: | |
performance = "π― GOOD" | |
grade = "B+" | |
elif multiple >= 2: | |
performance = "β ACCEPTABLE" | |
grade = "B" | |
else: | |
performance = "β οΈ BELOW EXPECTATIONS" | |
grade = "C" | |
return f""" | |
π° INVESTMENT RETURN ANALYSIS | |
π Investment Details: | |
β’ Initial Investment: ${investment_amount:,.0f} | |
β’ Exit Valuation: ${exit_valuation:,.0f} | |
β’ Your Ownership: {ownership_percentage:.2f}% | |
β’ Time to Exit: {years_to_exit} years | |
π― Return Metrics: | |
β’ Exit Value: ${exit_value:,.0f} | |
β’ Total Return: ${total_return:,.0f} | |
β’ ROI: {roi_percentage:.1f}% | |
β’ Multiple: {multiple:.1f}x | |
β’ IRR: {irr:.1f}% per year | |
π Performance: {performance} (Grade: {grade}) | |
π Benchmarks: | |
β’ Top-tier VC target: 10x+ multiple, 25%+ IRR | |
β’ Good VC return: 3-10x multiple, 15-25% IRR | |
β’ Acceptable return: 2-3x multiple, 10-15% IRR | |
π‘ Analysis: | |
{"This exceeds top-tier VC expectations!" if multiple >= 10 else | |
"Strong return meeting VC expectations." if multiple >= 3 else | |
"Below typical VC return expectations." if multiple >= 2 else | |
"Consider if this investment aligns with your risk tolerance."} | |
""" | |
# Cap Table Calculator | |
def calculate_cap_table(founders_shares, employee_pool_percent, series_a_investment, series_a_pre_money): | |
if not all([founders_shares, employee_pool_percent, series_a_investment, series_a_pre_money]): | |
return "Please fill in all fields" | |
if founders_shares <= 0 or employee_pool_percent < 0 or employee_pool_percent > 50: | |
return "Please enter valid values (employee pool should be 0-50%)" | |
if series_a_investment <= 0 or series_a_pre_money <= 0: | |
return "Please enter positive values for investment and pre-money valuation" | |
# Calculate pre-Series A cap table | |
employee_shares = (employee_pool_percent / 100) * founders_shares / (1 - employee_pool_percent / 100) | |
pre_series_a_shares = founders_shares + employee_shares | |
# Calculate Series A | |
post_money_valuation = series_a_pre_money + series_a_investment | |
series_a_price_per_share = series_a_pre_money / pre_series_a_shares | |
series_a_shares = series_a_investment / series_a_price_per_share | |
# Post-Series A ownership | |
total_shares = pre_series_a_shares + series_a_shares | |
founders_ownership = (founders_shares / total_shares) * 100 | |
employee_ownership = (employee_shares / total_shares) * 100 | |
investor_ownership = (series_a_shares / total_shares) * 100 | |
# Dilution calculation | |
founders_dilution = 100 - founders_ownership - employee_ownership | |
return f""" | |
π CAP TABLE ANALYSIS | |
π’ Pre-Series A Structure: | |
β’ Founders: {founders_shares:,.0f} shares | |
β’ Employee Pool: {employee_shares:,.0f} shares ({employee_pool_percent}%) | |
β’ Total Pre-Series A: {pre_series_a_shares:,.0f} shares | |
π° Series A Details: | |
β’ Investment: ${series_a_investment:,.0f} | |
β’ Pre-money Valuation: ${series_a_pre_money:,.0f} | |
β’ Post-money Valuation: ${post_money_valuation:,.0f} | |
β’ Price per Share: ${series_a_price_per_share:.2f} | |
β’ New Shares Issued: {series_a_shares:,.0f} | |
π₯ Post-Series A Ownership: | |
β’ Founders: {founders_ownership:.1f}% ({founders_shares:,.0f} shares) | |
β’ Employee Pool: {employee_ownership:.1f}% ({employee_shares:,.0f} shares) | |
β’ Series A Investors: {investor_ownership:.1f}% ({series_a_shares:,.0f} shares) | |
β’ Total Shares: {total_shares:,.0f} | |
π Dilution Impact: | |
β’ Founders diluted by: {founders_dilution:.1f} percentage points | |
β’ Founders retain: {founders_ownership:.1f}% ownership | |
π‘ Key Insights: | |
β’ Each founder share is now worth ${series_a_price_per_share:.2f} | |
β’ Total founder equity value: ${(founders_shares * series_a_price_per_share):,.0f} | |
β’ Employee pool value: ${(employee_shares * series_a_price_per_share):,.0f} | |
""" | |
# Create Gradio Interface | |
with gr.Blocks( | |
title="Startup Calculator - Essential Tools for Founders, VCs & Investors", | |
theme=gr.themes.Soft(), | |
css=""" | |
.main-header { | |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
color: white; | |
padding: 30px; | |
border-radius: 15px; | |
text-align: center; | |
margin-bottom: 20px; | |
} | |
.feature-card { | |
background: rgba(102, 126, 234, 0.1); | |
border-left: 4px solid #667eea; | |
padding: 15px; | |
margin: 10px 0; | |
border-radius: 8px; | |
} | |
.step-box { | |
background: rgba(255, 255, 255, 0.8); | |
border-radius: 8px; | |
padding: 15px; | |
margin: 10px 0; | |
border-left: 4px solid #667eea; | |
} | |
.footer { | |
text-align: center; | |
padding: 20px; | |
color: #666; | |
border-top: 1px solid #eee; | |
margin-top: 30px; | |
} | |
/* Dark theme support */ | |
.dark .main-header { | |
background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%); | |
} | |
.dark .feature-card { | |
background: rgba(74, 85, 104, 0.3); | |
border-left-color: #90cdf4; | |
color: #e2e8f0; | |
} | |
.dark .step-box { | |
background: rgba(45, 55, 72, 0.8); | |
border-left-color: #90cdf4; | |
color: #e2e8f0; | |
} | |
.dark .footer { | |
color: #a0aec0; | |
border-top-color: #4a5568; | |
} | |
""" | |
) as app: | |
with gr.Column(): | |
gr.HTML(""" | |
<div class="main-header"> | |
<h1>π Startup Calculator</h1> | |
<p>Essential financial tools for founders, VCs, and investors</p> | |
</div> | |
""") | |
with gr.Tabs(): | |
with gr.Tab("π Overview"): | |
gr.HTML(""" | |
<div style="padding: 20px;"> | |
<h2>π― Why Use This Calculator?</h2> | |
<div class="feature-card"> | |
<h3>β‘ Save Time:</h3> | |
<p>No more complex spreadsheets or manual calculations</p> | |
</div> | |
<div class="feature-card"> | |
<h3>β Avoid Errors:</h3> | |
<p>Automated formulas based on industry standards</p> | |
</div> | |
<div class="feature-card"> | |
<h3>π Make Better Decisions:</h3> | |
<p>Get instant insights for fundraising and investment decisions</p> | |
</div> | |
<div class="feature-card"> | |
<h3>π Free & Accessible:</h3> | |
<p>Use anytime, anywhere, no signup required</p> | |
</div> | |
<h2>π οΈ Available Tools</h2> | |
<div style="display: grid; gap: 15px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));"> | |
<div style="padding: 15px; background: rgba(40, 167, 69, 0.1); border-radius: 8px;"> | |
<h3>π° Equity Dilution</h3> | |
<p>Calculate ownership changes after funding rounds</p> | |
</div> | |
<div style="padding: 15px; background: rgba(255, 193, 7, 0.1); border-radius: 8px;"> | |
<h3>β° Runway Calculator</h3> | |
<p>Track cash runway and burn rate optimization</p> | |
</div> | |
<div style="padding: 15px; background: rgba(220, 53, 69, 0.1); border-radius: 8px;"> | |
<h3>π Startup Valuation</h3> | |
<p>Estimate company value using Berkus Method</p> | |
</div> | |
<div style="padding: 15px; background: rgba(111, 66, 193, 0.1); border-radius: 8px;"> | |
<h3>π Investment Returns</h3> | |
<p>Calculate ROI, IRR, and investment multiples</p> | |
</div> | |
<div style="padding: 15px; background: rgba(23, 162, 184, 0.1); border-radius: 8px;"> | |
<h3>π Cap Table</h3> | |
<p>Model ownership structure and dilution</p> | |
</div> | |
</div> | |
</div> | |
""") | |
with gr.Tab("π° Equity Dilution"): | |
with gr.Row(): | |
with gr.Column(): | |
pre_money = gr.Number( | |
label="Pre-money Valuation ($)", | |
info="Company value before investment" | |
) | |
investment = gr.Number( | |
label="Investment Amount ($)", | |
info="Amount being invested" | |
) | |
current_ownership = gr.Number( | |
label="Current Ownership (%)", | |
info="Your current ownership percentage" | |
) | |
dilution_btn = gr.Button("Calculate Dilution", variant="primary") | |
with gr.Column(): | |
dilution_result = gr.Markdown(label="Results") | |
dilution_btn.click( | |
fn=calculate_equity_dilution, | |
inputs=[pre_money, investment, current_ownership], | |
outputs=dilution_result | |
) | |
with gr.Tab("β° Runway Calculator"): | |
with gr.Row(): | |
with gr.Column(): | |
current_cash = gr.Number( | |
label="Current Cash ($)", | |
info="Cash in bank account" | |
) | |
monthly_burn = gr.Number( | |
label="Monthly Burn Rate ($)", | |
info="Monthly expenses/spending" | |
) | |
monthly_revenue = gr.Number( | |
label="Monthly Revenue ($)", | |
info="Monthly recurring revenue (optional)", | |
value=0 | |
) | |
runway_btn = gr.Button("Calculate Runway", variant="primary") | |
with gr.Column(): | |
runway_result = gr.Markdown(label="Results") | |
runway_btn.click( | |
fn=calculate_runway, | |
inputs=[current_cash, monthly_burn, monthly_revenue], | |
outputs=runway_result | |
) | |
with gr.Tab("π Startup Valuation"): | |
with gr.Row(): | |
with gr.Column(): | |
gr.Markdown("### Rate each factor from 0-5:") | |
idea_score = gr.Slider( | |
minimum=0, maximum=5, step=0.5, value=3, | |
label="Sound Idea (0-5)", | |
info="Quality and uniqueness of the business idea" | |
) | |
prototype_score = gr.Slider( | |
minimum=0, maximum=5, step=0.5, value=3, | |
label="Prototype/Product (0-5)", | |
info="Development stage and product quality" | |
) | |
team_score = gr.Slider( | |
minimum=0, maximum=5, step=0.5, value=3, | |
label="Management Team (0-5)", | |
info="Experience and track record of founders" | |
) | |
market_score = gr.Slider( | |
minimum=0, maximum=5, step=0.5, value=3, | |
label="Strategic Relationships (0-5)", | |
info="Market connections and partnerships" | |
) | |
revenue_score = gr.Slider( | |
minimum=0, maximum=5, step=0.5, value=3, | |
label="Product Rollout/Sales (0-5)", | |
info="Revenue generation and market traction" | |
) | |
valuation_btn = gr.Button("Calculate Valuation", variant="primary") | |
with gr.Column(): | |
valuation_result = gr.Markdown(label="Results") | |
valuation_btn.click( | |
fn=calculate_berkus_valuation, | |
inputs=[idea_score, prototype_score, team_score, market_score, revenue_score], | |
outputs=valuation_result | |
) | |
with gr.Tab("π Investment Returns"): | |
with gr.Row(): | |
with gr.Column(): | |
investment_amt = gr.Number( | |
label="Investment Amount ($)", | |
info="Initial investment" | |
) | |
exit_val = gr.Number( | |
label="Exit Valuation ($)", | |
info="Expected company value at exit" | |
) | |
ownership_pct = gr.Number( | |
label="Ownership Percentage (%)", | |
info="Your ownership stake" | |
) | |
years_exit = gr.Number( | |
label="Years to Exit", | |
info="Expected time to exit event" | |
) | |
returns_btn = gr.Button("Calculate Returns", variant="primary") | |
with gr.Column(): | |
returns_result = gr.Markdown(label="Results") | |
returns_btn.click( | |
fn=calculate_investment_returns, | |
inputs=[investment_amt, exit_val, ownership_pct, years_exit], | |
outputs=returns_result | |
) | |
with gr.Tab("π Cap Table"): | |
with gr.Row(): | |
with gr.Column(): | |
founders_shares = gr.Number( | |
label="Founders' Shares", | |
info="Number of shares held by founders" | |
) | |
employee_pool = gr.Number( | |
label="Employee Pool (%)", | |
info="Percentage reserved for employees (typically 10-20%)" | |
) | |
series_a_inv = gr.Number( | |
label="Series A Investment ($)", | |
info="Amount being raised in Series A" | |
) | |
series_a_pre = gr.Number( | |
label="Series A Pre-money ($)", | |
info="Pre-money valuation for Series A" | |
) | |
captable_btn = gr.Button("Calculate Cap Table", variant="primary") | |
with gr.Column(): | |
captable_result = gr.Markdown(label="Results") | |
captable_btn.click( | |
fn=calculate_cap_table, | |
inputs=[founders_shares, employee_pool, series_a_inv, series_a_pre], | |
outputs=captable_result | |
) | |
with gr.Tab("π How to Use"): | |
gr.HTML(""" | |
<div style="padding: 20px;"> | |
<h2>π Quick Start Guide</h2> | |
<div style="display: grid; gap: 15px;"> | |
<div style="padding: 15px; border-left: 4px solid #007bff; background: rgba(0, 123, 255, 0.1);" class="step-box"> | |
<h3>Step 1: Choose Your Tool</h3> | |
<p>Select the calculator that matches your needs from the tabs above</p> | |
</div> | |
<div style="padding: 15px; border-left: 4px solid #28a745; background: rgba(40, 167, 69, 0.1);" class="step-box"> | |
<h3>Step 2: Enter Your Data</h3> | |
<p>Fill in the required fields with your startup's financial information</p> | |
</div> | |
<div style="padding: 15px; border-left: 4px solid #ffc107; background: rgba(255, 193, 7, 0.1);" class="step-box"> | |
<h3>Step 3: Get Results</h3> | |
<p>Click the calculate button to see detailed analysis and insights</p> | |
</div> | |
<div style="padding: 15px; border-left: 4px solid #6f42c1; background: rgba(111, 66, 193, 0.1);" class="step-box"> | |
<h3>Step 4: Make Decisions</h3> | |
<p>Use the insights to make informed business and investment decisions</p> | |
</div> | |
</div> | |
<h2>β Frequently Asked Questions</h2> | |
<div style="margin: 20px 0;"> | |
<details class="step-box" style="margin: 10px 0; padding: 10px; cursor: pointer;"> | |
<summary style="font-weight: bold;">Are the calculations accurate?</summary> | |
<p style="margin: 10px 0;">Yes, all calculations use industry-standard formulas and methods commonly used by VCs and startup professionals.</p> | |
</details> | |
<details class="step-box" style="margin: 10px 0; padding: 10px; cursor: pointer;"> | |
<summary style="font-weight: bold;">Do I need to create an account?</summary> | |
<p style="margin: 10px 0;">No, all tools are completely free and require no registration or signup.</p> | |
</details> | |
<details class="step-box" style="margin: 10px 0; padding: 10px; cursor: pointer;"> | |
<summary style="font-weight: bold;">Is my data stored or shared?</summary> | |
<p style="margin: 10px 0;">No, all calculations are performed locally and no data is stored or shared.</p> | |
</details> | |
<details class="step-box" style="margin: 10px 0; padding: 10px; cursor: pointer;"> | |
<summary style="font-weight: bold;">Which valuation method should I use?</summary> | |
<p style="margin: 10px 0;">The Berkus Method is ideal for pre-revenue startups. For revenue-generating companies, consider DCF or market multiple approaches.</p> | |
</details> | |
<details class="step-box" style="margin: 10px 0; padding: 10px; cursor: pointer;"> | |
<summary style="font-weight: bold;">What's a good runway length?</summary> | |
<p style="margin: 10px 0;">Generally, 12-18 months is considered healthy. Less than 6 months requires immediate attention.</p> | |
</details> | |
</div> | |
</div> | |
""") | |
gr.HTML(""" | |
<div class="footer"> | |
<p>Β© 2024 Startup Calculator - Built for the startup ecosystem</p> | |
<p>Essential tools for founders, VCs, and investors worldwide</p> | |
</div> | |
""") | |
if __name__ == "__main__": | |
app.launch(server_name="0.0.0.0", server_port=7860) | |