Changed bot logic to not trade on really small difference in EMA
This commit is contained in:
parent
3d44bdd779
commit
a15ab7bf76
2 changed files with 3 additions and 3 deletions
|
@ -27,7 +27,7 @@ class Kraken:
|
|||
|
||||
# Calculates the exponential moving average by grabbing data from Kraken on the conversion rate every interval minutes.
|
||||
def calculateEMA(self, shortTime=round(time.time())-(7*24*3600), longTime=round(time.time())-(30*24*3600), interval=60):
|
||||
self.longEMA = self.prices.ewm(span=20).mean()
|
||||
self.longEMA = self.prices.ewm(span=30).mean()
|
||||
self.shortEMA = self.prices.ewm(span=10).mean()
|
||||
|
||||
|
||||
|
|
4
main.py
4
main.py
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
|||
if k.balances["vol"][currency_buy] > 10**-5:
|
||||
# Sell shit
|
||||
# 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]) and abs(float(k.shortEMA.tail(1)[0])-float(k.longEMA.tail(1)[0]))/((float(k.shortEMA.tail(1)[0])+float(k.longEMA.tail(1)[0]))/2) > 0.001:
|
||||
print("Selling shit")
|
||||
k.sellOrder(currency_pair, currency_buy, currency_sell, k.balances["vol"][currency_buy])
|
||||
print(k.balances)
|
||||
|
@ -38,7 +38,7 @@ if __name__ == "__main__":
|
|||
elif k.balances["vol"][currency_sell] > 10**-2:
|
||||
# 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]) and abs(float(k.shortEMA.tail(1)[0])-float(k.longEMA.tail(1)[0]))/((float(k.shortEMA.tail(1)[0])+float(k.longEMA.tail(1)[0]))/2) > 0.001:
|
||||
print("Buying shit")
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue