Analyzing Twitter for market-moving information has been a business for years. High-frequency trading firms have even built such analysis into their trading strategies.
Then along came @realdonaldtrump.
A month into Donald J. Trump's presidency, the best algorithmic minds on Wall Street and in Silicon Valley are still scrambling to come to grips with the phenomenon.
"Trump's tweeting habits seem to be as erratic as everything else about him," Max Braun, an employee of the Google-affiliated research laboratory known as X, said in a recent interview.
Mr. Braun has built an automated bot — Trump2Cash — that analyzes Mr. Trump's tweets and then automatically places a trade on the companies the president names.
But like others in his field, Mr. Braun has learned that Mr. Trump's behavior on social media does not always play out the way the science would predict.
After the president criticized Nordstrom for dropping his daughter's clothing line, the bot predicted that Mr. Trump's negative comments about the retailer would cause its stock price to go down, but instead it rose 4.2 percent by the end of the trading day. As of Thursday, however, the bot's overall returns are in the green, according to a benchmark Mr. Braun is keeping.
The science of trading based on Twitter predates President Trump.
Yet the president "is a volatility machine," said Joe Gits, the chief executive of Social Market Analytics, which produces automated analysis of social media for professional investors. "He generates more volatility than anything in the world right now, so these stocks are going to move one way or the other."
Mr. Gits noted that in the long run — or even within a few weeks — almost all the companies that have been hit by Mr. Trump's jabs appeared to have recovered from the damage, suggesting that investors are discounting Mr. Trump's resolve to act against the companies.
Shares of Boeing, which was attacked by Mr. Trump in December over the cost of producing Air Force One, initially dropped in price, but they are now 12 percent higher than they were on the day of the tweet.
But Mr. Gits said that any firm doing short-term trading had to take Mr. Trump's statements into account. It has not been easy.
In the seconds after Mr. Trump's Nordstrom tweet, for instance, before people would have had enough time to respond, it was evident that automated trading algorithms had crunched the information and begun either selling or betting against the stock. The company's share price fell 1 percent within a minute. But that decline quickly reversed, and by the end of the day the stock had made strong gains.
More from The New York Times:
Trump's inroads in union ranks have labor leaders scrambling
Consumer agency can demand answers about foreclosed homes, judge rules
Snap aims for Valuation of more than $20 billion in IPO
That complicated response is, in part, a result of the fact that professional traders are not the only ones trying to play the Trump markets — tens of thousands of armchair investors are watching the president's account and placing trades.
Rachel Mayer is the co-founder of a New York start-up, Trigger Finance, that creates automatic trading triggers for small-time investors, based on real-world events. The company has created triggers for all sorts of market-moving signals — like changes in Federal Reserve policy and big stock price moves — but the triggers that Ms. Mayer's company has built around Trump's Twitter account have been by far the most popular, gaining 10,000 subscribers.
Ms. Mayer, who used to be a currency trader at JPMorgan Chase, said there were a number of indications that many of her subscribers saw the tweet about Nordstrom and decided to buy the stock as a form of protest, just as many consumers said they would support the store after the president's attack.
Ms. Mayer said that over time the market responses to Mr. Trump's proclamations seemed to be more restrained, which may reflect a recognition that the president's bark is worse than his bite.
"The market doesn't seem to think that he's going to do anything else except complain," she said.
Trump2Cash, Mr. Braun's bot, is set to hold the stock only until the end of the same trading day as the tweet. If the sentiment is negative, it places a short sale, or a bet that the price will fall, to take advantage of the stock going down.
Mr. Braun has continually tweaked the rules governing Trump2Cash. He has, for instance, programmed the bot to ignore mentions of media companies, including The New York Times Company, because they amounted to more market noise than signal.
But Mr. Braun says he will not mind if the bot ends up losing money — he is thinking about Trump2Cash as more of an art project than an investing strategy, and he plans to donate any money he makes from the few thousand dollars he has invested to Planned Parenthood and the American Civil Liberties Union, as a rebuke to Mr. Trump's politics.
"I have a very particular set of skills, skills that allow me to have some fun with Mr. Trump's emotional incontinence and maybe effect positive change along the way," Mr. Braun wrote in a Medium post introducing the bot.