mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
catch errors
This commit is contained in:
parent
adbae20a08
commit
b84ec6fc2b
2 changed files with 18 additions and 12 deletions
|
|
@ -4,6 +4,7 @@ import history as hist
|
|||
|
||||
import time
|
||||
|
||||
import sys
|
||||
|
||||
MARKET = input("Pease enter what market you want to use: Kraken or bittrex ").lower()
|
||||
if MARKET == "kraken":
|
||||
|
|
@ -71,10 +72,15 @@ def main():
|
|||
mail.idle()
|
||||
start_time = time.time()
|
||||
while True:
|
||||
|
||||
responses = mail.idle_check(30)
|
||||
print("Server sent:", responses if responses else "nothing")
|
||||
|
||||
try:
|
||||
responses = mail.idle_check(30)
|
||||
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]
|
||||
if list_uid != []:
|
||||
global uid
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ with open(os.getcwd() + "/keys.json") as k:
|
|||
|
||||
API_KEY = keys["public"]
|
||||
PRIV_KEY = keys["priv"]
|
||||
TICKER = "CRVETH"
|
||||
TICKER = "ETHXBT"
|
||||
API = krakenex.API(API_KEY, PRIV_KEY)
|
||||
TIME = ""
|
||||
EXCHANGE = "kraken"
|
||||
|
|
@ -39,7 +39,7 @@ def open_trade():
|
|||
buyprice = marketcheck(TICKER)
|
||||
balancedf = kraken.get_account_balance()
|
||||
# balance = "200"
|
||||
balance = balancedf.vol["XETH"]
|
||||
balance = balancedf.vol["XXBT"]
|
||||
balance = float(balance)
|
||||
global buy_amount
|
||||
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
|
||||
|
|
@ -55,15 +55,15 @@ def open_trade():
|
|||
def close_trade():
|
||||
|
||||
sell_price = marketcheck(TICKER)
|
||||
if TICKER == 'ETHUSD':
|
||||
symbol = 'XETH'
|
||||
if TICKER == 'XBTUSD':
|
||||
symbol ='XXBT'
|
||||
#if TICKER == 'ETHUSD':
|
||||
# symbol = 'XETH'
|
||||
#if TICKER == 'XBTUSD':
|
||||
# symbol ='XXBT'
|
||||
|
||||
|
||||
balance = kraken.get_account_balance()
|
||||
sell_amount = buy_amount
|
||||
#sell_amount = balance.vol[symbol]
|
||||
#sell_amount = buy_amount
|
||||
sell_amount = balance.vol['XETH']
|
||||
|
||||
print(kraken.add_standard_order(pair=TICKER, type="sell", ordertype="market", volume=buy_amount, validate=False))
|
||||
print("selling", sell_amount, "of", TICKER)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue