mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
fix float error
This commit is contained in:
parent
c9e58d0a7b
commit
e1878b561f
1 changed files with 15 additions and 13 deletions
|
|
@ -18,8 +18,7 @@ API = krakenex.API(API_KEY, PRIV_KEY)
|
||||||
#BUY_CURRENCY = input().capitalize()
|
#BUY_CURRENCY = input().capitalize()
|
||||||
|
|
||||||
kraken = KrakenAPI(API)
|
kraken = KrakenAPI(API)
|
||||||
buyprice = ""
|
|
||||||
sellprice = ""
|
|
||||||
|
|
||||||
|
|
||||||
def marketcheck(TICKER):
|
def marketcheck(TICKER):
|
||||||
|
|
@ -32,10 +31,12 @@ def marketcheck(TICKER):
|
||||||
#done
|
#done
|
||||||
|
|
||||||
def open_trade():
|
def open_trade():
|
||||||
|
pd.options.display.float_format = '{:.2f}'.format
|
||||||
|
global buyprice
|
||||||
buyprice = marketcheck(TICKER)
|
buyprice = marketcheck(TICKER)
|
||||||
balancedf = kraken.get_account_balance()
|
balancedf = kraken.get_account_balance()
|
||||||
balance = balancedf.vol["ZUSD"]
|
balance = balancedf.vol["ZUSD"]
|
||||||
|
global buy_amount
|
||||||
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
|
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
|
||||||
# kraken.add_standard_order(TICKER,)
|
# kraken.add_standard_order(TICKER,)
|
||||||
print("buying", buy_amount, "of", TICKER)
|
print("buying", buy_amount, "of", TICKER)
|
||||||
|
|
@ -47,7 +48,7 @@ def open_trade():
|
||||||
|
|
||||||
def close_trade():
|
def close_trade():
|
||||||
|
|
||||||
sellprice = marketcheck(TICKER)
|
sell_price = marketcheck(TICKER)
|
||||||
if TICKER == 'ETHUSD':
|
if TICKER == 'ETHUSD':
|
||||||
symbol = 'XETH'
|
symbol = 'XETH'
|
||||||
if TICKER == 'XBTUSD':
|
if TICKER == 'XBTUSD':
|
||||||
|
|
@ -55,18 +56,19 @@ def close_trade():
|
||||||
|
|
||||||
|
|
||||||
balance = kraken.get_account_balance()
|
balance = kraken.get_account_balance()
|
||||||
|
sell_amount = buy_amount
|
||||||
sell_amount = balance.vol[symbol]
|
#sell_amount = balance.vol[symbol]
|
||||||
# print(trex.sell_limit(TICKER, sell_amount, rate=sellprice))
|
# print(trex.sell_limit(TICKER, sell_amount, rate=sellprice))
|
||||||
print("selling", sell_amount, "of", TICKER)
|
print("selling", sell_amount, "of", TICKER)
|
||||||
hist.tradehist(
|
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 = "
|
"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():
|
def open_orders():
|
||||||
kraken.get_open_orders(True)
|
kraken.get_open_orders(True)
|
||||||
|
|
@ -76,4 +78,4 @@ def open_positions():
|
||||||
kraken.get_open_positions()
|
kraken.get_open_positions()
|
||||||
return kraken.get_open_positions()
|
return kraken.get_open_positions()
|
||||||
|
|
||||||
# TODO uncomment buy/sells
|
# TODO uncomment buy/sells
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue