This commit is contained in:
Death916 2018-08-01 19:24:29 -07:00
parent 1afba9e91b
commit 4115aa8ddd
2 changed files with 13 additions and 18 deletions

View file

@ -16,7 +16,7 @@ last_alert = 0
def start_buy(): def start_buy():
print('trade is a buy') print('trade is a buy')
trade.open_trade(1) trade.open_trade()
global last_alert global last_alert
last_alert = "buy" last_alert = "buy"
hist.tradehist('buy test') hist.tradehist('buy test')
@ -25,7 +25,7 @@ def start_buy():
def start_sell(): def start_sell():
print('trade is a sell') print('trade is a sell')
trade.close_trade(1) trade.close_trade()
global last_alert global last_alert
last_alert = "sell" last_alert = "sell"
hist.tradehist('sell test') hist.tradehist('sell test')
@ -51,12 +51,11 @@ last_uid = 0
def main(): def main():
s = gconnect() s = gconnect()
idle = s
s.idle() s.idle()
start_time = time.time() start_time = time.time()
while True: while True:
responses = idle.idle_check(30) responses = s.idle_check(30)
print("Server sent:", responses if responses else "nothing") print("Server sent:", responses if responses else "nothing")
@ -91,18 +90,14 @@ def main():
if trade.open_orders() != None: if trade.open_orders() != None:
print(trade.open_orders()) print(trade.open_orders())
if time.time() - start_time > 1740: if time.time() - start_time > 1000:
try:
s.idle_done() s.idle_done()
print('restarting connection') print('restarting connection')
s = gconnect() s = gconnect()
s.idle() s.idle()
start_time = time.time() start_time = time.time()
except:
print('restart failed')
s = gconnect()
s.idle()
start_time = time.time()

View file

@ -21,7 +21,7 @@ def marketcheck(ticker):
return price return price
def open_trade(amount): def open_trade():
global buyprice global buyprice
buyprice = marketcheck(ticker) buyprice = marketcheck(ticker)
global buy_amount global buy_amount
@ -31,7 +31,7 @@ def open_trade(amount):
hist.tradehist('bought ' + str(buy_amount) + ' of ' + ticker + ' at ' + str(buyprice)) hist.tradehist('bought ' + str(buy_amount) + ' of ' + ticker + ' at ' + str(buyprice))
return return
def close_trade(amount): def close_trade():
global sellprice global sellprice
sellprice = marketcheck(ticker) sellprice = marketcheck(ticker)
amount = .0005 / sellprice amount = .0005 / sellprice