Hi, welcome to the Investment Blueprint. I'm your host, Raghu Kumar, from RAIN Technologies. The Investment Blueprint is a weekly podcast where you can find me interviewing real world quantitative traders and investors, hedge fund managers, and industry experts in the field of quantitative, data driven trading and investing. My goal is simple: I want to help you make more consistent, profitable trading decisions in a data driven and meaningful manner. Today's topic is on: how to do algorithmic trading in India, with a focus on the different types of algorithmic trading strategies.
We often tend to generalize trading strategies: if it's not an investing strategy, then it's a trading strategy! How many ways can I slice and dice the universe of trading strategies? Well it turns out that you can slice and dice them quite a bit! Today, i talk to Lakshmeesh Rao Chief Investment Officer at RAIN. Lakshmeesh joined us a few months ago, along with Bharath Rao, to take over the CIO duties at RAIN. Lakshmeesh used to run a company called Alpha Matters, where they built and licensed proprietary trading strategies for India's capital markets, the US markets, and all sorts of asset classes in between including cryptocurrencies and forex. Lakshmeesh is very diligent and methodical with his backtests, and it's been really fun to kind of get to see how he thinks about solving real world problems in a daily manner. Today, we talk about different
types of trading strategies, how they differ, and as a quant, what you should know about them. So, Laksheemsh, welcome to the podcast. Thanks a lot, Raghu, it's a pleasure to be here. Awesome, so you know, I thought we could start today's conversation by talking about your background with algorithmic trading. How did you get started with this whole field? Well, I finished my engineering in India in the field of electronics and telecommunication. After that,
I had a brief stint with Infosys for a year and a half, and then I went on to do my Masters from the Delft University of Technology in the Netherlands, where I specialized in Control Systems. So Control Systems was a multi-disciplinary field wherein you would take any system and abstract it into a mathematical model and then we used to design algorithms to control them. So when I was graduating, I also got into this project called IGEM which was mostly to do with biology, where we try to do some funny stuff with cells. But so there, I had a teammate, so he was into machine learning and he used to tell me a few things about the markets and all that. So once I graduated, I had to pick a field wherein I would implement all these learnings, whatever I had done in my Master's, so I thought like, okay the market seemed interesting to me at that point of time and I just wanted to see like, okay where I can go with it, so then I approached a bunch of people along with Bharat. So Bharat was one of the people to respond to me. And yeah today, I got started with Bharat. So that began my journey of algorithmic trading,
from there. Got it, so, generally your experience in the Netherlands, I think you've told me once about this but I totally forgot , just generally how was your experience in the Netherlands and how is it different from your upbringing in India. Well, it it was very different back there, I mean there you have to be independent, all on your own, here at least teachers everyone will follow up with you. But there's no such thing, right, and there it should be purely driven by you, what you want to achieve, your goals, your dreams, right. Your ambitions. Right, yep, got it. And it was mostly a project based education in a way, so you got it great. I think that helped me a lot. That's really cool, yeah, and one thing I've
noticed is you have very peculiar sleep habits, you know, everybody at RAIN generally works relatively normal hours, and you kind of come out of left field and you stay up until I think like four in the morning, and then you start at like nine in the morning or something, right, so how did you kind of get into that habit and is there any reason for that? Well , I think designing algorithms is more a creative process in a way, right, where you would need a lot of peace time. I mean, alone time, where you need to think a bit and try to come up with ideas, I think that entire process happens to me good in the night time, where everyone is sleeping, and there's no one to disturb me. That's amazing, I can totally attest to that, you know when I used to build algorithms you know, on a daily basis, I used to also have very odd sleeping hours, I would work at night, like completely in the night and then I'd go to bed at like three or four in the morning. Yes, and then, yeah totally I totally get that. So you know, today's topic is on the different types of trading strategies, right, so obviously, you know, we have the general bifurcation of investing and trading, but within trading strategies, I feel like there's oftentimes a generalization that happens, and all trading strategies kind of get clubbed together. So I thought we could kind of dive into that today, so you know, from your perspective, generally speaking, what are the different types of trading strategies that a quant should know about? Well, according to me, there are primarily two sorts of trading algorithms which you can build. One, which is based off of momentum, which means, let's say something goes up,
right, you tend to buy it higher and you tend to sell it even higher, or you trying to short it, and then try to buy it back at a lower price. Right. So that's more to do with momentum, there you're saying like, okay, if something runs up you will have enough momentum going forward to capture that extra alpha there and still try to make something out of it. Right. So that's one, and then there is value trading, right, or mostly mean reversion strategies. We are saying, once something goes down, it's most likely that it's going to come back to its mean. Similarly, if something goes up, again, you're expecting that that will also come back to the mean. So broadly, if I try to define it, or from at least from my experience, these are the main two categories of algorithms which you can come up with.
Got it. But there are also some other ways of looking at this entire process, like, what we do in the US, for example right ,so there we do, we trade volatility based instruments, there we try to identify some more fundamental factors and then combine it with machine learning. That doesn't fall into these two classes, but there we try to identify somehow the underlying phenomena due to which you can produce returns, so that's another class of algorithms all together. Got it, got it. So basically, the second class that you described is basically like a
mean reversion kind of. Yes, that's a purely mean reversion sort of a strategy. Got it, interesting ,okay so for example like an arbitrage strategy that would fall I guess into the second classification, right. Again, two ways of doing it. One you can either look at the pure time series itself where you're saying, okay, a time series itself is going to be in revert. For example, SPY in the US. So there, we had a
mean reverting strategy on the SPY itself, so there we did not compare it with any other instrument or anything, so there we worked off of purely the time series of SPY itself. So there, you say that, OK, if SPY falls x percentage, or depending on some quantitative factors, then we say, OK, it's fallen enough sufficiently down, so now you can buy and expect it to go back up. And similarly, when it goes up sufficiently, then we say okay, it's got run up, the run up is done, now it's time to short it. Got it, so that is one based off of the time series itself, and then you can also look at it in terms of the cross section. Okay. You can compare SPY with let's say the NASDQ or something like that, but a good example in India would be HDFC and HDFCBANK, for example, like a pairs trade up. So there, you can say like, OK HDFCBANK today has gone up
x compared to let's say HDFC, and then you say, OK, I'm going to short HDFCBANK and I'm going to go long on HDFC, expecting both of them to come back to the relative mean. Right. So that is another type of meatier version, so there you're not looking at the time series of one individual instrument, but you're looking at the time series of multiple instruments. Correct. Now, the same thing can further be extended into, let's say, a sector level, also, so that's where comes your stat-arb strategies, right, there you're saying, OK, instead of just comparing two stocks, now I'm going to look at the a bunch of stocks in a sector itself, and I'm going to go long on a bunch of sector on a bunch of stocks in that particular sector relative to their value with respect to the other stocks in the same sector. For example, we might take a look at banking. So in banking, we might say, OK, like let's say, SBI HDFCBANK, all of them are slightly undervalued today, whereas your ICICIBANK or AXISBANK are overvalued, so I'm going to go short on a bunch of stocks there, and I'm going to go along on a bunch of stocks in the same sector. As an extension to that, then we can also look at the entire universe of
the stocks itself, right, so there we don't need to limit ourselves to a sector, so then we can go on to, say, like we can do something like an index, we can compare it with respect to the index. An index can be something which you come up with on your own, or it can be the index like a NIFTY or something, and then you're going to say like, okay, Nifty has done this, some of the stocks have gone, have outperformed compared to NIFTY. Some of the stocks have underperformed compared to NIFTY. Got it, got it. So you know, for a newcomer to kind of start building strategies of their own, right, what types of trading strategies, or what category of strategies, would you recommend for a newcomer to kind of get started with, and why? OK, to get started with, I would say, even before he gets into actually designing a strategy, right, it becomes key for him to understand what he's trying to trade. For, example is he trying to trade NIFTY, so then, he has to understand what are the characteristics of that instrument. From at least, from my general experience, NIFTY and BANKNIFTY are mostly
trending stocks, so he could start experimenting with something, like a simple moving average, and then go on to more complicated ways of extracting trends. Right. For example, then, if I go to SPY, if someone wants to trade SPY, so then again, he has to understand how SPY behaves, I mean, you cannot go about implementing trend sort of systems on SPY because you know that it will not work out. Got it. All this is related to the time frames, but I'm mostly speaking about a daily time frame here. So then depending upon the particular characteristic of the instrument, for example if it's a simple trend it's a simple momentum based strategy that he wants to try out they can start off experimenting with a simple moving average and see how it behaves and he can also use any of the publicly available indicators, from my experience most of them don't work, yeah, okay but yeah given his understanding and if he knows when to exactly trade a certain indicator I think he can get it to work, but I would suggest just start off with a simple moving average, and see where it takes you from there. Got it, which is probably one of the most common, you know indicators that people use right. Yes, so in terms of like just kind of challenges that they would face right in terms of building a momentum strategy you know versus a mean reverting strategy what are some common things you've noticed with uh with either of them any sort of biases or anything ? Yes, okay that is one thing which as quants, we always need to take care of. The way we back test it.
The data that we backtest it on. For example, I mean, it's better if he just splits his data set into two parts where he is going to say, OK, I'm going to test only on a particular data set, and then I'm going to just leave out the other data set as a test bit. Right, where I'm not going to, so, let's say I'm going to optimize a bunch of parameters on my training set, I'm not going to go back and then re-optimize those parameters to again fit the test set. Right, yeah, because that is just for your testing, to see like, OK, whatever theory you have is valid or not. So once that gets invalidated, there's no point right for you to trying to optimize it over the entire time frame and then say like, OK, something is working, let me start running it with capital and all that, because more often than not, that will lead to problems. Right. The other problem is, you adding too many rules into one system. It's better if you can keep the system as simple as
possible, but come up with multiple systems. Yeah. So that way, you're trying to hedge out your risk, rather than trying to come up with one super optimized system, saying, OK, I'll add a bunch of rules, and then I'm going to be working just for the sake of it working, and then you know that most often than not, it's going to fail in the forward test, or in your live environment. Yep yep yep, that makes sense. Yeah, so one thing I'll say about it,
yeah, another thing is the data quality which you're dealing with. Yes, that also makes a lot of difference. For example, one thing we've noticed is, are the open values right? I mean, I can run a simple trend following strategy and say like, OK, I'm going to take the opening values of any day with assuming the day level data is available to me free of this one, I mean, it's available freely in most websites, and you can go and download it from YAHOO, but then you know that those numbers are not realizable in your real life, right, that's and again another problem which people have to understand that, data matters. The quality of data matters, the quality of data which you're going
to backtest on is very important. Makes sense, so you know, let's kind of pivot a little bit into something a slightly different topic, but you know still related to the topic of today, so you know one of the kind of introductions you and Bharath made to RAIN is this idea of running multiple strategies in tandem, right. Yes. Can you kind of elaborate on this whole concept , you know, why do you think it works, or why does it work, I should say, and how does one kind of think about that, you know? Yeah, and so, this goes back to my point of, like, not trying to over optimize something. There are only a certain ways you can extract alpha from an instrument yeah and any other way you try it will give you something or something there about itself but then you're trying you're better off adding different types of strategy into your portfolio than trying to say okay i'm just going to run only a trend following on the same instrument but i'm just going to change my moving average settings right i'm just going to make it from 100 to 50 or 25 yeah and this way i'm going to come up with 10 different systems but then if you can add a mean reversion strategy to just one single trend following strategy i mean the amount of diversification benefits that you get will be humongous yeah just to give you an example from the crypto markets yeah so crypto markets we know mostly are trending markets you know that okay once uh these are mostly called reflexive markets when you know that okay when something shoots up the trend is going to continue for some time yeah instead of just adding one strategy for example one of our strategies had like a drawdown of close to like 15 percent annualized to produce a return of 25 annualized unlevered and then what i do i come up with the same trading strategy but on let's say on a different instrument for example let's say we take bitcoin and ethereum as an example we run the same strategy on bitcoin the same strategy on ethereum and then we try to diversify across different time frames right you can run strategies at a d level data or at 1 hour 15 minutes these sort of things and then you try to combine different philosophies of reversion also in this from what we've observed at a very lower time frame the crypto markets are mean reverting yeah so what happens yes and then you can also add some intraday strategies yeah yeah on the same instrument as well right so what this does is eventually we were able to bring down the drawdown from let's say 15 to now let's say it's close to five six percent annualized but to produce the same sort of returns yeah which would be like uh let's assume on a conservative estimate like somewhere close to 50 to 70 percent unlevered right but then you see the beauty of it right you're able to produce to seventy percent with the five percent uh draw down right as compared to running a single model which would have suffered fifteen percent to produce similar returns yeah so so technically if you had a higher threshold for your drawdown you could even double down on leverage if there was leverage available right exactly yeah and then yes so then that that comes to my next point so what is the advantage of doing this yeah so then you can start levering your instruments up so let's say you were willing to take the same 15 risk but now for the same 15 risk when you know that your radon is 5 you can hit a leverage of 3x and that automatically boosts your returns up to like what 200 210 percent that's amazing yeah yeah so i think that's where the diversity helps one is you bring down the drawdowns yeah which brings down your risk and it can also help you take leverages uh knowing okay what you're dealing with yeah for example with the model which has like let's say 15 drawdown there's no way you're going to hit a 2x or even a 3x leverage because at one point of time i mean the numbers might say anything but when you're running something live you know that you'll start panicking and you'll do that right yeah it has to be realistic too exactly yeah yes yeah it has to be yes the numbers are one and then you also have to think about your life trading experience exactly yeah i mean will you still have confidence in the strategy after something you've lost 15 percent of your capital right it's something you'll have to think about so that's why what we're trying to do here at rain right now is to have uh to come up with for each portfolio come up with multiple strategies so that we are able to cut down on our risk one thing which we've learned is returns will come if you're able to manage risks properly right but once you blow out capital there's no way you can get back into the game exactly yeah that's the number one rule right to not lose money is money it's not to make money it's to not lose money right yes returns will come yeah if your models are good enough and given the market conditions are right the returns will surely come right but you need to have the holding power which is what the diversity of strategies will give you right all right so you know obviously you and have have made strategies for other markets as well not just india's capital markets you know cryptocurrencies forex and also the u.s markets right
so you know when you guys make strategies for the u.s market specifically right u.s versus india because obviously different asset classes have different you know things going on for them but specifically for the us and india how are the strategies different you know when you kind of uh you know your general approach towards the the environments and how are they similar to yeah yeah yes yeah so we don't try to differentiate between whether it's a what sort of a market it is okay we first try to identify okay what is the underlying behavior of any instrument and then we go about look for example nifty the index in india you know that a trend following strategies will work there the same thing will not work in the us over a long term there we know that okay mean reversion strategies at least for us has worked very well yeah if you're able to handle the risks that come with it the then the other aspect in u.s is that's a more deeper market compared to let's say india or your crypto currencies so that's again a challenge which you'll have to deal with yeah you'll have to start looking at probably lower time frames and those sort of things to deal with these issues for example a simple strategy which works on even a daily time frame in india would most likely not work out in us okay just with the depth of the market and the liquidity that's there in the market so there what we do we try to go go at lower time frames and see like okay what's the kind of alpha that's available there okay that's interesting so you're saying something which works for the daily market on ohlc data for india would probably not work in the us you're saying it'll not for example one simple strategy i can tell you is the fair trading strategy i mean that works very beautifully on the day level data in india but the same thing will not work in the us i mean if you just got it at least from our experience it hasn't yeah yeah so there then we try to move to lower time frames and see like okay if it's working there or not yeah got it got it and what about like different asset classes so you and bharath have built strategies for crypto as well you know yes we're looking to launch soon at rain as well but uh it is generally you know um kind of you know from a high level perspective how do cryptos kind of differ from stocks uh cryptos i think are highly volatile compared to stocks right right but then that's where you can also produce your returns for example one simple model which you are running in india a simple time strategy will produce was producing close to again like let's say for a drawdown of annualized max dot on like 15 volatility okay it used to give us close to 20 to 25 annualized returns the same strategy for the exact same risks in the crypto markets is giving us close to 80 to 90 percent annualized wow so that's the major difference there right but due to lack of competition or is it because it's a new asset class or both yeah it's a new asset class plus it's not as deep again right so the moves tend to be large so that's again where you need to handle your risks i mean the there also again i mean you're maxed out on can say anything but there's nothing stopping bitcoin from like going down 30 in a day just like that right right right right so i think we have to have a different conversation on just crypto you know i'm realizing this on the spot so we'll definitely do that and you know so kind of looking at you know the behavior um of of of a typical quad right especially you know someone was kind of starting out building their own strategies for the first time you know what are some common mistakes you know quants make when they're back testing and building strategies okay some of the common mistake i would say are biases which you introduce it's some sort of look ahead bias right i mean you know that okay you shouldn't be taking the closed data of that day for example but you'll still make a mistake of saying that okay just the data points that you take you'll have to be careful that i just do whatever i'm doing and data which i know that okay it's not in the future yeah right so that that is one point which you need to avoid and then again you'll have also have to take care of the way you implement your stop losses and all that so that you know that okay most of the times your stop losses are not going to get realized right just because of the gaps and all that right so that you'll have to be very careful of right and also you'll need to think about okay just the inherent uh biases which exist and let's say let's say i'm trying to do a a startup strategy on the universe of stocks in nifty today but before today also there were other stocks also in the nifty which have gotten taken out for various other reasons right survivorship bias survivorship bias exactly yeah so that is again what you need to consider like okay something has worked but i also need to know that okay what hasn't worked right they also need to go and analyze like okay why it hasn't worked and tomorrow if such a situation occurs how am i going to handle it right especially when the bias you know is is implicit right so for example um if you're talking about a strategy where you're building you know a portfolio of of stocks which are performing well right exactly uh and then you have survivorship bias with an index right that can make a huge difference because yes but those two things are correlated right but maybe in a stat or situation maybe not so much but still i would say it's something you should look out for right yeah yes yeah yeah you always have to yes yeah that becomes even more relevant in terms of pair trading and all those things right and you also need to know more importantly like when your strategies will not work right right more than when your strategies are working you also need to understand okay when can the strategy fail for example a a momentum or a trend following sort of a strategy even if there are no trends in the markets the market can go flat for quite a long time a classic example would be 2017 in india right or 2018 in the crypto markets when let's say the bitcoin didn't move at all yeah so there you're going to get whipped a lot yes so then you'll need to consider those things and say like okay these are the situations wherein this strategy will fail right and that is where again i would say like so instead of running one thing you tend to diversify yourself at a strategy level at a time frame level as well because i mean there might not be momentum let's say at the one day level but there might be momentum at a low at some lower time frames so if you can create that as well along with your existing that'll also help you cut your losses during the bad times right right right yeah and basically covering all the different market regimes right i think yes yeah so so yeah i would say as a beginner you would need to consider all these things so more importantly as to why a strategy is working yeah if a strategy is working you also need to make an analysis as to like why it's working also right i mean it just can't be just purely numbers right right yeah that understanding has to be there as to why something would work why something would not work it makes sense yeah so that they're conditioned yeah it is a never ending process yeah that's a beautiful thing right because the markets are evolving right see if anything you think is true today you know might not hold true so these concepts probably matter more than you know any sort of uh concrete you know strategies or anything right um so um yeah cool actually so last question for today you know you know i mean if you had to give some advice to any quants um listening to this who are building strategies for the first time because we do have many of those guys listening to this uh what you know like what would be your advice apart from the things that i've said yeah one thing i would like to say is if it's your money that you're trading you're still okay yeah because it's your personal money but at least at an organization level we know that people's monies are involved i mean they're hard earned money so we cannot be reckless with our strategies right i mean we cannot choose strategies which you know are going to undergo huge volatility right and you cannot take unnecessary risks i mean you can't take high leverages yeah right so you need to be careful in your risk management when you're dealing with at least an organization right and not dealing with public's money basically right so you need to understand that okay i'm dealing with someone else's money so let me ensure that i'm as safe as possible with others money yeah and i designed my strategies accordingly makes sense all right man well thank you so much that was a really engaging uh conversation and uh i'm sure we'll have many many more well i mean we have ours all the time but uh and i'm sure we'll have another one of the podcast as well yeah thanks a lot yeah it was a pleasure speaking to you yeah cheers bye you
2021-04-29