Trump2cash – A stock trading bot powered by Trump tweets
github.com
github.com
Ok, simple enough, go on.
> When he does, it uses sentiment analysis to determine whether his opinions are positive or negative toward those companies.
Eh, sentiment analysis isn't perfect but it has come a long way, plus Trump does typically say what he means in simplistic language.
> The bot then automatically executes trades on the relevant stocks according to the expected market reaction.
Ah market psychology. Stop. Do not pass Go. Do not collect $200. This is the tricky bit that a toy project will never get right and turns your slick algorithmic trading project into a monkey and a dart board.
Though this is a sweet example of an API mashup.
I've seen this working and working very well (day job), although not specifically with Trump tweets.
http://www.investopedia.com/articles/active-trading/040515/h...
I guess you could weigh it against his favorability polling, but you're right, this is all just guesswork masquerading as science.
Now your holding lots of Nordstrom and NYT, and riding the wave up. Congrats, your going to be a millionaire!
My answer was maybe but I'd rather not put my money at the mercy of a lunatic.
Dark money influencing elections = wild man at the tiller.
His other tweets regarding other companies were all future-tense, and companies he is in a position to bully. Except for Nordstrom, of course.
What would be needed? A line? Programmable robots? Inputs and outputs?
Interesting idea.
I'd be interested in learning why TradeKing was used , as I haven't used it myself - was it for an especially solid API, or just because TradeKing is easy to get set up and doesn't require a minimum investment? If anyone wants to play around with this and has at least $10k to play with, Interactive Brokers will give you better fees.
OP, you might be interested in Quantopian's Zipline algorithmic trading library, which is also in Python: https://github.com/quantopian/zipline
Also, I feel like there should be a disclaimer that given how accessible this strategy is (both in required skill and resources) and how much attention the Trump tweets phenomenon has gotten, any alpha from this has been almost certainly lost to other firms. This is a cool project, but it's probably not actually an effective strategy anymore.
Or backtrader (backtesting and live trading with Oanda and IB)
For anyone 25 or younger who's reading this, the required minimum for you is $3k[0].
"The efficient markets hypothesis may be "the best established fact in all of social sciences," but the best established fact in all of financial markets is that, when there is news about a big famous private company going public or being acquired, the shares of a tiny obscure public company with a similar name will shoot up. I don't know what that tells you about the efficient markets hypothesis, but it happened to Nestor, Inc., and to Tweeter Home Entertainment, and to Oculus VisionTech Inc., and now it has happened to SNAP Interactive Inc.:
In what is almost surely a case of mistaken identity, investors sent shares in a little known startup called SNAP Interactive Inc., ticker STVI, surging 164 percent in the four days since Snap Inc. filed for a $3 billion initial public offering. The $69 million SNAP Interactive makes mobile dating apps, while the IPO aspirant is the parent of the popular Snapchat photo-sharing app. These stories are always less impressive when expressed in dollar terms than they are in percentages. In the four trading days since Snap Inc. filed its S-1, SNAP Interactive has traded 19,963 shares, worth less than $200,000, according to Bloomberg data. If you had a cunning plan to buy up SNAP shares and sell them for a quick profit when Snap filed to go public, it might have worked, but not in particularly huge size."
article here: https://www.bloomberg.com/view/articles/2017-02-09/quasi-ind...
May 2016:
> Snap Interactive, Inc. (“SNAP”) develops, owns and operates dating applications for social networking websites and mobile platforms. SNAP’s flagship brand, FirstMet.com, is a multi-platform online dating site with a large user database of approximately 30 million users. FirstMet.com‘s mission is to improve the online dating experience of meeting new people by integrating a user’s friends and interests to enable more meaningful connections. SNAP’s newest application, The Grade, is a patent-pending mobile dating application catering to high-quality singles.
Present (emphasis mine):
> Snap Interactive, Inc. (“SNAP”) (OTCQB: STVI) develops, owns and operates real-time, rich media social networking and dating applications on desktop and mobile computing platforms. Supported by a portfolio of 25 patents, SNAP is a leader in real-time video communication, with groundbreaking products powering one of the world’s largest collections of video-based communities. Through brands such as Paltalk, FirstMet, Camfrog and Tinychat, SNAP has helped hundreds of millions of users around the world make meaningful friendships and romantic connections.
[1]: http://web.archive.org/web/20160506160057/http://www.snap-in...
Trump's last couple tweets have backfired and actually increased his targets' stock price though. You might have to flip the algorithm around if this continues.
But most of the other tweets are about cases where he could harm them as POTUS.
If you trade fast enough it still works. Nordstroms took a hit for few minutes before coming out slightly ahead.
That effect is most likely due to automated traders trying to profit from Trumps tweets.
Why don't you take it to the next level? Provoke Trump on Twitter, associating yourself with a company. Then short that company's stock and wait until he lashes out against them. Profit!
Is he looking?
There's no way he even reads 1% of it.
Anyone knowing a little of the stock market knows that different factors play the game and not a factor. e.g. maybe if Trump wouldn't have tweeted Intel would have gone down >2.6%
All you have provided is proof that it is sometimes wrong, which is not surprising at all.
What about a bot which would do just the opposite?
from https://github.com/maxbbraun/trump2cash/blob/02e66eddc4ea066...
# Determine bull or bear based on sentiment direction.
if sentiment > 0:
strategy["action"] = "bull"
strategy["reason"] = "positive sentiment"
return strategy
else: # sentiment < 0
strategy["action"] = "bear"
strategy["reason"] = "negative sentiment"
return strategyYou could argue he already has this power, but before the message needed to resonate with a large collective of people. Any public figure (like Warren Buffet, etc) can express an opinion that might effect the stock they are commenting on.
However as this group of people automate trades on only the contents of his tweets (and not say the contents of the tweet as well as past company performance, current POTUS approval ratings, dividend plans etc) he gains a scary amount of control over the markets.
To put another way. The only people who know what he will tweet earlier than these bots are Trump and maybe a select group of people he tells before hand.
Congress actually gets a free pass on buying and selling stocks with insider information and many have done so for decades: http://www.cbsnews.com/news/congress-trading-stock-on-inside...
Shall we go for refugee charity?
Other good options are FIRST, Girls Who Code, and The Geek Group, all orgs that focus on STEM Education and getting people into the STEM fields.
Just to name a few groups to directly counterbalance his behavior.
How do these technical organizations counterbalance anything he is doing?
________________________
*But the devil is in the execution - and the amount of capital leveraged.
So basically, instead of this bot betting that Trump's tweets will change stock prices, you're actually betting on the HFT bots being wrong about how much Trump's tweets change stock prices.
You know, funny enough, one of the biggest moments of
realization was when Donald Trump won the election because
when I came into the show, I said, I think this guy can win.
This was when he first came down that escalator. He gave his
first speech.
And then I was like, wow, this guy's going to do well. And I
remember people laughed at me. People were like, oh, you
silly ignorant person who's just come to this world. You
clearly shouldn't be at "The Daily Show" 'cause you don't
know what you're talking about. And I was like, but I don't
know. He seems like he connects with people. I can relate to
him as a performer. I can see what tools he's using. He's
good at riffing. He's good at taking the crowd on a journey.
I can see what he's doing.
And people would say - and all throughout the race - and
there were times when, on the show, I would mention it. You
know, I mean, that's why I said Trump reminds me of an
African dictator. And that's where that came from because
everyone said to me, this guy is - he's just a fool. He's
just - he's a buffoon. I said, yeah, you can say that. But
I've seen this before. I have seen this before. I've seen
clowns that go on to take over their countries. I've seen
buffoons who end up ruling their worlds. And it came to
pass.
Source: http://www.npr.org/2016/12/16/505847054/trevor-noah-says-he-grew-up-in-the-shadow-of-a-giant-his-momWhenever Trump signs on executive order or signals an intention, I presume it will either fail or will end in bad results for the poor and middle class.
Then, working as if that were true, I see if there are any stocks or ETFs that would benefit from that and buy some.
I have been doing pretty good!
You can even see on the chart how there was very little until inauguration, giant leaps after unpopular EO's, and you can even see the portfolio drop when Trump took a beat and eased up on the EOs after Feb 3rd.
This bot watches Donald Trump's tweets and waits for him to mention any publicly traded companies. When he does, it uses sentiment analysis to determine whether his opinions are positive or negative toward those companies. The bot then automatically executes trades on the relevant stocks according to the expected market reaction.
OK, so what's the expected market reaction? If Trump hates your company, does that make your stock go up, or down?The article just mentions how it ended the day (UP), but it started by going DOWN quite a few % after Trump spoke against it:
http://fox6now.com/2017/02/09/nordstrom-stock-defies-preside...
Makes me want to think of another fun way of crowdsourcing stock tips for fun.
Maybe something like TwitchPlaysWallStreet?
Looks like deciding the sentiment of the tweet is still on the to-do list.
def get_sentiment(self, text): """Extracts a sentiment score [-1, 1] from text."""
# TODO: Determine sentiment targeted at the specific entity.I feel like this game is just a small scale version of the one being played by a higher force by making Trump president.
In fact that wiki link I posted earlier previously says just this: https://en.wikipedia.org/wiki/Insider_trading#Definition_of_... (last paragraph on 'Definition of "Insider"')
Here's a hypothetical scenario:
My buddy Sean from the white house texted me a few days ago that "Trump is going to make negative comments about Nordstrom soon", I shorted Nordstrom stock based on this information and made huge profits when Trump said the things Sean promised he would.
Do you think someone would be guilty of insider trading here? Nobody involved is connected to Nordstrom in any way.
It's also extremely important to note that the SEC and the courts have very different definitions of "insider trading".
Unless you can find another citation that contradicts my point then I'm going to have to assume my point is correct. And I say that welcoming a correction in the name of "science" :)
Presumably it's not this chapter you're referring to.
>For example, illegal insider trading would occur if the chief executive officer of Company A learned (prior to a public announcement) that Company A will be taken over and then bought shares in Company A while knowing that the share price would likely rise.
Probably not this one either
>In the United States and many other jurisdictions, however, "insiders" are not just limited to corporate officials and major shareholders where illegal insider trading is concerned but can include any individual who trades shares based on material non-public information in violation of some duty of trust. This duty may be imputed; for example, in many jurisdictions, in cases of where a corporate insider "tips" a friend about non-public information likely to have an effect on the company's share price, the duty the corporate insider owes the company is now imputed to the friend and the friend violates a duty to the company if he trades on the basis of this information.
Despite the fact that this chapter doesn't contain anything relevant either, it's probably this one you're referring to. There's no corporate insiders or relationships involving a duty of trust here.
I think you may be misinterpreting your source.
"illegal insider trading requires that you not only trade on the basis of important nonpublic information but that you also have some sort of duty to keep the information confidential." - Kiplinger
If you overhear insiders talking, you can trade on it. (Unless you're in a position where they have reason to expect that you cannot, such as if you're an employee, etc.)
How often did that happen in the past?
(Not paying attention, specialty of the house ;-)
"Overall, the algorithm seems to succeed more often than not: The simulated fund has an annualized return of about 59% since inception. There are limits to the simulation and the underlying data, so take it all with a grain of salt."
Don't be surprised if this crazy economic system can collapse any seconds with ideas like this.
stocks are a random walk.
If this worked, I'd expect the HF funds to start doing it too, and even faster, and then the advantage would be destroyed.