Skip to content

Commit

Permalink
Merge pull request #187 from CyberPunkMetalHead/fix-timout
Browse files Browse the repository at this point in the history
Fix timout
  • Loading branch information
ShogunMan authored Jun 10, 2021
2 parents 8392f54 + 77bfc00 commit 533daf5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Binance Detect Moonings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +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, ConnectionError

# used for dates
from datetime import date, datetime, timedelta
Expand Down Expand Up @@ -589,8 +590,19 @@ def write_log(logline):

# seed initial prices
get_price()
READ_TIMEOUT_COUNT=0
CONNECTION_ERROR_COUNT = 0
while True:
orders, last_price, volume = buy()
update_portfolio(orders, last_price, volume)
coins_sold = sell_coins()
remove_from_portfolio(coins_sold)
try:
orders, last_price, volume = buy()
update_portfolio(orders, last_price, volume)
coins_sold = sell_coins()
remove_from_portfolio(coins_sold)
except ReadTimeout as rt:
READ_TIMEOUT_COUNT += 1
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}')


0 comments on commit 533daf5

Please sign in to comment.