Created
August 7, 2018 06:59
-
-
Save sam-thecoder/a3c6ea3e8b7fba951500750e156ab0c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decider(row): | |
if row['Drop 7'] < row['Up 7'] and row['Mean Change 7'] > 0 and row['Change'] > 0: | |
return 0 #invest/hold or put in 100 investment if none | |
#Withdraw 50% | |
elif row['Drop 7'] < row['Up 7'] and row['Mean Change 7'] > 0 and row['Change'] < 0: | |
return -50 | |
#Withdraw 75% | |
elif row['Drop 7'] < row['Up 7'] and row['Mean Change 7'] < 0 or row['Change'] < 0: | |
return -75 | |
#invest 50% more | |
elif row['Drop 7'] > row['Up 7'] and row['Mean Change 7'] < 0 and row['Change'] > 0: | |
return 50 | |
#all out | |
elif row['Drop 7'] > row['Up 7'] and row['Mean Change 7'] < 0 and row['Change'] < 0: | |
return -100 | |
else: | |
return 50 | |
df['Predict'] = df.apply(decider, axis=1) | |
df.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment