For my next project I decided I needed to try something that could possibly directly support my hobby financially. So I started creating a very high-level trading algorithm. Instead of focusing on standard mathematical metrics (moving averages, Bollinger bands, RSI, etc) which has been done to death and optimized at higher frequencies than I'll ever be able to achieve on my own, I decided to look at something a little more niche like /r/wallstreetbets sentiment. Don't worry, it's not another mention frequency based meme stock buying bot. I try to decide stocks to trade based on positive and negative sentiments present in the body of text. The idea is there is volatility in these stocks and that it may be possible to day trade these tickers based on what people are about to do (assuming my parsing logic extracts the signal the same way humans are interpreting posts). In short, sentiment analysis of user comments is already a challenging task. Having a computer program that can work its way through double negatives, sarcasm, jokes, and idioms - in a community that does these things to the fullest extent - is a challenging task to say the least. One example is a comment that goes like this

"Buying put options on $GME is free money"

The sentiment of the comment is positive, however the trading action of buying a put is negative (it means betting the stock will go down in price).

Extracting an accurate signal from this type of data is very tricky and time consuming, but I was able to come up with a quick solution to account for these comments. I monkey patched a sentiment analysis algorithm. I have used gevent monkey patching before in production where I was facing certain constraints with async code. This time I wanted to learn something new and decided to do my own monkey patching. Now my algorithm knows the meaning of words in the context of trading.

Another interesting problem that came up is the potential for fake accounts / bots to spread misinformation. Institutional investors have been keen on sentiment for trading for years now (the Bloomberg terminal has a section for Twitter sentiment) and similarly equipped groups could manipulate the impulsivity of /r/wallstreetbets to their advantage.

My next steps are to pull in sentiments about a company from a variety of other sources - twitter has a simple API as well. There are pretty sophisticated financial APIs out there that I am researching. The most challenging thing to do won't be simply answering whether "this news is good news" or "this financial data is bad", but what to do with that particular stock since apparently stocks get dumped on good news.

There are a number of algorithmic trading libraries available in the Python ecosystem. One I want to use is backtrader. The simple interface that "gets out of your way" is what I am looking for. It allows you to define custom data sources, do backtesting, and trade live.