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
|
||||
.venv
|
||||
|
||||
.txt
|
||||
.idea*
|
||||
|
||||
*.pyc
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -14,15 +14,13 @@ 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)
|
||||
API = krakenex.API(API_KEY, PRIV_KEY)
|
||||
|
||||
|
||||
kraken = KrakenAPI(API)
|
||||
buyprice = ""
|
||||
sellprice = ""
|
||||
|
||||
|
||||
def marketcheck(TICKER):
|
||||
def marketcheck():
|
||||
markets = kraken.get_ohlc_data(TICKER)
|
||||
price = markets[0]['close'][0]
|
||||
print(TICKER, "price is ", price)
|
||||
|
|
@ -33,16 +31,16 @@ def marketcheck(TICKER):
|
|||
|
||||
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)
|
||||
)
|
||||
return
|
||||
return buy_amount
|
||||
|
||||
|
||||
def close_trade():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue