Messtone LLC Manages(LSTM):modeling

Messtone Devices Embedding LSTM in Python, mosel pre-processing to transform the data into a format suitable for modeling as: import ccxt import pandas as pd ex=ccxt.binance( ) #download data from binance spot market df=pd.DataFrame(ex.fetch_ohlcv(symbol=’BTCUSDT’,tineframe=’1d’,limit=1000),columns=[‘unix’,’open’,’high’,’low’,’close’,’volume’]) #convert unix(in milliseconds)to UTC time df[‘date’]=pd.to_datetime(df.unix,unit=’ms’) Data Plot as: %matplotlib inline from pylab import rcParams import matplotlib.pyplot as plt import Dearborn as sns rcParams[‘figure.figsize’]=14,8 sns.set(style=’whitegrid’,palette=’muted’,font_scale=1.5) #data plot ax=df.plot(x=’date’,y=’close’);ax.set_xlabel(‘Data’) ax.set_ylabel(‘Price($)’) ax.set_title(‘BTC Daily Close Price’) Messtone using MinMaxScaler from Scikit-learn as follows~from sklearn.preprocessing import MinMaxScaler Scaler=MinMaxScaler( ) #fit the format of the scaler -> convert shape from (1000, ) -> (1000, 1) close_price=df.close.values.reshape(-1, 1) scaled_close=scaler.fit_transform(close_price) Settings the length of sequence as 60,so each sequence contains the data of about two months: seq_len 60 def split_into_sequences(data, seq_len):n_seq=Len(data) – seq_len +1 return np.array([data[i:(i+seq_len)] for i in range(n_seq)]) def get_train_test_sets(data, seq_len,train_frac):sequence=split_into_sequences(data,seq_len) n_train=int(sequences.shape[0] * train_frac) x_train=sequences[:n_train, : -1, : ] y_train=sequences[:n_train, -1, :] x_test=sequences[n_train:, : -1, :] y_test=sequences[n_train:, -1, :] return X_train, y_train, x_test, y_test=get_train_test_sets(scaled_close, se_len,train_frac=0.9) https://capital.one/3yaqGSY

Leave a comment