finish kraken

This commit is contained in:
Trent N 2021-05-17 05:10:07 -07:00
parent 3bf0a29485
commit e5b19da31c
2 changed files with 17 additions and 18 deletions

View file

@ -4,9 +4,7 @@ import history as hist
import os
import krakenex
from pykrakenapi import KrakenAPI
import pandas as pd
price = 0
with open(os.getcwd() + "/keys.json") as k:
keys = json.load(k)
@ -15,8 +13,8 @@ API_KEY = keys["public"]
PRIV_KEY = keys["priv"]
TICKER = "ETHUSD"
API = krakenex.API(API_KEY, PRIV_KEY)
# BUY_COIN = input("what coin to buy")
# SELL_COIN = input("what to buy it with")
kraken = KrakenAPI(API)
@ -28,10 +26,11 @@ def marketcheck():
# done
buyprice = marketcheck()
def open_trade():
buyprice = marketcheck()
balancedf = kraken.get_account_balance()
balance = balancedf.vol["ZUSD"]
buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025
@ -45,17 +44,17 @@ def open_trade():
def close_trade():
sellprice = marketcheck(TICKER)
sell_amount = trex.get_balance("ETH")["result"]["Available"]
print(trex.sell_limit(TICKER, sell_amount, rate=sellprice))
sell_price = marketcheck()
balancedf = kraken.get_account_balance()
sell_amount = balancedf.vol['XETH']
# print(kraken.add_standard_order(TICKER, "sell", "market", sell_amount))
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(
"profit = "
+ "{:.25f}".format((sellprice * sell_amount) - (buyprice * sell_amount))
+ "{:.25f}".format((sell_price * sell_amount) - (buyprice * sell_amount))
)

View file

@ -12,8 +12,6 @@ api_key = keys["api_key"]
priv_key = keys["priv_key"]
ticker = "BTC-ETH"
trex = Bittrex(api_key, priv_key)
buyprice = ""
sellprice = ""
def marketcheck(ticker):
@ -23,9 +21,11 @@ def marketcheck(ticker):
return price
buyprice = marketcheck(ticker)
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))
@ -38,17 +38,17 @@ def open_trade():
def close_trade():
sellprice = marketcheck(ticker)
sell_price = marketcheck(ticker)
sell_amount = trex.get_balance("ETH")["result"]["Available"]
print(trex.sell_limit(ticker, sell_amount, rate=sellprice))
print(trex.sell_limit(ticker, sell_amount, rate=sell_price))
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(
"profit = "
+ "{:.25f}".format((sellprice * sell_amount) - (buyprice * sell_amount))
+ "{:.25f}".format((sell_price * sell_amount) - (buyprice * sell_amount))
)