13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

446

sentiment.

In recent years there has been a steady growth of sentiment analysis vendors, including

Sentdex, PsychSignal and Accern. All use proprietary techniques to identify "entities" within

alternative data and then associate a timestamped sentiment score with any extracted information.

This information can then be aggregated over a time period (such as a day), in order to

produce date-entity-sentiment tuples. Such tuples form the basis of a trading signal.

The actual task of taking large quantities of "big data" and quantifying the sentiment is

beyond the scope of the book. An end-to-end production-ready sentiment analysis tool is a large

software engineering undertaking. Hence for retail traders it is often practical to obtain vendor

signals and use those as part of a broader portfolio of quantitative signals to form a strategy.

This chapter will describe a trading strategy based on a particular vendor’s sentiment data,

namely Sentdex, and how a basic long-only strategy can be generated around it.

30.1.1 Sentdex API and Sample File

Sentdex provides an API that allows download of their sentiment data for a wide variety of

financial instruments. The data is available at one minute or one day granularity. More details

of their (paid) offering can be found at their API page.

The API will not be discussed in this chapter since it is a paid product and is mostly useful

as a paper trading or live trading streaming event generator. Since this book concerns backtesting

strategies across historical data it is more appropriate to use a static, locally-stored file to

represent the sentiment data.

Fortuitously, Sentdex provides a sample data file (which can be found at http://sentdex.

com/api/finance/sentiment-signals/sample/) that contains almost five years worth of sentiment

signals, at daily resolution, for many of the constituents of the S&P500.

A snippet of the file is presented below:

date,symbol,sentiment_signal

2012-10-15,AAPL,6

2012-10-16,AAPL,2

2012-10-17,AAPL,6

2012-10-18,AAPL,6

2012-10-19,AAPL,6

2012-10-20,AAPL,6

2012-10-21,AAPL,1

2012-10-22,MSFT,6

2012-10-22,GOOG,6

2012-10-22,AAPL,-1

2012-10-23,AAPL,-3

2012-10-23,GOOG,-3

2012-10-23,MSFT,6

2012-10-24,GOOG,-1

2012-10-24,MSFT,-3

2012-10-24,AAPL,-1

It can be seen that each row contains a date, a ticker symbol and then an integer representing

strength of sentiment, between +6 ("strong positive sentiment") and -3 ("strong negative

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!