CyberPunkMetalHead / gateio-crypto-trading-bot-binance-announcements-new-coins

This is a crypto trading bot that scans the Binance Annoucements page for new coins, and places trades on Gateio
MIT License
1.22k stars 302 forks source link

implement telegram notifications #18

Closed HebelHuber closed 2 years ago

HebelHuber commented 3 years ago

Adds notifications via telegram bot.

Configuration is handled with the usual config file.

Configuration is done via environment variables.

~~I have another PR to allow config via env vars #17 which i hope can be merged. Then i would unify configuration for telegram as well.~~

HebelHuber commented 3 years ago

updated to work with #8

smuu commented 3 years ago

Great idea. That way we get notified if any trade is made, and we don't need to check the files/logs.

akrz commented 3 years ago

Can this be merged please?

pratikvelani commented 3 years ago

Great work @HebelHuber, can you add an option to lookup for the configurations from the config file.

HebelHuber commented 3 years ago

Great work @HebelHuber, can you add an option to lookup for the configurations from the config file.

Sure. I also added a way to automatically disable if it is not or wrongly configured. Config looks like this now;

  TRADE_OPTIONS:
    # In your pairing coin
    QUANTITY: 15
    # BTCUSDT will be bought for example
    PAIRING: USDT
    TEST: True
    # In %
    SL: -3
    TP: 2
    ENABLE_TSL: True
    TSL: -4
    TTP: 2
  LOGGING:
    # Logging levels used in this program are ERROR, INFO, and DEBUG
    LOG_LEVEL: INFO
    LOG_FILE: bot.log
  TELEGRAM:
    BOT_TOKEN: my_token
    BOT_CHAT_ID: my_chat_id
HebelHuber commented 2 years ago

@CyberPunkMetalHead what's your opinion?

DominicFrei commented 2 years ago

Are there similarities to https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/pull/48?

HebelHuber commented 2 years ago

It does the same thing, so there are similarities.

HebelHuber commented 2 years ago

Okay, I think I have the LoggingHandler setup, also moved telegram creds to auth.yml. It seems like my formatter messed with main.py, gonna fix

HebelHuber commented 2 years ago

Restored formatting main.py. Not so easy since there are a few lines that have weird whitespaces and other odditites... Since formatting is not the reason for this PR I reverted that and kept only the important changes.

HebelHuber commented 2 years ago

@DominicFrei thanks.
I think everything should be adressed.
Using the logger now instead of going a roundabout way.

Now the logger can be instructed to also send to telegram by providing an extra parameter called TELEGRAM.

logger.info("message",extra={'TELEGRAM': 'COIN_ANNOUNCEMENT'})

Then, only if this message type is set to True in config, a message will be sent. For telegram the loglevel is irrelevant, so that it can be used on info, warning, debug etc.

@Jrjy3 what do you think?

DominicFrei commented 2 years ago

Good job, @HebelHuber ! Thanks for the contribution. :)

HebelHuber commented 2 years ago

Thanks, happy to help!