This commit is contained in:
Death916 2018-09-21 18:56:22 -07:00
parent f32f6ce52f
commit 504bed83ae

View file

@ -24,10 +24,9 @@ def marketcheck(ticker):
def open_trade():
global buyprice
buyprice = marketcheck(ticker)
global buy_amount
balance = trex.get_balance('BTC')['result']['Available']
buy_amount = balance / buyprice
# print(trex.buy_limit(ticker, amount, rate=buyprice))
print(trex.buy_limit(ticker, buy_amount, rate=buyprice))
print('buying', buy_amount, 'of', ticker)
hist.tradehist('bought ' + str(buy_amount) + ' of ' + ticker + ' at ' + str(buyprice))
return
@ -35,10 +34,10 @@ def open_trade():
def close_trade():
global sellprice
sellprice = marketcheck(ticker)
global buy_amount
sell_amount = buy_amount
#sell_amount = trex.get_balance('ETH')['result']['Available']
# print(trex.sell_limit(ticker, amount, rate=sellprice))
sell_amount = trex.get_balance('ETH')['result']['Available']
print(trex.sell_limit(ticker, sell_amount, rate=sellprice))
print('selling', sell_amount, 'of', ticker)
hist.tradehist('sold ' + str(sell_amount) + ' of ' + ticker + ' at ' + str(sellprice))
hist.tradehist('profit = ' + '{:.25f}'.format((sellprice * sell_amount) - (buyprice * sell_amount)))