From c4c26b27e9bab0cf5a426fffc2bca5d97316c0a6 Mon Sep 17 00:00:00 2001 From: CodeLax IT GmbH Karl Date: Wed, 22 Dec 2021 13:30:01 +0100 Subject: [PATCH 1/5] Add Telegram update every 5 (or X minutes) - that the bot is still alive --- src/main.py | 7 +++---- src/new_listings_scraper.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main.py b/src/main.py index bec54ec..556e5ea 100644 --- a/src/main.py +++ b/src/main.py @@ -40,14 +40,13 @@ # Keep the supported currencies loaded in RAM so no time is wasted fetching # currencies.json from disk when an announcement is made -global supported_currencies +global supported_currencies logger.debug("Starting get_all_currencies") supported_currencies = get_all_currencies(single=True) logger.debug("Finished get_all_currencies") - -logger.info("new-coin-bot online", extra={'TELEGRAM': 'STARTUP'}) +logger.info("coinbot is online", extra={'TELEGRAM': 'STARTUP'}) def buy(): @@ -464,4 +463,4 @@ def main(): if __name__ == '__main__': logger.info('started working...') main() - logger.info('stopped working...') + logger.info('coinbot is offline', extra={"TELEGRAM": "STOPPED_WORKING"}) diff --git a/src/new_listings_scraper.py b/src/new_listings_scraper.py index 510deef..ac9e094 100644 --- a/src/new_listings_scraper.py +++ b/src/new_listings_scraper.py @@ -21,6 +21,7 @@ client = load_gateio_creds('auth/auth.yml') spot_api = SpotApi(ApiClient(client)) + global supported_currencies previously_found_coins = set() @@ -101,7 +102,7 @@ def get_last_coin(): uppers = None # returns nothing if it's an old coin or it's not an actual coin listing - if 'Will List' not in latest_announcement or found_coin[0] == globals.latest_listing or \ + if 'Binance Will List' not in latest_announcement or found_coin[0] == globals.latest_listing or \ found_coin[0] in previously_found_coins: # if the latest Binance announcement is not a new coin listing, or the listing has already been returned, check kucoin @@ -140,13 +141,17 @@ def search_and_update(): """ Pretty much our main func """ + counter = 0 + botPostAllMinutes = 5 while not globals.stop_threads: sleep_time = 3 + for x in range(sleep_time): time.sleep(1) if globals.stop_threads: break try: + counter+= 3 latest_coin = get_last_coin() if latest_coin: store_new_listing(latest_coin) @@ -155,7 +160,11 @@ def search_and_update(): if os.path.isfile('test_new_listing.json.used'): os.remove('test_new_listing.json.used') os.rename('test_new_listing.json', 'test_new_listing.json.used') - logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread)") + logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter)} seconds or {str(counter/60)} minutes") + if counter / 60 == botPostAllMinutes: + logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "STARTUP"}) + + except Exception as e: logger.info(e) else: From 37026a900c560b201b0fcee5c929ca1cf0ec4692 Mon Sep 17 00:00:00 2001 From: CodeLax IT GmbH Karl Date: Wed, 22 Dec 2021 13:52:52 +0100 Subject: [PATCH 2/5] fixed calculation problem with the timer --- src/new_listings_scraper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/new_listings_scraper.py b/src/new_listings_scraper.py index ac9e094..eb9a4e2 100644 --- a/src/new_listings_scraper.py +++ b/src/new_listings_scraper.py @@ -161,7 +161,7 @@ def search_and_update(): os.remove('test_new_listing.json.used') os.rename('test_new_listing.json', 'test_new_listing.json.used') logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter)} seconds or {str(counter/60)} minutes") - if counter / 60 == botPostAllMinutes: + if ((counter / 60) % botPostAllMinutes) == 0: logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "STARTUP"}) From 5e36dcdf0e5c98ea4655e22b0f72fcd301478012 Mon Sep 17 00:00:00 2001 From: CodeLax IT GmbH Karl Date: Wed, 22 Dec 2021 14:01:19 +0100 Subject: [PATCH 3/5] Formatting the sentence. --- src/new_listings_scraper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/new_listings_scraper.py b/src/new_listings_scraper.py index eb9a4e2..ddcb6bb 100644 --- a/src/new_listings_scraper.py +++ b/src/new_listings_scraper.py @@ -160,7 +160,7 @@ def search_and_update(): if os.path.isfile('test_new_listing.json.used'): os.remove('test_new_listing.json.used') os.rename('test_new_listing.json', 'test_new_listing.json.used') - logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter)} seconds or {str(counter/60)} minutes") + logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter / 360)} hours - {str(counter/60)} minutes and {str(counter)} seconds") if ((counter / 60) % botPostAllMinutes) == 0: logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "STARTUP"}) From f84a98903b6adf32d447d4b13f23b7c7b24380cf Mon Sep 17 00:00:00 2001 From: CodeLax Date: Wed, 22 Dec 2021 14:24:48 +0100 Subject: [PATCH 4/5] Fixed Hours calcualtion --- src/new_listings_scraper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/new_listings_scraper.py b/src/new_listings_scraper.py index ddcb6bb..e24854f 100644 --- a/src/new_listings_scraper.py +++ b/src/new_listings_scraper.py @@ -160,7 +160,7 @@ def search_and_update(): if os.path.isfile('test_new_listing.json.used'): os.remove('test_new_listing.json.used') os.rename('test_new_listing.json', 'test_new_listing.json.used') - logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter / 360)} hours - {str(counter/60)} minutes and {str(counter)} seconds") + logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter / 3600)} hours - {str(counter/60)} minutes and {str(counter)} seconds") if ((counter / 60) % botPostAllMinutes) == 0: logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "STARTUP"}) From 2663934fc375d49a315f3688f740c8f0a95ced0b Mon Sep 17 00:00:00 2001 From: CodeLax Date: Wed, 22 Dec 2021 20:02:49 +0100 Subject: [PATCH 5/5] make it more consistend regarding the naming --- src/config.example.yml | 73 +++++++++++++++++++------------------ src/main.py | 4 +- src/new_listings_scraper.py | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/config.example.yml b/src/config.example.yml index 9ccc4b6..577d633 100644 --- a/src/config.example.yml +++ b/src/config.example.yml @@ -1,37 +1,38 @@ --- - TRADE_OPTIONS: - # QUANTITY and PAIRING determine how much of your wallet value will be used to buy the new token. - # 'QUANTITY: 15' and 'PAIRING: USDT' means you will spend 15 USDT to buy XXX_USDT where XXX is the new token. - KUCOIN_ANNOUNCEMENTS: False - QUANTITY: 15 - PAIRING: USDT - # Test mode. No real money will be used. - TEST: True - # Stop Loss in % of your buy value. - SL: -3 - # Take Profit in % of your buy value. - TP: 2 - # DO NOT DISABLE TSL!!!! YOUR BOT WILL NOT SELL - ENABLE_TSL: True - # Trailing Stop Loss - TSL: -4 - # Trailing Take Profit - TTP: 2 - LOGGING: - # Logging levels used in this program are ERROR, INFO, and DEBUG - LOG_LEVEL: INFO - LOG_FILE: bot.log - LOG_TO_CONSOLE: True - TELEGRAM: - # set to True to enable telegram notifications - ENABLED: False - # Disable / Enable specific notifications - NOTIFICATIONS: - STARTUP: True # welcome message - COIN_ANNOUNCEMENT: True # detected new announcement - COIN_NOT_SUPPORTED: True # coin is not on gate.io - BUY_START: True # when entering position - BUY_ORDER_CREATED: True # when buy order is created - BUY_FILLED: True # when the buy order got filled - SELL_START: True # when starting to sell - SELL_FILLED: True # when sold +TRADE_OPTIONS: + # QUANTITY and PAIRING determine how much of your wallet value will be used to buy the new token. + # 'QUANTITY: 15' and 'PAIRING: USDT' means you will spend 15 USDT to buy XXX_USDT where XXX is the new token. + KUCOIN_ANNOUNCEMENTS: False + QUANTITY: 15 + PAIRING: USDT + # Test mode. No real money will be used. + TEST: True + # Stop Loss in % of your buy value. + SL: -3 + # Take Profit in % of your buy value. + TP: 2 + # DO NOT DISABLE TSL!!!! YOUR BOT WILL NOT SELL + ENABLE_TSL: True + # Trailing Stop Loss + TSL: -4 + # Trailing Take Profit + TTP: 2 +LOGGING: + # Logging levels used in this program are ERROR, INFO, and DEBUG + LOG_LEVEL: INFO + LOG_FILE: bot.log + LOG_TO_CONSOLE: True +TELEGRAM: + # set to True to enable telegram notifications + ENABLED: False + # Disable / Enable specific notifications + NOTIFICATIONS: + START_WORKING: True # welcome message + STOPPED_WORKING: True # Stopped Working Message + COIN_ANNOUNCEMENT: True # detected new announcement + COIN_NOT_SUPPORTED: True # coin is not on gate.io + BUY_START: True # when entering position + BUY_ORDER_CREATED: True # when buy order is created + BUY_FILLED: True # when the buy order got filled + SELL_START: True # when starting to sell + SELL_FILLED: True # when sold diff --git a/src/main.py b/src/main.py index 556e5ea..08d3f0e 100644 --- a/src/main.py +++ b/src/main.py @@ -46,7 +46,7 @@ logger.debug("Starting get_all_currencies") supported_currencies = get_all_currencies(single=True) logger.debug("Finished get_all_currencies") -logger.info("coinbot is online", extra={'TELEGRAM': 'STARTUP'}) +logger.info("coinbot started", extra={'TELEGRAM': 'START_WORKING'}) def buy(): @@ -463,4 +463,4 @@ def main(): if __name__ == '__main__': logger.info('started working...') main() - logger.info('coinbot is offline', extra={"TELEGRAM": "STOPPED_WORKING"}) + logger.info('coinbot stopped', extra={"TELEGRAM": "STOPPED_WORKING"}) diff --git a/src/new_listings_scraper.py b/src/new_listings_scraper.py index e24854f..f586bff 100644 --- a/src/new_listings_scraper.py +++ b/src/new_listings_scraper.py @@ -162,7 +162,7 @@ def search_and_update(): os.rename('test_new_listing.json', 'test_new_listing.json.used') logger.info(f"Checking for coin announcements every {str(sleep_time)} seconds (in a separate thread) - bot is running for {str(counter / 3600)} hours - {str(counter/60)} minutes and {str(counter)} seconds") if ((counter / 60) % botPostAllMinutes) == 0: - logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "STARTUP"}) + logger.info(f"Bot is still running for {str(counter/60)} minutes - will give live sign in {str(botPostAllMinutes)} Minutes again.", extra={"TELEGRAM": "START_WORKING"}) except Exception as e: