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 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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue