¶ Episode Introduction and Sponsor
Chat with Traders Collaboration with Quantopian Episode 4 What's happening crew? Your host Aaron Firefield here. Thank you for joining me. I really hope you've been enjoying these special episodes in collaboration with Quantopian up to this point and learning lots along the way. Right now you're listening to the fourth instalment. And as you'll soon hear, I'm again speaking with Delaney and also Scott Sanderson.
Scott is a software engineer at Quantopian and he's the one largely responsible for writing Zipline, which is an open sourced Python library that supports the Quantopian backtesting and live trading system. The topics we get into during this particular episode revolve around portfolio optimization, optimizing for maximum returns and minimal risk. We also talk about constraints that a quant may implement at a portfolio level.
other considerations and we step through how a researched news driven strategy which trades gun manufacturers could be optimized to better work within a portfolio. Now just a couple reminders, as per usual, any questions that you would like to ask, please submit them at quantopian dot com slash questions so we can answer these for you on the QA episode. This will be part six.
Uh for a full list of all the resources referenced during this episode and any previous episode, visit quantopian.com slash chatwithers. And lastly I'd like to give a big shout out to Data Camp. They are the ones who are backing this series. DataCamp is the one resource I always recommend to traders for whenever I get asked, where do I begin learning how to program?
¶ Scott's Journey to Quantopian
The reason being and the reason that DataCamp's courses are so good is that they teach you the skills necessary to work with and understand data, which is of course exactly what you're doing when you do any form of quantitative research as a trader. So visit datacamp.com and create a free account. You can start any one of their courses for free and they even have some courses which are entirely free.
Just to repeat the link once more, that's datacamp.com. Jump on it. All right, well I think that's everything. Uh please welcome Delaney and Scott Sanderson. And we're back again, episode number four. Delaney, how's it going? Pretty good. About the same as last time. No no major changes. Excellent. And we're joined by Scott for this episode. Scott, I'm thrilled to have you here, man. Thanks for doing it. Yeah, thanks for having me on.
Scott, tell us a little bit about your backstory. Like how'd you get into this? Yeah, so I had sort of an interesting introduction to finance. So I uh got introduced to Foss, who is the CEO here at Quantopian, because his brother coached wrestling with my brother at uh a day school in Newton, which is where I grew up.
Um, and Foss was in like early stages of prototyping the original version of Quantopia and when it was like a, you know, liv he was working out of his garage and sort of had this vague idea of what he wanted it to be and he was looking for people with uh for students with math backgrounds or with sort of math and science backgrounds, which is what I was studying at the time in college.
Um and so we met up, we had coffee and we talked about a bunch of stuff, we got along well. And so I was the original beta tester for the like early, early, early versions of Quantopian.
¶ Developing Zipline and API Design
Um, back when you couldn't do things like get the exception if your program crashed, you just had to sort of squint at the program and hope that uh your thing hope you could figure out what had what had gone wrong. Um, so for a summer I was the original beta tester for Quantopian. And then the next summer I interned and uh actually helped build some of the tools for doing things like error reporting and getting logs out of your
algorithms. Um and then that experience sort of convinced me that I wanted to pursue software engineering as a career. So I ended up doing a whole bunch of computer science classes in college. Um, got really interested in game design and graphics as well from that. And so when I graduated I actually worked for a game studio for about nine months.
Um, but I found that I I missed Quantopian, I missed finance, I missed working on open source software. Um and so about three and a half years ago now I came back to Quantopian and I've been an engineer here ever since. Very cool, man. A and prior to getting involved with Quantopian right back in the early stages, did you have any interest in uh trading or or quant finance or anything like that at at the time?
I mean I you know, I was aware of it as a thing that existed, but I and I like I said, I my academic background is in mathematics, um, but it's actually m pretty strongly on the pure mathematics side rather than the applied math side. So a lot of the math that's relevant to finance or for trading.
uh I wasn't actually all that familiar with. So it was really, you know, getting introduced to the platform and to FOSS and to the to this community of people who were excited about the idea that got me
interested and engaged with the problem. And I actually in part sort of fell in love with the problem because it was such a hard problem. You know, doing quantitative finance well, there's such a large incentive to do it. And it's such a hard problem for a variety of reasons that I sort of fell in love with the challenge of it as much as anything else.
Right, yeah, yeah, I can see how that would happen. Tell us a little bit about how what you're actually working on at Quantopian there. Like I correct me if I'm wrong, but I feel as though I think you had a pretty big part to play in actually developing the zipline package. Is that correct? Yep. Yeah. So uh one of the things that I did in that original internship was when we were first working towards open sourcing Zipline and so I
¶ Quantopian 2.0 Dynamic Portfolios
did a lot of the uh Zipline began its life actually as this like strange, very agnostic stream processing library and eventually morphed into being much more financially focused, uh, which is sort of where it is now that it's pretty firmly a a toolkit for just doing uh backtesting. And so uh most of what my responsibilities are right now is Um designing, building, and implementing the APIs that our users who are writing algorithms interact with.
If you're writing an algorithm, you know, an algorithm's a Python file and you can say, like, you know, I want to order five shares of Apple and that order function has a bunch of things that go into it. So you might say, All right, I want to order this many shares or I want to order this dollar amount or
you know, I want to order subject to different kinds of constraints or something like that. Um and so a lot of what my job is to sort of think about conceptually how should people be thinking about constructing their algorithms and then figuring out how to provide APIs that make it easy and clean for
people to express their ideas in code without having to jump through a whole bunch of hoops. And so some of that stuff happens in Zipline. Uh we try I like personally try to do as much of it is in Zipline as I can'cause I think it's valuable to us and to the community to have
those parts of the code be open source and be available and be resources to people who want to learn about quant finance or who wanna do their own thing. Um so in general Most of the work I do these days is is in zipline and the pieces that I do on Quantopian tend to be things that are around like
touching proprietary data sources or building like backhand infrastructure for us. It's something I'll just add on to that is that something that's oftentimes The im the importance of APIs are often lost and
¶ Portfolio Construction Fundamentals
Um APIs, namely like the way you interface with a problem or interface with some data, is incredibly important. And it's imagine that you are kind of talking about a problem but just using the wrong words and not just getting a clear picture of it. Um it's very easy to get into those kind of situations. So uh Scott does a really good job of kind of using his uh peer math background to kind of try to
figure out ways to elegantly express things um and kind of like group cases as much as possible. And so as a result, we've had some pretty nice pretty nice API work done in the last last couple of years. And I think the site has has vastly improved. uh as a result. I think we uh is your one of your How official is the title of API Czar? 'Cause I know that's been thrown around. So I I think it's it's unofficially official. Unofficially official. Yeah.
He is our our in house APIs are Yeah, one of the one of the things that uh you'll hear me say in in meetings around here a lot is that uh there's a famous joke that there's only two hard problems in computer science, which is cache invalidation and naming things. Uh and I actually would argue that naming things is often harder because, you know, putting a name on something, putting a box on something, figuring out how am I gonna refer to this thing
often sort of dictates where the rest of the design goes and figuring out kind of what the the ontology of your system is like what are all the different entities and how they gonna talk to each other and how they're gonna relate to each other. If you do that well, then A lot of the rest of the system just falls out naturally and sort of models the way that you'd want to talk about something or think about something in the real world.
And conversely, if you do that poorly, you end up kind of having to retroactively bolt on, you know, weird, strange things that don't make sense or don't seem natural. And so
¶ Optimizing Returns and Mitigating Risk
We spend a lot of time, especially because we run other people's code and so it's very hard for us to break or to make changes that are breaking. We spend a lot of time thinking about how do we get things right and do it right the first time and build designs that are elegant and simple and you know, easy to use without being broken in various ways. Absolutely. Yeah. Yeah. That's very important.
And I think it was uh maybe earlier in two thousand sixteen you rolled out, was it Quantopian like sort of two point oh? What what were some of the bigger changes you you made then? Yeah, so the the big change with that is we had been uh increasingly trying to build tools that allowed people to trade more dynamic portfolios. So the original earliest versions of Quantopian
Basically, you had to ahead of time declare that you cared about these 10 assets or something like that. And then you could place orders against those assets. And so with that, you could do kind of simple basket trades or pair trades or very limited kinds of statistical arbitrage, but you couldn't do a lot of the more sophisticated quantitative strategies that we've been working towards encouraging people to do where you're doing
dynamic universe selection or you're building factor models or you're doing interesting, you know, risk hedging and that sort of thing. Um, because the idea of those models is you're holding, you know, hundreds to thousands of positions and you're making lots of small uncorrelated bets.
And the idea is if I can make lots of those bets and I have a small chance of, you know, making money on each one of those, then in the aggregate I can end up making a lot of money. And so the goal for something like that, or the goal of those APIs was to make it easy and pleasant and intuitive. to do this kind of dynamic universe selection. And so the original system that we had had, you had to explicitly statically refer to some set of assets.
And then we had grown um a series of APIs that had kind of been duct taped onto that where you could implicitly set some universe of things behind the scenes based on a couple simple criteria. But then we had all these API functions where you could like ask for windows of data or ask for the current data or ask for fundamental data.
And it was implicitly depending on this universe that was either set at the start of your program or set in one of these very s few limited ways. And as people tried to do more sophisticated dynamic algorithms. those APIs weren't really serving the needs that they had. And so the big change in Q2 was that we moved away from this notion that your algorithm has some implicit universe that you have to set
in like specific places. And instead we gave people a lot more flexible APIs for querying for data based on mathematical criteria. So things like I want, you know, the top 10% of US equities by market cap or by trailing dollar volume or by some other interesting statistical property. And then you could use those APIs to dynamically select for sets of stocks and then you could pass those sets of stocks into other API functions to ask them for data.
Um and so that was a kind of a big conceptual shift in how the back tester and how the platform worked. And uh there were a bunch of internal changes that had to go along with it to to make it so that it could handle those more dynamic queries.
¶ Principles of Constrained Optimization
Right. Very good man. Very good. Well let's get into this. Um, you know, the last two episodes have revolved a lot around alpha factors, uh combining alpha factors. uh and classifiers. So I think this episode's gonna mostly be about sort of the next step, like what comes next. So Delaney, do you wanna take it away? I mean, what is the next step from this point onwards?
I mean, obviously this is going to be talking about it from a high level. Um, so you know, i it's not always gonna be exactly like this. You may have slightly different flow in your algorithm, but in general, once you've constructed uh your final model. Uh and that model is usually you know some combination of of smaller models. Um once you've constructed your final model, which is kind of
glomming together a bunch of smaller things, making one big overall prediction for each asset. Well now you have uh a forward prediction for each asset.
¶ Optimization Analogy and Generalization
And that forward prediction could be that it's gonna go up. It could be that it's gonna go up three percent tomorrow. Like whatever your prediction is, you know, whether it's a weak or strong prediction, you have a prediction. And the next step is okay, well
How do you actually translate that prediction into something that you can trade? Because just the prediction itself isn't sufficient. Um You know, that's just saying, here's what I think will happen, but then the next step is how do you actually place bets? such that if you are correct you will make money. Um and if you are incorrect, you won't lose all your money and and blow up. So um that process of of deciding what bets to place and what positions to take out is a complicated process.
in and of itself and it it's known as portfolio construction. So when people talk about portfolio construction, they're talking about how do I construct a portfolio that based on my expectation of where assets are going to go will
kind of try to make me the most money while at the same time not exposing me to excess sources of risk. And so this question has kind of been posed in many different ways using many different words. Um and Uh what people do in quantitative finance is just try to really condense it down into very simple mathematical ways of talking about these constraints.
Um, and so that's gonna be kind of one of the one of the subjects that we're gonna talk about today. It's like how do you actually express that? So um I think Scott actually has a really good story that he actually walked through in in a notebook. So he's actually and I'll let him talk about this, but I'll briefly I'll briefly sell it.
He's actually working on a new API right now, which I think is going to be amazingly useful. Um and what it is is it's a portfolio construction and optimization API. It allows you to do everything we're gonna talk about today. Um Kind of from an very easy-to-use perspective. And so he's encapsulating all of these notions of trying to maximize expected profits based on predictions, trying to reduce risk exposure, and and and um trying to you know put them all in quantitative mathematical terms.
And uh he recently released uh kind of a an alpha version of this API. It's not on the platform yet, but he released an alpha version of what it might look like. Um you can't actually play with it right now. Oh you can play with it? Quantopian.experimental dot optimizer. Oh we have like we have a we have a try at your own risk section now. Yeah. Gotcha. Okay. So uh you can actually play with it and what we'll do is again, as always, we'll link to that
Um at if you go to quantopian.com slash chat with traders, we'll have all of the content for all of each episode linked. And so that will be um one of the things you can access on the episode four section. Um and uh you can go and check it out if you want. Uh and uh but in the meantime I'll let I'll let Scott actually kind of Hawk through the story of what happens if you have some kind of expected returns for a set of assets and then you try to naively construct a portfolio based on that.
Yeah, so I I think it comes down to the idea that Delaney mentioned earlier, which is that when you're when you have some quantitative uh trading strategy, you reach a point in your model where you've built some prediction of what's gonna happen, um, but you're not sure about that prediction, right? So you your your model might have a belief that
¶ Common Portfolio Risk Constraints
various different assets are gonna go up and down, um, but there's some amount of uncertainty around that. In addition in addition to the uncertainty about the particular assets, you also might have Some amount of cer some amount of uncertainty around how different assets tend to move together. Or you might have some prediction about how different assets tend to move together. Um and so you have two kind of competing objectives.
Uh, as you think about what trades am I gonna place or what portfolio am I gonna hold. So on the one hand, you want to put as much of your money as you can. in the assets that you believe are going to go up, or you know, put as large a short position as you can into the assets that you believe are going to go down.
Um, but on the other hand, you want to mitigate the possible risk that one of your predictions is wrong, especially if it might be badly wrong. Right. So if I have some there's some asset that I think is gonna go up, you know, ten percent over the next month or something like that. Um, but I think there's uh 30% standard deviation around that, right? So I have some prediction it's centered super high, but I'm actually really uncertain about where exactly it's gonna land.
I might be ambivalent about how much money I want to put in that asset because I have these competing desires to, on the one hand, put my money in things that are going to go up, but on the other hand, not want to put my money, my money in things that I have uncertainty about. Um and so one of the ways that you can mitigate the that second aspect, uh which is the the risk aversion, is to force yourself to place that's in lots of assets that you believe to be uh
That you believe will move independent of one another. So if I have three different assets, I think they're each gonna go up, you know, three percent over some time period. Uh and I place I could just place, you know, all of my money in one of them and, you know, roll the dice and hope that I do well on that asset. But a smarter strategy might be to do something like put, you know, a third of my money in each of them, because if they all move independently, then I can be right
about two of them and wrong about one of them, and I I won't you know, I'll still end up ahead overall. Um and so Thinking about a simple example of this Uh if you imagine we have some model that produces uh expected returns predictions for
you know, a set of assets over some time frame. And I might say that, all right, I think Twitter is gonna go up two percent and Apple's gonna go up one percent and Microsoft's gonna go down one percent, you know, et cetera, et cetera, et cetera. I have, you know, predictions against some array of assets. Um, and I have some fixed amount of capital that I want to deploy to those assets. So that's the other constraint that we're generally operating under, is that we only have so much money.
to dole out among all the different assets we had. Right. If we if we were perfectly confident in some prediction about a particular asset, we might say, well, we're gonna put as much money as we possibly can into that. that's that won't work for other reasons'cause it'll the act of putting our money into the asset will move the price of that asset, but that's kind of bracketing that concern for a second.
uh in the real world we only have so much capital that we can put towards any single asset or towards some portfolio of assets. So that's another constraint that we operate under. Um but so if we imagine we're in this world right where we have
¶ Advanced Factor Risk Constraints
a set of assets and we have expected returns predictions about them. Uh if all we were trying to do was maximize our expected return and we had no concern for risk. then the optimal portfolio for us would be to put all of our money in the asset that had the largest expected returns. Again, that's I'm sort of bracketing the concern of
uh slippage that goes into actually entering that position. But if we could wave a magic wand and have whatever portfolio we wanted, the optimal best possible portfolio for us would be all of our money in the asset that we think is going to go up. uh by the largest amount. But for all the reasons we just talked about, uh
We often don't want to do that, right? Because we're not that confident in any single one of our predictions. And so we'd rather try to spread out our allocation to a smaller number of assets. And so one way of thinking about this is to frame our problem as what's called a constrained optimization problem. And the idea here is we have some objective, which is something like maximize returns.
and we have some uh set of constraints on that objective, right? So I have I'm trying to choose the portfolio that maximizes my objective, but that portfolio has to respect certain constraints that I'm putting on it. And so those constraints could be things like I only wanna put I I don't wanna put any more than five percent of my portfolio in any single asset or one percent of my portfolio in any single asset.
And they can get more sophisticated. So I might care about things like I want to be market neutral, right? So I want to have about as much long exposure as I have short exposure. because I don't have a strong belief about whether the market is going to go up or down over some period. Or even if I do, I don't want my portfolio to be correlated with that. Um and you can build progressively more complex constraints that you can place on your
¶ Risk Factors and Accidental Exposure
on the portfolios that you'll allow yourself to hold. And the effect that that has is you can, uh there's actually a sort of really beautiful, robust mathematical theory for how we can say, if I freeze my problem as this optimization problem with certain constraints, then there are good libraries and there's good mathematical theory for how to find the portfolio that sort of provably mathematically will maximize the expected return without violating any of those constraints.
Well I I feel like something maybe it would be useful just to to to talk about the this notion of optimization briefly and like um one it because it's a really central concept to a lot of engineering. Um, but it's something that is Outside of engineering, not really well understood, I would say. Um, and also it's very misapplied oftentimes, uh, because for instance.
People often talk about maximizing return when they forget that what they're really maximizing is estimated return, right? Because there's some model which is estimating what their return will be. Um and that model may be wrong. So you know there's another failure point that you have to be aware of.
Um but I I want to just get into this notion of optimization briefly because I I think it's a really useful concept to understand. And and we'll start from like the simplest example, which is um imagine that you have some um some you know box in front of you and you have uh you know a dial in the box that can be one in one of 100 positions, right? Um and then on the other side of the box
There's a light bulb and you can record how bright that light bulb is, right? And and an optimization problem in this case would be figure out a dial position to Maximize the brightness of the ball, right? I want to optimize the brightness of the bulb and the control I have over the system is this dial. So this is a very simple, it's known as a one dimensional optimization problem because the dial is just one dimension. You can kind of move the dial
to one position between one and one hundred. So a naive solution to this might be doing something very simple, which would just you try all the positions on the dial and then you pick the best one, right? In this case, that's pretty feasible because there's only one hundred positions. You can probably do that by hand. uh, you know, pretty easily. But the ne the next thing that I think is important to to pull out of this is okay, well then imagine that you plotted the brightness
for each dial position in a graph. So now you have on the x-axis the dial position and on the y-axis the brightness of the light bulb, right? And uh what this gives you is kind of you can start looking at how the brightness of the bulb corresponds with the input that you put into the system. And so you might notice that maybe it's
A quadratic dependence, or maybe it's a linear dependence on the dial, or something like that. You know, you don't know what it is yet. So this is one of the ways that. engineers and quants will start attempting to understand systems is they'll look at how they respond to the inputs they put into the system. So if you have this problem.
uh it's fairly easy to imagine how you might go about solving this optimization problem, right? Where you just kind of you could just try all the options, or maybe if there were too many options to try. you could look at the curve that it produced and then just kind of try to figure out where the maximum point on that curve was. And Generalizing this, all that a mathematical optimization is doing is just saying, well, now the box is a function.
¶ Biases in Historical Data Models
And the function has some inputs, which are your controls, and it has an output, right? And so in our case, we design a function which is Let's say that we hold this portfolio, we hold this weight of each asset. So if there's one hundred assets we could hold, now the function has one hundred variables as inputs, and each variable can just be, you know, the weight that we're holding of that asset in our portfolio. And then the output is
what our expected return is given that model we're using. And you know, that the model is model is in this case your your your your forecasting model, your alpha model. Um And what you're trying to do is you're just trying to tweak the weights uh such that you maximize that expected return. And again, in the one-dimensional case.
uh it's a very simple problem. You can kind of imagine, you can put it in your head how you might solve that. And as soon as but even if you move to say like a two dimensional case where you have two variables you can tweak, you start seeing that, well now you can't represent it
as a graph, you actually have to represent it as like like a as a a graph that has a third axis, you know, like one of the three dimensional graphs you may have seen at at some point. Um and then imagine like four variables as inputs. Well now we're up to a four dimensional graph. And that's a problem because We can't really think in four dimensions, right? Humans just have no capacity to visualize four dimensions.
And of course, like when we're talking about portfolio, that's actually like thousands of dimensions because there are often thousands of assets that you could hold. Optimization and I'm not going to go into like the the the nuts and bolts of it too much. We'll put some resources again at quantopian.com slash chat with traders. We'll put some links to tutorials we think are really good, visualizations we think are really good.
um to help help explain this. But without going into the nuts and bolts too much, generally optimization is just a mathematical way of expressing given any number of dimensions. Try to kind of walk along this space of how bright that light bulb is, how how much my expected returns are. Try to walk along, walk through that space. You can have imagine it as a landscape. Try to walk through that space.
¶ Look-Ahead and Distributional Biases
And find like the highest point. In that space. And that's the notice that's the notion of an optimization. And then when you add constraints into it, constraints are just like putting fences in that space, which say that you can walk through the space. But sometimes you hit s fences which are I can't hold more than this of this asset, or I'm not allowed to move the dial past this point because there's a physical blockage there. And so you hit that fence, you say, Okay, well
Um I can't move into that space. And so now let me try tweaking my parameters in another way. So Again, without going into the nuts and bolts of how this is actually done under the hood of an optimizer, uh I think it's really important just to get that intuition for what an optimization is actually doing. Did that make any semblance of sense? Yeah, yeah, absolutely.
Uh you you brought up an interesting point towards the end there about constraints that you might have um when you're optimising your portfolio. You know, you gave a few analogy for some constraints. What about some like actual real world um examples of some constraints that a quant might put into uh their portfolio or their their risk model? Sure, I can talk about that a little bit. So one one constraint that actually has a really nice geometric intuition actually is uh the
your maximum leverage constraint. You you only have so much capital to deploy. Um and so again, if we if we think back to say grainy's are Great at Douane uh Douaney's graph example. I've been a long day for Scott. I combined graph and Delaney in my head there. If we think back to Delaney's graph example, right, where we're imagining, say, plotting, you know, the expected returns of some portfolio as a function of the portfolio weights that we choose.
Um what it means to say that we're gonna constrain our leverage, right? We're gonna to constrain the amount of capital we're gonna deploy is to draw a circle if we're in two D or a a sphere if we're in three D or You know, as we get to higher dimensions, we have hyperspheres or something like that, which again we sort of lose the ability to visualize, but we can fall back on our intuition for circles and spheres.
But it bounds the region of possible portfolios that we'll allow ourselves to choose. So One that's one almost everyone in some capacity will have a a capital constraint on their portfolio. Um, but then some other common ones. So often you'll see um market neutral constraints if that's the style of strategy you're uh pursuing. And not everyone tries to be market neutral, but it's it's a common thing in the quant space.
¶ Gun Strategy: Hypothesis and Flaws
Um another common class of constraints is people concerned with uh sector exposures. So you might believe that companies that are in similar sectors or similar industries tend to move in correlated ways because their underlying exposures are similar, right? So Apple and Microsoft all things being equal
are more likely to move together than Apple and McDonald's. One one might hypothesize, say. And a rationale you might have for that is both Apple and Microsoft might be sensitive to changes in the price of silicon or changes in the amount of capital that US consumers have available to them to to spend or for any number of other reasons, you might have reason to believe that companies that are in similar businesses will tend to have the val their values fluctuate.
uh more together than companies that are in dissimilar businesses. And so one of the corollaries of that is that if I put all of my money in companies that are similar in similar businesses, I'm not actually reaping very many of the diversification benefits that I might get if I had a portfolio with lots of different companies in it. because again the whole point of uh diversifying a portfolio is that I'm gonna put my money into lots of different assets that I think are gonna move
in an uncorrelated way. And so it's very unlikely, statistically speaking, that my portfolio will have a very big uh movement up or down, right? I'm I'm sort of constraining the likelihood that I'm gonna have a big movement up in exchange for a better belief that I'm not gonna have a big movement down. And
humans being risk averse tend to be willing to make that trade off. They're tend to be willing to accept a smaller but more secure benefit in exchange for not having the possibility of a very bad thing happening to them. Um and so one reason why you might be interested in constraining sector exposure is this intuition that different stocks that are in the same sector.
uh still tend to move together. And so I might not want to put too much of my portfolio in any single stock. So you can go from kind of very basic, easy to visualize constraints like how much how much money you're gonna put in your portfolio and and kind of making sure that your
sector neutral and and a way to again another way to kind of visualize this, maybe get the intuition behind it, is you can imagine the optimization process as like a negotiation or a discussion between two people, right? And so
¶ Applying Constraints for Optimized Portfolio
the one part of it says, Hey, I came up with this great idea for how to weight my portfolio and shows it to the risk constraints. And the risk constraints say, you know, you can't actually trade this because This is gonna put a lot of weight in your portfolio into the energy sector.
Um and then the person who's in charge of constrain coming up with a portfolio uh comes says, Okay, well, okay, let me let me try again and it tweaks it a bit and it and it basically it's a discussion between these two parts where You know, one is trying to keep their returns being maximum maximized, and the other one is just saying, you can't do this, you can't do this, you can't do this. Um In terms of constraints, you can go all the way up to like uh five Uh some pretty good.
sophisticated and hard to visualize constraints. So I'm gonna be pretty technical for a second, so please bear with me. But remember in the last episodes we talked about risk factors, risk factors being return streams, sometimes computed as the returns of a portfolio
based on an alpha factor. So if you traded an alpha factor, what would your returns be on that portfolio? So like when you look at these risk factor return streams, oftentimes you'll want to make sure that your portfolio doesn't have excessive correlation to these other known return streams. Uh the market is one example of this where you want your portfolio maybe not to have excessive correlation with the market.
You might also want it not to have excessive correlation with value. You might want to make sure it doesn't have excessive correlation with momentum. So this is where the notion of kind of factor risk modeling comes in, where you can also have as constraints in your portfolio. Okay, now let's look at this new set of weights. Let's compute the returns had I held this portfolio for the last 90 days.
And then let's do a linear regression where I look at my portfolio versus all these other factors I'm worried about having excessive exposure to. And if any of these factors have betas above some cutoff, I I can't enter into that portfolio. That's another set of constraints.
that quants might apply um and and is a much more kind of sophisticated way of thinking about it. Another one that's more mid-range is uh I'm sure a lot of people might be familiar with var and c var. Uh and so you can put for instance that the the C var uh the conditional value at risk. uh of your portfolio um cannot exceed a certain amount. And that's another constraint that would be very reasonable to put on your portfolio, which is really just a measure of the
of the volatility. So there's a lot you can basically think of like any constraint you want, you can put in your portfolio. A constraint could be you can't be invested in fossil fuel companies. That's a perfectly valid constraint and is, you know, kind of something that people are starting to think about now.
um uh especially like as endowments are being pressured to divest from fossil fuels. So A constraint can really be anything, and it really just depends on on your risk tolerances and your style of investment. One of the things I also want to emphasize there is Delaney's talking about uh say limiting my ex my C bar or limiting my exposure to some linear regression. Um and
It's important to remember that we're always the only thing we can ever do is limit our expected exposures to things or our expected movements to stuff. So You know, we talk as though we have the ability to maximize our returns or minimize our variance or something like that. But all we can do is build models of what we think the world is gonna do and then try to assume that our functions are good enough or that our models are good enough.
That we can choose portfolios that would minimize our models if they turned out to be correct, or would maximize our models if they turned out to be correct. Sure. Now Delaney, you brought up uh risk factors in your answer there. Uh we spoke about risk factors a bit more on episode two, so I think it might be uh beneficial just to save any confusion. Maybe if you could differentiate between what is a risk factor and what is a actual risk model.
¶ Broader Use of Portfolio Constraints
Sure. So again, a risk factor is just a return stream. Um so it's it's really just kind of the returns on some asset. And the asset is usually um some known thing, a known phenomenon in the market. Uh and examples would be the market itself. That's probably the most commonly used risk factor is just the returns on the broad market. The notion being that if your portfolio is
highly correlated with the market, then you are taking on a lot of market risk. If the market crashes, you are more likely to crash if you have experienced, you know, high historic correlation with the market. Again, like Scott said, this is all estimates, right? And so when we're estimat this is all estimating future risks. This is not exactly quantifying future risk. So Um another example is value, in which you would say Compute high value stocks using your formula.
and compute low value stocks using your formula. And so now you have an alpha factor, right? This is the alpha factor which ranks everything by value. Then you construct a portfolio or you go long on high value stocks, short on low value stocks. That's your value portfolio. Um, you look at the returns of that portfolio and now because we're back to a return stream, we're back to a risk factor. And so what you can then do is you can say, well, I've come up with this interesting new strategy.
Um but it has very high correlation with value, this known value risk factor. Well
¶ Event-Driven Trading Signal Generation
That means that maybe what you're doing isn't that interesting. It's just taking on risk exposure to value. So a risk model just tries to estimate
future risk exposure to these risk factors. And usually how they do it is they look at like a trailing window. So they'll look at the last say 90 days or 200 days, whatever makes the most sense. They'll look at say like the last 90 days and they'll say, Over the last ninety days, if we run a linear regression um between your portfolio's return stream and the return stream of these known risk factors, what are the betas, the estimated dependencies between
your portfolio and these known risk factors. And the betas represent a quantification of the amount of risk you are exposing yourself to from each factor. So that's That's one form of a factor risk model. And again, like the notion of a risk model in general can be anything. A risk model is just trying to measure how much risk you're taking on. This is just one common way to do it.
Uh one one way that I often find helpful for thinking about this idea that I'm interested in quantifying my portfolio's exposure to these various risk factors is to think about the idea that usually in some algorithm you have some investment thesis, right? You have a belief that certain stocks are going to move in some way or that Stocks that have some statistical property to them will tend to outperform stocks that don't have that statistical property.
Um and if you can encode that idea in a trading algorithm and deploy it, uh one of the things that you want to be sure of or that you're interested in understanding is whether The reason if your algorithm say your algorithm does well on a back test or your algorithm starts doing well in live trading, you might be interested in trying to understand whether
¶ Next Episode: Machine Learning in Finance
the reason your algorithm does well is because your investment thesis was true or because or whether it's because your the decisions that your investment thesis implies tend to just really be subscribing you to some other risk factor, right? Or you just happen to be making decisions that were correlated with uh some other industry, right? So uh an example of this might be that I might look at a whole bunch of company fundamentals.
And decide that I think that companies with high price to book ratios or high earnings to capital ratios. are going to do well in over some time period. And so I build a portfolio that, you know, has a whole bunch of company that's long, a whole bunch of companies that have, you know, these high fundamental ratios and it shorts a bunch of companies that have these low fundamental ratios.
Um but one of the and you might deploy that and it might do well or it might not do well. Um but either way, one of the things that you might not realize about that portfolio if you looked at it is that Often, again, coming back to the sector case, often companies that report these financial metrics or for or report these uh
you know, these these different attributes of themselves, the way that those attributes are reported in different industries or in different sectors or the way they're calculated can be different. And so it might be that say tech stocks report uh or tend to have higher returns on certain kinds of investments or lower returns on certain kinds of investments than say natural gas companies. And so
I might have thought that I was building this portfolio that was interestingly optimizing over some fundamental ratio, but really I just accidentally built a portfolio of all tech stocks, right? And one way that I might come to notice that is if I look If I built a factor model or a risk model of all these different, you know, return streams and I might look at my returns and look at the returns of all these different risk models and realize that, oh
I'm actually not really doing anything interesting here. I'm basically just getting the returns that I would get by trading in the tech industry. And so one one of the things that a risk model can be good for, I think, is sort of understanding what asset classes you're subscribed to.
And especially understanding what assets classes you might have accidentally subscribed yourself to when that wasn't your intended investment thesis. Yeah, that's a classic failure mode for quants is doing something really complicated and fancy.
And then just finding out at the end of the day that it's just a combination of three already known things. So, you know, you come up with some fancy ranking method and then at the end of the day, it's the same as if you had just gone long in the consumer cyclical sector or something, you know, and and and the factor models give you a way to figure that out.
Okay, so this might be a good point to bring up uh biases. I mean this is something we spoke about in episode one uh of this of this series. You know, when quants are designing uh their their risk models and building uh constructing portfolios Is that something is this a stage where you need to be mindful of biases again or not so much? Yeah, I mean absolutely. I mean, anytime you're doing any kind of statistics on data, you have to be mindful of biases. And and again, like
Biases creep in in really subtle ways and and I'll I'll just I'll say it again. I've said it before. Like one of the things that I am commonly doing is I'll do like tours and and kind of Lectures at the subject of you don't know how wrong you are. Again, like the subject of our first podcast, and and really just trying to drive home how easy it is to miss.
a lot of biases. So I'll give you a really great example of this, um, which is actually like so I'm sure that a lot of people are familiar with this notion of Markovitz portfolio optimization. Um When Marguerite's portfolio optimization was developed The notion was was simple, which was let's say that I have some set of assets that I can invest in. And what I'm going to do is I'm going to look at the historical returns of those assets and the historical volatility of those assets.
And I'm gonna do a clever optimization which gives me weight. that maximize my um, you know historical returns a maximizes the average of the historical returns while minimizing the average of the historical uh volatility of the assets. So it's just this was kind of one of the first implemented or or published forms of portfolio optimization. And it's taught in kind of like every investment
uh curriculum these days. Um and and that if you try implementing that, it just does not work at all right now. And and the reason for that is what you're doing is you've implicitly made an assumption, which is that you are assuming that historic returns are predictive of future returns.
And what does that mean? Well, there's a strategy which does that, and it's called momentum. Momentum says if things are doing well in the past, I think that they're going to keep doing well in the future. So a momentum investor is placing these kind of bets.
Now momentum still exists, but it you know, you have to be careful about the time frame and the industry and like you have to kind of caveat it a lot more now than you used to. Um And w and back when Markovit's portfolio optimization was developed, there was so much like there there was so much free free money in the market basically, and and things weren't as efficient, things weren't as arbitraged away that you could still make money trading off of like a simple momentum factor.
Um and so it basically it's important to realize, well, you you you've done something which seems cool, but you've made an assumption which is Historical returns imply future returns. Therefore, you're actually, if you ran a return stream, if you like did this and then looked at your return stream, you should find yourself highly exposed to the momentum risk factor.
Um, and that would be an example of, oh, maybe you did this and then you looked at your return stream and you found a high dependency on the momentum risk factor. And then that would warn you, oh. Oh, I'm I'm probably doing something weird if that's my high dependence. You're also making the same assumption for volatility. You're assuming the historical volatility forecasts.
future volatility, that may or may not be true. You'd need to figure that out and validate that. So that's an example of like how easy it is For kind of biased assumptions to sneak into your model. I'll talk about one more, which is if you're trying to estimate the future risk of something. Um oftentimes you'll like construct some model which uses some input variables to try to forecast. uh the risk at some point in the future for some asset.
Um and oftentimes that will be done by looking at the volatility. And you'll say, okay, let's look at the last 30 days volatility and see how predictive that is of the next 10 days volatility. And you know, maybe that that's your model. What can be really easy to do is introduce say something like look ahead bias into that validation process in which you accidentally um don't shift your data in the right way or you provide your mo your your model access to future data by accident.
And so when you think you're looking at the last thirty days, maybe you're looking at like day minus twenty to day plus ten by accident. And so you're actually including the volatility of the period that you want to forecast in your model and and And it's it's kind of tricky to visualize this, but for anybody who actually has ever tried this, this is a problem that I guarantee you you'll you'll have run into is is is biases like look-ahead bias. And again,
Just remember that everything is an estimate and and it's very easy when you're constructing estimates, when you're constructing models to have biases sneak their way in. Yep. Well but yeah, biases and I I would also often phrase it as you have biases. You also have sort of implicit assumptions, which are yeah, I guess synonyms here. So like another assumption that often sneaks into statistically based models uh is like assumptions about how
uh random variables that we're modeling are distributed, right? So most statistics gets a lot simpler to calculate if you assume that lots of things are normally distributed. And normally a normal distribution is the nice bell curve that you see in on the front of every statistics book. And it lots of formulas sort of work out nicely if you believe that assets kind of or that returns or that volatilities or that
any other kind of thing that you're trying to uh predict is gonna be sort of shaped like this nice bell curve. Um but in practice that often tends n turns out not to be the case. And it's easy to look at a formula that comes out of a statistics textbook or that comes out of a paper and not realize that that formula that's trying to build a model for how something's gonna work in the future.
is making assumptions about, say, whether certain variables are normally distributed or distributed in some other way that may not actually be an accurate reflection of how the world actually works. Yeah, and and and just as a f as a quick last point, like this is a very common thing to do. Um
Very, very common thing to do. And and it just is again, if you don't check all your assumptions, just always check your assumptions. But if you don't check your assumptions, you might try to compute something like value at risk. But in such a way that you say, I'm assuming that everything's going to be normally distributed. We actually have um a lecture in the lecture series, uh, we'll link to it.
And basically the lecture shows that how different real returns distributions are from normal distributions. So if you use an assumed normal distribution to estimate you know, the conditional value of risk of your portfolio, you'll just be way off. from the actual amount you could expect to lose on your portfolio and in the wrong direction, which is you think that you will lose a lot less than you actually will.
Um in practice, very, very few things in finance are normally distributed. So this is that's a great example of of a bias that can sneak in. Sure, sure. Now Delaney, I know you wanted to bring up the gun trading strategy. I'm not sure what the proper title for it is. It's an inflammatory title. So, uh yeah, let let's go into that. I I think this is also very interesting and it might help to kinda bring some of these uh subjects we've been talking about uh together and kind of um
Yeah, bring it all together and talk about how things are actually implemented in the real world. So maybe if we just start by talking about what's the actual hypothesis of this trading strategy? Sure. And again we'll we'll we'll link to this uh at Quintopian.com slash chat with traders so you can actually go check it out and, you know, read the article. But this was actually some work that we did in um collaboration with a reporter at Reuters. And um
They this was back uh I when was this published? Early this year, um in in February, and this was at a time when there was a lot of public debate. Um un very unfortunately a lot of public debate about uh mass shootings. Um, especially in the US, where there's a lot of debate about, you know, like Does this make sense? Do we need to implement reforms? There's you know, there's just a lot of debate on both sides.
Um and and so one thing that people have started to think about is well what it how can we actually quantify this so that rather than you know like talking points we can actually maybe draw some conclusions based on the data. An option to this was a reporter was interested in if you tried to make a trading strategy um, you know, based on these mass shooting events, how would that work? And and basically testing this hypothesis that people tend to buy more guns in the state.
when mass shootings occur. So um what we did is we did s we did some work, specifically James Christopher, uh who's uh an intern at Quantopian, did some work and um uh on on this and they they came up with a strategy that uh says if you if you experience news of a mass shooting event, um buy into uh stocks uh of of gun companies, gun manufacturers, ammo manufacturers, etc. Um So this is a strategy, right? And it's based on a hypothesis.
And and again, I just wanna draw back to this notion of like hypothesis-based strategy design, where you have a hypothesis. You don't kind of like throw a bunch of stuff at the wall and see what works in a back test, but you have a hypothesis. The hypothesis is that
People buy guns after mass shooting events. And so you're gonna say, Well, can I actually trade off that? Do I notice the difference? And so um they tested that and they found that um uh it seems in the data set that they have, uh you do experience um a fairly good returns if you invest in um gun companies after either mass shootings or political events.
Um political events are things where maybe um uh politicians say that they're going to implement gun control, and then that can also be a driver of people going to buy uh buy weapons. So It's just an interesting example of a strategy and Uh I think that it has some interesting flaws which fall into the topic of portfolio construction and um can kind of show us some of the ideas of like, okay, well here's a strategy which is Looking at
How do I optimize returns based on my model? So my model in this case says that after this point in time, you know, after these events, I'm gonna forecast that these companies will will get good returns. These these gun companies will get good returns. And um the other companies, I'm not really making a forecast on them. Let's just say that they're gonna stay neutral, whatever. I don't I don't know what's gonna happen. Um so that's your model. And then you're you're you're you're
Challenge is uh how do you actually turn that into something that trades? So naively you might say, okay, well just after each event, buy into all those companies and just sit and hold them long. Right. There are some problems with this as we've discussed, basically, that if you just naively construct your portfolio this way, uh, well, not only are you exposed long only to the market. But you're also invested completely in one sector.
And you're also invested completely in companies that are likely to all be very correlated because they're all producing the same thing, the same good. So um This would be a good example of like maybe we can briefly talk about how you might go from this model which forecasts that gun companies will go up to a more reasonable portfolio. and how the constraints that we talked about earlier might start driving your portfolio into a more reasonable place. based on based on, you know, like
h how how you constrained the problem. So did you have any like questions about what I talked about or maybe we can just jump into talking about how the constraints might reshape your portfolio? Well yeah, I I think that'd be really interesting to hear about because obviously you pointed out there are a couple of flaws to this hypothesis. driven trading strategies. So um how would you actually go about implementing that into a portfolio and something that would be worthwhile uh trading?
So I I'll I'll let Scott jump in after this. But the idea would be that let's say that you had Scott's API ready to go. And uh, you know, you just you you get this signal of I wanna trade these stocks because I think they're gonna go up, right? Um well Okay, then you say, but I'm also going to constrain that
No um I can't put more than uh 1% of my capital into any individual asset. That's a reasonable constraint. Um but let's say that there are 10 10 gun companies total that were interested in investing in. What's gonna happen? Well what's gonna happen is that uh
That optimizer is going to say, I'm trying to get into the gun companies. I'm trying to put all my money into the gun companies, but the constraints aren't letting me. They're saying I'm going to max out at 1% of my portfolio in each gun company, and then I'm going to have to put the rest of it somewhere else.
And so you'll probably get like kind of an even distribution across other assets in in your universe. They just may may or may not be in the same industry, could be all over the place. And then we'll talk about maybe we'll put in another constraint, which is I cannot be Exposed to any sector, right? And so what does that mean? Well, we have a bunch of long bets in whatever sector gun companies live in. Um so that means that we also have to put in place a bunch of short bets in the same sector
to bring our n to bring our exposure in that sector back down to zero. We're not exposed to that sector. And so now the constraints say um because you have to be kind of even across the sector, it's gonna push you into having some short positions in the same sector.
companies in the same sector that aren't the gun companies you wanted to belong in. So already now we're starting to get into these interesting, you know, arc we've only put in place two constraints, but we've already switched from a portfolio that holds ten assets to a portfolio that holds, let's say, like 500 assets and a portfolio which has longs and shorts just based on these two constraints. Does that make sense?
I think so, yeah. Maybe if you could just repeat that part about why you need to take short trades, is that just a just an example of a constraint that you might put into your portfolio that that means that you can't just be long only? So so I I think Uh and this algorithm's a little bit interesting because it's it's an event study and and at least as it was originally implemented, it actually has long periods of time where it doesn't hold any positions at all. And so
Uh that's very different than some of the styles of strategies that we were talking about right now. But I I think the reason why you might be interested in optimization or something like it for a strategy like this. goes back to the idea that I was talking about a little bit earlier, which is that you wanna make sure that
What you're trading is actually your original hypothesis and not something that merely happens to coincide with the hypothesis. Um, so in this algorithm, right, our hypothesis is that Gun companies specifically, you know, these ten or these, I don't know how many assets this trades off the top of my head, but I have a specific hypothesis about a about the behavior of these specific assets when these specific events happen.
Um and so If I'm if that's the hypothesis I have, what I want to make sure that I'm doing is actually trading on that hypothesis. It might be, for example, that all of the uh gun companies that I'm trading also all say belong I don't I don't know how gun companies get classified by by sector by by industry, but uh they might also all have similar returns or similar risk profiles to
Um, I don't know, let's say like the retail market, right? They're probably sort of behave kind of similarly to sporting goods in a lot of ways. Um One thing that we might One way of phrasing our hypothesis, right, is that when mass shootings happen, gun companies will go up. And that might be the extent of our hypothesis. Um but that's actually quite hard to say, right? Because if the market is tanking, then even if gun companies do better than everybody else.
our our strategy might not do well, right? If it happened to be that mass shootings always happened at the same time as the economy was tanking, then even if our hypothesis was in some sense true, right, that gun companies do better on average than other companies when a shooting happens, we still might actually lose money on the strategy because
The whole market was tanking, so gun companies went down as well. They just went down less than other companies. And so We might move from our hypothesis being merely that you know, when a shooting happen a gun happens, a gun company goes up to when a shooting happens, a gun company will do better than other similar company or other companies that otherwise might behave similarly. Right. And so that's where you start to be interested in this
sort of hedging idea or this uh sector neutrality or market neutrality idea, right? Is that my hypothesis is no longer just that gun companies will unconditionally go up, it's that they will do better than similar companies. Uh or they will do better than the market as a whole.
Well and so if I wanted to trade on that more refined hypothesis, then I might be interested in this idea that okay, when I enter into a long position in you know these gun companies as a result of a mass shooting, I might simultaneously enter into a corresponding short position in, you know, other companies that are in the retail sector or just in a broad market uh
set of companies based on certain risk criteria. And then once I start if I go to that latter route, right, where I'm saying, all right, I'm gonna enter into a s a small number of longs in these specific companies. And I'm gonna enter in into a large number of shorts in these other companies to be to be say diversified there or to ensure that they're sort of stable, uh, then I might start to be interested in some of the more sophisticated exposure measures that we were talking about.
earlier where I want to make sure that I'm not accidentally just going like super short the food service industry or going super short the telecom industry or something like that. But that what I'm really doing is just hedging out the overall market effect or the overall consumer cyclical effect. Okay. Yeah, yeah. I think that that makes it a little clearer. Um Delaney, is there anything you'd like to add more onto th this particular trading strategy um and example?
Um no, I I think that Scott like really kind of touched on all the points that I want to touch on. I and I would just say like Just to reiterate, there's like a tremendous number of constraints you can put on a portfolio and they all kind of get it different ways you could you know, you could fall apart and uh This is just talking about a few different constraints you could put on to avoid a few, you know, try to avoid a few different sources of risk.
And uh at the end of the day, like the number of constraints that a professional quant shop is going to be putting on their portfolios is probably going to be, you know, a lot more than just saying We want to be neutral in each sector, we want to be neutral in the market, we want to invest this amount of money, and we want to be exposed to these factors. You might have a a few more, a few more things than that depending on your investment thesis. You might not be allowed to trade certain stocks.
for legal reasons because one of your board members owns some company and you know there's there's more complex constraints that you you you can have to put on on portfolios sometimes. But Yeah, I think one of the things I do I would want to add to that is that
Uh I wouldn't wanna say that, you know, a sector neutral portfolio or a market neutral portfolio or or some other sort of more fancily constructed portfolio is categorically better than, you know, a more simple event strategy or or a more simply constructed portfolio. But What what these more sophisticated tools allow you to do is refine hypotheses, right? And make sure that uh when I'm trying to trade a strategy that I am focused on uh building a strategy that actually reflects the specific
idea or the specific thesis that I have, right? It allows us to narrow down the sources of possible reasons why an algorithm might do well so that we have a better reason to believe that if an algorithm does does well, It's because we were actually correct about some feature of the market or some feature of particular companies. Mm-hmm. Okay. Um now I'm just curious. Um I know there was an article about this strategy on uh Reuters.
Um, I'm not sure if the article itself actually kinda laid out how the strategy actually traded around the events. Is there any way we can get more info on that? Yeah, we'll link to the actual Quantobian forum post, which goes along with the article, and that actually gives you the full source code of the strategy, so you can actually see exactly what it's doing. Yeah, that'd be great. That'd be great.
And um, you know, obviously we c we can check that out, but just while we got this opportunity, how were the actual trading signals generated? Like obviously this was not so much a uh a a strategy that's based on price action. It was based on um events and news and that sort of thing. Uh was it still obviously still an automated strategy? How how was it getting the trade signals? Was there a a news reading algorithm of some sort?
So um in this case we were just looking at a historical window. We weren't trading this thing live. Uh and so what we did is we just went back and with the help of Reuters, we just Before looking at the returns, we just laid out the events that we were concerned with, right? We just laid out all the events. Which they would say like they classify it as yes, we believe that this is an event
um, you know, after which uh the returns on gun companies would be higher than comparable companies. And um so we had just like a CSV of the date.
And whenever one of those dates came along, we would just jump into uh jump into uh gun companies. And so it was basically what you'd have to do if you wanted to switch that to something that could trade live is yes, you'd have to have um an automated way of Pulling in news of these events, classifying the events as: yes, this is an event which I believe is likely to influence.
um, you know, gun companies positively uh or not, and then kind of have that event feed in live rather than have it be a static CSV file. You could also just have a comp a human press a button whenever they thought that this was an event and then that would also, you know, add it to the queue. Um, that's perfectly reasonable as long as, you know, the rest of the chain is still is still quantified. I think that's an interesting idea because
Um you don't have to always be fully quantified. There are some things that humans still do better.
And if your strategy is trading on a frequency which is still reasonable, like it's not like, you know, tons of times a minute, if it's trading like once a day or whatever, well you can have a human press a button that says, I believe this event has happened. And then the nice thing is that the strategy will still go and do all the portfolio optimization and risk analysis and everything and construct a good portfolio and trade on that portfolio and get into it quickly.
Um and it's a way of just like saying, I'm gonna take the best part of what a human can do and also the best part of what a strategy and a c computer can do and kind of combine them together. So you you can you can get a little bit more flexibility around that. Yeah, sure. Okay. Excellent.
Well guys, let's leave it at that for now. Um, next episode, uh last one before we do the episode number six, which will be Q and A. So episode five, uh what are the key topics we'll be discussing uh on that one, Delaney? Well uh we're gonna talk about
good and bad uses of machine learning in quantitative finance or finance in general. Because turns out there are a lot of bad uses, but there are all also a lot of great uses. And uh I think that people who enter in, especially people who enter in with Um some machine learning under their belt. uh oftentimes will not have a good distinction of what are the good uses and bad uses because finance actually behaves very differently from a lot of other classical applications of
Machine learning. There's a lot of non stationarity conditions change all the time. Um you can think of this machine learning algorithm as like trying to learn about the world, but by the time it's figured out how the world works, the world has changed.
Um that's a classic failure mode. And also oftentimes machine learning algorithms operate in situations where the risk isn't really a huge problem. So for instance, if you're trying to like maximize the number of people who will respond to an email that you send out as a marketing
firm. Um, you know, there's not a huge risk necessarily in that case. Like nobody's directly losing money if you screw up. Um, I guess if you send out something really inappropriate in the email, then like you could face reputational damage. But Oftentimes machine learning techniques fit focus on maximizing reward. Um and and a big thing in finance is you need to talk about minimizing risk as well. So um we'll just talk a lot about kind of like
If you're approaching finance from a machine learning perspective, what are some concerns? What are some good applications? What are some bad applications? Um, and uh, you know, how to approach that. Excellent. And you're bringing in, is it Thomas for that one? Uh depends. I think Thomas may still be on vacation at this point. Uh I think I'm gonna try to bring in um Max, who's the guy who runs the lectures here for us, and and his background is in
um stats and and and all this good stuff. He's actually worked on uh startups before that were trading cryptocurrencies, cryptocurrency options, I think. So Um he has some really good experience and in in this kind of stuff and um is is is right up there with Thomas when it comes to uh evaluating these kind of
uh applications of machine learning. That's awesome. Well I'm keen to hear a bit more about his backstory too. That sounds uh pretty interesting. Yeah, so we finally convinced him to work here. All right, guys, well, thank you very much for doing this again. And Scott, awesome to have you on and get your input on these topics. So yeah, I appreciate it, man. Thank you. Thanks for having me on.
