Automated Trading Strategy using Social Media Sentiment

Introduction

This paper describes the implementation of an automated equity trading strategy based on social media derived bullishness and bearishness sentiment indicators and the results from back-testing this strategy. The sentiment factors were provided by PsychSignal who have developed natural language processing software with the purpose of calculating bullishness and bearishness indices from StockTwits, Twitter and chat rooms.

The PsychSignal data and market data used in this research, together with the QuantOffice implementation of this strategy, are available from Deltix Cloud Services (DCS). 

Trading logic description

We developed the trading strategy based on intraday PsychSignal bullish/bearish indices using two approaches. In both cases, we were operating on the hypothesis that past bullish/bearish indicators for a specific security provide predictive power on the future price of that security and that we can profitably trade using this insight.

1. Regression based model

We took as predictors the two most recent days of daily bullish and bearish indicators data. These daily predictors were smoothed using an EMA (Exponential Moving Average) indicator and acted as the regressors (independent variables) in our model. As the regressand (dependent variable), we calculated the close-to-next-day-open price change for each security in the S&P500 over a period of 50 days (the training period).  We applied linear regression to the resultant matrix of regressor values and the vector of the regressand values. The regression parameters were set as weights in the indicator formula and the following signal logic was applied:

If indicator  is positive and current price is lower than the 50 day EMA-smoothed day close price, then open a long position at market close and close that position at next market open.

If indicator is negative and current price is higher than 50 day EMA-smoothed day close price with then open a short position at market close and close that position at next market open.

The order size for opening order is calculated by the following formula:

where: retON = list of overnight returns collected for the last 50 days.

The following variations of this model are available via input parameters of the strategy:

  •   Using the return calculated as 15 min before close price, as an extra parameter in the regression model.
  • Instead of comparing the indicator to 0, we can compare it to some enhanced boundaries. As an example of such boundaries, +/- absolute value of the 30 day SMA (Simple Moving Average) of the indicator was used: if indicator is greater than the absolute value of the SMA, then open long position, if it is less then open a short position.

2. RSI based model

In this model, daily predictors are smoothed by collecting data for each predictor into an EMA indicator. The day close EMA values are smoothed with EMA daily indicators and the RSI (Relative Strength Index) is calculated as:

If RSI<15  and current price is lower than 50 day EMA-smoothed day close price then open long position at market close and close that position at next open.

If RSI>85  and current price is higher than 50 day EMA-smoothed day close price then open short position at market close and close that position at next open.

The order size for opening order is calculated by the following formula:

where: retON means list of overnight returns collected for the last 30 days.

Results

The strategy was run on securities in the S&P100.

Consolidated results

ParameterRegression basedSMA boundariesReturn in regression, SMA boundariesRSI
Net Profit/Loss390,804.54404,459.44325,423.34137,914.56
Total Profit2,176,093.571,734,422.431,614,855.21326,873.83
Total Loss-1,785,289.03-1,329,962.99-1,289,431.87-188,959.27
Cumulated Profit %390.80%404.46%325.42%137.91%
Max Drawdown-106,957.11-95,237.32-62,589.54-20,407.60
Max Drawdown %-18.80%-16.77%-13.00%-19.80%
Max Drawdown Date7/24/20137/23/20137/25/201312/31/2012
Return/Drawdown Ratio3,654,255,26,76
Drawdown Days %46.07%41.88%50.26%54.97%
Max Drawdown Duration21212129
CAGR771.97%805.16%617.77%225.39%
Sharpe Ratio2,883,133,12,7
Annualized Volatility184,48175,93143,0369,47
Sortino Ratio5,555,615,755,76
UPI5,186,794,134,14
Information Ratio2,883,133,12,7
Optimal f2,272,63,024,67
All Trades #565743414226739
Profitable Trades Ratio0,510,540,510,58
Winning Trades #289723382172427
Losing Trades #276020032054312
Average Trade69,0893,1777,01186,62
Average Winning Trade751,15741,84743,49765,51
Average Losing Trade-646,84-663,99-627,77-605,64
Avg. Win/ Avg. Loss Ratio1,161,121,181,26
Average Profit per Share0,020,030,030,05
Max Conseq. Winners13261947
Max Conseq. Losers15161413

Detailed results

1. Regression based algorithm

ParameterAll TradesLong TradesShort Trades
Net Profit/Loss390,804.54378,866.6211,937.92
Total Profit2,176,093.57845,980.891,330,112.68
Total Loss-1,785,289.03-467,114.27-1,318,174.76
Cumulated Profit %390.80%378.87%11.94%
Max Drawdown-106,957.11-53,779.96-158,289.04
Max Drawdown %-18.80%-15.74%-60.24%
Max Drawdown Date7/24/20136/24/20137/24/2013
Return/Drawdown Ratio3,657,040,08
Drawdown Days %46.07%45.03%64.40%
Max Drawdown Duration211627
CAGR771.97%743.23%16.59%
Sharpe Ratio2,883,080,07
Annualized Volatility184,48167,3242,09
Sortino Ratio5,555,570,11
UPI5,1810,020,05
Information Ratio2,883,080,07
Optimal f2,272,660,03
All Trades #565718593798
Profitable Trades Ratio0,510,610,47
Winning Trades #289711251772
Losing Trades #27607342026
Average Trade69,08203,83,14
Average Winning Trade751,15751,98750,63
Average Losing Trade-646,84-636,4-650,63
Avg. Win/ Avg. Loss Ratio1,161,181,15
Average Profit per Share0,020,070
Max Conseq. Winners135534
Max Conseq. Losers152344
 

2. +/- SMA value as boundaries

ParameterAll TradesLong TradesShort Trades
Net Profit/Loss404,459.44377,455.0827,004.36
Total Profit1,734,422.431,047,071.96687,350.47
Total Loss-1,329,962.99-669,616.88-660,346.11
Cumulated Profit %404.46%377.46%27.00%
Max Drawdown-95,237.32-70,438.24-99,399.48
Max Drawdown %-16.77%-16.54%-43.90%
Max Drawdown Date7/23/20136/24/201308.01.2013
Return/Drawdown Ratio4,255,360,27
Drawdown Days %41.88%45.55%60.73%
Max Drawdown Duration211628
CAGR805.16%739.85%38.46%
Sharpe Ratio3,132,540,28
Annualized Volatility175,93202,45131,01
Sortino Ratio5,614,30,43
UPI6,797,180,18
Information Ratio3,132,540,28
Optimal f2,61,810,22
All Trades #434122182123
Profitable Trades Ratio0,540,60,48
Winning Trades #233813251013
Losing Trades #20038931110
Average Trade93,17170,1812,72
Average Winning Trade741,84790,24678,53
Average Losing Trade-663,99-749,85-594,91
Avg. Win/ Avg. Loss Ratio1,121,051,14
Average Profit per Share0,030,060
Max Conseq. Winners263423
Max Conseq. Losers164034
 

3. Return in regression, SMA boundaries

ParameterAll TradesLong TradesShort Trades
Net Profit/Loss404,459.44377,455.0827,004.36
Total Profit1,734,422.431,047,071.96687,350.47
Total Loss-1,329,962.99-669,616.88-660,346.11
Cumulated Profit %404.46%377.46%27.00%
Max Drawdown-95,237.32-70,438.24-99,399.48
Max Drawdown %-16.77%-16.54%-43.90%
Max Drawdown Date7/23/20136/24/201308.01.2013
Return/Drawdown Ratio4,255,360,27
Drawdown Days %41.88%45.55%60.73%
Max Drawdown Duration211628
CAGR805.16%739.85%38.46%
Sharpe Ratio3,132,540,28
Annualized Volatility175,93202,45131,01
Sortino Ratio5,614,30,43
UPI6,797,180,18
Information Ratio3,132,540,28
Optimal f2,61,810,22
All Trades #434122182123
Profitable Trades Ratio0,540,60,48
Winning Trades #233813251013
Losing Trades #20038931110
Average Trade93,17170,1812,72
Average Winning Trade741,84790,24678,53
Average Losing Trade-663,99-749,85-594,91
Avg. Win/ Avg. Loss Ratio1,121,051,14
Average Profit per Share0,030,060
Max Conseq. Winners263423
Max Conseq. Losers164034
 

4.  RSI

ParameterAll TradesLong TradesShort Trades
Net Profit/Loss325,423.34304,738.1520,685.20
Total Profit1,614,855.21603,891.161,010,964.04
Total Loss-1,289,431.87-299,153.02-990,278.85
Cumulated Profit %325.42%304.74%20.69%
Max Drawdown-62,589.54-26,493.13-113,048.33
Max Drawdown %-13.00%-8.72%-48.37%
Max Drawdown Date7/25/20136/24/201308.01.2013
Return/Drawdown Ratio5,211,50,18
Drawdown Days %50.26%43.98%63.35%
Max Drawdown Duration211037
CAGR617.77%570.69%29.17%
Sharpe Ratio3,13,580,15
Annualized Volatility143,03115,91184,57
Sortino Ratio5,756,890,24
UPI4,139,860,09
Information Ratio3,13,580,15
Optimal f3,024,250,09
All Trades #422613012925
Profitable Trades Ratio0,510,620,47
Winning Trades #21728041368
Losing Trades #20544971557
Average Trade77,01234,237,07
Average Winning Trade743,49751,11739,01
Average Losing Trade-627,77-601,92-636,02
Avg. Win/ Avg. Loss Ratio1,181,251,16
Average Profit per Share0,030,080
Max Conseq. Winners193526
Max Conseq. Losers141746
 

·        Using the return calculated as 15 min before close price, as an extra parameter in the regression model.

·        Instead of comparing the indicator to 0, we can compare it to some enhanced boundaries. As an example of such boundaries, +/- absolute value of the 30 day SMA (Simple Moving Average) of the indicator was used: if indicator is greater than the absolute value of the SMA, then open long position, if it is less then open a short position.

The following two tabs change content below.

The Deltix Quantitative Research Team