Created
December 22, 2019 09:09
-
-
Save FrederikBussler/4bbe63dff2598eaa247f3fe73b2beea8 to your computer and use it in GitHub Desktop.
Momentum
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
df['returns'] = np.log(df['closeAsk'] / df['closeAsk'].shift(1)) # 12 | |
cols = [] # 13 | |
for momentum in [15, 30, 60, 120]: # 14 | |
col = 'position_%s' % momentum # 15 | |
df[col] = np.sign(df['returns'].rolling(momentum).mean()) # 16 | |
cols.append(col) # 17 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment