decimals
This commit is contained in:
parent
123a0daf7f
commit
e7374b1586
|
|
@ -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:
|
||||
|
|
|
|||
4
main.py
4
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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue