From ef99063dae005c8fb8a819c8f1341f78b14bea44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Sun, 5 Jan 2025 17:38:26 -0300 Subject: [PATCH] config items --- config.json | 38 ++++++++++ libraries/wrappers/earn_binance.py | 2 +- libraries/wrappers/earn_okx.py | 1 - main.py | 110 ++++++++++------------------- notes.txt | 67 ++++++++++++++++++ 5 files changed, 145 insertions(+), 73 deletions(-) create mode 100644 config.json create mode 100644 notes.txt diff --git a/config.json b/config.json new file mode 100644 index 0000000..4726623 --- /dev/null +++ b/config.json @@ -0,0 +1,38 @@ +{ + "exchanges": { + "binance": { + "currency": "USDT", + "minimum_amount_in_trading_account": 1000, + "step_size": 500, + "percentage": 0.5, + "time_between_subscriptions": 3600, + "time_between_redemptions": 0 + }, + "gateio": { + "currency": "USDT", + "minimum_amount_in_trading_account": 1000, + "step_size": 500, + "percentage": 0.5, + "time_between_subscriptions": 3600, + "time_between_redemptions": 0 + }, + "kucoin": { + "currency": "USDT", + "minimum_amount_in_trading_account": 1000, + "step_size": 500, + "percentage": 0.5, + "time_between_subscriptions": 3600, + "time_between_redemptions": 0 + }, + "okx": { + "currency": "USDT", + "minimum_amount_in_trading_account": 1000, + "step_size": 500, + "percentage": 0.5, + "time_between_subscriptions": 3600, + "time_between_redemptions": 0 + } + }, + "lap_time": 10 + +} \ No newline at end of file diff --git a/libraries/wrappers/earn_binance.py b/libraries/wrappers/earn_binance.py index aca9fb3..834fd25 100644 --- a/libraries/wrappers/earn_binance.py +++ b/libraries/wrappers/earn_binance.py @@ -1,7 +1,7 @@ ''' https://github.com/binance/binance-connector-python/blob/master/binance/spot/_simple_earn.py - ''' + from credentials import get_api_key from binance.spot import Spot as Client from binance.error import ClientError diff --git a/libraries/wrappers/earn_okx.py b/libraries/wrappers/earn_okx.py index 7370cd4..ee6acc0 100644 --- a/libraries/wrappers/earn_okx.py +++ b/libraries/wrappers/earn_okx.py @@ -2,7 +2,6 @@ https://www.okx.com/docs-v5/en/#financial-product-simple-earn-flexible https://github.com/okxapi/python-okx/blob/master/okx/Earning.py - ''' import okx.Earning as Earning diff --git a/main.py b/main.py index 05677d1..72b7d03 100644 --- a/main.py +++ b/main.py @@ -3,85 +3,53 @@ 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 -kucoin = earn_kucoin.kucoin_earn() -binance = earn_binance.binance_earn() -okx = earn_okx.okx_earn() -gateio = earn_gateio.gateio_earn() +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__": - ''' - Subscribe workflow in Binance: - 1. Get product id - 2. Subscribe + with open("config.json") as f: + config = json.load(f) - Redeem workflow in Binance - 1. Redeem with the same product id - ''' - #print(binance.get_available_products("USDT")) - #print(binance.subscribe_product("USDT001", "10", auto_subscribe=False)) - #print(binance.get_position("USDT")) - #print(binance.redeem_product("USDT001", amount="10")) + 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])) - - ''' - Subscribe workflow in Kucoin - 1. Get product id - 2. Subscribe - - Redeem workflow in Kucoin - 1. Get ORDER id (the order id of the position) - 2. Redeem - ''' - #print(kucoin.get_available_products("USDT")) - #print(kucoin.subscribe_product("2152", "10")) - #print(kucoin.get_position("USDT")) - #print(kucoin.redeem_product(order_id="2987632", amount="10")) - - - ''' - Subscribe workflow in OKX - 1. Transfer funds to funding account - 2. Confirm transfer via transfer_id - 3. Subscribe - - Redeem workflow in OKX - 1. Reddem product (with coin, no id is required) - 2. Transfer funds to trading account - 3. Confirm transfer via transfer_id - - ''' - #print(okx.get_available_products("USDT")) - #print(okx.transfer_to_funding("USDT","10")) - #print(okx.get_transfer_state("1064667293")) - #print(okx.subscribe_product("USDT", "10")) - #print(okx.get_position("USDT")) - #print(okx.redeem_product("USDT", "10")) - #print(okx.transfer_to_trading("USDT", "10")) - #print(okx.get_transfer_state("1064667720")) - - - ''' - Subscribe workflow in Gate.io - 1. Get minimum rate - 2. Subscribe product - 3. Use get_account to confirm (request returns error?) - - Redeem workflow in Gate.io - 1. Reddem product - 2. Use get_account to confirm (request returns error?) - ''' - - #print(gateio.get_min_rate("USDT")) - #print(gateio.subscribe_product("USDT", "10", "0.00000452")) - #print(gateio.get_position("USDT")) - #print(gateio.redeem_product("USDT", "10")) - - pass - + 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"]) diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..50d1752 --- /dev/null +++ b/notes.txt @@ -0,0 +1,67 @@ + ''' + Subscribe workflow in Binance: + 1. Get product id + 2. Subscribe + + Redeem workflow in Binance + 1. Redeem with the same product id + ''' + #print(binance.get_available_products("USDT")) + #print(binance.subscribe_product("USDT001", "10", auto_subscribe=False)) + #print(binance.get_position("USDT")) + #print(binance.redeem_product("USDT001", amount="10")) + + + + ''' + Subscribe workflow in Kucoin + 1. Get product id + 2. Subscribe + + Redeem workflow in Kucoin + 1. Get ORDER id (the order id of the position) + 2. Redeem + ''' + #print(kucoin.get_available_products("USDT")) + #print(kucoin.subscribe_product("2152", "10")) + #print(kucoin.get_position("USDT")) + #print(kucoin.redeem_product(order_id="2987632", amount="10")) + + + ''' + Subscribe workflow in OKX + 1. Transfer funds to funding account + 2. Confirm transfer via transfer_id + 3. Subscribe + + Redeem workflow in OKX + 1. Reddem product (with coin, no id is required) + 2. Transfer funds to trading account + 3. Confirm transfer via transfer_id + + ''' + #print(okx.get_available_products("USDT")) + #print(okx.transfer_to_funding("USDT","10")) + #print(okx.get_transfer_state("1064667293")) + #print(okx.subscribe_product("USDT", "10")) + #print(okx.get_position("USDT")) + #print(okx.redeem_product("USDT", "10")) + #print(okx.transfer_to_trading("USDT", "10")) + #print(okx.get_transfer_state("1064667720")) + + + ''' + Subscribe workflow in Gate.io + 1. Get minimum rate + 2. Subscribe product + 3. Use get_account to confirm (request returns error?) + + Redeem workflow in Gate.io + 1. Reddem product + 2. Use get_account to confirm (request returns error?) + ''' + + #print(gateio.get_min_rate("USDT")) + #print(gateio.subscribe_product("USDT", "10", "0.00000452")) + #print(gateio.get_position("USDT")) + #print(gateio.redeem_product("USDT", "10")) \ No newline at end of file