I have been researching for some time how to create trading strategies using Quantitative Finance and Machine Learning.
In this article I present a study made exclusively for the Bitcoin Portal to answer the following question: Is a machine learning model capable of overcoming the Buy & Hold in Bitcoin?
This is an interesting question even more so in a year like 2018 where bears are dominating the cryptocurrency market.
What is machine learning?
In plain English, machine learning is a subfield of computer science that has evolved from the study of pattern recognition and computational learning theories in artificial intelligence (Wikipedia / Encyclopedia Britannica).
That is, it is the ability to write an algorithm (via programming language) that uses an input database (training) to develop a mathematical equation that best represents a certain phenomenon, reducing as much as possible the difference between the predicted and the observed value (test / validation databases).
What is Quantitative Finance?
According to an excellent definition of FGV, quantitative finance and financial engineering are the areas of finance that involve the application of tools and methods of traditional finance, mathematics, physics, computer science, economics and econometrics to solve problems of interest in areas such as investment management, corporate finance, risk management, pricing and hedging of derivative instruments, trading, economic finance, structured products and asset allocation.
In a definition I like to use, that's when math meets the investment world.
Do past returns influence future returns?
This is a classic question when we talk about trading. The quest for the holy grail - the moneymaking machine - gets the attention of the brightest minds in the world. Even more at this moment where the power of processing, storage and access to data is the greatest of our entire history.
To help answer this question, I selected a database of Bitcoin quotes from every 15 minutes, from May 2017 to July 2018, and calculated the return for the period, going back to a total of 12 periods (or 3 hours, since we speak of intervals of 15 minutes). The central idea is to assess whether there is any interference or past return relationship for Bitcoin's current return. In the bottom chart, the current return is called Return_P0 (on the Y-axis) followed successively from the previous returns from P1 to P12 (on the X-axis of each chart). The scale is decimal representing the percentage of return.
The blue line is an added trend line on each chart that represents:
• If tilted down, it means that the current return tends to follow inversely past returns. That is, the stronger the market falls or rises, the opposite is perceived in the sequence, a trend to return to the mean;
• If it is horizontal, past returns do not influence the current return at all - this is the expected behavior according to the theory of efficient markets;
• If tilted up, it means that the current return tends to follow the same direction as past returns, presented what we call momentum;
Analyzing the graphs, we see that there is not a really significant slope of the blue line in any of the 12 behaviors. However, they are not all exactly horizontal. There is a slight downward slope in some of them, especially the periods P4, P5 and P6. And a slightly positive slope in the first period P1. This is very interesting because it means that the price tends to follow the moment of the last period.
The existence of these small inclinations up or down are the evidence that I needed to develop the mathematical model.
Developing the machine learning model
Using the statistical software R, I developed a simple linear regression. A linear regression is that of a kind Y = aX + b that we learn in high school, but no one has the ability to explain what it really means. If I had known these things since then, well ... this is another story.
I divided the database between training and testing. The training of the model consists of the data from 2017 and the test / validation of the model was done with the data of 2018. The target or dependent variable - the information we want to predict - is the (Period_P0) and the independent variables are the returns from P1 to P12.
The first result of the model is as follows:
Leaving aside the mathematical rigor to evaluate the results and to improve the model (they are not the purpose of this article), what matters at the moment is to understand the last information in the table, which are the 3 dots ***
Notice the fourth line of the image (from the bottom up) where we have
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1
This means that the variables accompanied by *** are the most relevant to explain the phenomenon of the model - our prediction of the return of the current period. And note that coincidence: they are the variables of returns P4, P5 and P6, precisely those with the greatest slope of the line in the first graph.
As the other variables are not statistically significant, I will remove them and run a new regression. The result is as follow, cleaner and more organized.
The moment when Machine Learning Outperforms Buy & Hold
Now I will apply this model in the test base (the year 2018). The result speaks for itself. Whoever bought Bitcoin in early 2018 and held it so far has a return of -44.6%. Anyone who had followed a model like this would have only -10.2% - without considering operational costs.
Of course, one can argue that the result is still negative. However, we must consider three very important points:
Recently, I have been following a thread on the www.forexfactory.com when I saw the post below from the user Cristiano Teixeira (tradista). In my opinion, it carries so many truths about a trader life, about the process on how really to become a trader, that I have decided to share with all readers from the Outspoken Market. Please, read it carefully and paying attention to the details.
"I wasted too many years of my life working a 9 to 5 just to see the unemployment line in my early forties, when the crisis took down half the world by storm. I saw my savings of many years go down the drain in a couple of years (not losses, just regular expenses, kids, mortgage, etc). I can't give advice, I can only tell what I know from my own perspective. Trading or any other endehavior won't save your life when you're in real complicated situation like I once was. What will save your life is keeping your head up, think by yourself (not from others opinions), get good at reading your own gut and instinct about people and about what you want to achieve, always believe you can handle whats coming (not always easy), read as many inspiring stories as you can, learn to trade without indicators and most importantly don't rush it, don't be in a hurry for anything when it comes to trading.
Pick a strategy, stick to it and see if it fits your temperament (took me 2 years to find this out as I was so stubborn and obsessed that I should make money to pay the bills, so... best scenario is no rush! Believe me, you'll be glad you took your time, because it'll end being faster than forcing things to work out. Find something to support yourself, either by getting another job (temporarily) or doing your own thing, but don't really expect anything from your trading journey until you actually see it happen!
People say "if you can see it in your mind you can achieve it", yeah sure... keep dreaming... of course, that has some truth to it, but that's not it... that's just the starting of the journey of hardship that you must be willing to endure. After seeing it in your mind you must work on your confidence, so you must see it with your eyes! How do you do that if you're a noob? Well, learn, study, trade every day without getting fixed with the profits, don't put your cash on the line, trade on demo for a while, but do it with a plan, a purpose, like "I'm testing this method for the next 30 days" and do it like if it's your bread and butter way of trading... keep track on your progress on that particular system. If it feels good and you didn't cheat or made some stupid non-related trades, then cool, that's the way to go... else, you're not taking it seriously enough, so no wonder you'll stay mediocre and never make money, you're just wasting time and playing the "wanna be" game.
If you really want to become a trader you must commit to becoming very extremely good at one particular method, and master it fully. This takes time. Then, little by little it will make sense and become part of you, of how you view your trading and the market. Put it to the test some more, bottom line being to try to trade under all market conditions possible, using always the same approach. When you start to see the profits based on an absolutely consistent approach, never deviated from the plan, never placed stupid "just trying" or "revenge" trades (which in a live account would cost you) then you'll start being confident in your ability, because you're seeing that you can be profitable each week, each month, time after time again. In the meantime, keep 'saving' money for a real account that will serve you to build on it (not to pay the market fee to learn the hard way!).
Then little by little work on growing the acount(s) by not taking money out too early for expenses, use compounding based solely on your consistency to make good trades. Focus should always be on the process of making the trades and never look at the balance once you're trading live. Then, little by little things start to pickup, people will come to you, you'll start making acquaintance with other traders, investors, whatever and opportunities will appear to grow your potential. Just give it time and stay at it (wanting to master your craft) like a maniac !
That's how I would have done if I could do it again."
Algorithm. Unless you live disconnected from the universe, you've probably heard or read this word that has changed the world and has more influence on your life than you think. It's never too late to understand it and know how it can help you!
What is an algorithm?
It is something that is not just correlated with computer science or scientists. Really! An algorithm is nothing more than a sequence of actions taken to achieve a specific goal. Every day you run an algorithm, from the time you wake up to the moment you go to sleep. And when you sleep, your body also performs various algorithms. The action of preparing a juice or to get ready to go to work in the morning are just a few examples. And that favorite app on your smartphone? They are a set of algorithms!
Most people tend to always do the same things. We call this a routine. One may like to have it and others do not. Even when you try to do something out of your routine or when you try not to have one, you are executing some tasks to get away from it. Try to google "how to get away from the routine". A high number of websites, books, and videos suggest you follow certain steps (tasks ?!) to try to do something different :) The same thing happens when you seek to be more productive: you look for tasks that will help you be more efficient, do more things with more quality in the same time. The more complex the objective, the more complex is the algorithm.
In the end, what we are really looking for is a way - the best way - to do something we want. As simple as preparing breakfast or complex as having an app that helps us escape the traffic.
To make it even clearer here is an example of an algorithm:
Algorithm to call someone from a cell phone.
1 - Pick up the phone from your pocket and open the calls app
2 - I know the number of the person?
2.1 - If yes, enter the number
2.2 - If not, search for the number in the phone book
3 - Press Call
4 - Did the person answer?
4.1 - If yes, talk
4.2 - If not:
4.3 - Was it important?
4.3.1 - If yes, wait a while and call again in a few minutes or leave a message
4.3.2 - If no, call tomorrow
5 - End the call
6 - Put your cell phone back to your pocket
And why should I care about algorithms?
Well, there's no way to get away from them. But it is very easy to benefit from it! And we can not dissociate programming from algorithms either. Programming is to write algorithms in some specific language so that we can automate tasks or execute them faster. In a way, many people are already programmers, from executing simple jobs in Excel to professional applications developers and solutions like programs to do astronomical calculations. Particularly I think that in the near future programming will be a discipline in schools, that we will be learning from an early age (at least it should be). It does not mean that we should all be programmers. The world will always need other types of professionals. However, programming or knowing how to create algorithms don't need to be an exclusive knowledge from software developers or scientists. Given its basis in mathematics and logic, the benefits are numerous. As each day we collect and store more data, knowing what to do with them and how to extract meaning from it, becomes evident how important this subject is. For instance, if you are a psychologist and want to analyze data from a survey done with your patients, of course, you can hire a good professional to help you. But would he have the same knowledge in psychology as you have?
There are 3 characteristics that define what a valid algorithm is:
Also, we said at the beginning of the post that the world is full of algorithms. In fact, it always was. What has happened over time is that we have found more efficient ways to run and automate our tasks. This is an endless process, and every time we take it one step further, life becomes easier and more beneficial to all of us.
Thank you for the reading and see you next post!
Whether you like it or not, we all have to make bets. The bets we make may not involve gambling, lotteries or casinos, but they are sure involving money and uncertainty. Do you want an example? When you buy a car or a house and buy an insurance, you are not making anything more than a bet; You are exchanging an amount (the value of the policy) in exchange for a higher payment (premium) based on the possibility of an uncertain event (a car accident or problems with your house). This is a kind of gamblimg, as well as health insurance, life insurance and investments. The question here is: Are they worth it?
Common sense always leads us to respond an yes at first. But is that correct? Let's take a simpler example, such as the extended warranty offered by the store when we buy any king of electronic goods. I am sure enough that it's a big deal for retail chains, but is it for you too? Some people say no because the chance of any problem occurring with products that go beyond the factory warranty is very small. Others say that it is not only a chance of a problem to happen, but the time you save and the headache you avoid when you need to exchange the product is worth paying the extended warranty. Luckily the rule to understand whether it really is worth it or not has already been developed centuries ago.
And how do I do it? Very simple, you just have some basic understanding of probability theory.
Now imagine that you are in front of a new TV that costs U$ 600 and offer you the extended 5 year warranty for only "U$ 49". It may seems a small value regarding the total value of the TV...but regardless the apparently low value, this extended warrant does not worth it. Why? Just follow the formula:
Honest Warranty = - Risk of Not Missing Nothing x Warranty Price + Risk of Loss x TV Price
If the result of this formula is negative or equal to zero, the extended warranty does not worth it. Considering the value of the TV U$ 600, this would be your total expected loss in case of any problem. The extended warranty is only worth it if it is less than the value of the TV multiplied by the chance you having some kind of problem in the next 5 years. A quick search on Google shows that less than 5% of televisions give some trouble in five years. So your chance of having no problems with your new TV is 95% or more. Therefore, our formula is:
Honest warranty= 95% x 49 + 5% x 600
Honest warranty= -16.55
As the result is negative, the warranty does not worth it. The fair price of the extended warranty based on the chance of any problem happening to you would be 5% x U$ 1,200, then U$ 30.
Now, if you apply the same formula with your car or home insurance, is it worth paying?
See you next post!
Unless you live in another reality or are a beginner and naive, you have realized that being a trader is not easy. I have posted on the blog a series of posts about some fundamental points that challenge you as a trader. In today's post I highlight the 5 most important points you need to keep in mind before you start doing your trades.
1. Know Yourself
It sounds likea philosophy jargon, but it's not. You need to carefully define your risk tolerance and understand your needs. To profit consistently you must, before knowing the markets, know yourself. The first step is to gain self-awareness of your risk tolerance by allocating the adequate capital. I'm not just talking about the famous risk management, but I'm talking about carefully studying your own financial goals and what you really want to gain from trading.
2. Define your goals, keep your plan
Once you know what you want, you should systematically set a deadline and a work plan for your career as a trader. What is failure or success for you? What is your deadline to accept a win/lose situation, perhaps more the lose ones than the winners, as long as you understand that this is an important part of your learning? How long can you devote yourself to your new journey? Do you aim for financial independence or simply want an extra income? These questions must be answered before you actually trade. Answering them is part of establishing your trading plan, your goals. Also, having clear and realistic goals is what will help you succeed.
3. Focus! Do not diversify
Yes, it may seems crazy and go against the common sense. But the truth is that the markets are deep and complicated. It is difficult to master all the different kinds of events taking place in this world, so it is a good idea to restrict our vision to the asset we understand and are familiar with, always remembering to join the most liquid and widely traded assets, whether you are a beginner or an advanced trader.
4. Do not add to a losing position. Do not make average price
Seriously, do not make average price. Sorry, but I had to be very clear about that. Nothing can be said about the future, so you do not know how long a stock will go up or down. If you are at a loss, the smallest one is the first.
5. Take notes. Study your success and your failure.
Have you ever heard about the trading journal? If so, why have not you made one yet? If not, know that the successful trader will keep a journal of his operations, where he will carefully understand his mistakes and successes to find out what works and what does not. This is one of the most important trading tips you will receive from a good mentor.
Thanks and see you next post!
As long as you cannot predict an event, it is considered random. However, is it true? What makes something be really random? The absence of a specific pattern? The inability to predict what the next event will be?
Humans have an almost uncontrollable desire to find patterns in things. Our evolutionary process has guaranteed our brain as a fantastic tool to classify things: from recognizing the face of your mother from the time you are born to knowing who you can trust or not (!?)
Regardless of what we have learned to classify or not, the big point is that we are too bad at dealing with the lack of patterns. In the post "Predicting Rare Events and Financial Crises" we left open the question "how to calculate the probability of the occurrence of 17 heads in a row if this never happened in your sample?
Do you think throwing a die or shuffling a deck are random events? Maybe not. The act of rolling a die is ruled by specific mathematical laws and if we knew precisely the rolling force, the direction of the wind, the friction with the air, initial position of the die, the throwing angle, the point of friction with the surface and all the other variables involved, it would be absolutely possible to predict what the outcome of the launch would be. The same rational can be applied to a deck or trading. So, possibly, randomness does not exist - and not even the free will - since everything is the result of a combination of previous events, and changing any one of them, lead us to have a totally different answer.
Any change in the initial conditions of the die will influence the final result. Stopping to look at a bird can prevent you from being hit by a car a few minutes later or make you to meet the love of your life - the famous butterfly effect. If things are like this on a daily basis, why would they be different in the financial markets?
When looking at a chart of any asset, the first thing that happens is to fall into the temptation to find a pattern in the prices. As our brain is a beautiful classification machine, we can find several of them already in the first 5 minutes looking at the chart ... we still have the ones who say: if you look at the chart and in less than 1 minute you find nothing, it's because there's nothing to be done! In fact, it is very easy to look at an already drawn chart and find a lot of things that "seem to have happened since others have happened," or better saying, the famous patterns of the technical analysis. What is really difficult is to find these same patterns live, in real time, while the chart is forming. Here is where the "men are separated from the boys".
Everything that happened in the past chart was a consequence of past events and events that no one would even know would happen, others already partially expected and all the consequences of the others - remember the butterfly effect described above. Everything that will happen from this second will still be influenced by the speed of response to the events that are happening now, what other people are seeing on the same chart and the consequences of other possible infinite variables. Any change in price now influences the present so much that forecasting what will happen in the future is practically impossible, assuming that we do not know all the variables involved.
This discussion brings us closer to chaos theory, as defined in one sentence: systems considered to be dynamic are extremely sensitive to their initial conditions. A personal example: one of the reasons for the 2008 financial crisis was the near-zero US interest rate cut by the Fed Chairman Alan Greenspan, to contain a chain effect caused by the dot-com crisis, the internet business bubble. The crisis of 2008 led the job offers and wages in the US to a huge reduction, a fact that made me choose another place to do my internship. This "new" place was close to a mountain region where I went one day to ski for the first time and I broke my knee! In other words, would I have broken my knee because of the dot-com bubble?
Anyway, does randomness exist or does not? Like everything in life, it depends! By the point of view of the classical physics, no...while by the point of view of the quantum physics, yes. The subatomic universe is completely different from the Newtonian physics. With all this talk of randomness, classification and cause-and-effect relationships, we leave an open question for the next post: Is technical analysis a fallacy?
Rare events are by definition events that happen with a very low frequency. Frequent examples of the literature are large tsunamis, earthquakes and the impact of an asteroid. However, the rare event to us is a financial crisis. Rare events exert so much fascination not because they are rare but also because they are difficult to predict, making whoever does it - by luck or not - the next great guru for a few months or even years.
I intentionally used the term "luck" because according to the efficient markets hypothesis, any financial crisis is practically impossible to be predicted, being practically impossible to make money trying to predict what will happen next in the markets. Consequently, when you get it right, it's nothing more than a coincidence of facts.
An interesting point here is that perhaps will never be possible to predict exactly when a crisis will happen, but it is possible to understand that a crisis is imminent with a certain degree of probability - which always brings us a certain degree of uncertainty as well. The problem lies in ignoring the degree of uncertainty and finding that only a high probability is a "guarantee" of occurrence of a particular event. Toss a coin 100 times gives you a high probability of a certain amount of "heads" happening - close to 50% - but nothing prevents you from having 100 "tails" in a row. Okay, it's rare, but nothing says it cannot happen.
Let's do a practical test. Check on the chart below the results from a 1000 coin tosses simulation.
A simple simulation of tossing a coin 1000 times, using Microsoft Excel (for the sake of the argument, lets forget questions such as if the RAND function is random and what is randomness), shows us in the following chart an idea of what can happen. In this example, in 1000 "tosses", a sequence of 15 heads (maximum value in a row obtained) occurred 2 times and in 16 times we had a sequence greater than 10.
What do we conclude from this, and what does this have to do with investments or trading?
The first point here is the fact most ignored by the beginners: "this stock has already gone up too much, it has been going up for 10 days ... it will go down, for sure". As we saw above in the coin toss example, if the coin were an stock share and the "head" was a bullish day, we saw that the stock would have gone up "15 days in a row", twice in a period of 1000 days. And we cannot forget that we had 16 times with more than 10 hypothetical bullish days.
This leads us to the second point: is it possible to profit from this? Yes, but never neglect the fact that we can perhaps have one single time 15, 20, or 30 heads in a row. But don't forget that your risk:return ratio, that is, how much your bet is worth is more interesting every time. It is guaranteed? Never will be...especially if the events are independent, like the toss of a coin ... but in markets, where everyone will probably be "seeing" the same event and trying to anticipate what will happen, we have the effect of the self-fulfilling prophecy. This would prove once again the efficiency of the markets and the impossibility of predicting it. One may try to predict something...but taking this guy seriously is another talk.
Finally, the third and final point is that crises are impossible to be predict, since they are examples outside of any sample - outliers. They never happened before, so it would be impossible to try to predict what never happened...it would simply be impossible to calculate the probability. Returning to our example of the 1000 tosses, how to calculate the probability of occurrence of 17 heads in a row if this never happened before?
Lets wait for our next posts!
Scalping in trading is a term used to describe the skill of take several small profits on a regular basis, buying and/or selling several times per day. Scalpers like to try and scalp a few pips from each trade (3 up to 10 pips) and then repeat this process over and over throughout the day. Using high leverage and making trades with just a few pips profit at a time can add up, especially if your trades are profitable and can be repeated many times over the course of the day.
We can also say that scalping is a variation of day trading. A "day trader" opens a position and then close it again during the current trading session; in other words he/she never carries a position overnight. A day trader may look to take a position once or twice, or even a few times a day, but scalpers are much more dynamic and try to take really small profits multiple times in a trading session. In particular, some scalpers like to try and catch the high-velocity moves that occur around the time of the release of economic data and other important news events, such as the release of the employment statistics or GDP releases if that is what is high on the economic agenda. And, for sure, As a scalper you only want to trade the most liquid markets. It is, in my honest opinion, almost impossible to scalp in the stock market. The best market to do it is Forex. We are talking about a key factor that is liquidity, and the Forex Market is by far the most liquidy one in the world. Also, we are usually talking about the major currency pairs, such as EUR/USD or USD/JPY.
The Scalper's way of living
One may think tha scalping is not a good way to trade. Yes, for sure it is for a minority, but still can be profitable. What you must have in mind is that a scalper will be in front of a computer for several ours, and they need to enjoy the intense concentration that it takes to scalp. You cannot take your eye off the screen. You must be the kind of person who can react very quickly because there is no time to think. Being able to "pull the trigger" is a necessary key quality for a scalper. This is especially true in order to cut a position if it should move against you - you have no time for the market take you out some few pips.
Saying it once more, scaping is a very fast paced way of trading. If you like the action and like to really focus, then scalping may be for you. If you have the temperament to react quickly, and have no shame in taking quick losses, then scalping may be for you. But if you like to analyze and think through each decision you make, perhaps you are not suited to scalp. There are lots of other ways to trade. Pick up the one that fits for you and dont worry about any buzz that may bother you when you are trading the markets!
"It has already been said that the true concepts bear the signature of their author; And I believe that are very few of those who carry a signature as sharp as the unconscious of Freud. "
There are few studies and references approaching psychoanalysis and economics. Such approach can be started in the face of the fact that economics is treated as a human science and therefore a social science. This means that it is thought and managed by individuals who are inserted and organized in a form of society. Thus, the fields of study of economics, among them: relations between individuals, way of society organization in relation to production, the exchange and consumption of services and goods in general, exchange of currencies - are the result, and inevitably , pass by individual and social meanings.
Regarding the psychoanalysis, one of its fundamental concepts, the unconscious, which was postulated by Freud and later by Lacan, is a system organized and governed by principles and laws of language: "... it must be assumed that the unconscious is the general basis of psychic life. The unconscious is the wider sphere, which includes within itself the smaller sphere of consciousness. (...) the unconscious is the true psychic reality " (Freud, 1900, p.554).
The manifestation of the unconscious on the individual occurs on daily occasions - as in dreams, symptoms, failure acts, as well as in mass behaviors; As well as in the subjectivity of each individual, in desires, choices, paradoxes and anxieties. According to Lacan (1990): "Stumble, faint, a crack. In a pronounced-written phrase, something pops out... There, something that wants to be realized - something that appears intentional, certainly, but also of a strange temporality. What is produced in this hilarity, in the full sense of being fully produced, presents itself as a finding. Thus, from the beginning, that the Freudian exploration finds what goes on in the unconscious " (p. 30).
Correlating the concepts mentioned above, psychoanalysis can contribute in the sphere of economics - since they are two sciences that perpass the social/human relations - going beyond the conceptions of conscience, considering the unconscious character that transpasses the actions of the inserted subjects in a society. Moreover, by providing the individual's autonomy and responsibility in his choices, psychoanalysis disrupts the individual with psychic and social alienation and can help with the apprehension/understanding and transformation of the production relations and monetary exchanges as conceptions of value. That is, the psychoanalytic investigation can become an important element, allowing the reflection and transformation of the subjects' actions against the markets and its transactions.
FREUD, S. The interpretation of dreams (1900). RJ: E.S.B p. 554 (Portuguese Edition)
LACAN, J. The Seminar - Book 11. RJ: Zahar, 1990, p.30.(Portuguese Edition)
About the author: Carina Guerra - Psychologist, expert in psychoanalysis and an Outspoker.
This is a question that many investors (if not all) try to answer every day. In fact, if it were possible, it would be possible to make large returns in a short period of time. However, there is a theory that says no, it is not possible to predict the value of an asset on the stock market, for example. It is known as Efficient Market Theory.
This theory is based on the assumption that all available information is rapidly absorbed by the market by all of its participants and it is impossible to make significantly gains above the market average. This characteristic is the concept of efficient market (FAMA, 1970). Secondly (FAMA, 1991), there are three variants for this hypothesis of efficient markets. The first is the weak hypothesis, which considers that markets absorb only the historical information that is public available. A medium or "semi-strong" hypothesis is based on the principle that asset prices reflect this public information instantaneously. Fama further adds the strong hypothesis, saying that the market instantly reflects even the information considered as insider.
That is, the theory of efficient markets suggests that stock prices follow the Random Walk theory. It states that it is not possible to predict the future on the basis of past data (in line with the theory of efficient markets), that is, it does not mean (for example) that the stock price has increased today, yesterday, or in another period that the price will increase tomorrow as well, because the market works irrationally so the price of a stock will be unpredictable (as well as the movement of a molecule into a fluid).
Let's show in practice how this works by using a decision tree. They are a supervised learning algorithm whose output is If - Then rules that classifies a discrete set of values, given continuous or discrete value inputs. In the figure below we have a classic example of a tree that assists in the decision to play or not given certain conditions like climate and humidity.
In our example we will use a database containing the trading information of the Ibovespa index, from 14.08.2014 to 04.09.2014, every 5 minutes. The available data are Date, Time, Opening, Maximum, Minimum, Last, Volume (contracts), Volume (R$). With this data (1617 records), we created 22 variables to try to predict if, in the next 5 minutes, the index will be up or down.
We run the decision tree in free software Tanagra. After loading the base, we run a χ 2 test to select only the attributes that are really relevant. Here we have our first cut. Of the 22 variables, only 3 remain. The first is if the difference between the maximum and the opening is less than 30 points. The second is whether the volume average of the last two periods is greater than the average of the previous period. Finally, the third measures whether the maximum price of the last period is greater than the maximum of the period prior to it.
Analyzing the result of the decision tree with these three attributes, we see that the chance of knowing if the market will fall or rise in the next 5 minutes is a little bigger than playing a coin. From the confusion matrix, we see that practically the decision tree goes right or wrong at the same frequency.
Notice also the rules that were created. None of them is able to hit more than 62% of the records, with most of them close to 50%.
A curiosity is that in the stock market, a strong consensus among traders is that the traded volume is a strong trend indicator, either for high or low, since it shows that market agents are determined in relation to a specific movement. Of our 3 attributes, 2 are related to the trading volume, showing that the tree was sensitive enough to understand this behavior. Even so, our result is in line with the theory of efficient markets.
Of course, there are more complex methods to try to estimate market movement, but even so, our approach shows that it is a Herculean task that has not yet been completed. The question that remains is: is there any information that is not immediately absorbed by the market, and given this, is possible to use it to predict stocks movement?
The studies continue around the world and if someone finds out, maybe we will never know ;)