Don't use all of our money to buy

This commit is contained in:
Logan G 2021-02-03 14:15:05 -07:00
parent abf3931f04
commit 315f4c3036
Signed by: logan
GPG key ID: E328528C921E7A7A
2 changed files with 17 additions and 9 deletions

View file

@ -1,5 +1,4 @@
import time, threading
import pandas
import time, threading, pandas, numpy
from api.kraken import Kraken
from api.fake import Fake
@ -21,7 +20,7 @@ if __name__ == "__main__":
while True:
#print("Main loop")
current_price = float(k.krakenWrapper.get_ticker_information(currency_pair)["c"][0][0])
current_price = numpy.float64(k.krakenWrapper.get_ticker_information(currency_pair)["c"][0][0])
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)
@ -41,7 +40,7 @@ if __name__ == "__main__":
# If short term goes above long term, buy
if(float(k.shortEMA.tail(1)[0]) > float(k.longEMA.tail(1)[0])):
print("Buying shit")
k.buyOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_sell] * (1/k.prices.tail(1)[0][0]))
k.buyOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_sell] * 0.95 * (1/k.prices.tail(1)[0][0]))
print(k.balances)
else:

19
plot.py
View file

@ -11,14 +11,23 @@ if __name__ == "__main__":
currency_pair = "XXBTZUSD"
k = Kraken()
print("1")
k.getBalances()
print("2")
print(1)
time.sleep(1)
k.getPrices(currency_pair, time=round(time.time())-(24*3600), interval=1)
print("3")
print(2)
time.sleep(1)
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")])
k.prices = pandas.concat([k.prices, pandas.DataFrame(new_row)], ignore_index=False)
print(3)
k.calculateEMA()
print("4")
print(4)
plt.plot(k.shortEMA)
plt.plot(k.longEMA)