In the following list you will find detailed information about all the files that the project consists of - and if they are necessary to run the bot or not.
README.mdto demonstrate how the bot looks and behaves. This file is not needed.
These are the files that are important to run the bot:
Before starting up the bot you have to take care of some settings. You need to edit two files:
This file holds the configuration for your bot. You have to at least edit the values for user_id and bot_token. After a value has been changed you have to restart the bot for the applied changes to take effect.
userinfobotand he will reply your ID (use the ID, not the username)
BotFatherwhen you create your bot. If you don't know how to register your bot, follow these instructions
/valuewill use the base currency and show you the current value in this currency. If you want to get the value of all your assets, this only works if all your assets can be traded to this currency. You can enter here any asset:
0disables the check. Every order (already existing or newly created - not only by this bot) will be monitored by a background job and if the status changes to
closed(which means that a trade was successfully executed) you will be notified by a message.
0disables the check. If there is a bot-update available you will be notified by a message
true, then all errors that happen will trigger a message to the user. If
false, only the important errors will be send and timeout errors of background jobs will not be send
true, the owner of the bot and any other user who tries to access the bot will both be notified. If
false, no one will be notified. Set to
falseif you get spammed with
Access deniedmessages from people that try to use your bot
"XLM": "XBT", ...
login a log-file. Only enable this if you're searching for a bug because the logfiles can get pretty big.
0, then Kraken API calls will be retried the specified number of times if they return any kind of error. In most cases this is very helpful since at the second or third time the request will most likely make it through
true, no need to choose a coin in
/pricecommand. Only one message will be send with current prices for all coins that are configured in setting
true, no need to choose a coin in
/chartcommand. Only one message will be send with links to all coins that are configured in setting
/balance, set this to
6or smaller. If you use
8, which is the maximum value and the one that Kraken uses internally, and you experience errors (while buying with volume
ALLyou could get an
Insufficient fundserror) set it to
This file holds two keys that are necessary in order to communicate with Kraken. Both keys have to be considered secret and you should be the only one that knows them.
Generate New Key
Nonce Window(or just use the default value)
When you have your Kraken API keys, open the file
kraken.key and replace
some_api_key (first line) with the value of
API Key and
some_private_key (second line) with the value of
In order to run the bot you need to execute the script
telegram_kraken_bot.py. If you don't have any idea where to host it, take a look at Where to host Telegram Bots. Since you have to provide sensitive data (Kraken API keys) to use the bot, i would only host this script on a server that you own. But services like Heroku should be save too. You can also run the script locally on your computer for testing purposes.
You have to use Python 3.6 to execute the script (because of enum method
auto()). If you would like to use Python 3.4 or 3.5, you have to remove
auto from imports and set the values in
KeyboardEnum yourself. Python 2.x is not supported.
Install a set of module-versions that is known to work together for sure (highly recommended):
pip3.6 install -r requirements.txt
If you want to install the newest versions of the needed modules, execute the following:
pip3.6 install python-telegram-bot -U pip3.6 install beautifulsoup4 -U pip3.6 install krakenex -U
To start the script, execute
python3.6 telegram_kraken_bot.py &
To stop the script, execute
which will kill every Python process that is currently running. Or shut the bot down with the
/shutdown command (recommended).
If you configured the bot correctly and execute the script, you should see some checks that the bot performs. After that a welcome message will be shown along with the information if you are using the latest version. There should also be a custom keyboard that shows you all the available commands. Click on a button to execute the command or type the command in manually (not case sensitive).
⚠️ In general, while entering the volume, make sure that you don't use smaller values then Kraken supports. Take a look at the order limits for various coins. If you do use smaller values, the bot will tell you it's not possible to use that value and will let you enter the volume again.
/trade: Create a new buy or sell order of type
/orders: Show all open orders (buy and sell) and close a specific one or all
/balance: Show all assets with the available volume (if open orders exist)
/price: Return last trade price for the selected crypto-currency
/value: Show current market value of chosen currency or all your assets
/chart: Show a trading chart for the chosen currency
/history: Show history of closed (executed) trades
/funding: Deposit or withdraw (only to wallet, not SEPA) funds
/state: Show performance state of Kraken API
/update: Update the bot to the latest version on GitHub
/restart: Restart the bot
/shutdown: Shutdown the bot
/settings: Show and change bot settings
/reload: Reload custom command keyboard
/initialize: Perform initialization (precondition for start)
If you want to show a list of available commands as you type, open a chat with Telegram user
BotFather and send the command
/setcommands. Then choose the bot you want to activate the list for and after that send the list of commands with description. Something like this:
trade - buy or sell assets orders - show or close orders balance - show all your assets price - show current price for asset value - calculate value for assets chart - display trading charts history - show completed trades funding - deposit or withdraw currencies bot - update, restart or shutdown
I know that it is unusual to have the whole source code in just one file. At some point i should have been switching to object orientation and multiple files but i kind of like the idea to have it all in just one file and object orientation would only blow up the code. This also makes the
/update command much simpler :)
/historythat shows executed trades
/chartto show TradingView Chart Widget website
/fundingto deposit / withdraw funds
/alertto be notified once a specified price is reached
/statsthat shows statistics
In case you experience any issues, please take a look at this section to check if it is described here. If not, create an issue on GitHub.
⚠️ It depends on the error but it is possible that a request to Kraken will return with an error and still be executed correctly.
⚠️ If it happens that a specific command doesn't trigger any action (no response from the bot on button click), try to reload the keyboard with
/reload or if that doesn't help, restart the bot with
Invalid nonce: It might happen that Kraken replies with this error. If you want to understand what a nonce is, read the Wikipedia article. This error happens mostly if you use different Telegram clients. Maybe you issued some commands on your laptop and then switched to your smartphone? That would be a typical scenario where this might happen. Or you didn't use the bot for a long time. To resolve it, just execute the command again. It should work the second time. Unfortunately there is not much i can do. The correct behavior would be to have one Kraken API key-pair for one device (one for your smartphone and one for your laptop). Unfortunately there is no way to identify the client. You can play around with the nonce value in your Kraken account (take a look at the settings for the generated key-pair). If you are really annoyed by this then here is what you could try: Create some key-pairs (5 might do it) and then, before you call the Kraken API, randomly choose one of the keys and use it till the next Kraken API call is made.
Service unavailable: If you get this error then because Kraken fucked up again. That happens regularly. It means that their API servers are not available or the performance is degraded because the load on the servers is too high. Nothing you can do here - try again later. If you want to have details on the API server performance, go to Kraken Status or execute the
I use this bot personally to trade on Kraken so i guess it's kind of stable but if you use it, then you are doing this on your own responsibility !!! I can not be made responsible for lost coins or other stuff that might happen due to some fuckup within the code. Use at your own risk!
If you find Telegram-Kraken-Bot suitable for your needs or maybe even made some money because of it, please consider donating whatever amount you like to:
If you can't or don't want to donate, please consider signing up on listed exchanges below. They are really good and by using these links to register an account i get a share of the trading-fee that you pay to the exchange if you execute a trade.