Skip to content

Instantly share code, notes, and snippets.

@joeng03
Created November 13, 2019 09:38
Show Gist options
  • Save joeng03/1c57b6cc13ae33222db34af582aa7ef7 to your computer and use it in GitHub Desktop.
Save joeng03/1c57b6cc13ae33222db34af582aa7ef7 to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
import pandas_datareader as pdr
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
TI= TechnicalIndicators()
close_data=TI.close_data[['4. close']]
macd_data=TI.macd_data
rsi_data=TI.rsi_data
bbands_data=TI.bbands_data
dataset = pd.concat([macd_data,rsi_data,bbands_data,close_data], axis=1,sort=True).reindex(macd_data.index)
dataset=dataset.drop(dataset.index[len(dataset)-1])
close_data = dataset[['4. close']]
X=dataset.drop(dataset.index[len(dataset)-1])
y=close_data.drop(close_data.index[0])
values_x=X.values
values_y=y.values
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_data_X = scaler.fit_transform(values_x)
scaled_data_y = scaler.fit_transform(values_y)
X_train=scaled_data_X[:int(X.shape[0]*0.8)]
X_test= scaled_data_X[int(y.shape[0]*0.8):]
y_train=scaled_data_y[:int(X.shape[0]*0.8)]
y_test=scaled_data_y[int(y.shape[0]*0.8):]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment