diff --git a/libraries/earner.py b/libraries/earner.py index 3189fe1..4f57e42 100644 --- a/libraries/earner.py +++ b/libraries/earner.py @@ -2,6 +2,7 @@ import time import datetime from libraries.balance_accounts import balance_accounts from libraries.colors import colors +from decimal import Decimal, getcontext, ROUND_DOWN class earner: @@ -24,6 +25,9 @@ class earner: self.is_paused = False self.status_string = "" + + getcontext().prec = 8 + getcontext().rounding = ROUND_DOWN def __str__(self): @@ -215,20 +219,20 @@ class earner: paused_string = "" if not self.is_paused: - target_trading_amount, target_earning_amount = balance_accounts(float(self.trading_balance), - float(self.earning_balance), - self.minimum_amount_in_trading_account, - self.step_size, - self.percentage) - earning_delta = 0 + target_trading_amount, target_earning_amount = balance_accounts(Decimal(self.trading_balance), + Decimal(self.earning_balance), + Decimal(self.minimum_amount_in_trading_account), + Decimal(self.step_size), + Decimal(self.percentage)) + earning_delta = Decimal(0) if self.earning_balance is None: print(f"{str(self.connector).upper()} - There was an error fetching earning balance") else: if float(self.earning_balance)!=0: - earning_delta = target_earning_amount - float(self.earning_balance) - if earning_delta>self.step_size and time.time()-self.last_subscription_time>self.time_between_subscriptions: + earning_delta = target_earning_amount - Decimal(self.earning_balance) + if earning_delta>Decimal(self.step_size) and time.time()-self.last_subscription_time>self.time_between_subscriptions: self.subscribe(earning_delta) - if earning_delta<-self.step_size and time.time()-self.last_redemption_time>self.time_between_redemptions: + if earning_delta<-Decimal(self.step_size) and time.time()-self.last_redemption_time>self.time_between_redemptions: self.redeem(-earning_delta) #print(f"{str(self.connector)} - Difference: {earning_delta}") else: diff --git a/main.py b/main.py index 1b0fe7f..393c86e 100644 --- a/main.py +++ b/main.py @@ -104,7 +104,7 @@ def main(): total_funds = total_on_earning+total_on_trading time_of_day = datetime.datetime.now().strftime('[%Y/%m/%d %H:%M:%S]') print(f"Last subscription: {last_subscription_key}{last_subscription_value} | Last redemption: {last_redemption_key}{last_redemption_value}") - print(f"Version {version} | Total funds: {total_funds:.2f} | On earn: {total_on_earning:.2f} ({total_on_earning/total_funds*100:.2f}%)") + print(f"Version {version} | Total funds: {total_funds:.2f} USDT | On earn: {total_on_earning:.2f} USDT ({total_on_earning/total_funds*100:.2f}%)") print(f"{time_of_day} | Uptime: {seconds_to_time(time.time()-start_time)}") print(colors.blue+"="*80+colors.white) #Wait for next lap @@ -395,7 +395,7 @@ def run_API(port): if __name__=="__main__": - version = "2025.01.08" + version = "2025.01.09" start_time = time.time() with open("config.json") as f: