 Going to talk a little bit about kind of the basics of options and options analytics and what I'm talking about is kind of plain vanilla your most basic equity options using and valuing them using the black shells framework. I'm going to get into some of the Greeks which you may have heard about which are sensitivities partial derivatives and then talk about how to kind of use Python and pandas to get real options data apply some of these methods to your data frame and do some math. So it's kind of a combination of mathematics not as much as the previous talk, but a bit stochastic calculus, so a little bit of overlap there. A lot of code and kind of some practicalities of trading options and how none of these models actually work in real life. So this is all on GitHub. I'll post it on Twitter and I'll post it on the meetup stream afterwards. I've got some links down here a little bit of an introduction to Python. Basically, what I'm trying to say here is that Python is becoming quite a an interesting tool in quantitative finance and quantitative analytics. I had a professor who's a research director at a QuantHedge fund in Chicago where I'm from and used Python exclusively to price some very very exotic and very interesting derivative contracts. You can actually find him on quant.stackoverflow.com. His name is Brian B. The man is absolutely genius. So I'm kind of all over, so you can stack, you can stock in how you want. I do have one website which is essentially curated resources for essentially deep learning, machine learning and finance that I post here. I won't go to there now, but feel free to visit. So I built this in a Python notebook and essentially just a walk through here, but a quick introduction to myself. So clearly I'm from the United States, or maybe not so clearly, but I am from the United States and from Chicago, which is actually consider the derivatives capital of country, the Black Shoals formula, actually people started trading that in Chicago and I did a undergrad in finance economics and computer science. I have a graduate degree in quantitative finance which I got in Chicago. I worked for a hedge fund trading interest rate derivatives. I worked for BP and I worked for Jason Morgan and now I'm a CIO at a global agricultural trading firm here in Singapore. So I've kind of gone to the dark side, as some people call it, meaning I've gone to IT, where actually being CIO has nothing to do with technology whatsoever. So I spent quite a bit of my free time coding and learning about all sorts of different things. So I'll start with some of the jargon. Just raise your hands. How many know the basics of options? Call option, put option. Okay. About half. So they're called a derivative contract because they're based, their values derived on an underlying security. So in this case, we're going to be talking, the underlying is listed equity options, Apple, Google, etc. So call option is a derivative contract that conveys the right to buy the underlying security at a specific time in the case of a European option, which we're going to be discussing here so we can use the Black Shoals framework to price them. At a specific price, the put option is exactly the opposite. So it conveys the right to the buyer to sell a security at a particular strike price at a specific time. You've got in, out, and at the money. So essentially an in-the-money option is when, for a call option, the stock price is greater than the strike price, meaning that that contract is conveying value to you. Out of the money is the opposite. At the money is when you're at about the same price. Implied volatility is actually something that's studied quite a bit. There's a lot of theories and papers about trying to forecast and predict implied volatility. It's pretty much the most interesting thing you can think of when thinking of plain-vinyl options and when you are using the Black Shoals framework, that's largely what you're doing is actually computing implied volatility. And what that is is essentially you're solving for a latent value. It doesn't actually exist. You're solving for that value using the model and the market option and the market price of the option. So you set those two equal and you keep putting in different values of volatility until those are equal. And obviously you use something like a root finder for that. We'll get into that. So for the Black Shoals formula, we'll talk about some of the input parameters. It's actually unique in the history of options pricing in that there's only five underlying values. Underlying stock price, the so-called strike price, time to expiration, the so-called risk-free rate, these four of what you're actually observed in the market. And this fifth, which is volatility, that's the volatility of the underlying stock price. So in layman's terms, you can kind of think of standard deviation of the stock price. That's one way to think about it, but the way that the stock moves through time. You all know that you can flip a coin and Apple might go up, Apple might go down. There's various ways that people try to model how stocks move through time. Generally, it's browning in motion, which is a stochastic process. That's how Black Shoals does it. But there's various different ways. So we're going to get in some code. Essentially, just do my imports here. I'm going to be relying pretty heavily on pandas, numpy, and scipy. And what we do is just declare each of these variables. So the five variables that we need, we take an underlying stock price. I basically create a vector of stock prices as well. Yes. Give me the fund deal. Yes. Better. Okay, and I'll see what this is doing. You'll see what this is doing later. This range is vector. We've got the strike price. We've got this time to expiration. So what this is saying, essentially is 164 days out of 365 days. So it's a fraction of the year. That's how the code is written. It takes a percentage of the year that's left to expiration. Expiration meaning then the contract goes away. This risk-free rate, so-called risk-free rate, 2%, which is actually like two basis points. But essentially, we'll just use it so we can just have some input. And then this kind of volatility figure, which is 25%. So the other versions, the most interesting thing here to note is I'm using pandas 17.1, 0.17.1. How many of you have not used pandas before? Okay. Very, very, very strong time series. I mean, I've been using this since 0.03. So to see where it's come from, where it used to be, is absolutely incredible. But it's essentially time series. It's very similar to the R data frame. That's where it came from. It actually instantiates from NumPy. So it inherits a lot of NumPy's attributes, models, features, et cetera. And then, of course, ubiquitous sci-fi. So we talked about options. Essentially, you've got everybody using options from professional traders all the way down to retail traders. So professional traders are not trading these kind of plain vanilla options. They're trading what are generally called exotics. I've got a link here to the Wikipedia page. These include all sorts of different options that have all sorts of different features. We'll see in a second what the payoffs look like. But essentially, options are defined by the payoff, by the payoff function. And the payoffs are generally actually pretty straightforward. So you'll see in a second what the actual black-shells model looks like, which is not nearly as simple as this. But this is the payoff for an option that is priced by the black-shells framework. So essentially what this is saying is that at the expiration of this product, of this option, the value is the maximum of either the stock price underlying stock price minus strike price, which is either a positive value or negative value. If it's positive, you take that number. If it's negative, you take zero. So essentially, if the stock price is greater than your strike price at expiration, there's value. If not, it's valueless. It expires worthless. A put option is essentially the same thing but backwards. So the value is when the stock price is underneath your strike price. The strike price remains constant the entire lifetime of that option. Strike price moves. So as it moves, at expiration, if the stock price is under the strike price at expiration, you've got value. Otherwise, it's zero. So this is easy. So why the big drama and why is black-shells so famous and all this? Well, it's not pricing the option at expiration. It's pricing the option before expiration. What's this option worth with 164 days left before it expires? We'll get to that in a second. So again, some code. So this is very simple. I created a Lambda function. So what I'm trying to do as well is kind of show some techniques in Python. So for those that are kind of beginner to intermediate in Python, I'm hoping that some of these techniques will come in handy for you. Those of you that are pros, it will look just kind of routine. So a Lambda function is essentially an anonymous function. They existed several languages. You can define it basically as a handler. I use a handler because I'm from MATLAB. But essentially you're assigning this function to this handle. And this is actually equivalent to this. So if you define a function with two parameters, it just returns the element-wise maximum of these two values. This is the exact same thing. And then we'll just plot it. So as you can see, and if you recall, I created that array of underlying stock prices. And that's for this purpose. So this was the low and this was the high. And what you can see here is that at expiration at a strike price of 45, as the stock price increases, zero value up until that strike price and then there's a linear payoff after. So there's only a linear payoff after the strike price. Otherwise, this is a nonlinear payoff function. And what you'll see is with black shoals, it'll kind of fit into this so-called hockey stick. So you might have, I mean, this is called a lot of different things, a risk profile, a hockey stick, payoff, P&L, all these different types of things. So this is the payoff. This is how much money the option is worth at expiration. And this is the stock price at expiration. So if the stock price is at 48 at expiration, the option is worth $3, which is 48 minus 45. The put option is the exact opposite. So it's literally a mirror image. In fact, there's a relationship called put call parity that exists that you can derive the price of an option, a put option using the call underlying stock price and strike price. Just a quick anecdote in Chicago where they started trading these things in the 70s, trading supposed to have some economic value. The regulators could not imagine a way that a put option would have economic value. Why would you ever buy a contract basically betting that the stock would go down? So they banned put options on the exchange and you could only trade call options. Well, you've got like PhDs down there, math PhDs and these incredibly brilliant people trading these options. So they essentially created a synthetic put option with this so-called put call parity. And that's how put call parity was essentially kind of made popular other than the mathematics behind it. But people are actually able to trade a synthetic put option by using only call options and stock. Okay. Any questions so far? Okay. So what is this black shells options pricing model? So there's kind of two things that you need to consider. I absolutely will not read that. This is for your consumption or complete ignoring later. Essentially, there's two things that you have to think about. The black shell model itself is a framework that describes a market. The actual pricing formula is derived from that market model. So that's kind of an important concept to understand. There are some assumptions that exist. So we're going to talk about the actual model that describes the market first. And there are some assumptions that the rate of return is riskless. And we learned in 2007, 2008 that there are really no riskless assets. I worked at JP Morgan and I sat next to bond traders who were actually selling U.S. government bonds at auction at minus one basis point. That means people were willing to lose money for the safety and security of U.S. government bonds. That's clearly not a riskless security. And surely enough, a lot of the interest rate models that existed before 2000, 2008, 2007, 2008 went to poop afterwards. I almost swore, but I ended. The other assumption is that the instantaneous long return of the stock price is a random walk. So essentially that browning motion holds. There's this thing called the Hearst component or the Hearst equation. I've heard it both ways. How many of you heard of the Hearst? H-U-R-S-T? That kind of measures if a time series is random walk or not. You can check that out. Oftentimes when you plug in stock return data, you'll find that it's essentially random. And the stock does not pay dividends. So there are adjustments to the Black Shields pricing formula that allow for dividends, but we will not discuss those here. So that's on the market. On the underlying security, there's no arbitrage opportunity. So there's no way to make a riskless profit. As we're seeing more and more with high frequency trading, that may or may not actually be true. It's possible to borrow and lend at any amount, even a fractional amount at that riskless rate. Nobody in here can go borrow money at the rate that the U.S. government pays. So that's not actually true. It's possible to buy and sell any amount and even fractions of a stock. So clearly you cannot buy or sell fractions of stock. And in fact, the government in the U.S., sorry, I keep going back to the U.S., but that's my frame of reference. In 2000, 2007, and 2008, they banned short-selling financial stocks. So that's not always true. And that transaction costs, transactions do not incur costs, which is generally not true. There are some sites out there now that allow you to trade for free, but in general, that's not considered true. So essentially, what this model does, and I just scraped this from Wikipedia, Wikipedia does actually a pretty good job discussing Black Shoals, so I recommend you going out there. But the model basically says it's possible to create a hedged position consisting of a long position in the stock and a short position in the option whose value will not depend on the price of the stock. So essentially, it describes a portfolio of assets, a money market, i.e. a bond, a stock, and some other thing that you can dynamically hedge through time. And that dynamic hedge is what makes the Black Shoals model a continuous model through time. It's this aspect of continuous hedging. When I was in grad school, we actually proved that this could not be true with any amount of transaction costs and anything less than infinitesimally small rebalancings of your portfolio. So essentially, it's practically impossible to implement this model in real life because you cannot continuously trade at every millisecond that a stochastic or a differentiable equation allows you to do, a continuous equation, nor can you do that for free. So a bit of the math, I promise it will not be that dense. I won't derive the actual formula, but this is the model. So this model is what is used to its derives to come up with the actual pricing model. So this model describes a market which, given these assumptions I've just described, allows it possible to create a hedged position consisting of a long position in the stock and the short position of the option. So this is actually this market framework. This is what Black and Shoals came up with. Another interesting anecdote on this, they try to publish their paper in some of the most prestigious finance journals of the time, and they didn't actually get accepted. So they got denied a publication. So they publish their paper as a way to value employee stock options. That's the guise that they used to unleash this formula and this model on the world, and it was published in some corporate liabilities paper. So it's a very interesting story if you're into that kind of thing. So nonetheless, the derivation is fairly long. If you know stochastic calculus and you can apply idoslemma, it's not entirely difficult. If you're rusty or you cannot, then it is very difficult. But nonetheless, you end up with something that looks like this, and while this is continuous, this is a close form solution. So this is an extremely important result because guys were on the trading floor with their programmable calculators, valuing options. And these guys, the Black and Shoals went to work for Goldman Sachs in the 70s, and they just destroyed the market because they had the best price. And through time, the traders on the floor were literally sitting on the floor with calculators, their programmable calculators, inputting the five parameters that you needed coming from the stock of an option price that was better than anybody else's, and you just imagine how much money that they were making. So in short, this is all you really need to know, and this is very, very easily programmed in Python, which I'll show you, or any programming language for that matter. There's a website that shows you how to program Black Shoals, I think in like 30 or 40 different programming languages, like the most archaic things you've never even heard of, like God, I can't even think of one. I'm going to say a name like Cobal, and some of the guys who have programmed Cobal are going to try to slap me afterwards, but if you haven't seen Cobal, I mean, Cobal is pretty tough. So if you're used to these high level abstracted languages like Python. So then the last, this is the formula. These are the input parameters, and let's see in code. So essentially this n, that's this, is a normal cumulative density function. And with that, you've got your Black Shoals formula, which you could probably do in one line of code, but I broke it into three for a little bit more readability. This should roughly follow this up here, and by the way, this is latex as well. So if you grab, if you grab the notebook, you can double click and you can see how the latex works. I know you're asking about that. High Python notebooks, i.e. Jupyter, you can get support latex clearly. So I'll use the Black Shoals call. I don't agree with this, this Docks string particularly, but that's how PyCharm does it, so I left it. And then the put value. So this is it. This is it. Literally six lines of code, and you can code up, call and puts. And you can see if you can put some parameters, you get some numbers. So it's interesting to note here that if, back to our payoff function, if you had a, if you had a option at expiration, that was worth $3. If you had a strike price of 45, and you had a stock price of 48, there's $3, right? But it's not $3, it's $3.20, right? And in the other way around, if you remember that the put option payoff, this should be zero, right? But it's $2.79. And what this is called is time value. What, you know, it's described many different ways, but essentially what that's doing is it's the optionality of your option. It's the probability of the option actually finishing in the money. So there's value in that. There's an opportunity for that stock based on the volatility to increase over that strike price or decrease under that stock strike price. So that's how, that's what the Greeks describe, which we'll talk about in a second. But it's just interesting to note. And what we'll see here is I basically created four arrays. So by the way, this is vectorized. So you can plug in an array of any one of these underlines and you'll get the output as an array, which is very useful when doing this kind of stuff. So basically what I did is I input this s underscore, which is that array of underlying stock prices. And I did six month expiration, three month expiration, one month expiration, and then at expiration. And I applied them. And what you see here, this is the call option, is this is identical payoff function that we saw above. This is the value of the option with one month of time left, three months and 12 months of time, six months of time left. And what you're seeing here is what I tried to just describe is the time value of the option. So this is why the black shell's formula exists and why it's important, because it doesn't just give you a price at expiration. It gives you a price six months from expiration. So that's why the black shell is important. And that's why a lot of these pricing models that the quants come up with are important is because they give you the opportunity to price these things before the payoff actually hits. So the Greeks are, I won't go through these, although they are extremely important, but this talk isn't, I don't want it to focus on the Greeks necessarily, but they're essentially the partial derivatives of the pricing formula with respect to the inputs. So V in this case is the value of the option. So the partial derivative of the value of the option with respect to the underlying stock price gives you delta. There's a different formula for calls and puts. The second partial of the value of the option with respect to the stock price, otherwise known as the convexity, if you ever study bonds and bond pricing, that's described this way. So that's basically how delta moves through time. Vega, which is described as volatility, is how the stock, excuse me, how the option price moves with respect to changes in volatility. And then theta. So theta is exactly what you might expect, how the option price moves with respect to time. And that's also called time decay. And then of course you have rho, which is the same thing with respect to the interest rate. When interest rates are normalized higher than they are now, it's a little bit more interesting to see how options move with interest rates, especially when you're pricing bond options. Plain vanilla stock options, not so interesting, especially when interest rates are trading in like time basis points. So then I could just go on and describe kind of what the input parameters are. Same as before, we describe the Greeks and Python. So literally it's one line of code here. It's so beautiful. It's even kind of scary. So I think Einstein said elegance is for tailors, right? When you're doing mathematics, that's often the case, but sometimes you just can't deny beauty, right? Okay. So again, I just print out some of these values. You can unit test these. I actually unit test them, but I didn't commit to the changes to GitHub. So I don't have them. I used just a website called 888Options. They weren't very interesting anyway because I just had four decimals and I just put this formula equals 5546 and it wasn't that interesting, but nonetheless you can do that. Okay. So implied volatility. This is kind of where the meat of the talk is. Essentially, the Black-Scholes formula isn't usually used for pricing options. If you were to trade using the Black-Scholes formula, you would lose money very quickly and then you would no longer be trading. So what it's usually used for is to extract this latent variable out of the market. So implied volatility is something that's estimated. It's an estimator. It has a range, you know, statistical significance and a confidence interval, theoretically. But people will use the Black-Scholes formula to take the actual market price and extract out the volatility input parameter that we saw from above. And that's called implied volatility. It's the volatility implied by the market. And this is really where Black-Scholes is used. I do have a blog out there where I talk a lot about this stuff and I implemented a very similar thing in C++. So what you can see, the thing to learn in this blog post is how to integrate C++ models with Python. It's actually very easy. You have to write a little wrapper code, but it's very interesting to see that. I spent all this time, there's a numerical recipe book in C++ and I found this Brent algorithm and I spent all this time modifying it for Black-Scholes and for options pricing and then I found out that the sci-pi implementation is like exactly the same speed because it's actually the exact same model. So, shame on me for not checking that first. But nonetheless, so we need to do two things here. We need to create this objective function and what this is is it takes the market price, so $3.20 in terms of the call, subtract it from the model price. So essentially what this is doing is if you put in a volatility of let's say $0.25 and you have some error here, that means that the market is not using the same volatility input parameter as you are. So essentially all we're doing is using this root finding algorithm to find what volatility input parameter do you need to set this error to zero, meaning that the Black-Scholes model price equals the market price, meaning that you have found the implied volatility. So that's essentially what I'm doing here. So you've got the objective function and then you've got this implied vol function and really the money is this right here, one line. You put in your function, which is the objective function. You put in a lower bound and an upper bound which is fairly easy because at some point you don't care if implied volatilities are like negative 5% because that's impossible, or way out to 5, which is 500%. Eventually you just cut it off and then you interpolate, which I'll show you how to do. So essentially I'll let you look through this. I don't even know how much time I have to talk about this for days, but I'll just leave it at that. So essentially this is just kind of some coding, some writing an algorithm how to do this, but this is really the money right here. This is the method from SciPy that allows you to solve this objective function. Same thing for the put, I just did it separately. And then what you can see here is call implied volatility, if market and model were equal, it should be close to 0.25 and it is exactly 0.25. And the reason it's that is because I just took the actual model price and plug it into the implied volatility formula so that the numbers were identical. So it's just a way to check it out. Okay, so that's a little bit of the theory and how to apply that theory in Python. So let's talk about getting data. Pandas, if you haven't seen pandas you need to go check it out like tonight. So pandas has this interface on how to gather all these data. You can download stock data, you can download economic data from the US St. Louis Fed website, you can download Google Analytics data, you can interface with SQL databases, you can interface with HDFS, you can interface with H5 files, all sorts of different interfaces. It's quite good. So to get the entire chunk of options that are trading for IBM, this is the code to do it. So you instantiate an object and then you call this method and then you've got this frame. This takes a while because it has to literally scrape through every website. So you can pickle it. And what pickling does is it essentially saves your data frame to an object, a flat file. It's very fast, very efficient. So I've just done that to show you how to do it. This is how you read the pickle. So you save the pickle and you read the pickle. And then you've got identical data. So assuming that you don't want to have to go out to the network every time or you want to test some things with the same data, you can do that very easily here. So what does it look like? This is what it looks like. So these are the attributes that we were able to pull down. It's a little bit over 53 kilobytes. It's a multi-index. That's what it's called. And this is what it looks like when you print it out. So the strike, for each strike, there's a series of expirations. You've got puts and calls. I just took the top 10 results through the top five. So we're going to do some work to clean this up. We're going to remove percent change. We're going to move Yahoo's version of implied volatility because of course ours is better. We're going to rename some of these columns just because I'm weird like that. And then I'm going to rename them and then re-index them. So essentially what this is doing is just what it looks like. Renaming these columns and it's deleting these columns. So we're going to apply some function. I'm going to show you how to actually apply functions row-wise. So you take a row as an input to a function and then you can do some stuff to that input and then output of value. I'm going to show you how to do that. But first we have to kind of create these methods. And I'm just going to fly by these quickly. What do we need to apply the Greeks, black-shells, implied volatility? That's what we're trying to do. So we need the days until expiration. We need the fraction of time and years until expiration. We need the interest rates. And I've just made this done this really cheap. I think these are the treasure rates and these are the swap rates. In real life there's a lot more nuance to creating a yield curve, continuous yield curve. But for argument's sake we just use this. Essentially I'm interpolating this. So this is every month. 30 days, 90 days, 120 days, etc. 180 days, etc. So what if an option falls at 137 days? We're essentially building a yield curve and then we're allowing ourselves to pick an interest rate anywhere on the yield curve. And I use the one-dimensional interpretation, interpolation method from sci-pi. There's a 2D, there's a cube explain. There's all sorts of different things you can do, but I just made it simple. Okay, get the mid price, which is the middle between the bid and ask. That's just the price essentially. Okay so this is how you do it. So I want to create a new column in my data frame and I'm going to apply a function row-wise. That's it. So I do that four times and then I have, you can see down here, my new columns. 519 non-null values. Days, time, interest rate, admit. And then you can kind of see that out here what that looks like. Okay so a little bit under a half year, a little bit over a year, etc. Okay so implied volatility. So we go back to the same concept of applying functions to or mapping a function to a data frame row-wise. The thing to note here is that I'm kind of generically calling this function by a string. So I'm passing an option type, either call or put. This allows some dynamic nature to this method. And then I'm formatting, or excuse me, I'm actually creating a method named string. So this will be call implied volatility or put implied volatility which is a string name of the function. And then I call that function against the globals. I think this is a dictionary. So globals are all the variables that are defined in your in your namespace. You can use get and then you call the method name and you can apply your variable. So this is actually a really useful kind of bit of code. I use it quite often. So I'm going to apply and I now have my applied volatility and I will take a look at what it looks like. And there we go. So implied volatility of 0.45, 0.41, 0.33, 0.42. Those are all very very reasonable numbers for implied volatility. I think I took these data yesterday, stocks in the U.S. in which IBM trades are absolutely tanking elsewhere as well. But specifically IBM has I think come down like $15 on a $145 stock. So the volatility is elevated. Normal volatility range for this stock is a big blue chip stock, maybe like 20 or 25% or trading at around 40, 45 essentially for these options. You can see an NAN value which I'll get to in a bit. So back in my interpolation function I've specifically cut out a whole range of different potential values for implied volatility. And the reason I want to do that is I want to show you how you can interpolate implied volatility. Professional traders will often do that. They'll take the most liquid points on a curve and they'll use that to create their own curve with some proprietary models. All I'm trying to do here is just prove the point. So you can see how many are actually NAN, so a few. And the question is really why, right? So we're going to use some data science and kind of what used to be called quantitative analytics but now the sexy thing is data science, otherwise known as statistics I think. So we'll talk about data science in a second. But first I've got this interpret implied volatility method which essentially does all this fancy code that I could have broken out into 30 lines but I didn't. But here's really what we're doing. Unstack is a way to create a pivot table. I'm interpolating the values and then I'm forward filling and back filling. So you take the last value that you had. You can't, so extrapolation is where you go out further. Interpolation is when you have a series of numbers and there's a missing number in the middle. We're not extrapolating here. We're interpolating inside and then we're just taking the last value out and filling in the NANs. And all I did was just, I just wanted to demonstrate these two methods because they're pretty common when you're dealing with time series data or other panel data. So essentially all we did is fill in the NANs with some sort of linear interpolated data. Okay, so and you can see that there's no more NANs than NANs. Okay, we follow the same thing and apply the Greeks. I'll skip this because I know you guys all want to hear about the data science. So here we are. We're back to the theoretical value, the delta, gamma, vega, theta, rho and model error and you can see that we've applied each one of those to the data frame. So this is actually really powerful. I mean 10 years ago or 15 years ago to be able to get an options chain like this, first of all it was expensive, second of all you had to write it in a compiled language, not necessarily an interactive language. You could have probably done it in R or even Python, but not in one line of code. You could not get an options chain in one line of code. You could not apply implied volatility, you could not map an implied volatility method to 519 options and it takes, you know, a few seconds if that before. So this is very, very powerful stuff and then you can see I just print out the frame again. Okay, so data science. So we've got these model error, right? You'd expect that if we're using black souls to come up with implied volatility and then plugging implied volatility back into the model, we would expect that there would be no model error. The mid price that's in the market would be the same as the model that we're coming up with. That's largely true, but not entirely. So a lot of zeros but there are a few that aren't zeros. So this is 50 cents, that's a dollar, that's one and a half dollars. So there's some fairly significant model errors here. So we have to form a hypothesis on why we think these model errors exist and then investigate those. We're not going to do it statistically rigorously, meaning that we're not going to do like statistical significance or anything like that, but we still want to walk through the steps. Okay, so basically what I'm doing here is a few things. So first of all, mapping the absolute value method to the model error to just make it static or the absolute value. Then I'm sorting. So all I want is the top 50 errors and then I want the top largest by strike because what I think is going on is that way out of the money options are giving us big model errors because the market makers get that bid ask spread very wide so that you have to pay up for that option. I know that a lot of that probably doesn't make any sense to you, but we have a hypothesis I guess to my point and what I think is way out of the money strikes are creating model error. So I want to test that. So indeed, I do some fancy stuff here with Python and I can see, I know it's hard to read, but the at the money strike is about here. There's no error, right? Our error occurs down here where we're way out of the money. So 115, 110, 100, etc. So this is evidence to suggest that I'm correct. My hypothesis is correct that the model error appears in out of the money strikes and indeed it looks could be following some sort of linear relationship as well. It probably be pretty weak, but nonetheless you can probably see it. Okay, so again, my hypothesis also is the wider the bid ask spread, the more the model error. Essentially what happens is the farther out of the money you are and I talk about this here. I talk about all this here so you can just read it and you'll find out. The farther out of the money strikes are, the wider the bid ask spread. So it's kind of doing the same thing, but nonetheless you can see spreads should be like 10, 15, 20 cents. $3, $4, $4.50, $5. So we're getting model errors that are quite big when we get out very wide bid ask spreads. This is data science in this kind of stuff. And then just because we all like scatter plots, I plotted a scatter plot and there's not enough, obviously there's not enough samples here to make any conclusive remarks, but you can see visually you can kind of fake it and say that there's probably a linear relation between model error and bid ask spread. So as the model error gets larger, bid ask spread is also getting larger. Of course, correlation is not always causation, but in this case it makes a lot of sense. So then we'll look at implied volatility, which is actually the title of the talk. So this is this famous implied volatility skew. If you can talk about implied volatility skew at the pub, then you're generally considered kind of in the note. And you often see shapes like this. This is actually called more like a smile. I just call everything a skew. But essentially what you're seeing here is a direct violation of the assumptions in the Black-Scholes model in the framework. It assumes a constant volatility. Clearly there's not a constant volatility across strikes. This is very clear. So this violates the Black-Scholes model. This is why you don't trade the Black-Scholes model. Because if you use this volatility and you plug it into the Black-Scholes model and the volatility should be somewhere else, somebody will pick you off and you will lose money. So the actual at-the-money strikes are around here. So we see that at higher strikes there's a lot less volatility. Another way to think of implied volatility is kind of the lever that people use to increase or decrease the price of an option. All else held equal. So if you hold all the input parameters equal and you increase the implied volatility, the option will become much more valuable and vice versa. So you can see that people are thinking that options around these strikers are not that valuable at the moment. Nobody's buying call options at these strikes when there's intense volatility in the market and the stock is trading here. That's kind of what this has shown here. This is actually quite a phenomenon. This was not observed in the market until after the 1987 market crash in October in the U.S. There's a Black Monday. There was a market crash. And this skew, if you will, in the term structure, which we'll see in a second, actually didn't exist before that. I think after that when people got their face ripped off, which is a saying in finance, when you lose a lot of money, they started rethinking how options should be priced and repricing options. And it's actually a pretty incredible phenomenon. Just imagine you're sitting there one week and it's flat skew and then two weeks later there's this giant curve and you keep seeing that over and over and over again. That's what kind of researchers really get excited about is finding this stuff in the market. And then we build the so-called, well, this is just a multi-expiration skew. So these just represent different expirations, okay? So you can see that way far out. So this is like two years from now. Over two years from now, the expiration, very low volatility because people think that in time, volatility will subside and they're pricing these options very low. There's not much demand for these options straight out. And you can see as the time gets smaller, the volatility gets higher because it's right now. I need this right now. Okay, and the so-called term structure of volatility, again, it's not constant clearly. So you see there's extremely high volatility. This might actually be because there's like only a very, very few days left on these options and this will go essentially to infinity when expiration goes to zero. But you can see that it generally flattens out and this also could be a function of the interpolation that we did. But you can see there's a curve. This is called the term structure. And this tell us traders things as well. Essentially it's like the forward markets, excuse me, it's the curves, backwardization and contango in the futures markets if you're familiar with that. It kind of helps understand where the demand is across time and how much it costs to carry such an option or a future. But in this case it's more of the demand. Okay, and lastly, just because I can, I plotted a 3D surface which just looks like a blob of nothing. But this is actually, and it's not even that useful to be honest with you, it just it's very famous. Everybody loves the volatility surface. And for us, right, for retail kind of traders, it doesn't do anything for us. Professional traders, it does. And I'll explain it in a second. We've got days to expiration, strike price and implied volatility. And not only does this not tell us anything, but it's like almost impossible to read because it doesn't have grids. So the point of doing it is just to show you that you can. So I use this CoolMesh grid function and kind of, you can just look at the code and figure out how to do it. So what people will actually do with the surface is if I have an option that I'm creating by scratch, right? So it's not a standardized option that trades in an exchange. Somebody calls me and says I've got this terrible financial problem. I need an option to hedge my risk, but I need it at 462-day expiration and a $141.36 strike price, which doesn't exist. What I do is I create a surface and I'll create models that will basically make this very smooth at every penny. And what I can do is I can I can go and say, okay, 442, 142. Here's your implied volatility. I've used this surface. It's called calibration. I'm calibrating this option that you want to the surface that I built that is generally observed in the market. So that's how the surface is actually used. It's used to price other options. You don't just sit and look at it and make like these brilliant trading decisions. You use it for pricing other options. So that's what the surface is for. Okay, any questions? Yes. You completed your presentation. I did. It's a very ignorant question. I always wonder this option thing, right? If the option is in the money, does it mean that the seller, the option is the loser and the buyer person? Yes. If you are a buyer of a call option and that option is in the money, you have the right, but not the obligation to buy that option at the strike price. If you're the seller, you are obligated to sell your stock at the strike price. So yes, you are correct. If you sold me a call option and it's in the money, you lose. Doesn't it mean that both parties are betting against different directions? Yes. That's a fundamental aspect of the markets is that you have to have people that are willing to take either side of the market to provide what's called liquidity so that anybody can come in with any trading decision they want and get the security that they're looking for. And the other piece that we didn't talk about at all is that you can combine options to create what's called complex options positions. So you can, one of the powers of options, I'm going way deeper than your question. Apologies, but I just can't stop sometimes. One of the important things of options is that you can control your risk profile. You know exactly what you can lose and exactly what you can make at any time. Okay? So just because you've sold me the option doesn't mean that you're not hedged somewhere else and it doesn't mean that you don't own another option to offset that as well. Yeah, but doesn't it mean that both parties are using mathematics, they are diametrically opposite pointing? Well, they're using they're using mathematics to come up with what they think the value of that option is. So there's a fundamental assumption underlying this. This is what they call arbitrage-free price. So for every winner that has to be lose it, that's the implication. So I guess the way to go about doing this is to manipulate the price at the expiration date. Well, never say manipulate. That's not exactly correct. Otherwise, we've seen in Singapore, like the authorities planned out, the markets basically like don't know if they're doing any trading. Right and exactly. So I know your currency, your currency doesn't move much, right? And the lack of volatility in the market is the bane of any trader. No, no, I used to trade it and I didn't even come to work because the bonds would trade in five tick spreads and I would just sit to be all day. So I'll just leave. So you're exactly right. And I should have prefaced this with don't try this at home because it's not a simple kind of thing. But you're fundamentally right. So if you sell me an option and you don't have any, if that's the only thing that you've done, you actually have infinite risk. Because if you've sold me an option, meaning that you are obligated to sell me that stock at $50, okay? Let's say the stock price goes to $500 and you don't own that stock. You have to go buy that stock at the market at $500 and you are obligated to sell it to me at $50. If that stock goes to $1,000, if that stock goes to infinite amounts. So in a theoretical sense, if you have what you're describing as selling a naked call option, you have infinite risk, which is why brokerages generally do not let you do it. Okay, the other thing to realize is that not only does this formula price the option, but largely they hedge the option. The delta function and the gamma function essentially price your risk at a point in time ahead of expiry. So that's the dynamic hedging that makes this extraordinary. It gives you an arbitrage free price, but it also allows you to hedge your option position, to hedge that risk. And there's cool things called like gamma scalping and gamma delta hedging and vega trading and all these really fancy sounding things that are exactly how we describe. So you can use these parameters to hedge away 80% of the risk of an option and only be exposed to the part of the option that you want. This is a very, very powerful tool if you use it correctly. And we are literally just scratching the surface. I mean this is a fairly broad introduction, but it's not very deep. It's just kind of the basics. Holland White, there are options and derivatives and swaps and whatever that book is called. That's kind of the bible. If you google Holland White, anybody help you with the name? Yeah, I'm just trying to... I always forget the... That's like swaps options and there it is. Futures, options and other derivatives. This is the book to read covers, well, options, futures and other derivatives. Anything else? I guess? So if the market is very volatile, I mean that came from my first experience. So buying both, call and put at the same time will be beneficial? Well, if you buy a call and a put, that's called strap, right? Yeah, so I mean, let's say the market is at 100. So if you buy a book for 90 and call for 110. So if the market is really volatile, that which I mean surely some of you could, right? So what you're describing is basically composing complex option conditions. So you can combine different types of options and different strikes and different expirations to basically design the risk profile that you want. So I don't know what buying a 100 call and a 100... You could do a 91 tenths, right? Could be. Yeah, could be. But what you'll see is literally this payoff will look different. So a straddle would be like this. And what you're essentially doing is betting or... Sorry, that's the other way. This, yeah. You're betting on volatility, meaning that you're betting that the stock will either go way up or way down. So you're not even exposed to the underlying, you're exposed to the volatility of the underlying. So that's another example why options are powerful. Is the market really volatile? Everyone in the market is sending the option notice for the price up. Just to the point that on average, an arm wins or loses is a kind of efficient market. Exactly. So the trick in what professional option traders will do is they'll have their own volatility models. They think that their model is better than the next guy's model. And when they plug in their volatility metric, they will get a better price that's more reflective of reality. So if they think implied value is 20%, the market is implying a 25%, then that option will be underpriced. So they will take a bet on their model and they will buy that security in, sorry, sell that security in anticipation of the market volatility coming down. Meaning that they think their model is better than the market. And the market will eventually revert to what their model says. So are you having one? Are you writing a script to do your trading automatically or are you doing it manually? I've done both. So I think trading discretionary trading is a losers game. You'll never win, especially when you have a day job. So what you can do is you can create models that will trade for you. Doing that in the options market is extremely difficult. So I've never actually traded live money. But there's a site called Quantopian. We've heard of Quantopian. Quantopian allows you to build stock trading models, back test them in Python. It's actually pretty incredible. Interactive Brokers has an API that you can connect to. And you can send any order that you want to the market. And actually Quantopian, you can trade against your Interactive Brokers account as well. You mentioned a few times about what is the surface and how generally traders build their own models on top of that. Because this is very basic and then people build more. I'm just wondering what point are they trying to get to? Well they're trying to, so a couple things. It depends on the purpose. So the example I described here was that they build a surface to price other options. So this would be an investment bank selling complex derivatives to an institution. Big money trades, 100 million dollar notional values, things like that. That's one example of why they're trying to build a model. So that they can price other derivatives correctly. That's important. Or they can get a better price for the same derivative than the other guy. So Goldman wants to sell you something. So does UBS. Well if UBS is a more accurate volatility model that that price is lower, you're going to buy that product from UBS. The other reason is for proprietary trading. So I use a very simple interpolation. I've got down here in the references section this article from NAG, Numerical Algorithms Group, and they used their proprietary numerical algorithms library, which is actually very expensive. You can get a demo version. And they did exactly what I did. Only they used a much more sophisticated method of smoothing the curve. And in that case, if you think your model is better than the next guy, then you will trade using your input volatility, your volatility input, and you'll trade on the difference between the price and the market. That's how professional traders do it. They're not going to buy a call option with the hope that Apple goes up. They're going to do what I just showed you on just a much more sophisticated level. Another one? Yes. Is it true that all these models is built based on backward looking data? So you have to trade the model using SSTing data. Pastime series? Actually, no. If you look at the model, this one particularly, it's completely independent of any past data. It has five input parameters and that's it. So there's actually no training whatsoever. And that's another beauty of the model is that you don't need any historic data. It's a completely closed form. But the volatility is dependent as well as the underlying and the coefficients will come from somewhere, right? You're right. So that's possibly a view of the underlying. Yes, the volatility is generally estimated as a standard deviation of log returns. So you're absolutely right. If you're using a very naive way to estimate an underlying's volatility, you take 252 returns. You take the log of that and then you take the standard deviation and you multiply it by a square root of 252. And that square root of 252 actually comes from Black-Scholes. But you're right. But that's only one way to estimate volatility. With the model, the model assumes kind of what the future looks like. So the model assumes a geometric Brownian motion of the stock going forward. That's just an assumption. Did that answer? You can plug whatever volatility you want to plug in. So like if you estimate the historic volatility at 20% and you think IBM is going to go for a burden or go through the roof, then you plug 30 and that tells you if the market price then is cheaper than the price you're getting from your model as long as you buy it. That's literally what I did. I just plugged volatility .25. There's literally no reason I used 25. I just used it. But you're right. It's just one method of estimating volatility and generally volatility estimators are based on the historic data. And this, if you do that, I mean it's an estimator, right? It's got its confidence level. It's got its statistical significance. So there's issues with this, which is why it's not generally used. You usually use the model to imply the volatility from the market. Did that answer the question? So you can like plug in anything you want like GDP or weather. I mean there's got to be an economic foundation to why you're using that number, right? You probably wouldn't put in like 34 degrees for an implied volatility number that takes, you know what I mean? You have to have some sort of economic foundation on to why you're using that, which is why you generally use that standard deviation number because it's easy to understand. It's generally accepted as a risk measure for the underlying stock movements. So did you say that the underlying assumption is that price movement is a Brownian motion? The model assumes that, yeah. So as in science it moves randomly around? That's what you mean? With a drift and a volatility. So if you think of, you know, the Wiener process, right? So that's just no drift, no volatility. Geometric Brownian motion kind of extends the Wiener process and it adds a drift meaning that it's got some average, meaning that it kind of on average goes up or average goes down. That's what drift is defined as. And some sigma or volatility parameter dictating how tall, you know, how big the spikes are. Of course, real stock price is determined partly by the financial forecast and the actual results. Yep. And whatever market manipulation and the economic, macroeconomic things, that's the way around. You're absolutely right. So the model clearly does not capture all that. But that's a model, right? So the financial models cannot capture all that. They're mathematical models. And like I mentioned earlier, there are other processes. There's a jump to fusion process that assumes that there's some probability of the stock jumping at some point in time. It uses a Poisson distribution. That's actually a little bit better because stocks do jump. They gap up, they gap down. So that's another model that you can use to model stock prices. But you're nailing it. You're absolutely correct. It does not capture the reality, which is true of any financial model. Which is actually why machine learning is becoming much more compelling for pricing these things. That's becoming, as you can imagine, kind of a hot topic. There was a hedge fund, I think, that was trading simply on sentiment from Twitter. It blew up. But nonetheless, it tried. I think it made money for like six months. And it was significantly different than random. So it actually had some significance, meaning that it was actually able to glean some information from Twitter. Sounds reasonable. I don't think it was there. It goes back. It was probably five years ago. Oh, there's a Russian in Singapore who said that he was traveling there with a customer. Using social media to give trading directions for hedge fund? Yeah. I mean, it's happening. The Bloomberg Professional Service has that. I went to a talk in London from a guy, the head data science, or the head machine learning researcher from Bloomberg. And he's trying to crack sentiment analysis, and he said it's extremely difficult for a British entrepreneur. I don't know, but still, my professional leaders would be sharing their trading directions on social media. Unless they want to influence the market. It's open source, man. Open source sharing ideas. Actually, the best argument that I have to pick is here in Singapore. It's better than yours. Yeah. It's pretty hot. Okay. So it's okay. Interesting. Talk to this guy. The truth is very, very few trading algorithms actually make money. That's why a lot of them share. Anything else, guys? Yes. Is the volatility of the stock effective by the percentage of shares that are actively traded, like the short-term market, because I imagine out of 100%, not all of them are actually changing hands quickly? Yeah, I would imagine. I don't. I can't say I've got empirical evidence to support that, but I certainly think they do. So usually, the fewer shares that are outstanding, the less liquid, meaning the fewer people are trading. And the less liquid the stock, the more you're going to see it jump. And that's usually true of smaller stocks. They'll have fewer shares outstanding, fewer trades per day, and that'll contribute to the increased volatility. And then those options will become much more expensive. Encovered by this model, or would you have to model that separately? No, I would. So what you could do is come up with this value here, the volatility parameter. And this, instead of, I can't type in here, but maybe instead of 0.25, you might have 0.5. Or 0.75. Or 1.25. And that's how you would incorporate that information into the model. Okay? Any more questions? You have a few more hours before the U.S. stock market. Get your accounts open. And we'll come in all the more days. Thank you very much, Jason, for your presentation. So, two more.