// Bitcoin mining profitability calculation // Units of measure [] type USD [] type BTC [] type sec [] type hour [] type H [] type GH [] type Watt [] type KW // Unit conversions let hashesPerGH : float = 1000000000.0 let secondsPerHour : float = 3600.0 let wattsperKilowatt = 1000.0 // Specification of S9 Antminer let unit_hash_power = 13000.0 let unit_consumption = 1375.0 let unit_cost = 2100.0 // miner cost + 200.0 // psu cost let hash_rate = unit_hash_power * hashesPerGH // Difficulty is recalculated every 2016 blocks (~ 14 days) let difficulty = 440779902287.0 // Block time solo mining let block_time : float = difficulty * (2.0 ** 32.0) / (hash_rate * secondsPerHour) // How many miners you need to mine 1 block per day let number_of_miners = block_time / 24.0 // Is it profitable ? let psu_efficiency = 0.97 // 97% let electricity_price = 0.12/wattsperKilowatt let btc_price = 1157.00 // Bitcoin price let block_reward = 12.5 let daily_power_consumption = number_of_miners * unit_consumption * 24.0 / psu_efficiency let daily_electricity_cost = daily_power_consumption * electricity_price let daily_profit = block_reward*btc_price - daily_electricity_cost // Hardware cost. let hardware_cost = unit_cost * number_of_miners // Asuming it is profitable, daily_profit > 0.0 let months_to_roi = hardware_cost / (daily_profit * 30.0)