Skip to content

fedy97/telegram-crypto-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Crypto Bot

Build and Deploy

Features:

  • Built with TelegramBots in Java
  • Track Coingecko Portfolio (create it here, copy the public address and save it in the bot with /saveportfolio, or delete it with /deleteportfolio)
  • MongoDB Integration (save your coins buy price with /save,/delete,/deleteall and see their multipliers after have saved a portfolio)
  • Coingecko Trending coins with /trend command
  • Caching System
  • Telegram Authorization
  • Maven Build
  • Dockerized image
  • Deployable on VPS
  • Full CI/CD Flow with Actions
  • Withdraw funds/check chains/check balance/trade/deposit with Kucoin

Design Patterns:

  • Command (to handle the Telegram commands)
  • Singleton (to reuse objects and spare memory and for the caching system)
  • Decorator (authorization check for some commands)
  • Proxy (caching system)
  • Flyweight (caching system)
  • Facade (to hide Coingecko operations to build the portfolio)
  • Factory (to create the right strategy)
  • Strategy (to change behaviour based on add/delete/deleteall actions)
  • Observer (to notify observers of a added/removed portfolio)
  • Visitor (to validate commands)

How to Use it:

To run the bot, you need to clone this prokect and define the following Environmental Variables:

  • TELEGRAM_BOT_NAME = Ask BotFather in Telegram
  • TELEGRAM_BOT_TOKEN = Ask BotFather in Telegram
  • MONGO_DB_URI = Optional, To connect to MongoDB. Some commands requires this to be set, list is below
  • TG_ADMIN = Optional, Telegram username of the owner, you have to set yours otherwise some commands will not be authorized. Check below for a full list
  • COINS_COLLECTION = Optional, name of the collection of your saved coins, default coins
  • PORTFOLIO_LINKS_COLLECTION = Optional, name of the collection of your coingecko portfolios, default portfolio_links
  • KUCOIN_API_KEY = Optional, set it if you want to use Kucoin functions. Create Kucoin Keys
  • KUCOIN_SECRET_KEY = Optional, set it if you want to use Kucoin functions
  • KUCOIN_PASSPHRASE = Optional, set it if you want to use Kucoin functions

You can start the bot with the command docker-compose up --build -d

Then go to your instance of the Telegram bot and type /start.

Create a Coingecko portfolio

Go here and create a public portfolio, like in the image below:

image

Commands

Public Commands

Here is the list of commands that do not require authorization, so every user can run these commands:

  • /start: welcome message
  • /help: lists of all available commands
  • /trend: shows Coingecko trending coins
  • /<name of the saved portfolio>: shows the list of the coins saved in the coingecko portfolio
  • /chains: it checks which chains are available for deposit/withdraw for a specific coin, for a specific platform
  • /deposit: it gives the deposit addresses, based on the platform specified and ticker

Authorized Commands

Here is the list of commands that require authorization, defined by setting the TG_ADMIN environmental variable:

  • /save: it saves a coin buy price, for example /save BTC 15000. Prices are in $ so that they can be compared with the coingecko current prices, when you run the /<portfolio name> command. (requires MONGO_DB_URI)
  • /delete: it deletes a coin buy price (requires MONGO_DB_URI)
  • /saveportfolio: it saves a coingecko portfolio, then you can fetch it by executing /<portfolio name> (requires MONGO_DB_URI)
  • /deleteportfolio: it deletes a portfolio (requires MONGO_DB_URI)
  • /prices: it lists all saved coins' buy prices (requires MONGO_DB_URI)
  • /withdraw: it withdraw funds from different platforms. Right now only Kucoin is available
  • /balance: it checks balance for the specified exchange (platform)
  • /trade: it performs a buy/sell action, by specifying the type (limit/market), ticker, amount and optionally the limit price

Example Usage

First, you add your coingecko portfolio to the bot, like this:

image

After that, you can call the portfolio command to show coins present in the coingecko portfolio, with some additional information:

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published