Fixed it
This commit is contained in:
parent
41cdd32184
commit
33c262b18a
1 changed files with 6 additions and 8 deletions
14
main.py
14
main.py
|
@ -4,8 +4,6 @@ import pandas
|
||||||
from api.kraken import Kraken
|
from api.kraken import Kraken
|
||||||
from api.fake import Fake
|
from api.fake import Fake
|
||||||
|
|
||||||
glubul = ":)"
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
currency_buy = "XXBT"
|
currency_buy = "XXBT"
|
||||||
currency_sell = "ZUSD"
|
currency_sell = "ZUSD"
|
||||||
|
@ -15,20 +13,20 @@ if __name__ == "__main__":
|
||||||
print("1")
|
print("1")
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
k.getPrices(currency_pair)
|
k.getPrices(currency_pair)
|
||||||
print("3")
|
print("3")
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
#print("Main loop")
|
#print("Main loop")
|
||||||
current_price = float(k.krakenWrapper.get_ticker_information(currency_pair)["c"][0][0])
|
current_price = float(k.krakenWrapper.get_ticker_information(currency_pair)["c"][0][0])
|
||||||
new_row = pandas.DataFrame([[current_price]], index=[pandas.to_datetime(time.time(), unit = "s")])
|
new_row = pandas.DataFrame([[current_price]], index=[pandas.to_datetime(time.time(), unit = "s")])
|
||||||
|
|
||||||
k.prices = pandas.concat([k.prices, pandas.DataFrame(new_row)], ignore_index=False)
|
k.prices = pandas.concat([k.prices, pandas.DataFrame(new_row)], ignore_index=False)
|
||||||
k.calculateEMA()
|
k.calculateEMA()
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -40,7 +38,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
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 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]))
|
||||||
|
@ -48,5 +46,5 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception("There is no currency in this account.")
|
raise Exception("There is no currency in this account.")
|
||||||
|
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
Loading…
Reference in a new issue