Created
September 6, 2021 00:56
-
-
Save SajidLhessani/23cde459d9a2cc789468809fb0e1e030 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Create a column 'Ret' with the calculation of returns | |
| df['Ret'] = (df['Open'].shift(-1)-df['Open'])/df['Open'] | |
| # Create n columns and assign | |
| for i in range(1, n): | |
| df['return%i' % i] = df['Ret'].shift(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment