|
9 | 9 | from alpha_vantage.timeseries import TimeSeries |
10 | 10 | import pandas as pd |
11 | 11 | import numpy as np |
12 | | -from statsmodels.tsa.arima_model import ARIMA |
| 12 | +from statsmodels.tsa.arima.model import ARIMA |
13 | 13 | from sklearn.metrics import mean_squared_error |
14 | 14 | import matplotlib.pyplot as plt |
15 | 15 | plt.style.use('ggplot') |
@@ -91,10 +91,10 @@ def arima_model(train, test): |
91 | 91 | predictions = list() |
92 | 92 | for t in range(len(test)): |
93 | 93 | model = ARIMA(history, order=(6,1 ,0)) |
94 | | - model_fit = model.fit(disp=0) |
| 94 | + model_fit = model.fit() |
95 | 95 | output = model_fit.forecast() |
96 | 96 | yhat = output[0] |
97 | | - predictions.append(yhat[0]) |
| 97 | + predictions.append(yhat) |
98 | 98 | obs = test[t] |
99 | 99 | history.append(obs) |
100 | 100 | return predictions |
@@ -337,7 +337,7 @@ def retrieving_tweets_polarity(symbol): |
337 | 337 | auth.set_access_token(ct.access_token, ct.access_token_secret) |
338 | 338 | user = tweepy.API(auth) |
339 | 339 |
|
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) |
341 | 341 |
|
342 | 342 | tweet_list = [] #List of tweets alongside polarity |
343 | 343 | 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): |
474 | 474 | arima_pred, error_arima=ARIMA_ALGO(df) |
475 | 475 | lstm_pred, error_lstm=LSTM_ALGO(df) |
476 | 476 | 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 |
478 | 480 |
|
479 | 481 | idea, decision=recommending(df, polarity,today_stock,mean) |
480 | 482 | print() |
|
0 commit comments