Skip to content

Commit

Permalink
Also added connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan getty committed Jun 9, 2021
1 parent 5e7dcec commit 77bfc00
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Binance Detect Moonings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# needed for the binance API / websockets / Exception handling
from binance.client import Client
from binance.exceptions import BinanceAPIException
from requests.exceptions import ReadTimeout
from requests.exceptions import ReadTimeout, ConnectionError

# used for dates
from datetime import date, datetime, timedelta
Expand Down Expand Up @@ -591,6 +591,7 @@ def write_log(logline):
# seed initial prices
get_price()
READ_TIMEOUT_COUNT=0
CONNECTION_ERROR_COUNT = 0
while True:
try:
orders, last_price, volume = buy()
Expand All @@ -599,4 +600,9 @@ def write_log(logline):
remove_from_portfolio(coins_sold)
except ReadTimeout as rt:
READ_TIMEOUT_COUNT += 1
print(f'We got a timeout error from from binance. Going to re-loop. Current Count: {READ_TIMEOUT_COUNT}')
print(f'{txcolors.WARNING}We got a timeout error from from binance. Going to re-loop. Current Count: {READ_TIMEOUT_COUNT}\n{rt}{txcolors.DEFAULT}')
except ConnectionError as ce:
CONNECTION_ERROR_COUNT +=1
print(f'{txcolors.WARNING}We got a timeout error from from binance. Going to re-loop. Current Count: {CONNECTION_ERROR_COUNT}\n{ce}{txcolors.DEFAULT}')


1 comment on commit 77bfc00

@celltronic01
Copy link

@celltronic01 celltronic01 commented on 77bfc00 Jun 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there
I have a suggestion. Please, if not much of a bother.
1: How about adding cost averaging.
Such as,
Max Amount per trade =$X,
Max Amount per coin = $X,
Max Number of coins to hold =X
If Coin is already in coins bought, and current price of coin is less then coin price in coins bought for, and total of Max Amount per coins($) is less then Max amount per coin($), then buy coin again and update volume quantity, and update bought for price by average cost and keep buying each time the price drops till Max Amount per coin is reached.

Also,

I need help with an issue

Bot functioning fine if Custom List = False
TLD = 'us', all is well.
However, when Customer List = True, and tickers.txt is present with list of coins, I get Key Error (BNBUSD)
Any Suggestions?

This is the Exact Error Message:

Traceback (most recent call last):
File "c:\Users\cellt\OneDrive\Desktop\Trading Bot\Binance\Binance_1.py", line 437, in
orders, last_price, volume = buy()
File "c:\Users\cellt\OneDrive\Desktop\Trading Bot\Binance\Binance_1.py", line 252, in buy
volume, last_price = convert_volume()
File "c:\Users\cellt\OneDrive\Desktop\Trading Bot\Binance\Binance_1.py", line 212, in convert_volume
volatile_coins, number_of_coins, last_price = wait_for_price()
File "c:\Users\cellt\OneDrive\Desktop\Trading Bot\Binance\Binance_1.py", line 157, in wait_for_price
while initial_price['BNB' + PAIR_WITH]['time'] > datetime.now() - timedelta(seconds=TIME_DIFFERENCE):
KeyError: 'BNBUSD'

Please sign in to comment.