diff --git a/.gitignore b/.gitignore index 24e953c..d826ee0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,8 @@ keys\.json tradehist\.txt .venv - +.txt +.idea* *.pyc diff --git a/emailtrade/history.py b/emailtrade/history.py index cefa7dd..d0c5bbf 100644 --- a/emailtrade/history.py +++ b/emailtrade/history.py @@ -1,8 +1,7 @@ import time - def tradehist(msg): - log = open('d:\\code\\emailtrade\\tradehist.txt','a') + log = open("tradehist.txt", 'a') log.write('\n' + time.ctime() + ' ' + msg) - + log.close() diff --git a/emailtrade/kraken.py b/emailtrade/kraken.py index 0134166..899a5b1 100644 --- a/emailtrade/kraken.py +++ b/emailtrade/kraken.py @@ -13,36 +13,34 @@ with open(os.getcwd() + "/keys.json") as k: API_KEY = keys["public"] PRIV_KEY = keys["priv"] -TICKER= "ETHUSD" -API = krakenex.api(API_KEY, PRIV_KEY) +TICKER = "ETHUSD" +API = krakenex.API(API_KEY, PRIV_KEY) kraken = KrakenAPI(API) -buyprice = "" -sellprice = "" -def marketcheck(TICKER): - markets = kraken.get_ohlc_data(TICKER) +def marketcheck(): + markets = kraken.get_ohlc_data(TICKER) price = markets[0]['close'][0] print(TICKER, "price is ", price) return price -#done +# done def open_trade(): - buyprice = marketcheck(TICKER) + buyprice = marketcheck() balancedf = kraken.get_account_balance() balance = balancedf.vol["ZUSD"] buy_amount = (balance / buyprice) - (balance / buyprice) * 0.0025 - kraken.add_standard_order(TICKER,) - print("buying", buy_amount, "of", TICKER) + # kraken.add_standard_order(TICKER, "buy", "market", balance) + print("buying", buy_amount, "of", TICKER, " for ", balance) hist.tradehist( - "bought " + str(buy_amount) + " of " + TICKER+ " at " + str(buyprice) + "bought " + str(buy_amount) + " of " + TICKER + " at " + str(buyprice) ) - return + return buy_amount def close_trade():