edeng23 / binance-trade-bot Goto Github PK
View Code? Open in Web Editor NEWAutomated cryptocurrency trading bot
License: GNU General Public License v3.0
Automated cryptocurrency trading bot
License: GNU General Public License v3.0
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.
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)
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?
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?
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)
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?
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
Any idea how to solve that?
2021-02-10 11:44:08,587 - crypto_trader_logger - INFO - APIError(code=-1013): Filter failure: MIN_NOTIONAL
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
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
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
Maybe stupid question, but I can't read the py script so well.
What is the time interval the bot checks the prices?
Can I just leave it running in the terminal?
I think its bug when script tries to do this: crypto_trader_logger - INFO - Initializing BTC vs BTC
And can you add quantity?
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.
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%.
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.
It seems that it buys a coin (VET in this case) and then everything after is this error
Hi,
Wondered if you could help.
just updated to the latest Master code and I keep on getting this when kicking off the script.
Any ideas?
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.
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?
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
ERROR!
Since there is no backup file, a proper coin name must be provided at init
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.
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
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.
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;
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
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'
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?
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?
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?
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'
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?
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.
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?
Hi,
Firstly, thanks for the publication.
I found this error
"APIError(code=-2014): API-key format invalid."
Plaese Let me know .How to solve this error?
Thank you
Hi am getting this error in log all the times.
2021-02-16 11:37:53,993 - crypto_trader_logger - INFO - APIError(code=-2013): Order does not exist.
can anybody help me ?
Anyone with this error?
RecursionError: maximum recursion depth exceeded
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
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?
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?
Maybe u can make it for list of coins, not only 4 one?)
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? 😅
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:
[binance_user_config] api_key=*********************** api_secret_key=******************* current_coin=XRP
Any ideas as to what could be going wrong?
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?
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.
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
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 "
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:
binance-trade-bot/crypto_trading.py
Lines 116 to 120 in 5078434
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)
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.