Created
May 6, 2021 22:21
-
-
Save nsa-yoda/6296ab7dedb13454c212d47edbd301de to your computer and use it in GitHub Desktop.
Crypto Profit Calculator https://replit.com/@jsanc623/GlossyDependentAfkgaming#main.py
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 locale | |
from dataclasses import dataclass | |
@dataclass | |
class ProfitCalculator(): | |
label: str | |
buy: float | |
sell: float | |
usd_amount: float | |
profit: float = 0.00 | |
def calculate_profit(self, just_gross: bool=False) -> float: | |
gross_profit: float = self.sell * (self.usd_amount / self.buy) | |
net_profit: float = gross_profit - self.usd_amount | |
self.profit = gross_profit if just_gross else net_profit | |
return self.profit | |
def print(self) -> None: | |
locale.setlocale(locale.LC_ALL, '') | |
formatted = locale.currency(self.profit, grouping=True) | |
print(f"{self.label} <> {formatted}") | |
# Bonfire | |
bonfire = ProfitCalculator("Bonfire", 0.000000125458, 0.01, 250) | |
bonfire.calculate_profit() | |
bonfire.print() | |
# Happy | |
happy = ProfitCalculator("Happy", 0.0000000254551, 0.01, 250) | |
happy.calculate_profit() | |
happy.print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment