Last active
September 18, 2021 16:33
-
-
Save Bilaboz/56572e81ace7b47d4302d6f5840118aa to your computer and use it in GitHub Desktop.
Rollercoin profit calculator
This file contains 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
import json | |
import urllib.request | |
current_hashrate = float(input("Your hashrate (TH/s): ")) | |
network_powers = [float(input("BTC network power (EH/s): ")), float(input("DOGE network power (EH/s): ")), float(input("ETH network power (EH/s): "))] | |
rewards = [0.00009, 240, 0.0017] | |
names = ["BTC", "DOGE", "ETH"] | |
r = urllib.request.urlopen("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin%2Cdogecoin%2Cethereum&vs_currencies=usd") | |
data = json.loads(r.read()) | |
prices = [data["bitcoin"]["usd"], data["dogecoin"]["usd"], data["ethereum"]["usd"]] | |
current_hashrate /= 1000000 | |
earnings = [] | |
for i, (network_power, reward, price) in enumerate(zip(network_powers, rewards, prices)): | |
currency_gain = reward * (current_hashrate / network_power) | |
earnings.append(currency_gain * float(price)) | |
max_index = earnings.index(max(earnings)) | |
print("\n---------------------------\n\n{} is the most profitable\n{}$ per block\n".format(names[max_index], earnings[max_index])) | |
input("Press enter to close") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment