Created
December 2, 2025 20:02
-
-
Save karmanyaahm/f01002eda7de3ca0344ca8ea14a149b0 to your computer and use it in GitHub Desktop.
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
| # Storage service profit accumulation simulation | |
| # Variables (constants in uppercase) | |
| print("Cost Price: $0.50 for operations, $0.99 for backup (AWS Glacier), $6 for Backblaze object storage * taxes") | |
| COST_PRICE = 7.49 * 1.0825 # $/TB/month | |
| USER_CHARGE = 20 # $/TB/month | |
| print(f"Google Photos is $10/TB/month, we charge ${USER_CHARGE}") | |
| print("Optimistic 0% inflation in storage if drive prices keep falling") | |
| INFLATION_RATE = 0.00 # annual % # assume storage costs don't go up as storage gets cheaper | |
| print("Optimistic market returns 10%") | |
| MARKET_RETURNS = 0.10 # annual % | |
| USER_STORAGE = 1.0 # TB (assuming user has 1TB) | |
| SIMULATION_MONTHS = 55 # run for a fixed number of months | |
| USER_PAYS_UNTIL_MONTH = SIMULATION_MONTHS | |
| # Explicit monthly rates (derived from annual rates for clarity and auditability) | |
| MONTHLY_MARKET_RATE = MARKET_RETURNS / 12 | |
| MONTHLY_INFLATION_RATE = INFLATION_RATE / 12 | |
| # Initial values | |
| accumulated_profit = 0.0 | |
| free_storage = 0.0 | |
| month = 0 | |
| prev_free_storage = 0.0 | |
| cumulative_user_paid = 0.0 | |
| paid_tbs = 0.0 # total paid TB accumulated (1 TB per paying month) | |
| # Print current configuration/parameters | |
| print( | |
| f"Config: COST_PRICE=${COST_PRICE:.2f} | USER_CHARGE=${USER_CHARGE:.2f} | " | |
| f"INFLATION_RATE={INFLATION_RATE:.2%} | MARKET_RETURNS={MARKET_RETURNS:.2%}" | |
| ) | |
| print( | |
| f"User: USER_STORAGE={USER_STORAGE:.2f} TB | SIMULATION_MONTHS={SIMULATION_MONTHS}" | |
| ) | |
| # Table header with fixed-width columns | |
| header = ( | |
| f"{'Month':>5} | {'Accum. Profit':>15} | {'Paid TB':>8} | {'Free TB':>10} | " | |
| f"{'User paid (mo)':>14} | {'Profit (mo)':>12} | {'Monthly Cost':>13} | {'Inv Gain':>9} | " | |
| f"{'Δ free TB':>10} | {'User paid (cum)':>16}" | |
| ) | |
| print(header) | |
| print("-" * len(header)) | |
| while month < SIMULATION_MONTHS: | |
| month += 1 | |
| paid_tbs = USER_STORAGE if month <= USER_PAYS_UNTIL_MONTH else 0.0 | |
| monthly_user_paid = paid_tbs * USER_CHARGE | |
| # Costs reflect both paid TB and accumulated free TB | |
| monthly_cost = (paid_tbs or free_storage) * COST_PRICE | |
| month_investment_profit = accumulated_profit * MONTHLY_MARKET_RATE | |
| monthly_profit = monthly_user_paid + month_investment_profit - monthly_cost | |
| cumulative_user_paid += monthly_user_paid | |
| # Accumulate profit | |
| accumulated_profit_before = accumulated_profit | |
| accumulated_profit += monthly_profit | |
| # Invest accumulated profit at end of month (monthly compounding) | |
| accumulated_profit_after_invest = accumulated_profit * (1 + MONTHLY_MARKET_RATE) | |
| accumulated_profit *= (1 + MONTHLY_MARKET_RATE) | |
| if paid_tbs: | |
| free_storage = max(prev_free_storage, accumulated_profit * MONTHLY_MARKET_RATE / COST_PRICE) | |
| # Increase costs by inflation (using explicit monthly inflation rate) | |
| COST_PRICE *= (1 + MONTHLY_INFLATION_RATE) | |
| # Print month by month | |
| # Diff of accumulated free storage vs previous month | |
| monthly_free_storage_diff = free_storage - prev_free_storage | |
| # Column output printed above; no verbose variable labels. | |
| if not (month % 3): | |
| print( | |
| f"{month:5} | ${accumulated_profit:15.2f} | {paid_tbs:8.2f} | {free_storage:10.2f} | " | |
| f"${monthly_user_paid:14.1f} | ${monthly_profit:12.1f} | ${monthly_cost:13.2f} | ${month_investment_profit:9.2f} | " | |
| f"{monthly_free_storage_diff:10.4f} | ${cumulative_user_paid:16,.2f}" | |
| ) | |
| if prev_free_storage < 1 and free_storage > 1: | |
| print("=" * 30) | |
| USER_PAYS_UNTIL_MONTH = month | |
| prev_free_storage = free_storage | |
| # No infinite loop guard needed with fixed-month simulation | |
| print(f"\nRan for {SIMULATION_MONTHS} months. User paid for {USER_PAYS_UNTIL_MONTH} months ({USER_PAYS_UNTIL_MONTH / 12:.2f} years). Ended simulation with {free_storage:.2f}TB free storage.") | |
| # --------------------------------------------- | |
| # Notes for future refinements (see plan): | |
| # 1) Distinguish list value vs actual operating cost for free storage: | |
| # - storage_list_value = 7.0 # promised value per TB to users | |
| # - storage_operating_cost = cost_price # actual cost to deliver | |
| # Track both credited (list TB) and deliverable (cost TB). | |
| # | |
| # 2) Withdrawal policy options: | |
| # - Fixed-rate (current): withdraw a constant annual rate / 12. | |
| # - Growth-only: withdraw only monthly gains (profit + investment growth), avoid principal erosion. | |
| # - Need-based schedule: withdraw exactly what's needed to hit a target free-storage trajectory, capped by available funds. | |
| # - Threshold-triggered: start withdrawals only after a reserve floor is met. | |
| # - Dynamic hybrid: min(fixed-rate, growth-only) or min(fixed-rate, schedule-need). | |
| # | |
| # 3) Explicit monthly rates: implemented above for market, inflation, withdrawal. | |
| # | |
| # 4) Scenario controls & reporting: | |
| # - Inputs: user_storage_paid, cohort_size, churn, volatility of returns. | |
| # - Outputs per month: operating profit, investment gain, withdrawal, TB credited (list vs cost), updated costs. | |
| # | |
| # 5) Inflation & price adjustments: | |
| # - Consider indexing user_charge or periodic price reviews; margin compresses if costs inflate. | |
| # | |
| # 6) KPI alignment: | |
| # - Choose stopping condition: list TB vs cost TB reaching target. | |
| # | |
| # 7) Risk management: | |
| # - Minimum reserve, pause withdrawals in drawdowns, cap withdrawal to available funds. | |
| # | |
| # 8) Multi-user scaling: | |
| # - Simulate cohorts, acquisition, churn, usage growth. | |
| # | |
| # 9) Guardrails: | |
| # - Warn if monthly_profit < 0; cap withdrawal; avoid negative accumulated_profit. | |
| # --------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment