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
import yfinance as yf | |
import streamlit as st | |
import datetime | |
import talib | |
import ta | |
import pandas as pd | |
import requests | |
yf.pdr_override() |
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
#import the libraries | |
import math | |
import warnings | |
import datetime | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from tensorflow.keras import Sequential | |
from pandas_datareader import DataReader | |
from sklearn.preprocessing import MinMaxScaler |
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
#get the root mean squared error (RMSE) | |
rmse = np.sqrt(np.mean((predictions-y_test)**2)) | |
#plot the data | |
train = data[:train_data_len] | |
valid = data[train_data_len:] | |
valid['Predictions'] = predictions | |
plt.figure(figsize=(16,8)) | |
plt.title('Model for {}'.format(stock.upper())) | |
plt.xlabel('Date', fontsize=16) |
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
#build LSTM model | |
model = Sequential() | |
model.add(LSTM(50, return_sequences=True, input_shape=(x_train.shape[1],1))) | |
model.add(LSTM(50,return_sequences=False)) | |
model.add(Dense(25)) | |
model.add(Dense(1)) | |
#compile the model | |
model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy']) |
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
df = DataReader(stock, "yahoo", start_date, end_date) | |
data = df.filter(['Close']) | |
dataset = data.values | |
train_data_len = math.ceil(len(dataset)*.8) | |
#scale the data | |
scaler = MinMaxScaler(feature_range=(0,1)) | |
scaled_data = scaler.fit_transform(dataset) | |
#create the training dataset |
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
#import the libraries | |
import math | |
import warnings | |
import datetime | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from tensorflow.keras import Sequential | |
from pandas_datareader import DataReader | |
from sklearn.preprocessing import MinMaxScaler |
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
import talib | |
import smtplib | |
import datetime | |
import numpy as np | |
import pandas as pd | |
from email.mime.text import MIMEText | |
from yahoo_fin import stock_info as si | |
from pandas_datareader import DataReader | |
from email.mime.multipart import MIMEMultipart | |
from bs4 import BeautifulSoup |
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
def getData(list_of_stocks): | |
for stock in list_of_stocks: | |
df = DataReader(stock, 'yahoo', start, end) | |
print (stock) | |
# Current Price | |
price = si.get_live_price('{}'.format(stock)) | |
price = round(price, 2) | |
# Sharpe Ratio |
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
def sendMessage(text): | |
message = text | |
email = "" | |
password = "" | |
sms_gateway = '' | |
smtp = "smtp.gmail.com" | |
port = 587 | |
server = smtplib.SMTP(smtp,port) |
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
import talib | |
import smtplib | |
import datetime | |
import numpy as np | |
import pandas as pd | |
from email.mime.text import MIMEText | |
from yahoo_fin import stock_info as si | |
from pandas_datareader import DataReader | |
from email.mime.multipart import MIMEMultipart | |
from bs4 import BeautifulSoup |