mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
fix buy function and uncomment
This commit is contained in:
parent
3306274acf
commit
20090349c5
1 changed files with 5 additions and 3 deletions
8
trade.py
8
trade.py
|
|
@ -20,14 +20,15 @@ trex = Bittrex(api_key, priv_key)
|
||||||
def marketcheck(ticker):
|
def marketcheck(ticker):
|
||||||
markets = trex.get_ticker(ticker)
|
markets = trex.get_ticker(ticker)
|
||||||
price = markets['result']['Ask']
|
price = markets['result']['Ask']
|
||||||
#print(markets)
|
print(ticker, 'price is ', markets)
|
||||||
return price
|
return price
|
||||||
|
|
||||||
|
|
||||||
def open_trade(amount):
|
def open_trade(amount):
|
||||||
global buyprice
|
global buyprice
|
||||||
buyprice = marketcheck(ticker)
|
buyprice = marketcheck(ticker)
|
||||||
#print(trex.buy_limit(ticker, amount, rate=price))
|
amount = .0005 / buyprice
|
||||||
|
print(trex.buy_limit(ticker, amount, rate=buyprice))
|
||||||
print('buying', amount, 'of', ticker)
|
print('buying', amount, 'of', ticker)
|
||||||
hist.tradehist('bought ' + str(amount) + ' of ' + ticker + ' at ' + str(buyprice))
|
hist.tradehist('bought ' + str(amount) + ' of ' + ticker + ' at ' + str(buyprice))
|
||||||
print(buyprice)
|
print(buyprice)
|
||||||
|
|
@ -36,7 +37,8 @@ def open_trade(amount):
|
||||||
def close_trade(amount):
|
def close_trade(amount):
|
||||||
global sellprice
|
global sellprice
|
||||||
sellprice = marketcheck(ticker)
|
sellprice = marketcheck(ticker)
|
||||||
#print(trex.sell_limit(ticker, amount, rate = None))
|
amount = .0005 / sellprice
|
||||||
|
print(trex.sell_limit(ticker, amount, rate=sellprice))
|
||||||
print('selling', amount, 'of', ticker)
|
print('selling', amount, 'of', ticker)
|
||||||
hist.tradehist('sold ' + str(amount) + ' of ' + ticker + ' at ' + str(sellprice))
|
hist.tradehist('sold ' + str(amount) + ' of ' + ticker + ' at ' + str(sellprice))
|
||||||
hist.tradehist('profit = ' + '{:.20f}'.format((sellprice * amount) - (buyprice * amount)))
|
hist.tradehist('profit = ' + '{:.20f}'.format((sellprice * amount) - (buyprice * amount)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue