Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Telegram update every 5 (or X minutes) - that the bot is still alive #125

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 37 additions & 36 deletions src/config.example.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 started", extra={'TELEGRAM': 'START_WORKING'})


def buy():
Expand Down Expand Up @@ -464,4 +463,4 @@ def main():
if __name__ == '__main__':
logger.info('started working...')
main()
logger.info('stopped working...')
logger.info('coinbot stopped', extra={"TELEGRAM": "STOPPED_WORKING"})
13 changes: 11 additions & 2 deletions src/new_listings_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
client = load_gateio_creds('auth/auth.yml')
spot_api = SpotApi(ApiClient(client))


global supported_currencies

previously_found_coins = set()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -140,13 +141,17 @@ def search_and_update():
"""
Pretty much our main func
"""
counter = 0
botPostAllMinutes = 5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value should be configurable via the config,yml and not be hardcoded

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also have some value to disable it e.g. 0 or -1.

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)
Expand All @@ -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 / 3600)} hours - {str(counter/60)} minutes and {str(counter)} seconds")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the total runtime matter? Why is it printed here?

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": "START_WORKING"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should generally be done outside of the listings scraper functionality.
If you just want a sign that the bot is still running, there is no need to do it here.
I would prefer a separate thread which which utilises time.sleep instead of having a counter variable which requires unnecessary processing power



except Exception as e:
logger.info(e)
else:
Expand Down