Skip to content

Commit 507591b

Browse files
Fix: update tweepy code + requirements
1 parent 10fa32f commit 507591b

8 files changed

Lines changed: 13 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ main.py - main machine learning module
3939
</ul>
4040

4141
# How to Install and Use
42-
<b>Python 3.8.5 is required for the python packages to install correctly</b><br>
42+
<b>Python 3.10.6 is required for the python packages to install correctly</b><br>
4343
<ol>
4444
<li>Clone the repo. Download and install <b>XAMPP server</b> from https://www.apachefriends.org/download.html and start <b>Apache</b> and <b>MySql</b> servers</li>
4545
<li>Open <b>phpmyadmin</b> by visiting http://localhost/phpmyadmin/ and go to User Accounts -> Add a User, give username and password as <b>admin</b> and click on <b>Check All</b> next to Global Privileges and hit Go</li>

Yahoo-Finance-Ticker-Symbols.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8343,6 +8343,7 @@ VHP.NZ,Vital Healthcare Property Trust,NZE,,New Zealand
83438343
WDN.TO,Waldron Energy Corporation,TOR,,Canada
83448344
VGI.AX,Vista Group International Limited,ASX,,Australia
83458345
FB,"Facebook, Inc.",NMS,Internet Information Providers,USA
8346+
META,"Facebook, Inc.",NMS,Internet Information Providers,USA
83468347
KRFT,"Kraft Foods Group, Inc.",,,
83478348
FCX,Freeport-McMoRan Inc.,NYQ,Copper,USA
83488349
FSLR,"First Solar, Inc.",NMS,Semiconductor - Specialized,USA

main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from alpha_vantage.timeseries import TimeSeries
1010
import pandas as pd
1111
import numpy as np
12-
from statsmodels.tsa.arima_model import ARIMA
12+
from statsmodels.tsa.arima.model import ARIMA
1313
from sklearn.metrics import mean_squared_error
1414
import matplotlib.pyplot as plt
1515
plt.style.use('ggplot')
@@ -91,10 +91,10 @@ def arima_model(train, test):
9191
predictions = list()
9292
for t in range(len(test)):
9393
model = ARIMA(history, order=(6,1 ,0))
94-
model_fit = model.fit(disp=0)
94+
model_fit = model.fit()
9595
output = model_fit.forecast()
9696
yhat = output[0]
97-
predictions.append(yhat[0])
97+
predictions.append(yhat)
9898
obs = test[t]
9999
history.append(obs)
100100
return predictions
@@ -337,7 +337,7 @@ def retrieving_tweets_polarity(symbol):
337337
auth.set_access_token(ct.access_token, ct.access_token_secret)
338338
user = tweepy.API(auth)
339339

340-
tweets = tweepy.Cursor(user.search, q=symbol, tweet_mode='extended', lang='en',exclude_replies=True).items(ct.num_of_tweets)
340+
tweets = tweepy.Cursor(user.search_tweets, q=symbol, tweet_mode='extended', lang='en',exclude_replies=True).items(ct.num_of_tweets)
341341

342342
tweet_list = [] #List of tweets alongside polarity
343343
global_polarity = 0 #Polarity of all tweets === Sum of polarities of individual tweets
@@ -474,7 +474,9 @@ def recommending(df, global_polarity,today_stock,mean):
474474
arima_pred, error_arima=ARIMA_ALGO(df)
475475
lstm_pred, error_lstm=LSTM_ALGO(df)
476476
df, lr_pred, forecast_set,mean,error_lr=LIN_REG_ALGO(df)
477-
polarity,tw_list,tw_pol,pos,neg,neutral = retrieving_tweets_polarity(quote)
477+
# Twitter Lookup is no longer free in Twitter's v2 API
478+
# polarity,tw_list,tw_pol,pos,neg,neutral = retrieving_tweets_polarity(quote)
479+
polarity, tw_list, tw_pol, pos, neg, neutral = 0, [], "Can't fetch tweets, Twitter Lookup is no longer free in API v2.", 0, 0, 0
478480

479481
idea, decision=recommending(df, polarity,today_stock,mean)
480482
print()

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
tensorflow
12
nltk==3.5
2-
keras==2.4.3
3+
keras
34
numpy
45
streamlit==0.52.1
56
seaborn==0.11.1
6-
tweepy==3.10.0
7+
tweepy
78
textblob==0.15.3
89
flask
910
pandas
1011
matplotlib
1112
scikit_learn
1213
statsmodels
13-
yfinance==0.1.54
14+
yfinance
1415
alpha_vantage==2.3.1
1516
gunicorn
1617
https://pypi.anaconda.org/berber/simple/tweet-preprocessor/0.5.0/tweet-preprocessor-0.5.0.tar.gz

static/ARIMA.png

5.69 KB
Loading

static/LR.png

3.5 KB
Loading

static/LSTM.png

2.45 KB
Loading

static/Trends.png

3.08 KB
Loading

0 commit comments

Comments
 (0)