DCAv2Earn/main.py

56 lines
1.8 KiB
Python

import libraries.balance_accounts as balance_accounts
from libraries.wrappers import earn_binance
from libraries.wrappers import earn_kucoin
from libraries.wrappers import earn_okx
from libraries.wrappers import earn_gateio
from threading import Thread
import time
import json
class earner:
def __init__(self, connector, config):
self.connector = connector
self.currency = config["currency"]
self.minimum_amount_in_trading_account = config["minimum_amount_in_trading_account"]
self.step_size = config["step_size"]
self.percentage = config["percentage"]
self.time_between_subscriptions = config["time_between_subscriptions"]
self.time_between_redemptions = config["time_between_redemptions"]
self.last_subscription = 0
self.last_redemption = 0
def __str__(self):
return f"Earner for {self.connector} with {self.currency} and {self.minimum_amount_in_trading_account} minimum amount in trading account and {self.step_size} step size and {self.percentage} percentage"
def run(self):
print(self)
if __name__=="__main__":
with open("config.json") as f:
config = json.load(f)
connectors = {"binance": earn_binance.binance_earn(),
"gateio": earn_gateio.gateio_earn(),
"kucoin": earn_kucoin.kucoin_earn(),
"okx": earn_okx.okx_earn()}
earners = []
for item in config["exchanges"]:
earners.append(earner(connectors[item], config["exchanges"][item]))
while True:
threads = []
for item in earners:
threads.append(Thread(target=item.run))
for item in threads:
item.start()
for item in threads:
item.join()
time.sleep(config["lap_time"])