38

Generate News Sentiment Scores in Excel

 3 years ago
source link: https://www.tuicool.com/articles/VnqQnuy
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

with a single function

IVbEJrr.jpg

Null result for days which have no news articles on The Business Times

Scraped news article

367je2r.png!web

Search result for USD on the 8th July, Sentiment Score: -0.1409

I have gotten a request from one of my readers of Algorithmic Trading using Sentiment Analysis on News Articles to create a general tool which would allow you to get the sentiment scores from web-scraped news articles ( The Business Times ). I previously used it as a metric in algo trading but I figured it would be very useful to people from the portfolio management or risk side of Finance as well.

Idea

The idea was to make it easier for non-technical users to get a simple -1 to 1 score on Excel, based on various terms they are interested in across different days. I would imagine this being used in portfolio re-balancing or even as an automated form of media monitoring. The web-scraping and sentiment scoring was described in my previouspost.

9 simple steps to get set up

*Windows only*

1. LinkedIn message me with your email for the project folder

2. Open sentiment.py in project folder

jIzEnaQ.jpg

Replace the highlighted path with your own aka C:/Users/bob/Desktop/sentiment/stock_lexicon.pickle

3. Download and install Anaconda (Python)

https://www.anaconda.com/distribution/#download-section

4. Open command prompt and create conda environment

MzmI3yj.png!web
conda create -n py36 python=3.6 && activate py36

5. Enter the sentiment project directory and install packages

Assuming the folder is on your desktop

cd desktop/sentiment && pip install -r requirements.txt

6. Reveal Developer tab in Excel

biA3yq7.jpg

File > Options > Customize Ribbon

7. Enable settings

E3u2eqA.jpg

File > Options > Trust Center > Trust Center Settings > Macro Settings > Trust access to the VBA project object model

8. Open sentiment.xlsm and enable xlwings

Y7JFNzr.jpg

9. Point xlwings to your conda environment and import python function

Specify the installation path to your Anaconda3

MVnIry2.jpg

Conda Base: C:\Users\bob\Anaconda3

And.. we’re done!

Feel free to share any comments or ideas!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK