This Python script, allows you to mantain a portfolio of binance coins, using the Threshold Rebalancing Strategy
This bot requires the Binance Exchange API Python implementation for automated trading. Download it and install, via pip: https://github.com/sammchardy/python-binance This bot buys altcoins (maximum 5), each one with a configured percentage of the global portfolio(valued in BTC), with all the BTC in the account, and will rebalance the portfolio, triggered by the coins that have the percentage of the global portfolio, with higher deviation, than the one configured in the bot. Initial configuration of the bot:- rebalance % = 5
- coin1 = 'ADA' - coin1perc = 30
- coin2 = 'XLM' - coin2perc = 20
- coin3 = 'ZEC' - coin3perc = 30
- coin4 = 'NEO' - coin4perc = 10
- coin5 = 'BTS' - coin5perc = 10
The coins are bought with all the BTC in the account, and the initial deviation would be something like this (the bot automatically prints this information in the screen):
- 15:00:36.684000
- Deviation Rebalance ADA 0.01%
- Deviation Rebalance XLM -0.02%
- Deviation Rebalance ZEC -0.01%
- Deviation Rebalance NEO 0.02%
- Deviation Rebalance BTS 0%
After a while, the distribution deviation would be something like this (the bot automatically prints this information in the screen):
- 18:00:36.684000
- Deviation Rebalance ADA 6.2%
- Deviation Rebalance XLM -3.2%
- Deviation Rebalance ZEC -1%
- Deviation Rebalance NEO 1%
- Deviation Rebalance BTS -3%
The bot would automatically sell ADA because it passed the rebalance percentage of 5%, and with the BTC, it would try to buy XLM, ZEC and BTS (only if the buy order was of more than 0.001 BTC that is the binance trading minimum LOT).
Whenever a buy or sell order is made, a email is sent by SMTP, with some trade information.
Configure the email notifications:
- server = smtplib.SMTP('smtp.gmail.com', 587)
- server.login("[email protected]", "your password")
Configure the Binance API credentials:
- api_key = 'yourapikey'
- api_pw = 'yourapipassword'
Configure the rebalance deviation percentage: rebal = 5
Configure the altcoins and respective portfolio percentages:
- coin1 = 'ADA'
- coin2 = 'XLM'
- coin3 = 'ZEC'
- coin4 = 'NEO'
- coin5 = 'BTS'
- coin1perc = 30
- coin2perc = 20
- coin3perc = 30
- coin4perc = 10
- coin5perc = 10
Configure send email, in the functions buy_order and sell_order:
server.sendmail("[email protected]", "[email protected]", message)
Run the script "tr-bot-mvs.py".
If you want to check the balances at any moment, you can use the script "tr-bot-mvs-balance.py" (configure the coin tickers and api information).
- This bot does not guarantee profits.
- This bot works with Buy/Sell Market Orders.