diff --git a/getsignal.py b/getsignal.py index 78a2731..72e7aae 100644 --- a/getsignal.py +++ b/getsignal.py @@ -16,16 +16,16 @@ last_alert = 0 def start_buy(): print('trade is a buy') - trade.open_trade(0) + trade.open_trade(1) global last_alert last_alert = "buy" hist.tradehist('buy test') -def start_sell(): +def start_sell(): print('trade is a sell') - trade.close_trade(0) + trade.close_trade(1) global last_alert last_alert = "sell" hist.tradehist('sell test') @@ -100,6 +100,9 @@ def main(): start_time = time.time() except: print('restart failed') + s = gconnect() + s.idle() + start_time = time.time() diff --git a/trade.py b/trade.py index fcf66c9..20c84bf 100644 --- a/trade.py +++ b/trade.py @@ -28,7 +28,7 @@ def open_trade(amount): buy_amount = .0005 / buyprice # print(trex.buy_limit(ticker, amount, rate=buyprice)) print('buying', buy_amount, 'of', ticker) - hist.tradehist('bought ' + str(amount) + ' of ' + ticker + ' at ' + str(buyprice)) + hist.tradehist('bought ' + str(buy_amount) + ' of ' + ticker + ' at ' + str(buyprice)) return def close_trade(amount): @@ -39,7 +39,7 @@ def close_trade(amount): print('selling', amount, 'of', ticker) hist.tradehist('sold ' + str(amount) + ' of ' + ticker + ' at ' + str(sellprice)) global buy_amount - hist.tradehist('profit = ' + '{:.20f}'.format((sellprice * amount) - (buyprice * buy_amount))) + hist.tradehist('profit = ' + '{:.25f}'.format((sellprice * amount) - (buyprice * amount))) def open_orders(): trex.get_open_orders()