Monitor your Binance portfolio

Overview

Binance Report Bot

The intent of this bot is to take a snapshot of your binance wallet, e.g. the current balances and store it for further plotting.

Install

Create the file conf_user.py based on conf_default.py. If a field is missing in conf_user.py, it will defaults to the one in conf_default.py.

Then run

pip3 install -r requirements.txt

Basic Usage

To save a snapshot of the binance account run:

python3 -m brb snapshot

To show the previously saved snapshots

python3 -m brb output # --help for options

Deployment

One can use crontab to use this code:

0 * * * * cd [FOLDER] ; python3 -m brb snapshot
2 19 * * * cd [FOLDER] ; python3 -m brb output --quiet

To have a snaphsot made every hour and a report made every day at 19:02.

The output can be sent to an external service, that can be configured with the APPRISE_URL parameter. See here to choose your external service and to create your APPRISE_URL. Please use a service that supports attachment, in order to send images. Recommended services : Discord, Telegram or Email.

Output example

Plot EOS equivalent holdings:

python3 -m brb output --symbol EOS

Plot ICX relative equivalent holdings:

python3 -m brb output --symbol ICX --relative

Plot ICX and EOS equivalent holdings since three days ago:

python3 -m brb output --symbol ICX,EOS --days 3

Plot the equivalent holdings of all soins registered in the conf file:

python3 -m brb output --symbol * # or '*' if using zsh

Plot the price of EOS and BTC over the last 10 days expressed in WIN:

python3 -m brb output --symbol EOS,BTC --graph-type price --price-in WIN

Note : The equivalent holding is your portfolio's value in a certain currency. It represents what you would be holding if all your portfolio was under this single currency.

CLI specification

$ python3 -m brb --help
Usage: python -m brb [OPTIONS] COMMAND [ARGS]...

  Binance Report Bot

  Take a snapshot of your binance wallet, e.g. the current balances and store
  it for further plotting.

Options:
  --debug / --no-debug  Prints debug data
  --help                Show this message and exit.

Commands:
  output    Output the previously stored data
  snapshot  Take a snapshot of your wallet
$ python3 -m brb snapshot --help
Usage: main.py snapshot [OPTIONS]

  Take a snapshot of the binance wallet and save it for further plotting

Options:
  --help                Show this message and exit.
$ python3 -m brb output --help
Usage: python -m brb output [OPTIONS

  Output the previously stored data with 'snapshot'

Options:
  --quiet / --no-quiet            Set to true if you don't want to print in
                                  the console or display an image
  --text / --no-text              Can be used to prevent the generation of the
                                  text report
  --graph / --no-graph            Can be used to prevent the generation of the
                                  graph report
  -r, --relative / --no-relative  If the graph should be plotted relative to

                                  its initial value
  -s, --symbol TEXT               The currency the graph will be plotted on.
                                  To plot several symbols on the same graph,
                                  separate them by a coma. If plotting several
                                  symbols, the --relative option is enabled.
                                  To plot all symbols, use '*'. Default : FIAT
  -d, --days INTEGER              The number of days over which the graph will
                                  be plotted. If set to 0, the graph will plot
                                  all the records. Default : 7 days
  -t, --graph-type [amount|price]
                                  Graph type. Amount : shows the equivalent
                                  amount that you are holding on your wallet.
                                  Price : shows price over time
  -p, --price-in TEXT             Currency in which to express the prices.
                                  Default : USD
  --help                          Show this message and exit.
Comments
  • KeyError: 'LDBNB'

    KeyError: 'LDBNB'

    Hey, after doing pip3 install -r requirements.txt and python3 main.py snapshot i get this message:

    Traceback (most recent call last):
      File "main.py", line 75, in <module>
        cli()
      File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
        return self.main(*args, **kwargs)
      File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1062, in main
        rv = self.invoke(ctx)
      File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
        return __callback(*args, **kwargs)
      File "main.py", line 19, in snapshot
        crypto_report = bot.crypto.get_report()
      File "/home/ubuntu/binance-report-bot/bot/crypto.py", line 58, in get_report
        total_usdt += balances[symbol]*tickers[symbol]
    KeyError: 'LDBNB'
    

    heres my config.py

    BINANCE_API_KEY = "XXXX"
    BINANCE_API_SECRET = "XXXX"
    COINS = ["ATOM","BAT","BTT","CAKE","ETC","ICX","IOTA","OMG","QTUM","ROSE","SRM","XLM","ONT","BNB","ZIL","ALGO","ADA","XRP","LTC","LINK","EOS","TRX","VET","NEO","DASH","MANA","OCEAN","UNI","MATIC","DOT"]
    CURRENCY = "EUR" #Or USD
    CURRENCY_SYMBOL = "€"
    RICH_PRINTING = True
    

    any idea? Thanks in Advance

    bug discussion 
    opened by SaLuci 14
  • KeyError: 'ATA'

    KeyError: 'ATA'

    Hey, its me again ;)

    the bug mentioned in #5 is fixed, however a new one appeared.

    Theres a coin called ATA, which is not "tradable" yet, but you can get them if you stake BNB. So the EUR/USD Value of those coins will be zero, till they become "tradable". I think thats the Problem.

    I will probably take a look at the code myself in the evening, should be a simple fix. (just ignoring coins with a USD value of zero)

    bug good first issue 
    opened by SaLuci 10
  • ZeroDivisionError: float division by zero

    ZeroDivisionError: float division by zero

    Hi there, I have cloned project at VPS server and created snapshot of account and run next command: python main.py --output print and I received next error at console:

    Traceback (most recent call last):
      File "main.py", line 54, in <module>
        main()
      File "/home/manager/binance-trade-bot/binance-trade-bot/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "/home/manager/binance-trade-bot/binance-trade-bot/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
        rv = self.invoke(ctx)
      File "/home/manager/binance-trade-bot/binance-trade-bot/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/home/manager/binance-trade-bot/binance-trade-bot/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "main.py", line 49, in main
        figname = bot.crypto.plot_symbol(reports, plot_symbol)
      File "/home/manager/binance-trade-bot/binance-report-bot/bot/crypto.py", line 92, in plot_symbol
        Y.append(report['total_usdt']/ticker)
    ZeroDivisionError: float division by zero
    
    opened by DmytroLitvinov 5
  • KeyError: 'NFT'

    KeyError: 'NFT'

    python -m brb snapshot leads to

    Traceback (most recent call last):
      File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/srv/bot/crypto/brb/__main__.py", line 92, in <module>
        cli()
      File "/srv/bot/crypto/venv/lib/python3.7/site-packages/click/core.py", line 1134, in __call__
        return self.main(*args, **kwargs)
      File "/srv/bot/crypto/venv/lib/python3.7/site-packages/click/core.py", line 1059, in main
        rv = self.invoke(ctx)
      File "/srv/bot/crypto/venv/lib/python3.7/site-packages/click/core.py", line 1665, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/srv/bot/crypto/venv/lib/python3.7/site-packages/click/core.py", line 1401, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/srv/bot/crypto/venv/lib/python3.7/site-packages/click/core.py", line 767, in invoke
        return __callback(*args, **kwargs)
      File "/srv/bot/crypto/brb/__main__.py", line 29, in snapshot
        crypto_report = brb.crypto.get_report()
      File "/srv/bot/crypto/brb/crypto.py", line 80, in get_report
        total_usdt += balances[symbol] * tickers[symbol]
    KeyError: 'NFT'
    
    bug 
    opened by titulebolide 1
  • Calculate from reports current coin's quantity or equivalent quantity through time

    Calculate from reports current coin's quantity or equivalent quantity through time

    Here is the code:

    CRYPTOCOMPARE_API_KEY = "your_key_here"
    COINS = ["ADA","ATOM","BAT","BTT","CAKE","DASH","EOS","ETC","ICX","NEO","OMG","ONT","QTUM","ROSE","TRX","VET","WIN","XLM"]
    
    import numpy as np
    import requests
    import threading
    import copy
    import time
    from progress.bar import Bar
    crypto = np.load('crypto.npy', allow_pickle=True)
    
    time = [i['time'] for i in crypto]
    
    def get_ticker(ts, symbol, datas):
        data = requests.get(
            f'https://min-api.cryptocompare.com/data/v2/histominute?fsym={symbol}&tsym=EUR&limit=1&toTs={ts}&api_key={CRYPTOCOMPARE_API_KEY}'
        ).json()
        try:
            ticker = data['Data']['Data'][0]['open']
        except KeyError:
            print(ts,symbol, data)
        if datas is not None:
            datas[ts][symbol] = ticker
        return ticker
    
    try:
        tickers = np.load('ticker.npy', allow_pickle=True).tolist()
    
    except:
        bar = Bar('', max=len(time))
        datas = {}
        simultaneous = 0
        threads = []
        for t in time:
            bar.next()
            ts = int(t)
            datas[ts] = {}
            threads = [threading.Thread(target=get_ticker, args=(ts, symbol, datas)) for symbol in COINS]
    
            for th in threads: th.start()
            for th in threads: th.join()
        bar.finish()
    
        np.save('ticker.npy', datas, allow_pickle=True)
        tickers = datas
    
    value = []
    for data in crypto:
        ts = int(data['time'])
        total = data['report']['total']
        value.append({})
        for symbol in COINS:
            value[-1][symbol] = total/tickers[ts][symbol]
    
    opened by titulebolide 0
  • Road to v1.0.0

    Road to v1.0.0

    This issue will be mapping the road to v1.0.0 and what's left to do before this code gets out of beta.

    Here is a first throw:

    • [x] Use of apprise as an output
    • [ ] Display of holding graphs (not only equivalent holdings) (see this branch)
    • [ ] Recovery of the binance history to prevent the need of calling repeatedly the snapshot
    • [x] Stabilisation of the API
    • [x] Use of logging
    • [x] ERROR level in logging should be forwarded to apprise
    • [x] Display of daily and weekly PNL in text report
    • [x] Support other fiats than USD and EUR
    • [x] Handling of error (e.g. when a user add a coin in conf.COINS after some snapshots it can mess up things
    • [x] Set the duration over the which the graph is plotted
    • [x] Plot the price of the currencies over time
    • [ ] Migrate from the current .npy database to an sqlite3 db
    • [x] When a currency is rejected (e.g. if it has no ticker), send log message with DEBUG level
    • [x] Make DEBUG mode (i.e. logging level is DEBUG) toggable easily (with a environment variable or a configuration line or a flag)

    Help is wanted!

    enhancement help wanted good first issue discussion 
    opened by titulebolide 0
Releases(v0.6.3)
  • v0.6.3(Sep 3, 2021)

  • v0.6.2(Jul 9, 2021)

    :warning: Reminder of the breaking changes since v0.5.1:

    • Replace python3 main.py calls by python3 -m brb
    • Rename conf.py to conf_user.py

    Features

    • Plot the prices of the symbols in your list over the time (see --graph-type argument)
    • Choose the currency in which the price is written (see --price-in argument)
    • Prevent the output of the text or the graph report (see --no-text and --no--graph arguments)

    Bugfix

    • Forward warning level to apprise
    • Ignore conf.py and conf_user.py
    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Jun 25, 2021)

    :warning: Please rename conf.py to conf_user.py

    Features

    • Forward log of level errors and warning to apprise
    • Wrap around every exception to forward them to apprise
    • The text report computes the difference between now and whenever you want (e.g. a day ago, a month, a year, four decades...)

    Improvement

    • Place the legend out of the graph zone fro a better reading
    • Increase the size of the graph if plotting more than ten currencies
    • Revisions of the configuration should no longer break your install since a missing information in the conf_user.py is fetched in conf_default.py

    Bugfix

    • Handle symbols in the wallet that has not ticker
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jun 10, 2021)

    :warning: 0.5.0 -> 0.6.0 INTRODUCES A BREAKING CHANGE IN THE API :warning:

    You have to replace python3 main.py calls by python3 -m brb

    Improvements:

    • Support many other currencies than USD and EUR
    • Check configuration file for insconsitancies
    • Use logging module
    • Converted to a module

    Bugfixes:

    • Minor fix for printing
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Jun 3, 2021)

    Improvements:

    • Send notification via apprise
    • Choose the numbers of days over which the graph is plotted

    API and conf modification:

    • For output command:
      • Drop --port and --type as this is replaced by APPRISE_URL
      • Add --days option to choose the number of days over whick the graph is plotted
      • Add --quiet to prevent printing in the terminal and the opening of a window displaying the graph
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jun 2, 2021)

    Official release of v0.5.0 based on rc2

    Improvements:

    • Beautiful formating of the time axis
    • Plotting of relative holdings
    • Plotting of several coins

    Bugfixes:

    • COIN not found if havinc coin in binance savings
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0-rc2(Jun 1, 2021)

  • v0.5.0-rc1(May 31, 2021)

  • v0.4.0(May 27, 2021)

    Improvements:

    • Add output option to choose which way to use to ouput data
    • Add snapshot option to make clear what is going on
    • Enrichment of README and help option.

    Bugfix:

    • If plot-symbol is used, the graph in FIAT is not generated.
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(May 26, 2021)

    The last release (0.3.0) was mistagged, jumping to the 0.3.1 direcly. Fixes:

    • Incorrect calculation of the overall owning in the text report

    The attached update.py file update the database to this new version. A cryptocompare API key is required.

    Source code(tar.gz)
    Source code(zip)
    update.py(1.75 KB)
  • v0.3.0(May 26, 2021)

  • v0.3.0-rc1(May 24, 2021)

    Changes:

    • Wipe old gsheet way of fetching data
    • Drop miner logging scripts
    • Change DB keys to store in USDT
    • Add option to change report currency
    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(May 22, 2021)

discord vc exploit to lightly lag vcs

discord-vc-reconnector discord vc exploit to lag vcs how to use open the py file, then open devtools on discord, go to network and join a vc, dont sta

Tesco 30 Aug 09, 2022
A multi-platform HTTP(S) Reverse Shell Server and Client in Python 3

Phantom - A multi-platform HTTP(S) Reverse Shell Server and Client Phantom is a multi-platform HTTP(S) Reverse Shell server and client in Python 3. Bi

85 Nov 18, 2022
“ HOLA HUMANS 👋 I'M DAISYX 2.0 ❤️ „ LATEST VERSION OF DAISYX.. Source Code of @Daisyxbot

❤️ DaisyX 2.0 ❤️ A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon... ⭐️ Thanks to everyone who starred Dais

TeamDaisyX 153 Dec 06, 2022
Asynchronous multi-platform robot framework written in Python

NoneBot ✨ 跨平台 Python 异步机器人框架 ✨ 文档 · 安装 · 开始使用 · 文档打不开? 简介 NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架,它基于 Python 的类型注解和异步特性,能够为你的需求实现提供便捷灵活的支持。

NoneBot 3.1k Jan 04, 2023
A simple Telegram bot which handles images in whole different way

zeroimagebot thezeroimagebot 🌟 I Can Edit Dimension Of An image which is required by @stickers 🌟 I Can Extract Text From An Image 🌟 !!! New Updates

RAVEEN KUMAR 4 Jul 01, 2021
Role Based Access Control for Slack-Bolt Applications

Role Based Access Control for Slack-Bolt Apps Role Based Access Control (RBAC) is a term applied to limiting the authorization for a specific operatio

Jeremy Schulman 7 Jan 06, 2022
Autofill HZDR Zeitman entries

Zeitman_autofill Filling out Zeitman is boring. This script might make some of the pain go away. Requirements The selenium package and Chrome webdrive

Tim Callow 8 Mar 14, 2022
Detects members having unicode names. Public bot: @scarletwitchprobot

✨ Scarletwitch bot ✨ Detects unicode names members in a tg chat & provides a option to take action on that user ! Public bot: @scarletwitchprobot Supp

ÁÑÑÍHÌLÅTØR SPÄRK 18 Nov 12, 2022
Plays air warning sound when detects a certain phrase or a word in a specified Telegram chat.

Tryvoha Bot Disclaimer: this is more a convenient naming, rather than a real bot. It is designed to play air warning sound when detects a certain phra

Dmytro Novikov 2 Mar 02, 2022
Python API wrapper around Trello's API

A wrapper around the Trello API written in Python. Each Trello object is represented by a corresponding Python object. The attributes of these objects

Richard Kolkovich 904 Jan 02, 2023
A simple telegram bot to forward files from one channel to other.

Forward_2.0 Bot to forward messages from one channel to other without admin permission in source channel. Can be used for both private and Public chan

SUBIN 56 Dec 29, 2022
A script written in python3 for bruteforcing Gmail accounts.

GmailBruteforce Made for bruteforcing gmail accounts. It needs Less Secure Apps setting turned on in order to work. Installation For windows git clone

Shinero 4 Sep 16, 2022
livestream-chat: Overlay para chats de livestreams

livestream-chat Overlay para chats de livestreams. Inicialmente para rodar dentro do browser do obs-studio. TODO: Issues iniciais Suporte a API do You

Eduardo Mendes 10 Dec 16, 2022
This project checks the weather in the next 12 hours and sends an SMS to your phone number if it's going to rain to remind you to take your umbrella.

RainAlert-Request-Twilio This project checks the weather in the next 12 hours and sends an SMS to your phone number if it's going to rain to remind yo

9 Apr 15, 2022
Projeto do segundo módulo da Resilia

@ Projeto Resilia : Módulo 2 Vamos jogar Forca ! O jogo da forca é um jogo em que o jogador tem que acertar qual é a palavra proposta, tendo como dica

Mateus Sartorio 2 Feb 24, 2022
A python script to download twitter space, only works on running spaces (for now).

A python script to download twitter space, only works on running spaces (for now).

279 Jan 02, 2023
Simple yet efficient tool used to check and sort tokens in terms of there validation.

Discord Token Checker Simple yet efficient tool used to check and sort tokens in terms of there validation.When the program is done,go to the "output"

Robotnik 15 Dec 27, 2022
Lambda-function - Python codes that allow notification of changes made to some services using the AWS Lambda Function

AWS Lambda Function This repository contains python codes that allow notificatio

Elif Apaydın 3 Feb 11, 2022
Source code for Profile REST API

PROJECT PROFILE REST API Creating local development server: We will create a local development server that can run and test our API as we build it. We

1 Mar 29, 2022
Python Library for Secp256k1 Bitcoin curve to do fast ECC calculation

secp256k1 Python Library for Secp256k1 Bitcoin curve to do fast ECC calculation Example Usage import secp256k1 as ice print('[C]',privatekey_to_addres

iceland 49 Jan 01, 2023