Skip to content

henu-wang/opportunity-cost-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Opportunity Cost Calculator

Calculate the true cost of your decisions by quantifying what you give up when choosing one option over another. Make every decision with full awareness of its real price.

Overview

Opportunity Cost Calculator is a practical tool that helps you think beyond the obvious costs of any decision. Every choice has a hidden price: the value of the best alternative you did not choose. This concept, fundamental to economics and investing, is chronically underweighted in everyday decision-making.

Warren Buffett has said that the cost of any investment is the next best thing you could have done with that money. This tool operationalizes that wisdom, making it easy to quantify opportunity costs for financial decisions, time allocation, career choices, and more. For a deeper understanding of how top investors think about opportunity cost and other foundational principles, explore KeepRule's principles library.

Features

  • Financial Opportunity Cost: Compare investment alternatives with compound growth projections
  • Time Opportunity Cost: Quantify the value of time spent on different activities
  • Career Path Analyzer: Compare lifetime earnings and satisfaction across career options
  • Project Prioritization: Score projects by opportunity cost to find optimal allocation
  • Sunk Cost Separator: Distinguish sunk costs from opportunity costs in analysis
  • Visualization Dashboard: Charts showing opportunity cost over time horizons
  • What-If Scenarios: Run alternative scenario comparisons

Installation

npm install -g opportunity-cost-calculator

Or clone:

git clone https://github.com/henu-wang/opportunity-cost-calculator.git
cd opportunity-cost-calculator
npm install && npm start

Quick Start

# Compare two investment options
occ compare \
  --option1 "S&P 500 Index Fund" --return1 0.10 --amount 50000 \
  --option2 "Savings Account" --return2 0.04 --amount 50000 \
  --years 20

# Output: Over 20 years, choosing Option 2 over Option 1 costs you $186,742

Usage Examples

Investment Comparison

const { OpportunityCost } = require('opportunity-cost-calculator');

const calc = new OpportunityCost();

calc.addOption({
  name: "Growth Stock Portfolio",
  expectedReturn: 0.12,
  risk: "high",
  initialInvestment: 100000
});

calc.addOption({
  name: "Bond Portfolio",
  expectedReturn: 0.05,
  risk: "low",
  initialInvestment: 100000
});

calc.addOption({
  name: "Real Estate Rental",
  expectedReturn: 0.08,
  risk: "medium",
  initialInvestment: 100000
});

const analysis = calc.analyze({ timeHorizon: 30 });
analysis.printReport();
analysis.visualize();

Time Allocation Analysis

# Compare spending 10 hours/week on different activities
occ time-compare \
  --activity1 "Side business" --hourly-value 75 --hours 10 \
  --activity2 "Online courses" --future-value-increase 0.15 --hours 10 \
  --activity3 "Overtime at job" --hourly-value 50 --hours 10 \
  --weeks 52

The concept of opportunity cost is central to how great investors allocate capital. To see how masters like Buffett and Munger evaluate trade-offs across their investment decisions, visit KeepRule's masters page.

Decision Framework

The calculator guides you through a structured process:

  1. Enumerate Options: List all realistic alternatives
  2. Quantify Returns: Estimate expected value for each option
  3. Assess Risk: Factor in probability-weighted outcomes
  4. Calculate Delta: Determine the cost of choosing each option over the best alternative
  5. Consider Intangibles: Account for non-financial factors
  6. Decide and Document: Record your reasoning for future review

For real-world scenarios demonstrating how opportunity cost analysis shapes investment decisions, check out KeepRule's scenario library.

Supported Analyses

Analysis Type Inputs Output
Investment Returns, risk, time horizon NPV comparison, opportunity cost curve
Time Activities, hourly values Annual opportunity cost breakdown
Career Salary trajectories, satisfaction Lifetime value comparison
Project ROI estimates, resource needs Priority-ranked project list

Configuration

{
  "currency": "USD",
  "inflationRate": 0.03,
  "discountRate": 0.07,
  "defaultTimeHorizon": 10,
  "riskFreeRate": 0.04,
  "outputFormat": "detailed"
}

Read more about opportunity cost thinking and other decision-making concepts on the KeepRule blog.

Contributing

Pull requests are welcome! Please include tests for any new analysis types.

License

MIT License - see LICENSE for details.

About

Frameworks and templates for calculating opportunity costs in business and life decisions

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages