# IBKR Quant Blog

### Quantopian - Idea to Algorithm: The Full Workflow Behind Developing a Quantitative Trading Strategy

Quantitative finance is, at the core, a process which is attempting to turn thought into money. In that light, it is no different from many other jobs, the main question is what path quants take in order to turn their thinking in cash. We’ll lay out some brief thoughts here on very high level workflows quants use, and link to supporting materials for those that would like to learn more.

Step 1: Hypothesize

"In general, we look for a new law by the following process: First we guess it. Then we – now don't laugh, that's really true. Then we compute the consequences of the guess to see what, if this is right, if this law that we guessed is right, to see what it would imply. And then we compare the computation results to nature, or we say compare to experiment or experience, compare it directly with observations to see if it works. If it disagrees with experiment, it's wrong. In that simple statement is the key to science. It doesn't make any difference how beautiful your guess is, it doesn't make any difference how smart you are, who made the guess, or what his name is. If it disagrees with experiment, it's wrong. That's all there is to it." - Richard Feynman

Implicitly, your hypothesis must come from your current model of how the world works. That is the reasoning underlying the hypothesis. As such, your work should be directed by where your understanding of the world breaks -- this is a core principle in the natural sciences. If your model disagrees with real observations in the real world it means that the model is wrong in some way. You should spend time examining how your model is wrong so that you can improve it, not examining where it’s right.

Step 2: Your Predictions Must be Correlated with Future Outcomes

Now that you have a model, you want to check if those predictions do indeed correlate with future returns. If they do, then that satisfies our first check. In industry, this is sometimes referred to as the ‘information coefficient’ of a model. What it means to correlated is also discussed in the linked lecture.

It’s important to note that this is not nearly enough. Your predictions have to survive the rest of the way through the process to realized returns. There are many steps ahead which can contort your predictions and lessen their correlations with future outcomes. This image is an example analysis from the linked lecture:

Step 3: Your Predictions Must Survive Portfolio Optimization

Let’s say you have a model which you believe fits well, and you’ve tested it rigorously and scientifically. That model will yield predictions of how the market should behave. Based on these predictions you can come up with a way to place trades that should take advantage of these predictions. This process is known as portfolio design, and is an often overlooked part of the workflow. Your portfolio should be designed to be risk aware/constrained, and try to take maximum advantage of your predictions. This lecture describes a canonical example of what quants refer to as a cross sectional portfolio.

One example I like to give is that of playing tennis against Federer. If you went up against Federer in a match, you’d want the match to last one serve (sample the process once). That way the volatility is maximized and you have the highest chance of beating him in a fluke. Meanwhile he wants a very long match with many events that sample both of your skills and decrease the volatility. As such you generally want to make as many independent predictions as possible if you truly think you can beat the market.

Basically, you want to take advantage of your predictions without taking on too much risk. As such you can imagine a function R(P) that for each portfolio P, tells you whether or not P takes on too much risk. You want to get your portfolio weights as close as possible to your predictions without violating R(P). This process is known as constrained optimization and is discussed at length here.

The portfolio weights that you end up with will not be exactly as you would have wanted due to these constraints. As such some of the correlation with future outcomes will be lost.

Step 4: Your Portfolio Weights Must Survive Portfolio Execution

Now that you have risk-constrained portfolio weights, we need to actually trade them. This is a very complicated process and the subject of a large amount of research. Your trades, if not placed carefully, can incur a large amount of trading costs. This will effectively be a discount on your final realized returns. Also, sometimes market conditions do not allow you to place precisely the trades you wanted. That means that the conversion of portfolio weights to real positions will contort your weights, and we now have a set of positions which are twice contorted from our original predictions.

Step 5: Realized Returns

Finally, only if your realized predictions have sufficient correlation with future returns will you make money. There have been two major steps which have contorted your original predictions at this point, so your original predictions must have been pretty good to survive this far. At this point you can still have issues converting your gains to cash as liquidating positions can be difficult for the same reasons trading is difficult.

Join Quantopian for a live comprehensive quantitative finance tutorial on March 7, 2018! Register for the webinar here: www.ibtweet.com/qtwm1

What I’ve tried to convey here is a very high level understanding of what a quant workflow looks like, and some of the broad principles necessary to work in the space. I linked many lectures which convey much deeper information, and in general there is always room for improvement. Quantitative finance, like any science, is an iterative process in which your knowledge can always be more complete. If you’d like to learn more I encourage you to:

• Read more of our lectures and get your hands dirty with code on our platform. You will understand many of these concepts more deeply when you have played around with real examples.
• Go through our getting started tutorial to see what an institutional grade algorithm looks like from start to finish.
• Go straight to our template quantitative finance algorithm .

Disclaimer:

The material in this post is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian.

In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

16651