GithubHelp home page GithubHelp logo

titulebolide / binance-report-bot Goto Github PK

View Code? Open in Web Editor NEW
35.0 7.0 11.0 126 KB

Monitor your Binance portfolio

License: MIT License

Python 100.00%
binance record management monitoring graph plotting python portfolio

binance-report-bot's Issues

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

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)

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

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'

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:

  • 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
  • Stabilisation of the API
  • Use of logging
  • ERROR level in logging should be forwarded to apprise
  • Display of daily and weekly PNL in text report
  • Support other fiats than USD and EUR
  • Handling of error (e.g. when a user add a coin in conf.COINS after some snapshots it can mess up things
  • Set the duration over the which the graph is plotted
  • Plot the price of the currencies over time
  • Migrate from the current .npy database to an sqlite3 db
  • When a currency is rejected (e.g. if it has no ticker), send log message with DEBUG level
  • 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!

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]

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.