How to Invest like a Data Scientist | by Noah Xiao | Towards Data Science

Surely you know data science is a multi-disciplinary field that has something to do with statistics, mathematics, computer science, and business knowledge.
The mindset and the multi-disciplinary skill set required for being a data scientist are powerful tools. Instead of a Ph.D. degree1, they are the qualifications of a good data scientist. They not only benefit your career, but also have a huge and positive influence on how you deal with things in life.
Investment is a life-long task for anyone who seeks financial freedom. Whether it is investing in stocks or yourself, there are a handful of principles one should keep in mind. These principles are important but also easy to forget. Why? Because “thanks” to human nature, it is certain that one needs an unsuccessful investment experience to appreciate the importance of them.
Is there a way to truly master these principles without going through failure? Yes, with the mindset and the multi-disciplinary skill set, good data scientists should know the shortcut. Hope you will be amazed by how these two skills can benefit the way you invest too.
“The whole of science is nothing more than a refinement of everyday thinking.”
— Albert Einstein
A casino is a very profitable business, which can even feed an entire city’s welfare system, like in Las Vagas. Apart from tourists and casual visitors, the largest profit earned by a casino is from gamblers’ greed.
You rarely see data scientists in Casinos. If you do, they either work for the casino or they were just pretending to be “social” with their non-data scientist friends there 😲. Why? Because a good data scientist knows mathematics.
Let‘s see a simplified example:
A gambler plays a game, with exactly 50% of chance of winning and losingIf he wins, he earns 1 dollar; if he loses, he loses 1 dollarThe gambler has $X at the startThere are only two ways to finish the game: 1) lose all $X, 2) the total money reaches his target, $Y
A gambler plays a game, with exactly 50% of chance of winning and losing
If he wins, he earns 1 dollar; if he loses, he loses 1 dollar
The gambler has $X at the start
There are only two ways to finish the game: 1) lose all $X, 2) the total money reaches his target, $Y
The game seems straightforward but unveils two attributes of all gambling games. Firstly, they all look fair games which make you feel you would simply end up a draw if your luck is average. Secondly, gamblers are greedy.
Let’s say, the probability of losing all $X is P(X)
Therefore
P(X) = 50% × P(X - 1) + 50% × P(X + 1)
i.e., 2 × P(X) = P(X - 1) + P(X + 1)
i.e., P(X) - P(X - 1) = P(X + 1) - P(X), this satisfies the property of a typical arithmetic progression
It is known that for any arithmetic progressions2,
i.e. the nth term of the sequence = the first term + the distance between 1th and nth, which can be seen as (n - 1) × the common distance between any two terms.
We also know that:
P(0) = 1, when one has 0 dollars, the probability of losing everything is 100%
P(Y) = 0, when one has Y dollars, the game is finished, so the probability of losing everything is 0%
Thus, d = 1 / Y
The sequence can now be transformed into below:
With the formula above,
P(X) = P(Y) + (n - 1)d = P(Y) + (Y - X) ▪ 1 / Y = (Y - X) / Y
That is to say, if X = $1,000
if Y = $1,200, P(X) = 1/6if Y = $1,500, P(X) = 1/3if Y = $2,000, P(X) = 1/2if Y = $5,000, P(X) = 4/5
if Y = $1,200, P(X) = 1/6
if Y = $1,500, P(X) = 1/3
if Y = $2,000, P(X) = 1/2
if Y = $5,000, P(X) = 4/5
If you want to make $200, it is relatively easy to achieve. However, if you get greedy and want to make 5 times, there’s an 80% chance you will lose everything.
“Quit while you’re ahead” — Old Chinese Wisdom
You may have heard about the craziness of cryptocurrencies in 2017 when Bitcoin increased its value by 20 times within a year, followed by a big crash till today.
Let us start with a simplified example and you may see how to invest in volatile markets in the future:
Sofia invites Noah to play a game that each of them is given a coinIn each round, both of them show a side of the coinIf the result is 2 heads, Noah wins $3 dollarsIf the result is 2 tails, Noah wins $1 dollarIf the result 1 head and 1 tail, then Noah loses $2 dollars
Sofia invites Noah to play a game that each of them is given a coin
In each round, both of them show a side of the coin
If the result is 2 heads, Noah wins $3 dollars
If the result is 2 tails, Noah wins $1 dollar
If the result 1 head and 1 tail, then Noah loses $2 dollars
It is not hard to imagine that the result of tossing a coin is 50–50, so there are 25% of the times the result is 2 heads, 25% 2 tails, and 50% 1 head and 1 tail.
Therefore, the expectation of Noah and Sofia’s reward is $0:
25% × $3 + 25% × $1 - 50% × $2 = $0
Yes, it seems to be a fair game plus Noah always wants to play a game with a charming lady, like Sofia, so why not playing. But, after hours of the gaming date, the outcome shows that Noah has almost lost everything in his wallet, including the wallet. How did that happen?
The trick is: instead of randomly showing the coin every round, Sofia gets to control the probability. What strategy did she use? Here is what Sofia did:
Let’s say A represent the event in which Sofia shows the head, B for the event Noah shows the head.
The expectation of Noah’s reward:
Plotting this equation:
The areas under the flat surface represent the negative E(Noah), and there is a certain range of P(A), Sofia’s probability of showing head, that makes the E(Noah) always negative! This is Sofia’s trick. The code below reveals the range:
[0.34 0.35 0.36 ... 0.38 0.39 0.4]
That’s it. If Sofia manages to force the probability falls between 0.34 and 0.4, she will always make Noah lose money!
This game is a problem in game theory. It can be a perfect analogy teaching us how one can get tricked from a “fair” game. Here, the game can be seen as an investment, Noah represents the individual investors, and Sofia represents the institutional investors, a.k.a., big whales. In small capital investments, such as cryptocurrency and penny stocks, big whales can easily manipulate the market with a big amount of money, i.e., big sell-out or buy-in. Individual investors can make money if they luckily follow the movement of the “whales”, but ultimately individual investors will lose because they are just being manipulated.
During an investment, it is the most common thing that one will both win and lose at different points of time. When you are winning, never get greedy (proved earlier). When you are losing, cut the loss wisely.
Sam has been holding a stock which worths $10k. Recently the company hasn’t been in the wrong hands and the stock price suddenly dropped to below the purchase price, now it only worths $8k.
If Sam keeps holding or adding positions, 90% of chances he will lose more. Obviously cutting the loss is the way to go. However, many people fail to do this, even they were presented with the stats beforehand. This is all due to human egos, such as “You can’t lose money if you never sell”, “Never lose money”. Do NOT be dogmatic about these words.
Setting the ego aside, a.k.a., objective thinking, is not as simple as it seems, it requires regular training and one’s persistence. This skill is a fundamental requisite for any scientists and researchers.
When the loss is not recoverable, e.g., the company is a scam/bubble, do NOT hope it may get better anytime soon, admit the loss has already become a sunk cost, and pull out immediately. Although sometimes the loss might get recovered by HODLing, considering the opportunity cost, the time you spend waiting till the investment gets back to the previous level, you may have already doubled your position if you chose to move the money somewhere else.
When it comes to investment survival, it’s always recommended to conduct more research about the stock and do some calculations to support the investment decision. Another simple and smart way is to treat the stock was given to you for FREE. You will find the decision becomes much easier to make if Sam received a free $10k stock but one day the stock dropped to $8k with very little chance to come back up.
There are countless good and bad ways to evaluate an investment, and three of the worst ones are listed above. For individual investors, value investing, discounting, scorecard, PB + PE + PEG are great ways to start. I won’t elaborate on them in this article, please click through the links and you will discover how useful they are.
What I would like to call out is an interesting and sometimes counter-intuitive way that lots of people including professionals rely TOO MUCH on — Expected Return. Below shows when it does and doesn’t.
Say there is a coin-tossing game. Every round, if it is the head, the player makes $1, if it is the tail, the player makes $2. How much should (s)he pay for playing one round of this game?
The expected return is $1.5 so the game is worth playing only if the entry fee is less than $1.5.
Say you have $X, there are 50% of chances it will become 0.9 × $X and 50% 1.11 × $X in the next unit time. Is it rationale to all-in every time?
This means, in the next unit time, you are expected to gain 0.5% from the $X you have. That is to say, every time you invest, you would make a profit, so of course, you should all-in every time!
However, in reality, you are would lose everything if you do so. Counter-intuitive right? Below shows you why.
With Monte Carlo simulation, I created 10,000 investors over 500 time units, all start at $100.
Each point on the graph represents the return of an investor at a particular time unit. From it, we can see that a few investors have achieved very significant return as time moves on, while the majority of the investors are not so lucky.
How unlucky are they? 88.56% of the investors have a return lower than where they started at, $100. What is more unfortunate is that 84.76% of the 10,000 investors end up with $0. Yes, the majority of the investors lose every single cent in the end.
It seems that the investment is extremely optimistic, and one should theoretically gain an infinite amount of money if (s)he keeps playing, but there is almost NO real winner in the market.
Below code reproduces the simulation:
In case you are not 100% convinced, below explains why from a mathematical lens:
We already know that the Expected Return is
How about one’s Limit of Return:
Because
Thanks to the law of large numbers
Therefore
Boom! Counter-intuitive again! The Expected Return is positive but the Limit is zero. This is because some of the Xs are very large in the end, but that is extremely hard to achieve. The average return is dragged to positive due to these very few large Xs, but the truth is the majority of the Xs are almost zero.
While investing, one should use the tools wisely. Expected Return is a simple and useful tool but overly relying on it will make you ignore certain important information, which could be fatal sometimes.
I have two messages I would love to convey from this article:
Data science is beyond just a day-to-day job. The mindset and multi-disciplinary skill set required for being a good data scientist are powerful equipment, which benefits the way one interacts with everything in life.Don’t get greedy, keep distance with volatile markets, cut the loss short, and use tools knowing what they are first. These four investment principles probably are well known among many investors. However not many keep them in mind every time because the principles are taught by words, rather by real-life experiences, a.k.a, failures. I hope by revealing the data and the science behind these lessons, you won’t have to experience the failure to become a master of investment.
Data science is beyond just a day-to-day job. The mindset and multi-disciplinary skill set required for being a good data scientist are powerful equipment, which benefits the way one interacts with everything in life.
Don’t get greedy, keep distance with volatile markets, cut the loss short, and use tools knowing what they are first. These four investment principles probably are well known among many investors. However not many keep them in mind every time because the principles are taught by words, rather by real-life experiences, a.k.a, failures. I hope by revealing the data and the science behind these lessons, you won’t have to experience the failure to become a master of investment.
Hope you enjoy and find it useful. Please follow and connect if you’d like to read more.
[1] Medium, Towards Data Science. (2018). Do you need a graduate degree for data science? https://towardsdatascience.com/do-you-need-a-graduate-degree-for-data-science-8e3d0ef39253
[2] Wikipedia. Arithmetic progression. https://en.wikipedia.org/wiki/Arithmetic_progression