mirror of
https://github.com/Death916/emailtrade.git
synced 2026-04-10 03:04:40 -07:00
kraken.opentrade and history update
This commit is contained in:
parent
977b03e4f6
commit
3bf0a29485
3 changed files with 14 additions and 16 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -3,7 +3,8 @@ keys\.json
|
||||||
|
|
||||||
tradehist\.txt
|
tradehist\.txt
|
||||||
.venv
|
.venv
|
||||||
|
.txt
|
||||||
|
.idea*
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
def tradehist(msg):
|
def tradehist(msg):
|
||||||
log = open('d:\\code\\emailtrade\\tradehist.txt','a')
|
log = open("tradehist.txt", 'a')
|
||||||
log.write('\n' + time.ctime() + ' ' + msg)
|
log.write('\n' + time.ctime() + ' ' + msg)
|
||||||
|
log.close()
|
||||||
|
|
|
||||||
|
|
@ -13,36 +13,34 @@ with open(os.getcwd() + "/keys.json") as k:
|
||||||
|
|
||||||
API_KEY = keys["public"]
|
API_KEY = keys["public"]
|
||||||
PRIV_KEY = keys["priv"]
|
PRIV_KEY = keys["priv"]
|
||||||
TICKER= "ETHUSD"
|
TICKER = "ETHUSD"
|
||||||
API = krakenex.api(API_KEY, PRIV_KEY)
|
API = krakenex.API(API_KEY, PRIV_KEY)
|
||||||
|
|
||||||
|
|
||||||
kraken = KrakenAPI(API)
|
kraken = KrakenAPI(API)
|
||||||
buyprice = ""
|
|
||||||
sellprice = ""
|
|
||||||
|
|
||||||
|
|
||||||
def marketcheck(TICKER):
|
def marketcheck():
|
||||||
markets = kraken.get_ohlc_data(TICKER)
|
markets = kraken.get_ohlc_data(TICKER)
|
||||||
price = markets[0]['close'][0]
|
price = markets[0]['close'][0]
|
||||||
print(TICKER, "price is ", price)
|
print(TICKER, "price is ", price)
|
||||||
return price
|
return price
|
||||||
|
|
||||||
|
|
||||||
#done
|
# done
|
||||||
|
|
||||||
def open_trade():
|
def open_trade():
|
||||||
|
|
||||||
buyprice = marketcheck(TICKER)
|
buyprice = marketcheck()
|
||||||
balancedf = kraken.get_account_balance()
|
balancedf = kraken.get_account_balance()
|
||||||
balance = balancedf.vol["ZUSD"]
|
balance = balancedf.vol["ZUSD"]
|
||||||
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, "buy", "market", balance)
|
||||||
print("buying", buy_amount, "of", TICKER)
|
print("buying", buy_amount, "of", TICKER, " for ", balance)
|
||||||
hist.tradehist(
|
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():
|
def close_trade():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue