crypto: RSI short term
This commit is contained in:
+27
-13
@@ -77,7 +77,7 @@ class Cryptocoin(object):
|
||||
|
||||
#dermines the expected growth of coin
|
||||
def analyseCoin(self, coinId):
|
||||
N_DATAPOINTS = 12
|
||||
N_DATAPOINTS = 10
|
||||
TIME_BETWEEN_DATAPOINTS = 86400 * 7 #one week
|
||||
|
||||
#Get the price history:
|
||||
@@ -105,10 +105,19 @@ class Cryptocoin(object):
|
||||
return growPercentage, stability, history
|
||||
|
||||
#TODO:
|
||||
# - iets met stabiliteit?
|
||||
# - https://en.wikipedia.org/wiki/Head_and_shoulders_(chart_pattern)
|
||||
# - neural networks???
|
||||
|
||||
#get the last 14 dayprices of a coin. (can be used by RSI)
|
||||
def getRecentCoinHistory(self, coinId):
|
||||
N_DATAPOINTS = 14
|
||||
TIME_BETWEEN_DATAPOINTS = 86400 #one day
|
||||
|
||||
history = []
|
||||
for j in range(0, N_DATAPOINTS-1):
|
||||
history.append(self.getCoinPrice(coinId, "USD", int(time.time()) - (N_DATAPOINTS-j)*TIME_BETWEEN_DATAPOINTS))
|
||||
history.append(self.getCoinPrice(coinId, "USD")) #now
|
||||
return history
|
||||
|
||||
#will return some random advice about a semi-random crypto coin
|
||||
def getRandomCoinAdvice(self):
|
||||
@@ -233,31 +242,36 @@ class Cryptocoin(object):
|
||||
|
||||
coinId = coinId.upper()
|
||||
|
||||
growPercentage, coinStability, coinHistory = self.analyseCoin(coinId)
|
||||
growPercentage, coinStability, dummy = self.analyseCoin(coinId)
|
||||
|
||||
if (growPercentage == 0 and coinStability == 1.0): #aanname. anders moet je weer een extra call doen.
|
||||
yield from ctx.channel.send("Die cryptocoin ken ik niet... :frowning2: ")
|
||||
return
|
||||
|
||||
time.sleep(0.1) #don't overload the API
|
||||
coinHistory = self.getRecentCoinHistory(coinId)
|
||||
coinRsi = self.rsi(coinHistory)
|
||||
#TODO, get more recent data to feed the RSI
|
||||
|
||||
message = ""
|
||||
|
||||
if (growPercentage < -0.04):
|
||||
if (coinRsi > 70):
|
||||
if (coinRsi > 65):
|
||||
message = "Sell! Sell! Sell! Aan " + coinId + " heb je niks meer."
|
||||
elif (coinStability < 0.3):
|
||||
message = coinId + " takelt op lange termijn af en is instabiel. Net als je moeder."
|
||||
elif (coinRsi < 30):
|
||||
elif (coinRsi < 35):
|
||||
message = "Op de lange termijn is " + coinId + " waardeloos, maar wacht nog even met verkopen."
|
||||
else:
|
||||
message = "Als je " + coinId + " hebt, verkopen die handel. Daar heb je op de lange termijn niks aan."
|
||||
message = coinId + " is geen goede lange termijn investering."
|
||||
elif (growPercentage < 0):
|
||||
message = coinId + " gaat geen winnaar worden. "
|
||||
if (coinRsi > 70):
|
||||
if (coinRsi > 65):
|
||||
message += "Ditchen."
|
||||
elif (coinRsi < 30):
|
||||
message += "Maar hou hem nog even vast."
|
||||
elif (growPercentage < 0.025):
|
||||
if (coinStability > 0.6):
|
||||
message = coinId + " lijkt redelijk stabiel. "
|
||||
if (coinRsi < 30):
|
||||
if (coinRsi < 35):
|
||||
message += "Bovendien een goed moment om te kopen."
|
||||
elif (coinRsi > 70):
|
||||
message = "Ik zou " + coinId + " verkopen."
|
||||
@@ -266,7 +280,7 @@ class Cryptocoin(object):
|
||||
elif (growPercentage < 0.08):
|
||||
if (coinStability > 0.45):
|
||||
message = coinId + " is een stabiele groeier. "
|
||||
if (coinRsi < 30):
|
||||
if (coinRsi < 35):
|
||||
message += "Nu kopen!"
|
||||
elif (coinStability < 0.2):
|
||||
message = coinId + " groeit lekker, maar is instabiel."
|
||||
@@ -275,11 +289,11 @@ class Cryptocoin(object):
|
||||
if (coinRsi > 70):
|
||||
message += "Hij lijkt overbought, dus je kan nu verkopen."
|
||||
else:
|
||||
if (coinRsi < 30 and coinStability > 0.4):
|
||||
if (coinRsi < 35 and coinStability > 0.4):
|
||||
message = "TO THE MOON! Nu " + coinId + " kopen!!"
|
||||
elif (coinStability > 0.7):
|
||||
message = coinId + " is op de lange termijn erg sterk en stabiel!"
|
||||
elif (coinRsi < 30):
|
||||
elif (coinRsi < 35):
|
||||
message = "Ik raad sterk aan om " + coinId + " te kopen."
|
||||
elif (coinRsi < 70):
|
||||
message = coinId + " groeit wel erg hard. Wellicht overbought?"
|
||||
|
||||
Reference in New Issue
Block a user