Package: kraken-rebalance-bot
Welcome to the Spot rebalance bot for the Kraken Cryptocurrency Exchange 🐙⚠️ This is an unofficial trading bot that performs buys and sells
on the Kraken cryptocurrency exchange using Python.Backend to access the Kraken API:python-kraken-sdk📌 DisclaimerThere is no guarantee that this software will work flawlessly at this or
later times. Of course, no responsibility is taken for possible profits or
losses. This software probably has some errors in it, so use it at your own
risk. Also no one should be motivated or tempted to invest assets in
speculative forms of investment. By using this software you release the
author(s) from any liability regarding the use of this software.It is not certain that this software will ever lead to profits.📝 The StrategyThis algorithm can buy and sell one or more Spot assets without leverage.The goal is to hold a certain amount of each base currency so that, for
example, there is always about $1000 worth of BTC in the portfolio. If
the price of Bitcoin increases so that there is now $1050 worth of
Bitcoin in the portfolio, the excess $50 is sold. If the price of
Bitcoin falls, so that the Bitcoin in the portfolio are only worth $950,
the algorithm buys Bitcoin, to hold a value of about $1000 in Bitcoin
in the portfolio again.The algorithm checks the price range every 6 hours by default. The
margin, from how many percent price difference the algorithm becomes
active, can also be adjusted.Actions can be logged on the command-line using the logging module with
active INFO-level and can also be sent to a telegram bot.⚙️ Quick start and configuration0. Check the source code of this algorithm on GitHub and read the README.md carefullyhttps://github.com/btschwertfeger/Kraken-Rebalance-Bot1. Install the Python module:python3-mpipinstallkraken-rebalance-bot2. Register at Kraken and generate API keys with trading access:https://www.kraken.com/u/security/api3. (optional) Create a Telegram Bot to get notified when the algorithm takes actionCreate a bot using@BotFatherWrite down/remember the tokenStart@RawDataBotand write down your personalchat_id4. Setup the configuration and start the algorithmAn example configuration can be found inexample_config.jsonand looks like
this:{"base_currency":["ETH","XBT"],#baseasset(s)tomaintain"quote_currency":["USD","USD"],#quoteasset(s)totradewith"target_quantity":[500,500],#howmanyofthebasetohold(valueinquote)"quote_to_maintain":[200,200],#freezedquote"margin":[0.035,0.035],#buy/sellthreshold"lowest_buy_price":[1000,15000],#don'tbuybelowthisprice"times":["06:00","18:00"],#hasnoeffectifuse_build_in_scheduleristrue"use_build_in_scheduler":false,#ifsettofalse,thescriptwillonlyrunonce"demo":true,#settofalsetoenabletrading"telegram":{#optionaltogetnotifiedviatelegram"token":"telegram-bot-token","chat_id":"your-telegram-chat-id"}}In the following a minimal working example is shown that uses this strategy
to hold atarget_quantityof $500 of ETH and $500 worth of XBT (as in the
example config above). Both are traded against USD. Thedemokey must be
set toFalseto enable the trading functionality. Of course, this also works
with only one asset, too.rebalance\--api-key"your-kraken-api-key-here"\--secret-key"secret-key-here"\--configconfig.jsonNote: Ifuse_build_in_scheduleris enabled, there will be no output until
the time is one oftimes.📖 ConfigurationKeyTypeDescriptionbase_currencylist[str]List of base currencies to trade and hold.quote_currencylist[str]List of quote currencies to trade the base currency with.target_quantitylist[float] | list[int]Defines how much of a base currency should be held. This value is the worth of the base currency in quote currency.quote_to_maintainlist[float] | list[int]How much of quote currency should not be touched in the portfolio.marginlist[float]Rebalance levels e.g. 0.035 = 3.5%: at a change of 3.5% the algorithm will buy or sell the missing/surplus quantitylowest_buy_pricelist[float](optional) The bot will not buy if the price falls below this price to avoid catching a falling knife. Acts Kind of stop loss, but without selling.timeslist[str](optional, default:['00:00', '06:00', '12:00', '18:00']) At which time the bot should check the balances.use_build_in_schedulerbool(optional, default:False) Checks the balances once and exits if set to False. Otherwise the program will run forever and check the balances at the specifiedtimesdemoboolTrade or not sample trade output. Set to True if you know what this algorithm does.telegram{'chat_id': str, 'token': str}(optional) Specify token and chat id to get notified when the bot does something.Ifuse_build_in_scheduleris set tofalse, the program is executed once
and ends after the iteration over all assets. This offers the possibility to
create own scripts, which execute this algorithm at individual times
(e.g. usingcron).📍 NotesMake sure to always have enough quote currency in your Kraken portfolio. Too
lowtarget_quantityvalues can cause the bot not to trade or even crash.
Therefore, pay attention to theminimum order sizes.Example situation:minimal order size of ETH is 0.01price of ETH: $1300marginis set to 0.04target_quantityis 200what will happen:If your actual holdings of ETH is $192 the bot tries to buy Ethereum
with a volume of $8 because $200 - $200 * 0.04 will trigger the buy
order. But the minimum order size of Ethereum is 0.01 ETH
(seehere),
and with a price of $1300 => 0.01 ETH equals $13 so: $13 < $8 will
raise an error.So make sure that the minimum order sizes of the respective assets
are consistent with themarginvalue and thetarget_quantity.
The example would work if thetarge_quantityis set to 500,
because $500 _ 0.04 = $20 which is larger than $1300 _ 0.01 = $13.Also make sure that there is enough quote currency, otherwise the
bot cannot buy anything.This strategy is one of the simplest and most basic approaches for trading
cryptocurrencies. For this reason, it should be noted here that this does not
necessarily lead to profits. Before running such an algorithm, everyone
should be clear about what products are being traded, what these products are
for in the first place, and what makes them valuable. Even the best companies,
stocks, materials, and also cryptocurrencies can become worthless from one day
to the next, so everyone should do their own research and make their decisions
based on these results.It has been decided here not to present any material regarding the profitability
of this algorithm, as this could lead you to make your decisions based on my
successes and failures. What works once or over a long period of time does not
necessarily work in the future. But please let me know what you think about this
basic algorithm and what could be improved.For any problems or suggestions - please open an issue.🆕 Contributions… are welcome!🔭 Referenceshttps://python-kraken-sdk.readthedocs.io/en/stable