Skip to content

This Python script, allows you to mantain a portfolio of binance coins, using the Threshold Rebalancing Strategy

License

Notifications You must be signed in to change notification settings

alimogh/binance-portfolio-rebalancing-bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

binance-portfolio-rebalancing-bot

This Python script, allows you to mantain a portfolio of binance coins, using the Threshold Rebalancing Strategy

Requirements

This bot requires the Binance Exchange API Python implementation for automated trading. Download it and install, via pip: https://github.com/sammchardy/python-binance

Strategy

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.

Example

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.

Configuration

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)

Execution

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).

Disclaimer and Important Information:

  • This bot does not guarantee profits.
  • This bot works with Buy/Sell Market Orders.

About

This Python script, allows you to mantain a portfolio of binance coins, using the Threshold Rebalancing Strategy

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages

  • Python 100.0%