File size: 5,199 Bytes
59e2ce6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import pandas as pd
import numpy as np
from datetime import datetime, timedelta

def calculate_runway(current_cash, burn_rate, monthly_revenue, growth_rate, months=12):
    """
    Calculate the startup's runway based on financial parameters
    
    Args:
        current_cash (float): Current cash balance
        burn_rate (float): Monthly burn rate
        monthly_revenue (float): Current monthly revenue
        growth_rate (float): Monthly revenue growth rate
        months (int, optional): Projection period. Defaults to 12.
    
    Returns:
        tuple: (runway months, runway dataframe)
    """
    # Create projection dataframe
    df = pd.DataFrame(index=range(months))
    
    # Initialize first month
    df.loc[0, 'Revenue'] = monthly_revenue
    df.loc[0, 'Burn_Rate'] = burn_rate
    df.loc[0, 'Net_Burn'] = burn_rate - monthly_revenue
    df.loc[0, 'Cumulative_Cash'] = current_cash - df.loc[0, 'Net_Burn']
    
    # Project forward
    for i in range(1, months):
        # Grow revenue
        df.loc[i, 'Revenue'] = df.loc[i-1, 'Revenue'] * (1 + growth_rate)
        
        # Adjust burn rate (simplified model)
        df.loc[i, 'Burn_Rate'] = burn_rate  # Could make this more sophisticated
        
        # Calculate net burn
        df.loc[i, 'Net_Burn'] = df.loc[i, 'Burn_Rate'] - df.loc[i, 'Revenue']
        
        # Calculate cumulative cash
        df.loc[i, 'Cumulative_Cash'] = df.loc[i-1, 'Cumulative_Cash'] - df.loc[i, 'Net_Burn']
        
        # Stop if out of cash
        if df.loc[i, 'Cumulative_Cash'] <= 0:
            break
    
    # Calculate runway months
    runway_months = df[df['Cumulative_Cash'] > 0].shape[0]
    
    return runway_months, df

def generate_sample_startup_data():
    """
    Generate sample startup financial data for demonstration
    
    Returns:
        dict: Sample startup financial data
    """
    return {
        "name": "TechHealth AI",
        "stage": "Seed",
        "founded": "18 months ago",
        "employees": 12,
        "last_funding": "$1.2M seed round 10 months ago",
        "cash": 320000,
        "burn_rate": 85000,
        "revenue": 15000,
        "growth_rate": 0.08
    }

def generate_sample_cash_flow_data():
    """
    Generate sample cash flow data for demonstration
    
    Returns:
        pd.DataFrame: Sample cash flow DataFrame
    """
    cash_flow_data = {
        "Month": [f"Month {i}" for i in range(1, 11)],
        "Revenue": [8000, 8500, 9200, 10000, 10800, 11700, 12600, 13600, 14700, 15800],
        "Payroll": [60000, 60000, 62000, 62000, 65000, 65000, 70000, 70000, 75000, 75000],
        "Marketing": [8000, 9000, 10000, 12000, 15000, 18000, 15000, 12000, 10000, 8000],
        "Office": [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],
        "Software": [3000, 3200, 3500, 3800, 4000, 4200, 4500, 4800, 5000, 5200],
        "Travel": [2000, 1800, 2500, 3000, 4000, 4500, 3500, 3000, 2500, 2000],
        "Legal": [1500, 1000, 800, 1200, 800, 2000, 1500, 1000, 3000, 1200],
        "Misc": [1000, 1200, 1300, 1500, 1700, 1800, 2000, 2200, 2500, 2800]
    }
    
    # Create DataFrame
    df = pd.DataFrame(cash_flow_data)
    
    # Add calculated fields
    df["Total_Expenses"] = df[["Payroll", "Marketing", "Office", "Software", "Travel", "Legal", "Misc"]].sum(axis=1)
    df["Net_Burn"] = df["Total_Expenses"] - df["Revenue"]
    
    return df

def generate_sample_transactions_data():
    """
    Generate sample transactions data for demonstration
    
    Returns:
        pd.DataFrame: Sample transactions DataFrame
    """
    transactions = pd.DataFrame([
        {"Date": "2023-11-05", "Category": "Travel", "Vendor": "Caribbean Cruises", "Amount": 8500, "Description": "Team Retreat Planning", "Flag": "Suspicious"},
        {"Date": "2023-11-12", "Category": "Marketing", "Vendor": "LuxuryGifts Inc", "Amount": 4200, "Description": "Client Appreciation", "Flag": "Suspicious"},
        {"Date": "2023-11-22", "Category": "Office", "Vendor": "Premium Furniture", "Amount": 12000, "Description": "Office Upgrades", "Flag": "Suspicious"},
        {"Date": "2023-11-28", "Category": "Consulting", "Vendor": "Strategic Vision LLC", "Amount": 7500, "Description": "Strategy Consulting", "Flag": "Suspicious"},
        {"Date": "2023-12-05", "Category": "Software", "Vendor": "Personal Apple Store", "Amount": 3200, "Description": "Development Tools", "Flag": "Suspicious"},
        {"Date": "2023-12-12", "Category": "Legal", "Vendor": "Anderson Brothers", "Amount": 5800, "Description": "Legal Services", "Flag": "Normal"},
        {"Date": "2023-12-20", "Category": "Payroll", "Vendor": "November Payroll", "Amount": 75000, "Description": "Monthly Payroll", "Flag": "Normal"},
        {"Date": "2023-12-22", "Category": "Marketing", "Vendor": "Google Ads", "Amount": 8000, "Description": "Ad Campaign", "Flag": "Normal"},
        {"Date": "2023-12-25", "Category": "Office", "Vendor": "WeWork", "Amount": 5000, "Description": "Monthly Rent", "Flag": "Normal"},
        {"Date": "2023-12-28", "Category": "Software", "Vendor": "AWS", "Amount": 5200, "Description": "Cloud Services", "Flag": "Normal"}
    ])
    
    return transactions