-
-
Save quantra-go-algo/405f1cb252447663767da6f00fb194b2 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
# Features construction | |
data['Open-Close'] = (data.Open - data.Close)/data.Open | |
data['High-Low'] = (data.High - data.Low)/data.Low | |
data['percent_change'] = data['Adj Close'].pct_change() | |
data['std_5'] = data['percent_change'].rolling(5).std() | |
data['ret_5'] = data['percent_change'].rolling(5).mean() | |
data.dropna(inplace=True) | |
# X is the input variable | |
X = data[['Open-Close', 'High-Low', 'std_5', 'ret_5']] | |
# Y is the target or output variable | |
y = np.where(data['Adj Close'].shift(-1) > data['Adj Close'], 1, -1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment