Skip to content

Commit 304c5c4

Browse files
fix: tweepy partial match
1 parent 307f1c4 commit 304c5c4

7 files changed

Lines changed: 106335 additions & 2 deletions

File tree

Yahoo-Finance-Ticker-Symbols.csv

Lines changed: 106329 additions & 0 deletions
Large diffs are not rendered by default.

main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,15 @@ def LIN_REG_ALGO(df):
329329
return df, lr_pred, forecast_set, mean, error_lr
330330
#**************** SENTIMENT ANALYSIS **************************
331331
def retrieving_tweets_polarity(symbol):
332+
stock_ticker_map = pd.read_csv('Yahoo-Finance-Ticker-Symbols.csv')
333+
stock_full_form = stock_ticker_map[stock_ticker_map['Ticker']==symbol]
334+
symbol = stock_full_form['Name'].to_list()[0][0:14]
335+
332336
auth = tweepy.OAuthHandler(ct.consumer_key, ct.consumer_secret)
333337
auth.set_access_token(ct.access_token, ct.access_token_secret)
334338
user = tweepy.API(auth)
335339

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

338342
tweet_list = [] #List of tweets alongside polarity
339343
global_polarity = 0 #Polarity of all tweets === Sum of polarities of individual tweets
@@ -424,7 +428,7 @@ def recommending(df, global_polarity,today_stock,mean):
424428
print()
425429
print("##############################################################################")
426430
print("According to the ML Predictions and Sentiment Analysis of Tweets, a",idea,"in",quote,"stock is expected => ",decision)
427-
elif global_polarity < 0:
431+
elif global_polarity <= 0:
428432
idea="FALL"
429433
decision="SELL"
430434
print()

static/ARIMA.png

3.31 KB
Loading

static/LR.png

5.36 KB
Loading

static/LSTM.png

3.55 KB
Loading

static/SA.png

-1.09 KB
Loading

static/Trends.png

5.21 KB
Loading

0 commit comments

Comments
 (0)