catch errors

This commit is contained in:
root 2021-12-09 01:23:28 -08:00
parent adbae20a08
commit b84ec6fc2b
2 changed files with 18 additions and 12 deletions

View file

@ -4,6 +4,7 @@ import history as hist
import time import time
import sys
MARKET = input("Pease enter what market you want to use: Kraken or bittrex ").lower() MARKET = input("Pease enter what market you want to use: Kraken or bittrex ").lower()
if MARKET == "kraken": if MARKET == "kraken":
@ -71,10 +72,15 @@ def main():
mail.idle() mail.idle()
start_time = time.time() start_time = time.time()
while True: while True:
try:
responses = mail.idle_check(30) responses = mail.idle_check(30)
print("Server sent:", responses if responses else "nothing") print("Server sent:", responses if responses else "nothing")
except KeyboardInterrupt:
print("quitting")
sys.exit(0)
except otherError as e:
print(e)
continue
list_uid = [i[0] for i in responses] list_uid = [i[0] for i in responses]
if list_uid != []: if list_uid != []:
global uid global uid

View file

@ -13,7 +13,7 @@ with open(os.getcwd() + "/keys.json") as k:
API_KEY = keys["public"] API_KEY = keys["public"]
PRIV_KEY = keys["priv"] PRIV_KEY = keys["priv"]
TICKER = "CRVETH" TICKER = "ETHXBT"
API = krakenex.API(API_KEY, PRIV_KEY) API = krakenex.API(API_KEY, PRIV_KEY)
TIME = "" TIME = ""
EXCHANGE = "kraken" EXCHANGE = "kraken"
@ -39,7 +39,7 @@ def open_trade():
buyprice = marketcheck(TICKER) buyprice = marketcheck(TICKER)
balancedf = kraken.get_account_balance() balancedf = kraken.get_account_balance()
# balance = "200" # balance = "200"
balance = balancedf.vol["XETH"] balance = balancedf.vol["XXBT"]
balance = float(balance) balance = float(balance)
global buy_amount global buy_amount
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025 buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
@ -55,15 +55,15 @@ def open_trade():
def close_trade(): def close_trade():
sell_price = marketcheck(TICKER) sell_price = marketcheck(TICKER)
if TICKER == 'ETHUSD': #if TICKER == 'ETHUSD':
symbol = 'XETH' # symbol = 'XETH'
if TICKER == 'XBTUSD': #if TICKER == 'XBTUSD':
symbol ='XXBT' # symbol ='XXBT'
balance = kraken.get_account_balance() balance = kraken.get_account_balance()
sell_amount = buy_amount #sell_amount = buy_amount
#sell_amount = balance.vol[symbol] sell_amount = balance.vol['XETH']
print(kraken.add_standard_order(pair=TICKER, type="sell", ordertype="market", volume=buy_amount, validate=False)) print(kraken.add_standard_order(pair=TICKER, type="sell", ordertype="market", volume=buy_amount, validate=False))
print("selling", sell_amount, "of", TICKER) print("selling", sell_amount, "of", TICKER)