mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
live
This commit is contained in:
parent
4115aa8ddd
commit
75a649956d
2 changed files with 21 additions and 15 deletions
20
getsignal.py
20
getsignal.py
|
|
@ -90,14 +90,18 @@ def main():
|
|||
|
||||
if trade.open_orders() != None:
|
||||
print(trade.open_orders())
|
||||
if time.time() - start_time > 1000:
|
||||
|
||||
s.idle_done()
|
||||
print('restarting connection')
|
||||
s = gconnect()
|
||||
s.idle()
|
||||
start_time = time.time()
|
||||
|
||||
if time.time() - start_time > 1740:
|
||||
try:
|
||||
s.idle_done()
|
||||
print('restarting connection')
|
||||
s = gconnect()
|
||||
s.idle()
|
||||
start_time = time.time()
|
||||
except:
|
||||
print('restart failed trying again')
|
||||
s = gconnect()
|
||||
s.idle()
|
||||
start_time = time.time()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
16
trade.py
16
trade.py
|
|
@ -15,7 +15,7 @@ trex = Bittrex(api_key, priv_key)
|
|||
|
||||
|
||||
def marketcheck(ticker):
|
||||
markets = trex.get_ticker(ticker)
|
||||
markets = trex.get_ticker(ticker)
|
||||
price = markets['result']['Ask']
|
||||
print(ticker, 'price is ', price)
|
||||
return price
|
||||
|
|
@ -25,7 +25,8 @@ def open_trade():
|
|||
global buyprice
|
||||
buyprice = marketcheck(ticker)
|
||||
global buy_amount
|
||||
buy_amount = .0005 / buyprice
|
||||
balance = trex.get_balance('BTC')['result']['Available']
|
||||
buy_amount = balance / buyprice
|
||||
# print(trex.buy_limit(ticker, amount, rate=buyprice))
|
||||
print('buying', buy_amount, 'of', ticker)
|
||||
hist.tradehist('bought ' + str(buy_amount) + ' of ' + ticker + ' at ' + str(buyprice))
|
||||
|
|
@ -34,12 +35,13 @@ def open_trade():
|
|||
def close_trade():
|
||||
global sellprice
|
||||
sellprice = marketcheck(ticker)
|
||||
amount = .0005 / sellprice
|
||||
# print(trex.sell_limit(ticker, amount, rate=sellprice))
|
||||
print('selling', amount, 'of', ticker)
|
||||
hist.tradehist('sold ' + str(amount) + ' of ' + ticker + ' at ' + str(sellprice))
|
||||
global buy_amount
|
||||
hist.tradehist('profit = ' + '{:.25f}'.format((sellprice * amount) - (buyprice * amount)))
|
||||
sell_amount = buy_amount
|
||||
#sell_amount = trex.get_balance('ETH')['result']['Available']
|
||||
# print(trex.sell_limit(ticker, 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)))
|
||||
|
||||
def open_orders():
|
||||
trex.get_open_orders()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue