From 7194dfc69210bbd97f957dd62f8802e31819f54b Mon Sep 17 00:00:00 2001 From: Jamie Wade Date: Sun, 29 Aug 2021 10:27:33 +0100 Subject: [PATCH 1/2] Renames variables --- PieBot.py | 10 +++++----- _config-example.py | 5 ++++- functions.py | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/PieBot.py b/PieBot.py index 251ef34..9630e18 100644 --- a/PieBot.py +++ b/PieBot.py @@ -18,13 +18,13 @@ def buy(pairs): print(colored("Placing orders...", "cyan")) total_portfolio_value = get_portfolio_value(pairs, True) - total_usdt_reserve = (total_portfolio_value / 100) * (usdt_reserve * 100) + total_stablecoin_reserve = (total_portfolio_value / 100) * (stablecoin_reserve * 100) - total_usdt_value = get_coin_balance("USDT") - total_usdt_available = total_usdt_value - total_usdt_reserve - required_usdt = buy_order_value * len(pairs) + total_stablecoin_value = get_coin_balance("USDT") + total_stablecoin_available = total_stablecoin_value - total_stablecoin_reserve + required_stablecoin = buy_order_value * len(pairs) - if required_usdt <= total_usdt_available: + if required_stablecoin <= total_stablecoin_available: for pair in pairs: order_value = buy_order_value diff --git a/_config-example.py b/_config-example.py index 404533d..d52a54e 100644 --- a/_config-example.py +++ b/_config-example.py @@ -2,6 +2,9 @@ api_key = "xxx" api_secret = "xxx" +# Set the stablecoin you want to trade with +stablecoin = "USDT" + # The list of coin pairs you want to trade with pair_list = [ ("ADA", "ADA_USDT"), @@ -26,4 +29,4 @@ # How much USDT do you want to keep as a reserve. This is a percentage of the total portfolio balance # 0.05 = 5% # 0.15 = 15% -usdt_reserve = 0.02 +stablecoin_reserve = 0.02 diff --git a/functions.py b/functions.py index 5f3319a..077a28e 100644 --- a/functions.py +++ b/functions.py @@ -38,10 +38,10 @@ def current_time(new_line): # Gets the total available value of the portfolio def get_available_portfolio_value(value): - # Keeps aside the defined USDT reserves - usdt_reserve_value = (value / 100) * (usdt_reserve * 100) + # Keeps aside the defined stablecoin reserves + stablecoin_reserve_value = (value / 100) * (stablecoin_reserve * 100) - total_available_balance = value - usdt_reserve_value + total_available_balance = value - stablecoin_reserve_value return total_available_balance @@ -93,7 +93,7 @@ def get_instrument(instruments, name): # Gets the total value of the portfolio -def get_portfolio_value(pairs, include_usdt): +def get_portfolio_value(pairs, include_stablecoin): total_balance = 0 for pair in pairs: @@ -105,11 +105,11 @@ def get_portfolio_value(pairs, include_usdt): total_balance = total_balance + (coin_balance * coin_price) - if include_usdt: + if include_stablecoin: # Get the total balance of USDT and add it to the current collected balance - usdt_total_balance = get_coin_balance("USDT") + stablecoin_total_balance = get_coin_balance("USDT") - total_balance = total_balance + usdt_total_balance + total_balance = total_balance + stablecoin_total_balance return total_balance @@ -236,15 +236,15 @@ def pre_flight_checks(): # Checks whether the USDT reserve amount has been defined try: - usdt_reserve + stablecoin_reserve except NameError: print(colored("Your USDT reserve amount is missing from the config file", "red")) sys.exit() else: - if usdt_reserve < 0: + if stablecoin_reserve < 0: print(colored("You need to define a valid USDT reserve. If you don't want to use a reserve, set the value as 0", "red")) sys.exit() - elif usdt_reserve > 80: + elif stablecoin_reserve > 80: print(colored("Your USDT reserve must be 80% or lower", "red")) sys.exit() From 437ce2bd221863cf3df15ec2006ab5b862ab55b5 Mon Sep 17 00:00:00 2001 From: Jamie Wade Date: Sun, 29 Aug 2021 10:36:47 +0100 Subject: [PATCH 2/2] Adjusts comments --- _config-example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_config-example.py b/_config-example.py index d52a54e..5452ded 100644 --- a/_config-example.py +++ b/_config-example.py @@ -23,10 +23,10 @@ buy_frequency = 6 rebalance_frequency = 1 -# The USDT value that PieBot will buy for each enabled coin pair in the "Buy" task +# The value in your chosen stablecoin that PieBot will buy for each enabled coin pair in the "Buy" task buy_order_value = 0.50 -# How much USDT do you want to keep as a reserve. This is a percentage of the total portfolio balance +# How much of your chosen stablecoin do you want to keep as a reserve. This is a percentage of the total portfolio balance # 0.05 = 5% # 0.15 = 15% stablecoin_reserve = 0.02