Skip to content

BitcoinCoderBob/Mining-Opportunity-Cost-Calculator

Repository files navigation

Mining-Opportunity-Cost-Calculator

Run this go program with the flags and you will get command line output stats as well as a generated points.png file generated in the root of this repo.

Note only the cli folder is fit to use for cli usage, the pkg folder is being used as a server to serve up the data/chart since eventually this may run somewhere and support a front end. If you want to run the server, head to the bottom of this page for instructions.

Not that your slush token does expire after some time, and using an expired token will results in the calls to fail. Also note that using a slush token is optional, if you know your total amount of bitcoin mined just use the -bitcoinMined flag instead.

Flags

  • -token slush pool token (https://slushpool.com/settings/access/) you can use this flag or the -bitcoinMined flag if you dont use slush
  • -startDate mm/dd/yyyy format for start date of mining operation
  • -kwhPrice price paid per kilowatt-hour
  • -watts watts used by the miers
  • -electricCosts if you know your total amount spent on electric, can use it here instead of kwhPrice and watts and uptimePercent
  • -uptimePercent percent of time mining operation is online (expressed as an integer)
  • -fixedCosts total costs of miners, hardware, and other operational fixed costs
  • -bitcoinMined amount of bitcoin mined (whole bitcoin units not sats)
  • -messariApiKey api key from messari.io for historical price data
  • -hideBitcoinOnGraph Will hide bitcoin on y-axis of graph, good for opsec when sharing the image. true to hide, false to keep the figure displayed

Run this from within the cli folder.

Example with token: go run main.go -token abc123 -startDate 01/01/2022 -kwhPrice .14 -watts 3300 -uptimePercent 98 -fixedCosts 7500 -hideBitcoinOnGraph=true

Example without token and with known total electric costs: go run main.go -bitcoinMined 0.420 -startDate 01/01/2022 -electricCosts 3400 -fixedCosts 7500

Output (these are made up figures for the example here):

Bicoin current price: $35947.77
Days since start: 420.93
Average coins per day: 0.00040153
Dollarinos earned: $4931.38
Total electric costs: $2231.03
Percent paid off: 68.88%
Bitcoin percentage increase needed to be breakeven: 49.53%
Breakeven price: $63751.70
Expected more days until breakeven: 128.57
Total mining days (past + future) to breakeven: 549.50
Expected breakeven date: 11/21/2022


------------------------------------------------

Electric costs per day: $8.64
bitcoin mined: 0.155
AmericanHodl: 0.1500202135019427
Daily-DCA: 0.19892472898958916
Anti-Miner: 0.16783636213105427


------------------------------------------------

Percentage comparison of strategies versus mining. 

Daily-DCA: 21.56%
Anti-Miner: 2.65%
AmericanHodl: -9.08%

Example output plot

Lines Explained

  • AmericanHodl - This strategy is if on the first day you slam bought all the bitcoin with all the fiat. This fiat amount is the sum of your mining operations fixed costs plus all the costs in electricity usage
  • DCA Short for "Dollar cost averaging" this strategy refers to taking the sum of the fixed and varialbe costs (electric), dividing this number by total number of days since mining started, and stacked that amount of dollars worth of bitcoin each day. (daily DCA strategy)
  • Anti-Miner This strategy refers to the person who spend an equal number of dollars on bitcoin purchasing each time the miner spends money on a cost. So on the first day, they buy the amount of bitcoin (in fiat terms) equal to the amount for the mining operation's fixed cost setup. Each day after they purchase the amount of bitcoin equal to the amount the miner spent of electricity that day
  • Mined This line represents total bitcoin mined. This tool does not yet support entering amount miner per day to generate a proper historical line, and really should be represented as a singular point all the way on the last day of the x-axis. However, that becomes visually hard to see and for optics I simply had it plot as the entire width of the axis.
  • Server Instructions

    This can be run as a server from the root of this repo.

    Bring up ther server with go run main.go

    There are two endpoint: /data and /chart where /data will return the text data you would see if you used the CLI, and /data yields the chart the CLI also generates.

    Ping localhost:8080/data or localhost:8080/data with a json body that may look something like:

    {
      "bitcoinMined": 0.12345,
      "startDate": "06/30/2021",
      "fixedCosts": 5000,
      "hideBitcoinOnGraph": false,
      "electricCosts": 3000.45
    }
    

    Here's a curl command for example:

    curl -i -H "Accept: application/json" -H "Content-Type: application/json" -d '{"bitcoinMined": 0.12345, "startDate":"06/30/2021", "fixedCosts":5000, "hideBitcoinOnGraph":false, "kwhPrice": 0.1133, "watts": 3400, "uptimePercent": 99 }' -X POST http://localhost:8080/chart
    
    

    About

    No description, website, or topics provided.

    Resources

    License

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published