Giter VIP home page Giter VIP logo

binance-portfolio-rebalancing-bot's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.