Skip to content

Instantly share code, notes, and snippets.

@sam-thecoder
Created August 7, 2018 06:59
Show Gist options
  • Save sam-thecoder/a3c6ea3e8b7fba951500750e156ab0c7 to your computer and use it in GitHub Desktop.
Save sam-thecoder/a3c6ea3e8b7fba951500750e156ab0c7 to your computer and use it in GitHub Desktop.
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