Sentiment Analysis

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
Hi guys

Pet project I'm playing around with, basically it takes tweets (scanning for JSE shares/tags)
with the C# API, sends the tweets to DialogFlow - where Ive trained a Machine learning model to identify
whether the tweet is:

Bullish/Bearish - direction can be determined by the words
Neutral - (eg) Not much happening with XYZ today
None - unrelated to trading/direction (eg) See SENS article on

Any thoughts, ideas, etc happy to chat about

http://www.mytrading.co.za/tweets/index.php


The project used
C# .NET (Twitter)
SQL
PHP + Javascript + JSON
DialogFlow
 
Last edited:

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
Out of interest sake in 1 month, there were 430 tweets from 70 posters.

Thats the whole twittersphere for SA....at least with these #tags
There are some I skip because it brings in to much noise
(like searching for ASPEN brings in too many tweets about the area in the US)
 

jezzad

Well-Known Member
Joined
Jan 2, 2013
Messages
367
Very cool, would be interesting to pull in news reports.

Also would be great to have the company name
 

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
Interested, by chance will you be releasing the code?
I wont release the code in its entirety as its different libraries with different apps everywhere.
But happy to post any snippets of anything asked.

All the code can be found on the internet somewhere though, there's nothing really special about my code.
 

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
I find this quite hysterical. My first wrong prediction....

Words like "Im going short" is obviously bearish and "short" has been noted as bearish.

So the latest tweet is:
ANH looks constructive - on my watch list. A very short list :: Deemed -> bearish

:ROFL:


1561106318685.png
 

initroot

Senior Member
Joined
Jul 30, 2011
Messages
855
How did you perform the training data wise? Split? Dataset based on the tweets or did you feed investment lines for sentiment and then applied on the tweet dataset?

Sorry I'm not sure if dialogflow just applies their trained models.
 

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
How did you perform the training data wise? Split? Dataset based on the tweets or did you feed investment lines for sentiment and then applied on the tweet dataset?

Sorry I'm not sure if dialogflow just applies their trained models.
The training is done by taking the first 400 tweets and going through them - they were really
just around 70 bearish/bullish ones and lots of repetition within that as well, so wasnt a lot of work.
Taking the bits out that stood as giving direction and recording those.
Its not how I would normally train and test a model - rather split the data test etc - but its all still
infant/playing around phases, so I was happy to in this case train it using 100% of the 1 month data.

I also then just added some sayings that I knew was also used often like "catch a falling knife".
Im now going through the iterative phase, seeing what's worked what hasnt and what to update.
Will probably update the mistake until the model is fully trained.
It's all still very much in the development phase.

I'm still just learning as I go, so any thoughts on suggestions are welcome.
Was also looking at rather using the Python libraries to test this out, as there's a couple of free libraries.

DialogFlow:: Bearish

1561192094966.png
 

initroot

Senior Member
Joined
Jul 30, 2011
Messages
855
The training is done by taking the first 400 tweets and going through them - they were really
just around 70 bearish/bullish ones and lots of repetition within that as well, so wasnt a lot of work.
Taking the bits out that stood as giving direction and recording those.
Its not how I would normally train and test a model - rather split the data test etc - but its all still
infant/playing around phases, so I was happy to in this case train it using 100% of the 1 month data.

I also then just added some sayings that I knew was also used often like "catch a falling knife".
Im now going through the iterative phase, seeing what's worked what hasnt and what to update.
Will probably update the mistake until the model is fully trained.
It's all still very much in the development phase.

I'm still just learning as I go, so any thoughts on suggestions are welcome.
Was also looking at rather using the Python libraries to test this out, as there's a couple of free libraries.

DialogFlow:: Bearish

View attachment 675533
Nice, thank you for sharing. Very interesting project.
 

cguy

Expert Member
Joined
Jan 2, 2013
Messages
4,878
Have you done the analysis to see if the result of the analysis is actually predictive?
 

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
Have you done the analysis to see if the result of the analysis is actually predictive?
the past 2 weeks have been really busy so havent had any chance to play around with it yet.

but if you mean to be predictive on the actual stock markets, then I doubt it will...in South Africa
The twittersphere in SA is basically about 40 people tweeting and more than half are only retweets.
Dont think this really represents enough investors to make a difference in the moves,
but will keep track and see if there's anything to it.

I think the sentiment analysis that IG does on its members on their actual accounts probably has better insight.

These analytics really work much better on US, Australia, Europe sphere etc
Even India has more of a stock following.
 

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
The scary thing about the 40 people who tweet, between my friend and I
we know all of them...thats how small the industry is here.
 

cguy

Expert Member
Joined
Jan 2, 2013
Messages
4,878
the past 2 weeks have been really busy so havent had any chance to play around with it yet.

but if you mean to be predictive on the actual stock markets, then I doubt it will...in South Africa
The twittersphere in SA is basically about 40 people tweeting and more than half are only retweets.
Dont think this really represents enough investors to make a difference in the moves,
but will keep track and see if there's anything to it.

I think the sentiment analysis that IG does on its members on their actual accounts probably has better insight.

These analytics really work much better on US, Australia, Europe sphere etc
Even India has more of a stock following.
Yeah, I meant the actual stock markets. You could broaden the available data by using correlated tweet sentiment data (e.g., usd/eur to zar, stock indices, political news, etc.). Definitely not an easy problem though. :)
 
Last edited:

bchip

Senior Member
Joined
Mar 12, 2013
Messages
864
Still dont have much time to really play around.
Ive noticed some of the tweets arent classified well, so thats the next step to do is analyze and retrain the model
then run it all through again.

But in the mean time (this took only about 20 minutes to make)
I added data visualization software to just play around with the data.
I used Qlik Sense software, here are some results.

Overview:
Filters
: only show bullish & bearish tweets for the past 7 days.
Pie Chart: Bearish is 37% / Bullish is 63%
Word Cloud: all tweets broken up into words and analyzed for the most common ones
In this case: Others, confirmed, chart, above, JSESOL show as the most common words

Bar Chart: Shows the most spoken about JSE stocks in the past 7 days,
In this case, in the following order: INP, SOL, GLN, RDF, SHP, BHP


1563795404713.png

I can also analyze these things per user:
1563795605441.png
 
Top