 So nine years ago this summer I had a freshly minted PhD in finance from the University of Arizona and I was about to post to my first academic job at Utah State University and my first academic teaching assignment was to teach the graduate level sequence in econometrics and to tell you the truth I had a little bit of PTSD for my own learning experience coming through graduate school with that particular sequence and I was searching about for a new way a new a new way to teach econometrics and deliver it and as I was searching I was very fortunate to come across this what to me is very important paper by Peter Kennedy and Kennedy contends that we should teach statistics and econometrics especially the convergence concepts asymptotics with Monte Carlo simulation and that this helps the students bridge the gap of the concepts and connect with those concepts in a much more meaningful way than just the symbolic mathematical representation. He contends that most students after even several courses in statistics and econometrics don't fully internalize the main ideas of econometrics and my teaching experience is that that's very much the case and he points out that the the crucial concept for students to learn that defines statistical thinking as separate from the mathematical representation is that of the sampling distribution concept and simulation with the Monte Carlo method is particularly powerful tool for that. This paper sent me on a nine-year intellectual journey that I'm going to share with you a little bit about today but let me start with a demonstration. Imagine that your students of mine maybe an introductory statistics or econometrics class and my task on the day is to teach you about the law of large numbers. I could put up a definition from a textbook like this with some some words and a definition some mathematical representation. I could go more in depth with probability conversions concepts but my experience is when I put slides like like this one and the next one up that my students I as glazed over and I they don't connect with the material in any meaningful way and I tend to lose them. Imagine instead that I just start with a simple example. Everyone's seen the the example from a baby statistics class of starting with rolling a fair die that has six sides and equal probability for each of the outcomes. We can calculate with simple mathematics the expected value of the population of being three point five. Of course we can verify this in in Python with some simple calculations so that the students can verify this for themselves. But even more meaningful I can only after a little bit of instruction about Python have them run a simulation like this. So what this simulation does is it rolls the die a certain number of times and takes the average and what we see plotted is on the horizontal axis the sample size and the dot on the vertical axis is going to be the average taken from that side. So they say don't run code in presentation but I'm going to risk it. So imagine that we start with sample sizes one to ten. So each of those ten points is an average taken from rolling the die that many times. And what I can do for my students is simply increase the number of sample size runs that I do and you can start to visually see the convergence. If we go to a thousand the the story begins to be pretty clear here. We can see this fight. I'll stop at ten thousand because I don't want it to run and run. But in the in this funnel like shape of the graph the students can immediately play with and interact with and connect with the concept of the law of large numbers here. We see that the sample average as the sample size increases converges to the true population size. So my experience has confirmed Peter Kennedy's contention that teaching with simulation methods is a powerful pedagogical tool and I'm going to talk about how I've incorporated that in teaching computational finance. So the year after I arrived one of my next academic assignments was to create a new course that hadn't been taught before in computational finance for our master's program. But this this created a bit of a conundrum because most of my students had never programmed before. They are trained in economics and in finance and have never coded before. And what I wanted to avoid was the situation where at the end of the semester they feel a little bit like Delmar here. I don't know if you've seen this particular clip from this film but Delmar is a little left out of the storyline. And I don't want the kinds of abstractions that they're going to see in programming to leave them behind. And what I want to do is use this as an opportunity to help them to learn to think in a new way. And so one of the question becomes what is the adequate level of abstraction to think about options and option pricing which one of the topics that we're going to to learn about in the computational finance course. By and large the students come into my course with pretty strong math and statistics skills. Pretty deep background as far as that goes. But as I said most of them have never done any kind of programming. And so my job is for the first third or so part portion of the course to teach them to program. And my objective is to use this as an opportunity. It is certainly a challenge but it can also be an opportunity to help them to learn to think in a new way that will augment and add to their mathematical and statistical thinking. This has been referred to as computational and inferential thinking. And of course Python is an excellent tool for this. It's designed for learners but they'll never outgrow it. And so it's been a very powerful tool for the first third of the course to get them up to speed in basic programming and then to launch into computational finance concepts. And again as I say I want to have them rather not just having a list of skills on their resume. Python is wonderful as you know but I want them to leave with a new way of thinking about the world. And whereas Kennedy is oriented towards econometric students and he wants them to think about the concept of the sampling distribution which turns out to be perfect for teaching econometrics at least of the classical variety. I need to adapt this a little bit. I want students to think about what we might call the predictive distribution because in finance we're always predicting forward a random variable, a random outcome. And I want them to be able to think about the payoff of an asset in terms of that predictive density but I can make a strong connection to Peter Kennedy's sampling distribution. And the Monte Carlo method turns out to be a very powerful tool for that as well. So I'll ask you if you can it's a little bit hard for those who have many years of experience but to think back to the time when you were first learning to program for the first time. And you came across concepts like variables and control flow and functions and how these new kinds of ways of thinking, these new abstractions sort of changed your brain a little bit, rewired your neural network. And I get to see this every semester as the students come in and are learning to think in a new way every fall semester. I myself learned to program with these intro books and they were wonderful with little toy games. So I'll ask you to think about what it was like to be a student maybe sitting in my class. I also remember the summer that I decided to dive into Mark Joshi's book on design patterns and object-oriented programming for option pricing. And I wanted to be able to deliver this to the students but in a more accessible way. C++ would be a very powerful tool. It's a kind of a gold standard in computational finance. It's a little bit inaccessible for my students never having programmed before but I wanted to sort of introduce some of these concepts especially the idea of design patterns with object-oriented programming. And so I want to introduce you to the module that my students and I build each semester together from the ground up. It's for educational purposes, it's to help the students understand a little bit about how to do some design in their programming oriented towards option pricing but it's not really geared towards production or research. Although on my last slide I'll mention a project that's moving Probo in that direction. So the first place to start is to help the students conceive of an option contract outside of their textbook in some representation in code. And so I begin with them with the facade design pattern. And so here we have the option facade class and it composes three objects, the option which is going to represent the option contract. What we're calling engine here is going to be a pricing engine and that sort of abstracts out the idea of a pricing model. And then the data object is going to represent market data. We end up not doing much with that but I'll mention it a little bit later. And then there's a single method, the price method and it's going to call out to the engines calculate method. And because Python is so simple and easy to present, this almost provides the students with a domain specific language to price an option and help them think about that in, as I say, a new way, a new mode of abstraction. So for those not familiar with what an option is, here's the textbook definition. It's the right but not the obligation to buy or sell another asset called the underlying asset at a preset time at a preset price. There are variations on that but that's the simplest definition. So a call option is going to be the right to buy the underlying asset and put the right to sell it. The strike price will be the preset price of the underlying asset and the expiry is going to be the date of exercise, at least if it's a European option. So how can we represent this in code? We start by creating a simple interface for the option contract that we can use derived classes to specialize. And so I get to explain to the students the concept of an interface and help them think about that level of abstraction of something that can represent different kinds of option contracts. And I'll draw your attention to the method, the payoff. That's going to be the key way to help them think about how to price the option is through its payoff function. So here's a simple concrete class called, we call here the vanilla option simply because it's the simplest kind. And what I'll draw your attention here to is in the payoff method, simply calling out to a composed object payoff and that's going to allow us, I'll give a second more here just to look at the code, but that's going to allow us to use the strategy pattern so that at runtime we can swap out the payoff function for different kinds. And this turns out to be really simple in Python because functions are first class objects and I don't have to create a higher level object to pass into the option contract. So I can create two simple one line functions to represent a call on a put option. And by this time students are pretty familiar with writing functions and this turns out to be a pretty easy exercise for them. So a simple demonstration of instantiating these so we can create a vanilla call option. Here with a spot price of $41, the expiry will be the 1.0, that's one year to expiration. And with a strike price of $40 and then I can simply pass the call payoff function to get the call payoff behavior. And I can do the same thing for the put option. Here I've changed the spot price so that we have more interesting payoff. And students can play with this in the notebook and get familiar with it and really connect with the definition of what an option is. And these tools provide a very powerful pedagogical environment for students to learn and sort of beyond the austere representation in the textbook to get to know what options are all about. So the next biggest part of the course that we're going to do is spend some time on developing different option pricing models which we're going to represent here as pricing engines again just to help them maybe understand and begin to use some of the lingo that's used on the street. But option pricing models are not unique and I want to have them think about that in an abstract way. And so once again we're going to use the strategy pattern. And so we'll create a simple interface for the pricing engine with a single method called calculate. And this allows flexibility to represent different kinds of pricing models. So it could be an analytic model like the Black-Scholes model or it could be a simple numerical model like the binomial model or even a PDE solver. One in particular that I'll be showing you is the Monte Carlo pricing model. A simple form of that. So here is a particular pricing engine, the Monte Carlo engine. And again if we look at the calculate method we can see that it's calling out to the composed object pricer. And that again makes it for the students so that creating different option pricing algorithms is as easy as writing different functions. And so let me give just a little bit of mathematical review. Not too much. I don't want to go too in depth. But to explain a little bit what's going on with Monte Carlo option pricing, we can take Peter Kennedy's idea about teaching econometrics with Monte Carlo method and simulation and apply that again adapting it to think about the predictive density for the option. It turns out that an option can be thought of as the present discounted value of an average payoff under many thousands of simulations. So the term in the parentheses is going to be the average payoff at the time of expiry. So m here is going to be some big enough number for the law of large numbers to work. And the term in the front e to the negative r t is going to represent a discounted value. And so with that as background I can now show the simple function that students can write. And again at this point in the course they're pretty adept at being able to write something like this. Just a few lines of code to represent the Monte Carlo option pricing method. The block of code in the middle there, the middle line represents the simulation. This is vectorized so we're running many thousands of simulations here at the same time. So z is going to be an array that's replications long and so that will drive many thousands of payoffs. I can take the average and discount it and I've got an option price. So we can test this pretty simply for a European option using the Naive Monte Carlo method. So we'll do some imports from Probo. Yeah, maybe I'll take a second now and tell you about market data. It doesn't do much right now except for abstract away the other bits of market data that are needed to price the option. But at this point the students understand the idea of abstraction and I can tell them that this might represent a historical database. Maybe it's streaming data from Bloomberg. The students have access to the Bloomberg terminal. This last semester actually did have a student put behind the market data object a SQL historical database and we could use this to price historical options. But typically that's just a small way to encapsulate those bits of data that are needed. So here I'm going to get the different bits that are needed, the Monte Carlo engine and the Naive Monte Carlo Pricer. And I can set up the market data. This is an example that comes out of their textbooks so they're very familiar with it. They've calculated it by hand. They know the answer a priori with something like the Black Shoals model or the Binomial model. So they have an idea about what the pricing method should, the answer that it should yield. And then we can set up here the option, both a put and a call option. And here so we've got a one year to expiry of $40 strike price. And I can instantiate the call and the put objects. And here I'll just run 100,000 simulations using that Naive Monte Carlo Pricer, build the pricing engine. And then we can use the option facade to encapsulate the call option, the pricing engine and the market data, and call out to the price method and it will yield the price of the option. So the Black Shoals benchmark here is actually $6.96. So at 100,000 repetitions we're coming pretty close to the true Black Shoals price. And again with Monte Carlo simulation I can help them think about the option as the discounted average pay off and they've had to simulate through this process to build this code. We can do the same thing for the put option and they can compare that again to the Black Shoals price. I think this is a penny or two off. It's pretty close. So I went a little bit fast. I thought I had more less time than this. But what's next for this project is to extend Probo in a couple different directions. So one is a project called Preza that we intend for academic research and production hopefully. Building that with some graduate students. We're building on top of PyTorch where we want performance and we want access to GPU compute pretty simply. And one of the next directions for both teaching and research is to think about another layer of abstraction that might be referred to as agent based simulation. So one of the key concepts in the Black Shoals option pricing model and therefore any of the subsequent models is that of the delta hedging market maker if you're familiar with that vocabulary. And this is a concept that is really challenging to help the students to think about the idea of a risk neutral density. And the argument in Black Shoals is that there is a market maker who is hedging an option that has been purchased or sold. And through Monte Carlo simulation we can actually simulate that behavior and show that the Black Shoals price will be a special case of this if the assumptions of the Black Shoals model hold. So we can take those assumptions and break them. For example I can introduce different frictions like transactions costs or discreet hedging and we can see that that will give a more general answer than the Black Shoals. And we're also using this with some of my graduate students in research to actually implement that as a pricing method. And we refer to this as hedging Monte Carlo. So I finished a little bit early but I'll take some questions if anyone has. Thank you for your time and attention. We do do that. Yeah so one of the things we'll do is we'll say pull up Bloomberg and we'll look at what an option is trading at and have that conversation. And we also do other exercises like build in a implied volatility solver so they can see what when we take an observed option price what kind of volatility does that imply. So they work through exercises using real world data. So that's a good question. It helps them but now having this computational sort of framework to build with it helps them sort of build with and make that that concept real for them. Whereas just the simple mathematical symbolic representations a little bit too abstract for them. Yeah so about the first month or so I do a rapid instruction in Python. Most of them have never programmed before so I got to get in from there to what you just saw doing object-oriented programming with design patterns. It's a bit fast and I'm sure my computer science colleagues would be a little bit horrified by how fast and how sloppily I go but I get them there and then the next two-thirds of the class so the middle third is going to be teaching them the various pricing models so we start with the binomial model and then we introduce black souls and the concepts of black souls and then we work through Monte Carlo for the rest of the semester. The students then have a project at the end of the semester and by this point you know we're 75%, 80% of the way through the course and their project is to extend Probo and to build in a new pricing engine or to price a new kind of option or something like that and so the course is just over three months and it's pretty ambitious but so far we've over the last couple of years we've been able to do it. It's a full-time course. It's a full-time course on campus in our master's program. We just created this whole cloth and I was just asked to create a course in computational finance and I had extreme freedom about what to do and so I devised this. I'm excited to hear anyone's feedback on this if you have great ideas for me. Yes, I definitely can. In fact, maybe I shouldn't admit this but the first year or two I was ambitious enough to try C++ because I had assistant professoritis and I was going to teach them everything I knew and we were still fighting compiler errors by the time the finals were rolling around. By the time the students are working on their project to build a new pricing engine or to price a new option, they know how to play around and break things and discover and so they have a computational platform to do educational discovery on and I've definitely discovered that it's a new way to think about and teach these concepts rather than just the sort of austere textbook types of teaching in chalk and talk kind of a way and it's been very powerful learning tool. Thanks for that question. I do both of those so every lecture is going to have a Jupiter notebook attached with it and it's going to be attached to something in their textbook. Once we get to the computational finance material but I have to go very rapidly for the first month through Python and so I've tried different things but I've just created I think 10 or 11 of my own notebooks and I don't try to teach them all of Python. I try to teach them enough to get going on the kinds of things we want to do and they continue to learn Python throughout the semester as they need extra bits to do their exercises but so far it's worked pretty well but yeah they have a github repository and they know that that github repository is updated each lecture. I can't imagine doing this without the notebook and these kinds of tools. Thank you for your time and attention.