# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + colab={"base_uri": "https://localhost:8080/"} id="6_qcYMI_WqWb" outputId="bdb3c7ef-3c7f-4f80-9e65-87325fa6b591"
pip install yfinance

# + id="HKZd_3g2WkIE"
from LSTM_API import LSTM_train, predict
from get_stock_prices_API import get_stock_prices
import yfinance as yf
import pandas as pd

# + id="jKvK_NzpVi_V"
Stock = None        #choose stock
period = None       #choose period

# + colab={"base_uri": "https://localhost:8080/"} id="2EPP47NzWo55" outputId="26ca5c80-742c-43bc-d784-7c018b99bca9"
Stock = yf.download(tickers=Stock, period = period, interval = '1d')

# + id="zChDjiNeW-MD"
timestep = 3

epochs = 15
batch_size = 50
validation_split = 0.1
train_test_split_date = '2021-09-05'


# + id="8AmuVjIPXIz7"
reddit_data = pd.read_csv("group.csv")                                                      ### Reddit Data from the Reddit Post Generator Script
reddit_data['Date']= pd.to_datetime(reddit_data['Date'])
reddit_data = reddit_data.drop(columns=['Unnamed: 0'])
reddit_data = reddit_data.rename(columns={"0":"Average_Reddit_Sentiment"})

twitter_data = pd.read_csv("group2.csv")                                                     ### Twiiter Data from the Twitter Post Generator Script
twitter_data = pd.read_csv("group2.csv")
twitter_data['Date']= pd.to_datetime(twitter_data['Date'])
twitter_data = twitter_data.drop(columns=['Unnamed: 0'])
twitter_data = twitter_data.rename(columns={"sentiment_value":"Average_Twitter_Sentiment"})

data = BTC.copy()
data = data.reset_index()
data.drop(data.tail(16).index,inplace = True)

data = pd.merge(data, reddit_data, how="left", on=["Date"])
data = data.fillna(method="ffill")

data = pd.merge(data, twitter_data, how="left", on=["Date"])
data = data.fillna(method="ffill")

data_training = data[data['Date']<= train_test_split_date].copy()
data_test = data[data['Date']> train_test_split_date].copy()

# + colab={"base_uri": "https://localhost:8080/", "height": 802} id="j_nSTm4qXPSK" outputId="70063fec-8f37-4779-e5bd-208f41d57f88"
model, scaler = LSTM_train(data_training,timestep = 3,epochs = 15,batch_size = 50,validation_split = 0.1,train_test_split_date = '2021-09-05')


# + colab={"base_uri": "https://localhost:8080/", "height": 350} id="QJd24ZJdYBYw" outputId="fb3a622f-3565-4b11-d374-094348c6e8af"
predict(model,data_training,data_test,timestep,scaler)

# + id="TtwCPXyjVEBZ"


StarcoderdataJupyterScriptsDedupFiltered