edeng23 / binance-trade-bot

Automated cryptocurrency trading bot
GNU General Public License v3.0
8k stars 2.21k forks source link

crypto_trading_logger - ERROR - Error while scouting...ent coin #235

Open ABTDoug opened 3 years ago

ABTDoug commented 3 years ago

Using the US version, on the current version as of this issue report.

Traceback (most recent call last): File "/mnt/USBDrive/Python/binance-trade-bot/binance-trade-bot/binance_trade_bot/scheduler.py", line 25, in _run_job super()._run_job(job) File "/mnt/USBDrive/Python/binance-trade-bot/lib/python3.7/site-packages/schedule/init.py", line 147, in _run_job ret = job.run() File "/mnt/USBDrive/Python/binance-trade-bot/lib/python3.7/site-packages/schedule/init.py", line 491, in run ret = self.job_func() File "/mnt/USBDrive/Python/binance-trade-bot/binance-trade-bot/binance_trade_bot/strategies/default_strategy.py", line 41, in scout self._jump_to_best_coin(current_coin, current_coin_price, all_tickers) File "/mnt/USBDrive/Python/binance-trade-bot/binance-trade-bot/binance_trade_bot/auto_trader.py", line 129, in _jump_to_best_coin ratio_dict = self._get_ratios(coin, coin_price, all_tickers) File "/mnt/USBDrive/Python/binance-trade-bot/binance-trade-bot/binance_trade_bot/auto_trader.py", line 116, in _get_ratios transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee( File "/mnt/USBDrive/Python/binance-trade-bot/binance-trade-bot/binance_trade_bot/binance_api_manager.py", line 35, in get_fee base_fee = self.get_trade_fees()[origin_coin + target_coin] KeyError: 'DOGEUSDT'

uhaldejm commented 3 years ago

I have a similar issue. On the first run it fails on the first purchase:

2021-03-24 00:36:08,078 - crypto_trading_logger - INFO - Setting initial coin to TRX 2021-03-24 00:36:10,432 - crypto_trading_logger - INFO - Purchasing to begin trading 2021-03-24 00:36:17,142 - crypto_trading_logger - INFO - Failed to Buy/Sell. Trying Again. 2021-03-24 00:36:17,148 - crypto_trading_logger - INFO - unsupported operand type(s) for *: 'NoneType' and 'int' 2021-03-24 00:36:20,785 - crypto_trading_logger - INFO - Failed to Buy/Sell. Trying Again. 2021-03-24 00:36:24,488 - crypto_trading_logger - INFO - Failed to Buy/Sell. Trying Again. 2021-03-24 00:36:28,174 - crypto_trading_logger - INFO - Failed to Buy/Sell. Trying Again.

And after that:

2021-03-24 00:43:34,573 - crypto_trading_logger - ERROR - Error while scouting...ent coin: TRXUSDT Traceback (most recent call last): File "C:\Users\uhald\Projects\Python\binance-trade-bot\binance_trade_bot\scheduler.py", line 25, in _run_job super()._run_job(job) File "C:\Python39\lib\site-packages\schedule__init.py", line 147, in _run_job ret = job.run() File "C:\Python39\lib\site-packages\schedule\init__.py", line 491, in run ret = self.job_func() File "C:\Users\uhald\Projects\Python\binance-trade-bot\binance_trade_bot\strategies\default_strategy.py", line 41, in scout self._jump_to_best_coin(current_coin, current_coin_price, all_tickers) File "C:\Users\uhald\Projects\Python\binance-trade-bot\binance_trade_bot\auto_trader.py", line 129, in _jump_to_best_coin ratio_dict = self._get_ratios(coin, coin_price, all_tickers) File "C:\Users\uhald\Projects\Python\binance-trade-bot\binance_trade_bot\auto_trader.py", line 116, in _get_ratios transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee( File "C:\Users\uhald\Projects\Python\binance-trade-bot\binance_trade_bot\binance_api_manager.py", line 40, in get_fee self._sell_quantity(origin_coin.symbol, target_coin.symbol) File "C:\Users\uhald\Projects\Python\binance-trade-bot\binance_trade_bot\binance_api_manager.py", line 200, in _sell_quantity return math.floor(origin_balance 10 origin_tick) / float(10 origin_tick) TypeError: unsupported operand type(s) for : 'NoneType' and 'int'

ghost commented 3 years ago

I can confirm the failure:

2021-03-27 00:06:50,010 - crypto_trading_logger - ERROR - Error while scouting...
Traceback (most recent call last):
  File "/app/binance_trade_bot/scheduler.py", line 25, in _run_job
    super()._run_job(job)
  File "/usr/local/lib/python3.8/site-packages/schedule/__init__.py", line 147, in _run_job
    ret = job.run()
  File "/usr/local/lib/python3.8/site-packages/schedule/__init__.py", line 491, in run
    ret = self.job_func()
  File "/app/binance_trade_bot/strategies/default_strategy.py", line 41, in scout
    self._jump_to_best_coin(current_coin, current_coin_price, all_tickers)
  File "/app/binance_trade_bot/auto_trader.py", line 129, in _jump_to_best_coin
    ratio_dict = self._get_ratios(coin, coin_price, all_tickers)
  File "/app/binance_trade_bot/auto_trader.py", line 116, in _get_ratios
    transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee(
  File "/app/binance_trade_bot/binance_api_manager.py", line 35, in get_fee
    base_fee = self.get_trade_fees()[origin_coin + target_coin]
KeyError: 'DOGEUSDT'
edeng23 commented 3 years ago

Hmm strange. Does this happen with other coins or only with DOGE?

ABTDoug commented 3 years ago

@edeng23 It seems to happen with the two coins I've tried, but I'm not sure which one the other one was.

blakeloring commented 3 years ago

I just grabbed the latest code and am getting the same errors. I am holding ADA, and tried setting that to my initial coin as well, but got the same errors.

2021-04-05 15:19:56,555 - crypto_trading_logger - ERROR - Error while scouting...ent coin: ADAUSDT Traceback (most recent call last): File "/home/ubuntu/binance-trade-bot/binance_trade_bot/scheduler.py", line 25, in _run_job super()._run_job(job) File "/home/ubuntu/.local/lib/python3.8/site-packages/schedule/init.py", line 147, in _run_job ret = job.run() File "/home/ubuntu/.local/lib/python3.8/site-packages/schedule/init.py", line 491, in run ret = self.job_func() File "/home/ubuntu/binance-trade-bot/binance_trade_bot/strategies/default_strategy.py", line 40, in scout self._jump_to_best_coin(current_coin, current_coin_price, all_tickers) File "/home/ubuntu/binance-trade-bot/binance_trade_bot/auto_trader.py", line 128, in _jump_to_best_coin ratio_dict = self._get_ratios(coin, coin_price, all_tickers) File "/home/ubuntu/binance-trade-bot/binance_trade_bot/auto_trader.py", line 115, in _get_ratios transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee( File "/home/ubuntu/binance-trade-bot/binance_trade_bot/binance_api_manager.py", line 43, in get_fee base_fee = self.get_trade_fees()[origin_coin + target_coin] KeyError: 'ADAUSDT'

Amraki commented 3 years ago

EDIT: On re-reading the log, it's not the same error. But since it starts the same and appears to be related to the same files, I will still leave the questions: has the cause of the errors in this Issue been identified?

Just got the same error. Did anyone find a solution or at least a workaround? So far has just happened with ZRXUSDT just after buying it.

2021-05-19 23:05:21,154 - crypto_trading_logger - INFO - Starting
2021-05-19 23:05:21,580 - crypto_trading_logger - INFO - Chosen strategy: default
2021-05-19 23:05:21,580 - crypto_trading_logger - INFO - Buy type: LIMIT, Sell type: MARKET
2021-05-19 23:05:21,581 - crypto_trading_logger - INFO - Creating database schema if it doesn't already exist
2021-05-19 23:05:23,408 - crypto_trading_logger - INFO - Setting initial coin to ZRX
2021-05-19 23:05:25,717 - crypto_trading_logger - INFO - Purchasing <ZRX> to begin trading
2021-05-19 23:05:29,181 - crypto_trading_logger - INFO - BUY QTY 20.06 of <ZRX>
2021-05-19 23:05:29,234 - crypto_trading_logger - INFO - {'symbol': 'ZRXUSDT', 'orderId': 29518111, 'orderListId': -1, 'clientOrderId': '4KnjU3Ki9ZEypxNeWVA6yG', 'transactTime': 1621479929265, 'price': '0.99030000', 'origQty': '20.06000000', 'executedQty': '0.00000000', 'cummulativeQuoteQty': '0.00000000', 'status': 'NEW', 'timeInForce': 'GTC', 'type': 'LIMIT', 'side': 'BUY', 'fills': []}
2021-05-19 23:05:31,541 - crypto_trading_logger - INFO - Bought ZRX
2021-05-19 23:05:33,832 - crypto_trading_logger - INFO - Ready to start trading
2021-05-19 23:05:35,030 - crypto_trading_logger - ERROR - Error while scouting...ent coin: ZRXUSDT 
Traceback (most recent call last):
  File "C:\Users\Amraki\OneDrive\Cody\VS Code Projects\Binance Trading Bots\binance-trade-bot_idkravitz\binance_trade_bot\scheduler.py", line 25, in _run_job   
    super()._run_job(job)
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\schedule\__init__.py", line 172, in _run_job
    ret = job.run()
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\schedule\__init__.py", line 661, in run
    ret = self.job_func()
  File "C:\Users\Amraki\OneDrive\Cody\VS Code Projects\Binance Trading Bots\binance-trade-bot_idkravitz\binance_trade_bot\strategies\default_strategy.py", line 
32, in scout
    self._jump_to_best_coin(current_coin, current_coin_price)
  File "C:\Users\Amraki\OneDrive\Cody\VS Code Projects\Binance Trading Bots\binance-trade-bot_idkravitz\binance_trade_bot\auto_trader.py", line 146, in _jump_to_best_coin
    ratio_dict, prices = self._get_ratios(coin, coin_price)
  File "C:\Users\Amraki\OneDrive\Cody\VS Code Projects\Binance Trading Bots\binance-trade-bot_idkravitz\binance_trade_bot\auto_trader.py", line 132, in _get_ratios
    transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee(
  File "C:\Users\Amraki\OneDrive\Cody\VS Code Projects\Binance Trading Bots\binance-trade-bot_idkravitz\binance_trade_bot\binance_api_manager.py", line 50, in get_fee
    base_fee = self.get_trade_fees()[origin_coin + target_coin]
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\cachetools\decorators.py", line 26, in wrapper
    v = func(*args, **kwargs)
  File "C:\Users\Amraki\OneDrive\Cody\VS Code Projects\Binance Trading Bots\binance-trade-bot_idkravitz\binance_trade_bot\binance_api_manager.py", line 43, in get_trade_fees
    return {ticker["symbol"]: float(ticker["takerCommission"]) for ticker in self.binance_client.get_trade_fee()}
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 2411, in get_trade_fee
    return self._request_margin_api('get', 'asset/tradeFee', True, data=params)
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 358, in _request_margin_api
    return self._request(method, uri, signed, **kwargs)
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 309, in _request
    return self._handle_response(self.response)
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\client.py", line 318, in _handle_response
    raise BinanceAPIException(response, response.status_code, response.text)
  File "C:\Users\Amraki\AppData\Local\Programs\Python\Python39\lib\site-packages\binance\exceptions.py", line 14, in __init__
    self.code = json_res['code']
KeyError: 'code'
Blaklis commented 3 years ago

This is not the same problem. A patch is already available for the bug described in this ticket.

Amraki commented 3 years ago

I don't see a linked PR for this Issue.

You may be referring to PR #269 that I mentioned previously. I reviewed that solution determining it to be incomplete as I continued to get the same error. Hopefully my comment to it will get acknowledged and the new information will help determine a proper fix.

ragendem commented 3 years ago

I am having this problem with ADA on the US server ERROR - Error while scouting... Traceback (most recent call last): File "C:\tools\binance-trade-bot\binance_trade_bot\scheduler.py", line 25, in _run_job super()._run_job(job) File "C:\Users\Josh\AppData\Local\Programs\Python\Python39\lib\site-packages\schedule__init.py", line 147, in _run_job ret = job.run() File "C:\Users\Josh\AppData\Local\Programs\Python\Python39\lib\site-packages\schedule\init__.py", line 491, in run ret = self.job_func() File "C:\tools\binance-trade-bot\binance_trade_bot\strategies\default_strategy.py", line 34, in scout self._jump_to_best_coin(current_coin, current_coin_price, all_tickers) File "C:\tools\binance-trade-bot\binance_trade_bot\auto_trader.py", line 140, in _jump_to_best_coin ratio_dict = self._get_ratios(coin, coin_price, all_tickers) File "C:\tools\binance-trade-bot\binance_trade_bot\auto_trader.py", line 127, in _get_ratios transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee( File "C:\tools\binance-trade-bot\binance_trade_bot\binance_api_manager.py", line 45, in get_fee base_fee = self.get_trade_fees()[origin_coin + target_coin] KeyError: 'ADAUSDT'

BMoankee commented 3 years ago

I am on the binance US server and I'm having this issue. Also, I cant seem to change trading pairs no matter what I set it to in the config files it always defaults to DOGE 2021-05-31 02:24:14,443 - crypto_trading_logger - ERROR - Error while scouting...ent coin: DOGEUSDT Traceback (most recent call last): File "C:\Users\braid\binance-trade-bot\binance_trade_bot\scheduler.py", line 25, in _run_job super()._run_job(job) File "C:\Python39\lib\site-packages\schedule__init.py", line 172, in _run_job ret = job.run() File "C:\Python39\lib\site-packages\schedule__init__.py", line 661, in run ret = self.job_func() File "C:\Users\braid\binance-trade-bot\binance_trade_bot\strategies\default_strategy.py", line 34, in scout self._jump_to_best_coin(current_coin, current_coin_price, all_tickers) File "C:\Users\braid\binance-trade-bot\binance_trade_bot\auto_trader.py", line 140, in _jump_to_best_coin ratio_dict = self._get_ratios(coin, coin_price, all_tickers) File "C:\Users\braid\binance-trade-bot\binance_trade_bot\auto_trader.py", line 127, in _get_ratios transaction_fee = self.manager.get_fee(pair.from_coin, self.config.BRIDGE, True) + self.manager.get_fee( File "C:\Users\braid\binance-trade-bot\binance_trade_bot\binance_api_manager.py", line 45, in get_fee base_fee = self.get_trade_fees()[origin_coin + target_coin] File "C:\Python39\lib\site-packages\cachetools\decorators.py", line 26, in wrapper v = func(*args, kwargs) File "C:\Users\braid\binance-trade-bot\binance_trade_bot\binance_api_manager.py", line 38, in get_trade_fees return {ticker["symbol"]: ticker["taker"] for ticker in self.binance_client.get_trade_fee()["tradeFee"]} File "C:\Python39\lib\site-packages\binance\client.py", line 2411, in get_trade_fee return self._request_margin_api('get', 'asset/tradeFee', True, data=params) File "C:\Python39\lib\site-packages\binance\client.py", line 358, in _request_margin_api return self._request(method, uri, signed, kwargs) File "C:\Python39\lib\site-packages\binance\client.py", line 309, in _request return self._handle_response(self.response) File "C:\Python39\lib\site-packages\binance\client.py", line 318, in _handle_response raise BinanceAPIException(response, response.status_code, response.text) File "C:\Python39\lib\site-packages\binance\exceptions.py", line 14, in init__ self.code = json_res['code'] KeyError: 'code'

michaelmohamed commented 3 years ago

https://github.com/edeng23/binance-trade-bot/pull/397/files should resolve the KeyError: 'code'