Merge branch 'kraken'

This commit is contained in:
Trent N 2020-10-20 12:55:31 -07:00
commit bb1ba78b5a
5 changed files with 57 additions and 0 deletions

57
emailtrade/kraken.py Normal file
View file

@ -0,0 +1,57 @@
import json
import history as hist
import os
price = 0
with open(os.getcwd() + "/keys.json") as k:
keys = json.load(k)
api_key = keys["api_key"]
priv_key = keys["priv_key"]
ticker = "BTC-ETH"
kraken = Bittrex(api_key, priv_key)
buyprice = ""
sellprice = ""
def marketcheck(ticker):
markets = trex.get_ticker(ticker)
price = markets["result"]["Ask"]
print(ticker, "price is ", price)
return price
def open_trade():
buyprice = marketcheck(ticker)
balance = trex.get_balance("BTC")["result"]["Available"]
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
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
def close_trade():
sellprice = marketcheck(ticker)
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))
)
def open_orders():
trex.get_open_orders()
return