fix float error

This commit is contained in:
Death916 2021-06-25 04:28:05 -07:00
parent c9e58d0a7b
commit e1878b561f

View file

@ -18,8 +18,7 @@ API = krakenex.API(API_KEY, PRIV_KEY)
#BUY_CURRENCY = input().capitalize()
kraken = KrakenAPI(API)
buyprice = ""
sellprice = ""
def marketcheck(TICKER):
@ -32,10 +31,12 @@ def marketcheck(TICKER):
#done
def open_trade():
pd.options.display.float_format = '{:.2f}'.format
global buyprice
buyprice = marketcheck(TICKER)
balancedf = kraken.get_account_balance()
balance = balancedf.vol["ZUSD"]
global buy_amount
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
# kraken.add_standard_order(TICKER,)
print("buying", buy_amount, "of", TICKER)
@ -47,7 +48,7 @@ def open_trade():
def close_trade():
sellprice = marketcheck(TICKER)
sell_price = marketcheck(TICKER)
if TICKER == 'ETHUSD':
symbol = 'XETH'
if TICKER == 'XBTUSD':
@ -55,18 +56,19 @@ def close_trade():
balance = kraken.get_account_balance()
sell_amount = balance.vol[symbol]
# print(trex.sell_limit(TICKER, sell_amount, rate=sellprice))
sell_amount = buy_amount
#sell_amount = balance.vol[symbol]
# 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)
"sold " + str(sell_amount) + " of " + TICKER+ " at " + str(sell_price)
)
hist.tradehist(
"""hist.tradehist(
"profit = "
+ "{:.25f}".format((sellprice * sell_amount) - (buyprice * sell_amount))
)
+ "{:.25f}".format((sell_price * sell_amount) - (buyprice * sell_amount)))
"""
profit = (sell_price * sell_amount) - (buyprice * sell_amount)
hist.tradehist("profit = " + "{:.25}".format(profit))
def open_orders():
kraken.get_open_orders(True)
@ -76,4 +78,4 @@ def open_positions():
kraken.get_open_positions()
return kraken.get_open_positions()
# TODO uncomment buy/sells
# TODO uncomment buy/sells