Help
This commit is contained in:
parent
c39164f2b7
commit
41cdd32184
1 changed files with 5 additions and 1 deletions
6
main.py
6
main.py
|
@ -13,7 +13,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
k = Kraken()
|
k = Kraken()
|
||||||
print("1")
|
print("1")
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
k.getPrices(currency_pair)
|
k.getPrices(currency_pair)
|
||||||
print("3")
|
print("3")
|
||||||
|
|
||||||
|
@ -30,18 +32,20 @@ if __name__ == "__main__":
|
||||||
# If we have crypto, check for sell behaviour, if we have fiat, check for buy behavior, otherwise, get really confused
|
# If we have crypto, check for sell behaviour, if we have fiat, check for buy behavior, otherwise, get really confused
|
||||||
if k.balances["vol"][currency_buy] > 10**-5:
|
if k.balances["vol"][currency_buy] > 10**-5:
|
||||||
# Sell shit
|
# Sell shit
|
||||||
# TODO: Needs to check if fresh start
|
|
||||||
# If short term change dips below long term change, sell
|
# If short term change dips below long term change, sell
|
||||||
if(float(k.shortEMA.tail(1)[0]) < float(k.longEMA.tail(1)[0])):
|
if(float(k.shortEMA.tail(1)[0]) < float(k.longEMA.tail(1)[0])):
|
||||||
print("Selling shit")
|
print("Selling shit")
|
||||||
k.sellOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_buy])
|
k.sellOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_buy])
|
||||||
print(k.balances)
|
print(k.balances)
|
||||||
|
|
||||||
elif k.balances["vol"][currency_sell] > 10**-2:
|
elif k.balances["vol"][currency_sell] > 10**-2:
|
||||||
# Buy shit
|
# Buy shit
|
||||||
|
# If short term goes above long term, buy
|
||||||
if(float(k.shortEMA.tail(1)[0]) > float(k.longEMA.tail(1)[0])):
|
if(float(k.shortEMA.tail(1)[0]) > float(k.longEMA.tail(1)[0])):
|
||||||
print("Buying shit")
|
print("Buying shit")
|
||||||
k.buyOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_sell] * (1/k.prices.tail(1)[0]))
|
k.buyOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_sell] * (1/k.prices.tail(1)[0]))
|
||||||
print(k.balances)
|
print(k.balances)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception("There is no currency in this account.")
|
raise Exception("There is no currency in this account.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue