This commit is contained in:
Nicolás Sánchez 2025-01-09 08:06:45 -03:00
parent 123a0daf7f
commit e7374b1586
2 changed files with 15 additions and 11 deletions

View File

@ -2,6 +2,7 @@ import time
import datetime import datetime
from libraries.balance_accounts import balance_accounts from libraries.balance_accounts import balance_accounts
from libraries.colors import colors from libraries.colors import colors
from decimal import Decimal, getcontext, ROUND_DOWN
class earner: class earner:
@ -25,6 +26,9 @@ class earner:
self.status_string = "" self.status_string = ""
getcontext().prec = 8
getcontext().rounding = ROUND_DOWN
def __str__(self): def __str__(self):
return str(self.connector) return str(self.connector)
@ -215,20 +219,20 @@ class earner:
paused_string = "" paused_string = ""
if not self.is_paused: if not self.is_paused:
target_trading_amount, target_earning_amount = balance_accounts(float(self.trading_balance), target_trading_amount, target_earning_amount = balance_accounts(Decimal(self.trading_balance),
float(self.earning_balance), Decimal(self.earning_balance),
self.minimum_amount_in_trading_account, Decimal(self.minimum_amount_in_trading_account),
self.step_size, Decimal(self.step_size),
self.percentage) Decimal(self.percentage))
earning_delta = 0 earning_delta = Decimal(0)
if self.earning_balance is None: if self.earning_balance is None:
print(f"{str(self.connector).upper()} - There was an error fetching earning balance") print(f"{str(self.connector).upper()} - There was an error fetching earning balance")
else: else:
if float(self.earning_balance)!=0: if float(self.earning_balance)!=0:
earning_delta = target_earning_amount - float(self.earning_balance) earning_delta = target_earning_amount - Decimal(self.earning_balance)
if earning_delta>self.step_size and time.time()-self.last_subscription_time>self.time_between_subscriptions: if earning_delta>Decimal(self.step_size) and time.time()-self.last_subscription_time>self.time_between_subscriptions:
self.subscribe(earning_delta) 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) self.redeem(-earning_delta)
#print(f"{str(self.connector)} - Difference: {earning_delta}") #print(f"{str(self.connector)} - Difference: {earning_delta}")
else: else:

View File

@ -104,7 +104,7 @@ def main():
total_funds = total_on_earning+total_on_trading total_funds = total_on_earning+total_on_trading
time_of_day = datetime.datetime.now().strftime('[%Y/%m/%d %H:%M:%S]') 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"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(f"{time_of_day} | Uptime: {seconds_to_time(time.time()-start_time)}")
print(colors.blue+"="*80+colors.white) print(colors.blue+"="*80+colors.white)
#Wait for next lap #Wait for next lap
@ -395,7 +395,7 @@ def run_API(port):
if __name__=="__main__": if __name__=="__main__":
version = "2025.01.08" version = "2025.01.09"
start_time = time.time() start_time = time.time()
with open("config.json") as f: with open("config.json") as f: