Giter VIP home page Giter VIP logo

binance-trade-bot's Introduction

binance-trade-bot

Automated cryptocurrency trading bot

github docker Deploy

Deploy to DO

Follow me on Twitter :)

Twitter

Why?

This project was inspired by the observation that all cryptocurrencies pretty much behave in the same way. When one spikes, they all spike, and when one takes a dive, they all do. Pretty much. Moreover, all coins follow Bitcoin's lead; the difference is their phase offset.

So, if coins are basically oscillating with respect to each other, it seems smart to trade the rising coin for the falling coin, and then trade back when the ratio is reversed.

How?

The trading is done in the Binance market platform, which of course, does not have markets for every altcoin pair. The workaround for this is to use a bridge currency that will complement missing pairs. The default bridge currency is Tether (USDT), which is stable by design and compatible with nearly every coin on the platform.

Coin A → USDT → Coin B

The way the bot takes advantage of the observed behaviour is to always downgrade from the "strong" coin to the "weak" coin, under the assumption that at some point the tables will turn. It will then return to the original coin, ultimately holding more of it than it did originally. This is done while taking into consideration the trading fees.

Coin A → USDT → Coin B

Coin B → USDT → Coin C

...

Coin C → USDT → Coin A

The bot jumps between a configured set of coins on the condition that it does not return to a coin unless it is profitable in respect to the amount held last. This means that we will never end up having less of a certain coin. The risk is that one of the coins may freefall relative to the others all of a sudden, attracting our reverse greedy algorithm.

Binance Setup

  • Create a Binance account (Includes my referral link, I'll be super grateful if you use it).
  • Enable Two-factor Authentication.
  • Create a new API key.
  • Get a cryptocurrency. If its symbol is not in the default list, add it.

Tool Setup

Install Python dependencies

Run the following line in the terminal: pip install -r requirements.txt.

Create user configuration

Create a .cfg file named user.cfg based off .user.cfg.example, then add your API keys and current coin.

The configuration file consists of the following fields:

  • api_key - Binance API key generated in the Binance account setup stage.
  • api_secret_key - Binance secret key generated in the Binance account setup stage.
  • current_coin - This is your starting coin of choice. This should be one of the coins from your supported coin list. If you want to start from your bridge currency, leave this field empty - the bot will select a random coin from your supported coin list and buy it.
  • bridge - Your bridge currency of choice. Notice that different bridges will allow different sets of supported coins. For example, there may be a Binance particular-coin/USDT pair but no particular-coin/BUSD pair.
  • tld - 'com' or 'us', depending on your region. Default is 'com'.
  • hourToKeepScoutHistory - Controls how many hours of scouting values are kept in the database. After the amount of time specified has passed, the information will be deleted.
  • scout_sleep_time - Controls how many seconds are waited between each scout.
  • use_margin - 'yes' to use scout_margin. 'no' to use scout_multiplier.
  • scout_multiplier - Controls the value by which the difference between the current state of coin ratios and previous state of ratios is multiplied. For bigger values, the bot will wait for bigger margins to arrive before making a trade.
  • scout_margin - Minimum percentage coin gain per trade. 0.8 translates to a scout multiplier of 5 at 0.1% fee.
  • strategy - The trading strategy to use. See binance_trade_bot/strategies for more information
  • buy_timeout/sell_timeout - Controls how many minutes to wait before cancelling a limit order (buy/sell) and returning to "scout" mode. 0 means that the order will never be cancelled prematurely.
  • scout_sleep_time - Controls how many seconds bot should wait between analysis of current prices. Since the bot now operates on websockets this value should be set to something low (like 1), the reasons to set it above 1 are when you observe high CPU usage by bot or you got api errors about requests weight limit.

Environment Variables

All of the options provided in user.cfg can also be configured using environment variables.

CURRENT_COIN_SYMBOL:
SUPPORTED_COIN_LIST: "XLM TRX ICX EOS IOTA ONT QTUM ETC ADA XMR DASH NEO ATOM DOGE VET BAT OMG BTT"
BRIDGE_SYMBOL: USDT
API_KEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A
API_SECRET_KEY: NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j
SCOUT_MULTIPLIER: 5
SCOUT_SLEEP_TIME: 1
TLD: com
STRATEGY: default
BUY_TIMEOUT: 0
SELL_TIMEOUT: 0

Paying Fees with BNB

You can use BNB to pay for any fees on the Binance platform, which will reduce all fees by 25%. In order to support this benefit, the bot will always perform the following operations:

  • Automatically detect that you have BNB fee payment enabled.
  • Make sure that you have enough BNB in your account to pay the fee of the inspected trade.
  • Take into consideration the discount when calculating the trade threshold.

Notifications with Apprise

Apprise allows the bot to send notifications to all of the most popular notification services available such as: Telegram, Discord, Slack, Amazon SNS, Gotify, etc.

To set this up you need to create a apprise.yml file in the config directory.

There is an example version of this file to get you started.

If you are interested in running a Telegram bot, more information can be found at Telegram's official documentation.

Run

python -m binance_trade_bot

Docker

The official image is available here and will update on every new change.

docker-compose up

If you only want to start the SQLite browser

docker-compose up -d sqlitebrowser

Backtesting

You can test the bot on historic data to see how it performs.

python backtest.py

Feel free to modify that file to test and compare different settings and time periods

Developing

To make sure your code is properly formatted before making a pull request, remember to install pre-commit:

pip install pre-commit
pre-commit install

The scouting algorithm is unlikely to be changed. If you'd like to contribute an alternative method, add a new strategy.

Related Projects

Thanks to a group of talented developers, there is now a Telegram bot for remotely managing this project.

Support the Project

Buy Me A Coffee

Join the Chat

FAQ

A list of answers to what seem to be the most frequently asked questions can be found in our discord server, in the corresponding channel.

Disclaimer

This project is for informational purposes only. You should not construe any such information or other material as legal, tax, investment, financial, or other advice. Nothing contained here constitutes a solicitation, recommendation, endorsement, or offer by me or any third party service provider to buy or sell any securities or other financial instruments in this or in any other jurisdiction in which such solicitation or offer would be unlawful under the securities laws of such jurisdiction.

If you plan to use real money, USE AT YOUR OWN RISK.

Under no circumstances will I be held responsible or liable in any way for any claims, damages, losses, expenses, costs, or liabilities whatsoever, including, without limitation, any direct or indirect damages for loss of profits.

binance-trade-bot's People

Contributors

abanchev avatar aleksei-grigorovskii-epam avatar algae12 avatar amilkov avatar ardgraft avatar bamooxa avatar benqoder avatar blaklis avatar coinbookbrasil2021 avatar conight avatar danvilar avatar darmiel avatar dmytrolitvinov avatar dv-hoang avatar edeng23 avatar ghostnetrn avatar idkravitz avatar ixtalo avatar j-waters avatar knifa avatar masaiasuose avatar nazegnl avatar nfacha avatar przemyslawsarnacki avatar quantumsheep avatar rel-s avatar s0undt3ch avatar segersniels avatar tdurieux avatar tinchogon34 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance-trade-bot's Issues

Detecting and Using Direct Pairs

Is there a way for me to use the script to only trade between BTC <-USDT -> ETH?

Would this entail that I edit the supported coins file and just input those coins in there and remove the rest?

Would it be better to use market order rather than limit

As the bot uses buy / sell order limit, if the price moves too quickly the order limit may never be filled as it gets placed too low (buy) or too high (sell), when that happens the order just stays open and is never cancelled - would it be better to use market buy / sell?

Here's snip of a log,

Swapping from SNX to USDT no worries,

2021-02-04 09:56:47,586 - crypto_trader_logger - INFO - Scouting...
2021-02-04 09:56:53,686 - crypto_trader_logger - INFO - Scouting...
2021-02-04 09:56:53,925 - crypto_trader_logger - INFO - Will be jumping from SNX to BNB
2021-02-04 09:56:55,310 - crypto_trader_logger - INFO - Selling 56.04 of SNX
2021-02-04 09:56:55,432 - crypto_trader_logger - INFO - Balance is 56.041067
2021-02-04 09:56:55,548 - crypto_trader_logger - INFO - order
2021-02-04 09:56:55,548 - crypto_trader_logger - INFO - {'symbol': 'SNXUSDT', 'orderId': 122188026, 'orderListId': -1, 'clientOrderId': 'eI3gQvilceEdqYESEaM6q8', 'transactTime': 1612432615495, 'price': '0.00000000', 'origQty': '56.04000000', 'executedQty': '56.04000000', 'cummulativeQuoteQty': '1026.33224200', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'fills': [{'price': '18.31600000', 'qty': '7.84100000', 'commission': '0.00206497', 'commissionAsset': 'BNB', 'tradeId': 8131259}, {'price': '18.31400000', 'qty': '48.19900000', 'commission': '0.88271649', 'commissionAsset': 'USDT', 'tradeId': 8131260}]}
2021-02-04 09:56:55,549 - crypto_trader_logger - INFO - Waiting for Binance
2021-02-04 09:57:03,679 - crypto_trader_logger - INFO - {'symbol': 'SNXUSDT', 'orderId': 122188026, 'orderListId': -1, 'clientOrderId': 'eI3gQvilceEdqYESEaM6q8', 'price': '0.00000000', 'origQty': '56.04000000', 'executedQty': '56.04000000', 'cummulativeQuoteQty': '1026.33224200', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'stopPrice': '0.00000000', 'icebergQty': '0.00000000', 'time': 1612432615495, 'updateTime': 1612432615495, 'isWorking': True, 'origQuoteOrderQty': '0.00000000'}
2021-02-04 09:57:03,802 - crypto_trader_logger - INFO - Sold SNX

Puts up buy order limit for BNB but price was moving up too quickly, so never gets filled
2021-02-04 09:57:05,504 - crypto_trader_logger - INFO - BUY QTY 19.68
2021-02-04 09:57:05,735 - crypto_trader_logger - INFO - {'symbol': 'BNBUSDT', 'orderId': 1374648203, 'orderListId': -1, 'clientOrderId': 'ZFLc7YahEHewDF0AylcxrM', 'transactTime': 1612432625681, 'price': '52.09000000', 'origQty': '19.68000000', 'executedQty': '0.00000000', 'cummulativeQuoteQty': '0.00000000', 'status': 'NEW', 'timeInForce': 'GTC', 'type': 'LIMIT', 'side': 'BUY', 'fills': []}
2021-02-04 21:09:06,381 - crypto_trader_logger - INFO - ('Connection aborted.', OSError("(104, 'ECONNRESET')"))
2021-02-04 21:09:07,524 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-04 21:09:08,661 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-04 21:09:09,578 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-04 21:09:10,755 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-04 21:09:11,702 - crypto_trader_logger - INFO - BUY QTY 0.0
.... this just repeats indefinitely

Would market order work better or has that already been ruled out? could a parameter to use either Limit Order or Market Order be added somewhere so we could easily switch between the two?

Main coin price caching

When the trade threshold is being updated the current_coin price is requested on each loop iteration. Why not calculate it once before the loop and reuse it inside. This may get a price that is couple of seconds stale, but improves the performance a lot.

The same for the scouting, we could calculate the curr_coin_price before the loop, and if a trade jump occurs we can break out of the loop

Tried to SET current coin to XVG, gives following error

2021-02-13 16:37:04,034 - crypto_trader_logger - INFO - Started
2021-02-13 16:37:04,960 - crypto_trader_logger - INFO - Initializing XLM vs XLM
2021-02-13 16:37:05,278 - crypto_trader_logger - INFO - Initializing XLM vs TRX
2021-02-13 16:37:05,694 - crypto_trader_logger - INFO - Initializing XLM vs ICX
2021-02-13 16:37:06,020 - crypto_trader_logger - INFO - Initializing XLM vs EOS
2021-02-13 16:37:06,346 - crypto_trader_logger - INFO - Initializing XLM vs IOTA
2021-02-13 16:37:06,694 - crypto_trader_logger - INFO - Initializing XLM vs ONT
2021-02-13 16:37:08,061 - crypto_trader_logger - INFO - Initializing XLM vs QTUM
2021-02-13 16:37:08,406 - crypto_trader_logger - INFO - Initializing XLM vs ETC
2021-02-13 16:37:08,846 - crypto_trader_logger - INFO - Initializing XLM vs XVG
Traceback (most recent call last):
File "crypto_trading.py", line 362, in
main()
File "crypto_trading.py", line 351, in main
initialize_trade_thresholds(client)
File "crypto_trading.py", line 317, in initialize_trade_thresholds
float(get_market_ticker_price(client, coin + 'USDT'))
TypeError: float() argument must be a string or a number, not 'NoneType'

DO NOT RUN THE PROGRAM FOR ME

I have done all the steps from visual studio but when I run the program with the command it runs and it instantly shuts down. Somebody help me please?

get_market_ticker_price() returning NoneType

This is the error I'm getting. I just added USDT to the current coins

Traceback (most recent call last):
  File "crypto_trading.py", line 349, in <module>
    main()
  File "crypto_trading.py", line 338, in main
    initialize_trade_thresholds(client)
  File "crypto_trading.py", line 304, in initialize_trade_thresholds
    float(get_market_ticker_price(client, coin + 'USDT'))
TypeError: float() argument must be a string or a number, not 'NoneType'

APIError(code=-1013): Invalid price.

Hello,
I encountered an issue when attempting to order a limit buy. Specifically, I assigned order_price = get_market_ticker_price(client, alt_symbol+crypto_symbol) * 1.005 then rounded decimal places using math.floor(order_price * floor(10 ** ticks[alt_symbol])) / floor(10 ** ticks[alt_symbol]).

Eventually, I got "APIError(code=-1013): Invalid price" error. How to resolve this?

Error installing Dep

Anyone managed to run this on Mac OS?
I am getting below error:

ERROR: Command errored out with exit status 1: /Library/Developer/CommandLineTools/usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-4r84o1lb/twisted_f26a68bf0dac4915a457aa54e4911bdf/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-4r84o1lb/twisted_f26a68bf0dac4915a457aa54e4911bdf/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-js45t0wc/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Python/3.8/include/Twisted Check the logs for full command output.

Current coin sold but the opt is never bought

Hi, unfortunately there's no chat or forum for this bot. I would like to thank edeng23 for posting the code.
I faced this problem several times already:
The sell is done but the buy can't be done because the price jumped high. In this case the bot will stay in this loop forever (until the price goes down back which can never happen):
function buy_alt
while stat[u'status'] != 'FILLED':
There should be timer implemented and a logic if the buy can't be done on a desired price after some time we have to buy something else, update the threashold table and return to scouting.

What do you think?

profit and loss

I am asking for those who use the bot, can you write your profit and loss situation?

When I first run it, it was -10%.

Failed to Buy/Sell

Hi. I'm struggling to start the program and receive the failed to buy/sell error.

Everything is set up correctly including the API.

Any ideas please?

Telegram notifications

I added a telegram bot to the script as I'm running it from a container from my nas.

It this interesting to submit as new functionality? I've not coded py before so i don't think the code is the best but i got it working in an hour or so.

Via telegram BotFather there are instructions to create a bot where messages are sent.

thiazzz@efcfed1

thiazzz@37df6cd

Stuck on BUY QTY

Attempts to swap from ADA to OMG,

2021-02-05 14:22:10,593 - crypto_trader_logger - INFO - Scouting...
2021-02-05 14:22:19,033 - crypto_trader_logger - INFO - Scouting...
2021-02-05 14:22:27,678 - crypto_trader_logger - INFO - Scouting...
2021-02-05 14:22:31,297 - crypto_trader_logger - INFO - Will be jumping from ADA to OMG
2021-02-05 14:22:32,664 - crypto_trader_logger - INFO - Selling 1976.0 of ADA
2021-02-05 14:22:32,786 - crypto_trader_logger - INFO - Balance is 1976.022
2021-02-05 14:22:32,898 - crypto_trader_logger - INFO - order
2021-02-05 14:22:32,898 - crypto_trader_logger - INFO - {'symbol': 'ADAUSDT', 'orderId': 880992292, 'orderListId': -1, 'clientOrderId': 'l2yoG0mJ3KTYa7Va64NXdR', 'transactTime': 1612534952846, 'price': '0.00000000', 'origQty': '1976.00000000', 'executedQty': '1976.00000000', 'cummulativeQuoteQty': '1003.49184000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'fills': [{'price': '0.50784000', 'qty': '1976.00000000', 'commission': '1.00349184', 'commissionAsset': 'USDT', 'tradeId': 66013675}]}
2021-02-05 14:22:32,898 - crypto_trader_logger - INFO - Waiting for Binance
2021-02-05 14:22:41,028 - crypto_trader_logger - INFO - APIError(code=-2013): Order does not exist.
2021-02-05 14:22:54,160 - crypto_trader_logger - INFO - {'symbol': 'ADAUSDT', 'orderId': 880992292, 'orderListId': -1, 'clientOrderId': 'l2yoG0mJ3KTYa7Va64NXdR', 'price': '0.00000000', 'origQty': '1976.00000000', 'executedQty': '1976.00000000', 'cummulativeQuoteQty': '1003.49184000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'stopPrice': '0.00000000', 'icebergQty': '0.00000000', 'time': 1612534952846, 'updateTime': 1612534952846, 'isWorking': True, 'origQuoteOrderQty': '0.00000000'}
2021-02-05 14:22:54,280 - crypto_trader_logger - INFO - Sold ADA

Buys OMG without any issues per this screen shot - the timestamps of logs don't match the screen shot as my host running the bot has different timezone, just keep forgetting to fix it.

image

but it still continues to try and buy 0.1,
2021-02-05 14:22:55,758 - crypto_trader_logger - INFO - BUY QTY 201.7
2021-02-05 14:22:55,989 - crypto_trader_logger - INFO - {'symbol': 'OMGUSDT', 'orderId': 356543082, 'orderListId': -1, 'clientOrderId': 'X7fRAlNsFpvsnW0IiEphTy', 'transactTime': 1612534975936, 'price': '4.96860000', 'origQty': '201.70000000', 'executedQty': '0.00000000', 'cummulativeQuoteQty': '0.00000000', 'status': 'NEW', 'timeInForce': 'GTC', 'type': 'LIMIT', 'side': 'BUY', 'fills': []}
2021-02-05 14:22:59,235 - crypto_trader_logger - INFO - APIError(code=-2013): Order does not exist.
2021-02-05 14:22:59,718 - crypto_trader_logger - INFO - BUY QTY 0.1
2021-02-05 14:23:00,324 - crypto_trader_logger - INFO - BUY QTY 0.1
2021-02-05 14:23:01,139 - crypto_trader_logger - INFO - BUY QTY 0.1
...
2021-02-05 21:50:20,343 - crypto_trader_logger - INFO - BUY QTY 0.1
2021-02-05 21:50:20,950 - crypto_trader_logger - INFO - BUY QTY 0.1
2021-02-05 21:50:21,559 - crypto_trader_logger - INFO - BUY QTY 0.1

In this case I've had to manually intervene;

  • stopped the application
  • delete .current_coin and .current_coin_table
  • change current_coin in user.cfg to OMG
  • restart application

Bot will keep attempting to perform a swap for ADA (which I assume is last coin in the table?), but we don't have anymore as that was already swapped for OMG before,

Log snip of restart without deleting .current_coin and .current_coin_table
2021-02-05 21:50:56,786 - crypto_trader_logger - INFO - Scouting...
2021-02-05 21:50:57,015 - crypto_trader_logger - INFO - Will be jumping from ADA to XLM
2021-02-05 21:50:58,385 - crypto_trader_logger - INFO - Selling 0.0 of ADA
2021-02-05 21:50:58,502 - crypto_trader_logger - INFO - Balance is 0.022
2021-02-05 21:50:58,617 - crypto_trader_logger - INFO - APIError(code=-1013): Invalid quantity.
2021-02-05 21:50:58,989 - crypto_trader_logger - INFO - Selling 0.0 of ADA
2021-02-05 21:50:59,114 - crypto_trader_logger - INFO - Balance is 0.022
2021-02-05 21:50:59,700 - crypto_trader_logger - INFO - Selling 0.0 of ADA

can u?

Maybe u can make it for list of coins, not only 4 one?)

Getting 1000ms Time issue

My PC Clock is to the second to that of the binance app and I am getting as soon as iot says it want to jump "Timestamp for this request is 1000ms ahead of the server's time "

Order failing

2021-01-30 18:17:10,529 - crypto_trader_logger - INFO - Started
2021-01-30 18:17:32,089 - crypto_trader_logger - INFO - Jumping from DOGE to XLM
2021-01-30 18:17:35,329 - crypto_trader_logger - INFO - APIError(code=-1013): Invalid quantity.

Its trying to sell the qty of 0.0

Account has insufficient balance for request action

I got this error after selling:

2021-02-16 21:00:23
APIError(code=-2010): Account has insufficient balance for requested action.

It took a few tries until it bought a new currency, but not sure why this happened?

ERROR! Since there is no backup file, a proper coin name must be provided at init

Hi,

I'm trying to test out your bot but I keep getting the following error:
ERROR! Since there is no backup file, a proper coin name must be provided at init

Steps I followed:

  1. Cloned the repo
  2. Installed requirements
  3. Created a file called user.cfg and inserted the following:
    [binance_user_config] api_key=*********************** api_secret_key=******************* current_coin=XRP

Any ideas as to what could be going wrong?

Feature: multiprocessing in initialize_trade_thresholds

First of all thanks for sharing the project.

When I add a lot of alt coins the initialize_trade_thresholds is very slow. I added multi core support to speed it a little. Hope you find it useful.

import multiprocessing as mp

def get_coin_value(client, coin_dict, coin):
    coin_dict_price = float(get_market_ticker_price(client, coin_dict + 'USDT'))
    coin_price = float(get_market_ticker_price(client, coin + 'USDT'))
    return coin_dict, coin, coin_dict_price / coin_price

def add_coin(results):
    coin_dict = results[0]
    coin = results[1]
    price = results[2]
    g_state.coin_table[coin_dict][coin] = price

def initialize_trade_thresholds(client):
    '''
    Initialize the buying threshold of all the coins for trading between them
    '''
    global g_state
    
    pool = mp.Pool(processes=14) # core count - 2
    for coin_dict in g_state.coin_table.copy():
        for coin in supported_coin_list:
            if coin != coin_dict:
                pool.apply_async(get_coin_value, args = (client, coin_dict, coin, ), callback = add_coin)
    pool.close()
    pool.join()

    with open(g_state._table_backup_file, "w") as backup_file:
        json.dump(g_state.coin_table, backup_file)

Trading stops after "Bought "XXX""

I have been noticing a strange phenomena with the bot.

It suddenly and randomly stops trading after buying a crypto, the latest was ICX.

It shows no error, or anything, it just sits there with:

2021-02-17 01:00:42,066 - crypto_trader_logger - INFO - Bought ATOM
2021-02-17 01:03:22,017 - crypto_trader_logger - INFO - Will be jumping from ATOM to ICX
2021-02-17 01:03:23,529 - crypto_trader_logger - INFO - Selling 3.3 of ATOM
2021-02-17 01:03:23,757 - crypto_trader_logger - INFO - Balance is 3.30736
2021-02-17 01:03:23,985 - crypto_trader_logger - INFO - order
2021-02-17 01:03:23,987 - crypto_trader_logger - INFO - {'symbol': 'ATOMUSDT', 'orderId': 314607984, 'orderListId': -1, 'clientOrderId': 'FlLbzCxm9m1UMBkS2HrXd2', 'transactTime': 1613520203876, 'price': '0.00000000', 'origQty': '3.30000000', 'executedQty': '3.30000000', 'cummulativeQuoteQty': '82.33170000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'fills': [{'price': '24.94900000', 'qty': '3.30000000', 'commission': '0.08233170', 'commissionAsset': 'USDT', 'tradeId': 21429788}]}
2021-02-17 01:03:23,989 - crypto_trader_logger - INFO - Waiting for Binance
2021-02-17 01:03:32,220 - crypto_trader_logger - INFO - {'symbol': 'ATOMUSDT', 'orderId': 314607984, 'orderListId': -1, 'clientOrderId': 'FlLbzCxm9m1UMBkS2HrXd2', 'price': '0.00000000', 'origQty': '3.30000000', 'executedQty': '3.30000000', 'cummulativeQuoteQty': '82.33170000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'stopPrice': '0.00000000', 'icebergQty': '0.00000000', 'time': 1613520203876, 'updateTime': 1613520203876, 'isWorking': True, 'origQuoteOrderQty': '0.00000000'}
2021-02-17 01:03:32,463 - crypto_trader_logger - INFO - Sold ATOM
2021-02-17 01:03:36,841 - crypto_trader_logger - INFO - BUY QTY 48.3
2021-02-17 01:03:37,305 - crypto_trader_logger - INFO - {'symbol': 'ICXUSDT', 'orderId': 175101890, 'orderListId': -1, 'clientOrderId': 'I6FrIxUrdykrvTZhzqWVIi', 'transactTime': 1613520217179, 'price': '1.70150000', 'origQty': '48.30000000', 'executedQty': '0.00000000', 'cummulativeQuoteQty': '0.00000000', 'status': 'NEW', 'timeInForce': 'GTC', 'type': 'LIMIT', 'side': 'BUY', 'fills': []}
2021-02-17 01:03:42,176 - crypto_trader_logger - INFO - Bought ICX

In a few occasions it stays like this for hours. It usually trades for the first 15 mins then stops forever.
When I then close it and reopen it, it sits at:
2021-02-17 01:21:19,827 - crypto_trader_logger - INFO - Started

Has anyone encountered this issue, if so, how did you go about it?

What i usually do is, delete : ".current_coin_table" and ".current_coin" then it kind of starts again, then stops after around 15 minutes.

ERROR in _make_request six.raise_from(e, None)

after leaving the Code running over night, I woke up to this Error Message, im quite new to Python (im more of a C++ guy). Anyone got any ideas?

Traceback (most recent call last):
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\util\retry.py", line 531, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\packages\six.py", line 735, in reraise
    raise value
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\binance-trade-bot-master\crypto_trading.py", line 365, in main
    scout(client)
  File "D:\binance-trade-bot-master\crypto_trading.py", line 332, in scout
    curr_coin_price = float(get_market_ticker_price(
  File "D:\binance-trade-bot-master\crypto_trading.py", line 140, in get_market_ticker_price
    for ticker in client.get_symbol_ticker():
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\binance\client.py", line 1035, in get_symbol_ticker
    return self._get('ticker/price', data=params, version=self.PRIVATE_API_VERSION)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\binance\client.py", line 237, in _get
    return self._request_api('get', path, signed, version, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\binance\client.py", line 202, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\binance\client.py", line 196, in _request
    self.response = getattr(self.session, method)(uri, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\util\connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\socket.py", line 953, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connection.py", line 353, in connect
    conn = self._new_conn()
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x00000278C7ED5E50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\util\retry.py", line 573, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1616917551:AAFvK9u7kJkJOcJedLrsGV3Ew-MzYzcIh3g/sendMessage (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000278C7ED5E50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\binance-trade-bot-master\crypto_trading.py", line 371, in <module>
    main()
  File "D:\binance-trade-bot-master\crypto_trading.py", line 367, in main
    logger.info('Error while scouting...\n{}\n'.format(e))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 1434, in info
    self._log(INFO, msg, args, **kwargs)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 1577, in _log
    self.handle(record)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 1587, in handle
    self.callHandlers(record)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 1649, in callHandlers
    hdlr.handle(record)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\logging\__init__.py", line 948, in handle
    self.emit(record)
  File "D:\binance-trade-bot-master\crypto_trading.py", line 53, in emit
    return requests.post("https://api.telegram.org/bot{token}/sendMessage".format(token=TELEGRAM_TOKEN),data=payload).content
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Samuel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot1616917551:AAFvK9u7kJkJOcJedLrsGV3Ew-MzYzcIh3g/sendMessage (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000278C7ED5E50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

D:\binance-trade-bot-master>pause

"APIError(code=-2013): Order does not exist" is not handled

Firstly, thanks for the publication. I've used this for couple days while watching over what it does, and it seems to work fairly well to your theory.

But there is a problem:
Sometimes the script gets stuck in loop during transaction_through_tether() due to APIError(code=-2013): Order does not exist, and leaves the currency in Tether.

I assume it is due to this section:

order = client.order_limit_buy(
symbol=alt_symbol + crypto_symbol,
quantity=order_quantity,
price=get_market_ticker_price(client, alt_symbol+crypto_symbol)
)

I've adjusted the section as seen below, as a band-aid fix, but it might be better to have more graceful check for it.
(Also, I am not completely certain this solves the problem, as it seems to be sporadic)

order = None
while order is None:
    order = client.order_limit_buy(
        symbol=alt_symbol + crypto_symbol,
        quantity=order_quantity,
        price=get_market_ticker_price(client, alt_symbol+crypto_symbol)
    )

Coin


ERROR!
Since there is no backup file, a proper coin name must be provided at init


Log file

Hi, I have been running the bot for 4 days so far. I believe that the scouting shouldn't be included in the log because it doesn't provide any useful information and just contributes to large log files. My log file is now effectively 22k lines long. Also, I can provide you with the trades the bot performed for analysis if that's something you are interested in.

COIN=COIN

I think its bug when script tries to do this: crypto_trader_logger - INFO - Initializing BTC vs BTC
And can you add quantity?

Invalid Quantity 1013

Hi I keep getting Invalid quantity after the 1st few trades even though there is USDT in my account available

image

Account balance in USDT swings wildly each day

I've been running the bot for 5 days now and noticed the total USDT one day will be $96 then $160 the next then back down to $92 the next day. Am I mistaken in thinking this bot is suppose to gradually increase the USDT profits or is the profit only noticed when holding the original coin that you started with? Kind of hard to gauge if the bot is working properly but then may I am not looking at it right.

Error While Scouting Temporary failure in name resolution

Could this be possible because of connection issues?

2021-02-13 17:21:26,438 - crypto_trader_logger - INFO - Bought XLM
2021-02-13 17:48:42,678 - crypto_trader_logger - INFO - Error while scouting...
HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)

2021-02-13 17:49:37,978 - crypto_trader_logger - INFO - Error while scouting...
HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)

2021-02-13 17:52:12,911 - crypto_trader_logger - INFO - Error while scouting...
HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)

2021-02-13 17:52:29,209 - crypto_trader_logger - INFO - Error while scouting...
HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/ticker/price (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f3f56e2ff10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

2021-02-13 17:56:10,362 - crypto_trader_logger - INFO - Error while scouting...
HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)

crypto_trader_logger - INFO - APIError(code=-1013): Filter failure: MIN_NOTIONAL

Afer this error , program falls into infinite loop with:
2021-02-13 21:20:08,520 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:08,752 - crypto_trader_logger - INFO - Balance is 199.8

on and on and on..

2021-02-13 21:19:19,245 - crypto_trader_logger - INFO - Started
Scouting...{} 0
Scouting...{} 1
Scouting...{} 2
Scouting...{} 3
2021-02-13 21:20:05,065 - crypto_trader_logger - INFO - Will be jumping from DOGE to ICX
2021-02-13 21:20:06,591 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:06,825 - crypto_trader_logger - INFO - Balance is 199.8
Failed to Buy/Sell. Trying Again.
2021-02-13 21:20:07,050 - crypto_trader_logger - INFO - APIError(code=-1013): Filter failure: MIN_NOTIONAL
2021-02-13 21:20:07,536 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:07,770 - crypto_trader_logger - INFO - Balance is 199.8
Failed to Buy/Sell. Trying Again.
2021-02-13 21:20:08,520 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:08,752 - crypto_trader_logger - INFO - Balance is 199.8
Failed to Buy/Sell. Trying Again.
2021-02-13 21:20:09,680 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:09,915 - crypto_trader_logger - INFO - Balance is 199.8
Failed to Buy/Sell. Trying Again.
2021-02-13 21:20:10,643 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:10,876 - crypto_trader_logger - INFO - Balance is 199.8
cFailed to Buy/Sell. Trying Again.
2021-02-13 21:20:11,634 - crypto_trader_logger - INFO - Selling 100.0 of DOGE
2021-02-13 21:20:11,866 - crypto_trader_logger - INFO - Balance is 199.8

until i break the program with ctrl c

Why it bought only 200DOGE, and left almost 3 USDT ? and why it want to sell only 100 of DOGE instead of 200?
As i understand i cannot sell because there is too small transaction, then why only sell 100 DOGE?

APIError(code=-2015)

2021-02-13 10:55:03,901 - crypto_trader_logger - INFO - APIError(code=-2015): Invalid API-key, IP, or permissions for action.

I believe this is because I am using a Binance.US api key?
Is it possible to get it to work with Binance.US also?

Bot leaves very small amounts of currencies during the exchange.

Your bot works with no problems so good job but I do not fully understnd why it keeps very small changes of currencies during every exchange.
After a few exchanges carried out with the help of the bot I have small leftovers of every exchanged currency in my wallet.
Those changes are too small to convert and there's no further use of them.
Is it possible to change bot's logic so it uses MAX amount of given currency on exchange?

tradeAmount

Can the tradeAmount parameter be added?
Is it okay to make a transaction by chat, not with the full balance?
thanks.

tradeAmount = 100.0 USDT

update coins without deleting old cache

update_trade_threshold should loop through supported_coin_list instead of the current coin_table
this way if we add any coins to the list (and restart the script) it will take them into account after at least one trade is completed

of course care should be taken that the current or next coin is not removed from the list

Re-create Order if Price Shoots Up

Is it possible to cancel an order and recreate it at a new price if the price shoots up past the buy limit?

For example, a buy order is placed for $1 a coin but the price instantly shoots to $1.20 when the order is placed. It will attempt to place the order over and over but fail until the price drops back down.

Instead, can it cancel the order after a certain number of attempts and place a new one for the new price? Or switch to another coin if that's not possible?

Infinite BUY QTY 0.0 loop

After some time trading this was the result, IOTA was sold and XMR was bought, but the code didn't detect it and went into an infinite loop. After killing and restarting the app the .current_coin was still listed as IOTA.

2021-02-07 19:03:21,386 - crypto_trader_logger - INFO - Scouting...
2021-02-07 19:03:26,351 - crypto_trader_logger - INFO - Will be jumping from IOTA to XMR
2021-02-07 19:03:28,132 - crypto_trader_logger - INFO - Selling 436.9 of IOTA
2021-02-07 19:03:28,376 - crypto_trader_logger - INFO - Balance is 436.93577
2021-02-07 19:03:28,622 - crypto_trader_logger - INFO - order
2021-02-07 19:03:28,622 - crypto_trader_logger - INFO - {'symbol': 'IOTAUSDT', 'orderId': 163337096, 'orderListId': -1, 'clientOrderId': 'q1TGWbcI7XhGyMNsBUfWsc', 'transactTime': 1612724608504, 'price': '0.00000000', 'origQty': '436.90000000', 'executedQty': '436.90000000', 'cummulativeQuoteQty': '242.12998000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'fills': [{'price': '0.55420000', 'qty': '436.90000000', 'commission': '0.24212998', 'commissionAsset': 'USDT', 'tradeId': 13046599}]}
2021-02-07 19:03:28,623 - crypto_trader_logger - INFO - Waiting for Binance
2021-02-07 19:03:36,882 - crypto_trader_logger - INFO - {'symbol': 'IOTAUSDT', 'orderId': 163337096, 'orderListId': -1, 'clientOrderId': 'q1TGWbcI7XhGyMNsBUfWsc', 'price': '0.00000000', 'origQty': '436.90000000', 'executedQty': '436.90000000', 'cummulativeQuoteQty': '242.12998000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'stopPrice': '0.00000000', 'icebergQty': '0.00000000', 'time': 1612724608504, 'updateTime': 1612724608504, 'isWorking': True, 'origQuoteOrderQty': '0.00000000'}
2021-02-07 19:03:37,130 - crypto_trader_logger - INFO - Sold IOTA
2021-02-07 19:03:39,169 - crypto_trader_logger - INFO - BUY QTY 1.6246
2021-02-07 19:03:39,663 - crypto_trader_logger - INFO - {'symbol': 'XMRUSDT', 'orderId': 405283291, 'orderListId': -1, 'clientOrderId': 'mZM4HWQpBRxy1IJTzpINCr', 'transactTime': 1612724619543, 'price': '148.90000000', 'origQty': '1.62460000', 'executedQty': '0.00000000', 'cummulativeQuoteQty': '0.00000000', 'status': 'NEW', 'timeInForce': 'GTC', 'type': 'LIMIT', 'side': 'BUY', 'fills': []}
2021-02-07 19:03:46,900 - crypto_trader_logger - INFO - APIError(code=-2013): Order does not exist.
2021-02-07 19:03:47,692 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:48,986 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:50,257 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:51,536 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:52,827 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:54,131 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:55,418 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:56,699 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-07 19:03:58,024 - crypto_trader_logger - INFO - BUY QTY 0.0

Default currency list

Is there a reason why these currencies were selected in the list. Is there a reason not to include more coins (any negatives if we add too many coins?). Why BTC is not in the list for example?

Error while scouting...

ahh Blackadder,

Probably more of a question as I'm a bit new to all this. Are you able to explain the message "Error while scouting..." in a little more detail? I can get the script running but in the logger, file I'm getting the following (continually);
2019-07-14 15:10:30,742 - crypto_trader_logger - INFO - Jumping from XRP to ALGO
2019-07-14 15:10:31,070 - crypto_trader_logger - INFO - Error while scouting...
2019-07-14 15:12:38,962 - crypto_trader_logger - INFO - Jumping from XRP to ALGO
2019-07-14 15:12:39,295 - crypto_trader_logger - INFO - Error while scouting...

Thanks

How to reset the bot?

Is there any way to reset the bot?
I have changed my tokens in the .py file but it keeps reverting to my previous choices.

Order does not exist

First order is executed but than it gives a "Order does not exist" causing it to have no balance to continue

2021-01-30 22:46:04,838 - crypto_trader_logger - INFO - Jumping from DOGE to XLM
2021-01-30 22:46:07,051 - crypto_trader_logger - INFO - order
2021-01-30 22:46:07,051 - crypto_trader_logger - INFO - {'symbol': 'DOGEUSDT', 'orderId': 167939712, 'orderListId': -1, 'clientOrderId': '52j6rP6AUqajIprbUEd3LG', 'transactTime': 1612043166940, 'price': '0.00000000', 'origQty': '2100.00000000', 'executedQty': '2100.00000000', 'cummulativeQuoteQty': '56.86191000', 'status': 'FILLED', 'timeInForce': 'GTC', 'type': 'MARKET', 'side': 'SELL', 'fills': [{'price': '0.02707710', 'qty': '2100.00000000', 'commission': '0.05686191', 'commissionAsset': 'USDT', 'tradeId': 19356651}]}
2021-01-30 22:46:09,291 - crypto_trader_logger - INFO - APIError(code=-2013): Order does not exist.
2021-01-30 22:46:12,142 - crypto_trader_logger - INFO - Jumping from DOGE to XLM
2021-01-30 22:46:14,373 - crypto_trader_logger - INFO - APIError(code=-1013): Invalid quantity.

APIError(code=-1022): Signature for this request is not valid

hi there,

i searched the issues and the code already but could not find an answer, also did some googling and found out about a param called: recvWindow

and checked this page but i dont know your code too little: https://dev.binance.vision/t/faq-signature-for-this-request-is-not-valid/176

logs:

➜  binance-trade-bot git:(master) ✗ ./crypto_trading.py
Failed to Buy/Sell. Trying Again.

2021-02-13 13:22:56,426 - crypto_trader_logger - INFO - Will be jumping from DOGE to TRX
2021-02-13 13:22:58,062 - crypto_trader_logger - INFO - APIError(code=-1022): Signature for this request is not valid.

also my API key is not IP limited.

any idea? 😅

Infinit Loop

sometime i am sucked in infinite loop :(

2021-02-16 11:47:57,415 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-16 11:47:59,526 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-16 11:48:00,774 - crypto_trader_logger - INFO - BUY QTY 0.0
2021-02-16 11:48:02,015 - crypto_trader_logger - INFO - BUY QTY 0.0

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.