Skip to content

Instantly share code, notes, and snippets.

@marcosan93
Created September 23, 2021 20:06
Show Gist options
  • Select an option

  • Save marcosan93/599da4bda9cc6f6dde43979112ec253c to your computer and use it in GitHub Desktop.

Select an option

Save marcosan93/599da4bda9cc6f6dde43979112ec253c to your computer and use it in GitHub Desktop.
def get_prophet_positions(df, short=True):
"""
For these positions, buy when actual value is above the upper bound and short
when actual value is below lower bound. Otherwise do nothing.
"""
if df['Open'] >= df['yhat_upper']:
return 1
elif df['Open'] <= df['yhat_lower'] and short:
return -1
else:
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment