10 MATLAB Features for Finance You Need to Know - MATLAB
Video Player is loading.
Current Time 0:00
Duration 52:58
Loaded: 0.31%
Stream Type LIVE
Remaining Time 52:58
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 52:58

    10 MATLAB Features for Finance You Need to Know

    In this webinar, learn about some of the new features that improve financial services workflows in the latest releases of MATLAB, including R2022a, and see the latest methods for:

    • Accessing your data sources wherever they are.
    • Developing financial and risk models powered by advancements in AI.
    • Utilizing the latest frameworks for time-series modeling, backtesting, and reporting with your existing workflows (Python, SQL, and others).
    • Interfacing with the latest technologies in web, cloud, and enterprise solutions to share your work with colleagues.
    • Applying these new features with examples from asset allocation, risk management, and economic analysis. The new product updates allow quick model development and automated workflows, leveraging many no-code/low-code GUI apps.

    Published: 10 Jun 2022

    Hi. This is Bob Meindl, and thank you for coming to our session on 10 new MATLAB features that you need to know if you're in finance. This is part of our ongoing series of webinars for finance professionals. And with that, I'd like to introduce you to one of our finance account managers, Greg McGean.

    Hello, everyone. Thank you very much for your time today. I am Greg McGean, one of the account managers of the North American finance team. Today we'll be going over some of the latest features and capabilities of the most recent releases of MATLAB and MATLAB for financial applications.

    If you see anything in this webinar that you would have additional questions on or just like to take a deeper dive, please feel free to reach out to David or I. Our contact information will be at the end of this. I am now going to pass things over to our application engineer, David Barnes. Thank you.

    Hey, everybody. Good morning. Thank you for coming to our session. I'll go ahead and turn my video off so we can go to the slides and save some of that bandwidth. So on this slide here we have a lot of our contact information. Like Greg mentioned, if you do have any questions for us throughout this presentation or this webinar, feel free to reach out to us. We'd love to engage with you, find out a little bit more about what you're working on, and see how MATLAB can help you with your workflows.

    And so with that, this webinar we named this with these 10 new features for finance. And the goal here is to help you with the workflow that you have in your financial services. And when we're looking at that, it's going to begin with this question-- how do I blank with financial models easily? And we're going to fill in that blank with-- there are three main pillars of our workflows.

    And that always starts with accessing our data. Our data lives in all sorts of places. Maybe it's coming from you nice and cleanly in Excel sheets, maybe it's coming from a database, or maybe it's coming from some places where you're getting your data live in some real time-- maybe places like Refinitiv or Bloomberg. And so despite wherever your data is, you're going to need to take that and manipulate it and move it in to wherever your environment is.

    And so once you've got your access to your data, you then get to do our favorite part of our job, which is actually building and working with our algorithms and doing model development. This may be with cutting-edge AI. It may be doing things like traditional portfolio management and asset allocation. And wherever you're doing your work here, you could be able to make these models, and you get them right where you want them.

    And then you get to do this next piece, which is sharing your work, whether that's just creating something static, like a report that you give to your boss, or something that is dynamic. It's a web app maybe or something that you've moved off into production so that things can really go smoothly. You can share your work with all of your colleagues or your clients.

    And so as we're looking at each of these three different pieces, we're going to look for ways for us to automate this the whole way through, making it so that it's very easy to be repeatable as you're moving through this workflow of accessing, doing model development, and then finally, sharing your work. And so each of the 10 features we're looking at are going to be hanging on each of those three pillars today.

    Let's go ahead and take a look at this app that I have here that's going to show us a little bit of what we're going to look at today. And so the first thing we'll do as we're looking at our data is, how do we access our data? And so one of these first couple of features that we're looking at there, showing you ways for you to pull this into MATLAB, be able to start manipulating it and working it with ease.

    We'll then spend a lot of time today also showing you how you can develop some of your models, really making it easy for you to work with things as complicated as AI or whatever your workflows are, showing you some of the apps that are available to help you. And then finally, we'll show you some of the ways that you can easily share your work with your colleagues, put things into production, and moving things through. And so with that, let's go ahead and jump into MATLAB.

    So it may have been a while since you've jumped into MATLAB, or maybe it's your first time seeing this. And throughout this webinar, we're going to go and show you all the different features that we have across there. And the first tab that we have here, our Home tab, has got a lot of these nice features for us to get started with as we're getting started with MATLAB.

    And so the first aspect that we're wanting to do is we need to start working with our data. We need to work with it by accessing it first. And so in this case, I'm going to work with some data that's here in Excel. So let me actually go ahead and open up this Excel data.

    So in this case, I've got some Excel data for a bunch of assets that I have for-- they're daily close prices. This is some daily data that we have here. And as I look through here, we can see that we've got some of this information we've got for our closing prices. But we also see that I've got some missing data that could be here. So this is some dirty data. Not all of our data comes in nice and clean, but we'll also show you some tools that we have to manipulate that data once we pull it into MATLAB. So let's go ahead and take a look at how we can do that now.

    So this case-- we've got a really great tool that we've got right here on the Home tab. It's this Import Data tool. So go ahead and open that up. I can select all different types of data that can be pulled in. We've got these local files for this tool-- in this case, again, working with just our Excel data. And so this really great GUI interface is going to provide you really this-- familiar aspects that you have if you've been working with Excel, but maybe you're wanting to pull in and use some of MATLAB's features for things like AI or machine learning.

    And that's going to start with still pulling your data in. So we've got this nice interface where we can come through and select. We can make sure that our data's coming in properly. We can select the output data type that's there. But MATLAB makes it really easy for me to just automatically import my data into MATLAB. With one click, I've got my data already there in my workspace.

    One of the things that we talked about was that we wanted to make this automated. This point and click feature is really helpful. We're going to show you quite a few of those to help you speed up and get started with your workflows, but each time we pull up one of these GUIs, at the end of it, we're really trying to show you some of the ways that you can look at some of the generated code. And all of these apps and GUIs should have a way for you to do those.

    So I'm going to go ahead and drop this down, and here we're going to see some of the options that we've got. So we could just directly import our data, which is fine. But as we're really wanting to start to automate things and speed up our processes, we can do things like generating our live scripts. And these generated scripts are really fantastic, especially if you're getting new into MATLAB or wanting to find some key features that are there-- for a couple of reasons.

    One, we've got some documentation that's already here. It's already got nice formatting for us, and it's really readable code as we're looking through, if you're new to MATLAB in terms of the programming language. As we're looking through, we can see maybe some of the new features, and ways, and functions that we can start to use with this. But this isn't a black box, that we're just exposed. We can fully edit this code if we need to, making in different changes, like maybe changing the Excel sheet for this case.

    So we've got our data pulled in, and it's in the form of a table. We've got a lot of different data types that are there to really help you speed up your workflows. And we're dealing with a lot of time data-- we had a new feature that came out a few releases ago-- to work with something called our timetable data type. So in this case, I'm going to move my prices and I'm going to convert my table to a timetable. And then I can pass in my data set.

    If you've ever really started to work with your time-based data, and you really want to try to change things like the frequency-- we've got daily data right now, but maybe you want monthly or quarterly-- working with that, with the typical data types-- maybe vectors, matrices-- is really difficult. But you're going to have a lot of really great features as you're working with timetables to synchronize your data, to change its frequency with ease, because it stores a lot of this information for you, making it really easy.

    So our data's here in MATLAB, and now we can start to take a look at it. And one of the things that we know right off the bat that we have is that this data is, in fact, dirty. So looking back again at this home strip, we see that right next to this Import Data is this new Data Cleaner tool. This is going to give us a really great ability for us to, again, use the point and click methods as we're getting started to find out some of the ways that MATLAB can help us work with some of our clean data.

    So with this app interface, they're all going to move left to right. We'll start with importing our data into the tool, we'll look at some of the different cleaning methods that are available, we'll get to look and see as a live function, and see how these plots are going to change, and then finally we'll get to exported data back out maybe things-- like scripts or just pulling our data directly. Let's go ahead and get started. So I've imported by price data, which is in as a timetable. This tool works really well with this time data with some of the cleaning methods that it's going to use.

    So in this case, where data has been pulled in, and it's going to go ahead and give us a preview plot of one of our assets. In this case, I know that one of my worst data sets is actually this BP data set. And we can see over here that I've got a lot of data that's actually missing-- pretty large chunks of it, in fact. So how can this tool help me get through and start to clean and fill in this missing data? Well, let's take a look at the cleaning methods.

    You see there's a lot of these that are really going to help you get started on their work and built on the back of the timetables. And one of those that we need in this case is cleaning our missing data, but we also have tools for things like normalizing, or even smoothing your data as well. So this is going to give us a nice little interface over here for us to take a look at some of the options with cleaning our data that are available to us.

    In this case, it's going to give us this nice live interface, where I can see where some of this data could be coming in. And I can change the fill method, so if I wanted something besides linear interpolation, I've got a whole host of algorithms that I can use as I start to fit and miss and put this missing data back into its place.

    And this tool speaks in the language of time. We've already got these units that are down here, so if I want to specify things like the maximum amount of quarters and the maximum amount of years, this tool is there speaking the same language as the time data. So in this case, I'm going to be perfectly fine working with linear interpolation for all of these algorithms.

    And I want to go ahead and actually select all of my data, because I know there's at least one piece missing from all of them. So after after I hit Accept, MATLAB's going to go through and start to replot this data, apply the same cleaning algorithm across all of them. And it's going to give me live plots back so I can go through and check this work.

    So now MATLAB's gone through, I can take a look and do some spot checks to try to see if there's anything that may be a little bit out of the ordinary. I can come through and do things like remove my cleaning signals and see that, in fact, all of my data still looks really nice and clean. And if you have multiple steps to your data, I could rearrange those even as we're working through this app. It's a really great way, as you're getting started and need to explore and see how these different steps and their order might affect your different ways that your data pops out.

    So in this case, I'm ready to just go ahead and export my data back out. MATLAB's told me here that it's coming in as prices1, so I can go ahead and look at that variable. But once again, if I drop this down, we have options to generate scripts and functions that are automatically documented, and I can start to work with as I start to build up larger workflows.

    So I've got my prices data, and it's nice and clean, so I'm going to go ahead and reassign it in here. But I don't need just price data when I'm looking at some of these things. I also want things like my returns. But how can I get there? There's definitely ways that I could find the different ways in MATLAB to do things. I could do some googling and find out how to do all the math.

    I could look at maybe some of the MATLAB documentation and see what some of those options are. Or directly from the Command Window, I can use this great little function search and find some things. So let's, for example, find a way to convert price to return. Go ahead and searching through, we see that there's a couple of functions that we've got right here. This one's going to be the perfect one for me. It's going to convert my price series over to a return series. So now all I have to do is put in my prices data. So there we go. We've got our data. It's nice and clean, and it's been pulled into MATLAB. Let's go ahead and take a look back at this little app so we've gotten the first section done.

    So as we're looking at some of these with MATLAB, many of you are probably really comfortable with using some of the graphics that are available. And I want to show you a new feature that came out recently that, if you've been working with subplot, this is like subplot 2.0. This is going to give you the ability for you to really start to work with your visualizations and take them to the next level.

    And that is using the tiledlayout. I can pass this in a couple of sections. So I've got two rows and two columns. And it's going to give me a nice blank figure for me to start working with some of these things. So I can go through each of these tiles by using nexttile, which makes it really easy for me to start to interface with this. I could pass in the indices there.

    So my nexttitle now-- if I look at my figure, it's really great. I've got this axes that's already been generated for me, and now all of the commands that I'm going to follow are all going to get applied to this figure right here. So in this case, I want to take a look at my cleaned up return datas and try to see based off of the histogram whether my data is normal or whether I've got some maybe odd behaviors that are here.

    So I'll go ahead and open my returns data and I'll just take a look at my ALLIANCETRUST. So coming over here, we're now going to explore the second tab that we've got in MATLAB, which is the Plots. We see that, right off the bat, I've got a histogram. So I can select that. And we've already got this populated here. So my data looks pretty good. We've got some fat tails, which-- maybe, if I want to normalize the data, I can put that back in the data Cleaner App normalize, it, and spit it back out if I needed to as well.

    We can also come through and start to work with some of these other things, like the next section. So this nexttile that I have is going to be moved over here. And MATLAB's been adding a lot of ways and features for me to not just have static images, but ones that are dynamic, ones that are going to help me tell the story and move things forward. And so in this case, I want to show you this option that we have here.

    So in this case, I want to take a look at this exact same data, but I want to watch it as it actually happens as a function of time. In this case, I can use this comet to show me one of these live algorithms and so as I show it here, over on the right-hand side, my data is moving forward. And I can go through and save this in such a way so that I can actually export it out as a GIF automatically through MATLAB, which is one of the new features in 22a.

    But as I've looked through some of this data, MATLAB has shown me automatically ways that I can pull this data in and start to predict what types of plots are there. But we've been adding a ton of plots throughout time, whether you're working with geospatial data, really specific things with statistical analysis. You can even build and work with some of the things in the File Exchange to build out and build on top of some of these base functionalities.

    So the next piece, now that I've looked at some of those in terms of the price-- or the returns data, I want to then take a look at plotting my price data. So now it's really easy. I can just do nexttile, give it in the index and the span that I want. So in this case, we've got this access that's appeared, and now I can take a look at my prices data. I can go ahead and select all of it and plot as multiple.

    So now, with pretty easy steps, I've got this really great way for me to dynamically take a look at all of my data, share this with maybe my boss or different clients have things that are there. Like I said, every time we start to pop up these figures, these GUIs, we're looking for ways for us to be able to generate code out of them. In this case, we can generate code from figures. We can come down from File, and drop down, and Generate Code.

    This is a really great way as maybe even playing around like we have here in the command line, to put some things together, start to of understand maybe some of the ways that our graphics are interfacing. And then we've got it exactly how we want it, and now we need to do it for all of our assets. Maybe we have 200 or 300 assets. We can do that, and generate the code, and be able to easily call in and make these functions work well.

    So we've done a good part of looking at the beginning sections. Our data's been pulled into MATLAB, and it's working really well, but now I want to look into, how can we make the modeling faster? And this is what we want to spend a good amount of time on, because this is where a lot of our customers really have a lot of questions about, how can MATLAB really help me and speed up my processes?

    And so one of those first ways is through some of the apps that we have available to us. So there's a lot of apps that you could take a look through. They're all going to be very similar, and we'll show you one example that's going to be here through the Curve Fitter app. But we're constantly making updates to these, and so if you're working with some of the AI space that we'll talk about a little bit later in this webinar, we'll take a look and see that there's a lot of apps that are available as you're getting started with really complex workflows so that you can then not have to go through the documentation and find all of the exact functions. You can just take a look through the app, to point and click, and then generate your code on the other side.

    So in this case, I'm going to go ahead and open up my Curve Fitter app. So while I've been looking at all of this data-- and it's been time series data-- the Curve Fitter app is not for that time-based things, so I'm actually going to convert this back to a prices table. And in this case, I'm going to take-- I'm going to use the same functions, where I can go from timetable to a table.

    So let's go ahead and take a look at this app. Like I said, this is really typical of how all of our apps are designed to work from. They have the exact same theme. We're looking across this tool strip, and we're going to move left to right. We can import things like starting new sessions and saving those. It makes it really easy, as we're really wanting to use this point and click workflow for a lot of our customers. But we'll start through by selecting our data, we'll see the different types of fits that are available, and then we'll get to look at ways that we can start to look at the visualization and start to understand and see whether or not these models that we're making actually work well. And then finally, we can export them in different ways.

    So with this new tool that's been updated in 22a, we have this great little dialog box that gets us started. So I can go ahead and give this a fit name. We'll call this myFit 1. And I can select my data. This works with data that you might have that it's just in matrices or vectors, but in this case, because I'm working with things like my tables, I can really easily select from dropdowns exactly what kind of data I'm looking at.

    In this case, I can pick my x and my y data. We'll just pick a couple of these there. So while this isn't necessarily the fit that you would want to be using in some of this data, it definitely shows the workflow as we're getting started. So we see that this interface has now plotted my data, and it's shown what the split looks like. And now I can really easily just go through and change things and different parameters that are there, like increasing maybe the different polynomial size of this.

    But maybe polynomial is not the only type of fit that you might be interested in. We've got a lot that are readily available for you so that, if you've got things like Fourier analysis you want to do, you can do that here. Or for a lot of our customers that are interested, that they know the equation that they have-- maybe they pulled it from a textbook or they've pulled it from a paper that's come out recently-- they can insert custom equations here to make it really easy for you to start to fit those in if the functionality is not already there for you.

    And so we've got our fits. They've been done, and now let's take a look at some of the things like the actual statistical analysis. In this case, we might look at something like our confidence intervals. We can see, well, how well this kind of fit is here in this case, it's not really great because of the type of data that we're working with. We're just showing this as a bit of the example.

    But this is a really powerful graphic as you're starting to show and be able to present to regulators maybe how these fits are working, and start to understand and think about whether these models are going to work well for you.

    Once again, we are moving to that last step of each of these app workflows, where we're going to drop this down and export. If you want just the figure, which a lot of our customers want, you can immediately export that out. You can generate code, or if you're ready, and you've got this model working well, and you want this particular fit, you can also just export that out to the workspace.

    And so all of the apps that we're looking at, ways for you to get started with pointing and clicking, are great ways that you're getting started to start to understand ways that our data can come through. And point and clicking is a really powerful way to get started, but as you've started to generate maybe a lot of your functions and a lot of your systems, how do you start to prototype quickly? We need to connect all of these things together.

    How can we document some of these? I may need to insert equations, maybe some images or hyperlinks to the paper that I've got there. I want to add text and all of my live graphics, not just straight images, that are copied in. We'll show you here now how we can start to prototype quickly.

    And so in this case, we're going to go ahead and open up this demo, which is a cashflow matching. So we're doing this through what's known as our live scripts. And if you have been on a little bit earlier-- or previous releases of MATLAB, you may not have seen them, or-- they've really improved a lot with some of the things that we can start to handle.

    But they're a great way for me to not only put in documentation and type things with nice layouts and things, but I can also start to insert and run this as code. It's like notebooks, if you're familiar with those. And so I've already pulled in some of those pieces. And in this case, we're going to look at an example of using optimization in MATLAB. This is one of the really powerful ways that a lot of customers want to use MATLAB because of some of the options that we have for really known robust algorithms for optimization or global optimization.

    In this case, we're looking at it through the lens of, how do we match some cash flow using bonds? So maybe you're in a pension or insurance, and you may already know your projected outs for each year, how much you may need to pay out. And you want to use bonds as your instrument to then be able to match those cash flows year over year.

    So we've gone through already, and we've connected to some of our data. We've got Excel data right here, and I've generated some of my plots from figures that I already had before. So I can come through here and take a look at my required payoffs. I've got this for the next eight years, and now I can take a look at some of my bond data once again.

    So not only can I put in all of my code-- I can start to document and write out sentences and things that are here-- but I also have these really great things called live controls, and this gives me an ability to really start to work through and make almost like an app interface for some of my code. I can come through and select different bonds to come through, and be able to look at them and see what's there.

    I can also then hand this over to other MATLAB users, and they can interact with these live controls as well, just start to interact and see some of those things that are there. So with my bond data, and everything's been pulled in, I now need to move into my next step, which is optimization.

    So if it's been a while since you've used some of our optimization tools, a lot of the common workflows are looking like exactly what we have here. We've got this problem set up where we're dealing with matrices, and we're looking at very specific solvers where we need really exact ways-- we may need to look at the documentation-- to know how to work with all of these different algorithms. I need to know which one is right for my tool.

    But that's the old way of doing things. What if we didn't need to do that anymore? So I can run this section and show you that, yes, in fact, this does run. We've got this algorithm that works. But what if you don't have this? How would you get started running your own optimization tasks?

    Well, here we've got really great ways for you to start to interact with your code and build these out with some really powerful ways of embedding other types of apps into your live scripts. And that's through live tasks. We see here that we've got some ways that we've interacted with things before, like cleaning our missing data. So we could do that directly from our scripts. Or we can come all the way down here to things like optimization.

    So in this case, we're going to start with this beginning section, which is really the way with-- those of you that maybe not familiar with Optimization Toolbox, we've got two main approaches that are there-- one which is the older way over here, which is the solver-based. But there's this new really robust framework for you to get started, where you start to write and define the problem as it makes sense, as you would writing it out on paper. So we'll go ahead and load in this approach to go ahead and solve our problem.

    In this case, we'll start with declaring a variable, and we're going to set the dimensions for it. This is actually a really particular and special type of problem. We've got a hint of it up here at the top-- is that many times, our bonds might be purchased in large lots of 1,000. So we can't buy an individual or specific bond, or half of a bond. So we can actually just buy integers of them, and we can constrain our problem to have that requirement.

    We can give it an initial point to get started. And I've already gone through before and defined my objective functions as a local function here. I've also defined my constraint as local functions. And as we're going to see, MATLAB is going to go through and it's going to read them, and it's going to give me an interface for me to manipulate and change maybe some of the inputs that might be there.

    So I'm only just approaching this problem from the things that I know. I'm able to write functions, but I could make these as files that I have that are there. But I don't have to worry about anymore what solver I think is best. In this case, I can come here and look at the solvers that are available. In this case, there's two really great algorithms for you as you're getting started with them.

    And if you ever want to learn more about what they are, I can hit this help button here, and that's going to take me to the documentation, where I can start to learn and understand a little bit more if I needed to deep dive into some of those. So in this case, we've got this task. It's defined our optimization problem, and we see this nice printout where I didn't have to write this code to come through and show it and then shape it in this way.

    But with one click of a button, I can go ahead and solve my optimization problem. I didn't have to worry about the exact way that this particular solver needed the data to be massaged in and moved. I didn't have to do any of that. I just hit a button. But for a lot of people, they're very interested in moving to those, and they're going to want to take a look at the data that's behind here, the actual code.

    And with all of our different tools that we have, we're going to show you that it's not just a black box that's happening here. We'll show you the code that's actually running in MATLAB under the hood, show you how the ways for you to be able to do this start to manipulate it on your own. So we've run our optimization problem, and now let's go ahead and take a look at our results.

    So we're looking for our bond matching. So we see in this case that we've gone both long and short at a few different bonds. And in the end, we're able to match our cash flows, which is great. Our work is done our. Modeling is finished. We've accessed all of our data.

    But we also have that third category, which is, how do I start to really start to share some of these things together? One of those options that we have is to give this over to one of my colleagues. But if I come over here-- it's over on the right-- I can actually hide my code.

    So in this case, when I come through, this is going to look exactly like a Word doc, where I still have embedded functionality. These sliders are still going to work, and it's still going to live and dynamically move all of my fingers, but it gives me an ability to get a lightweight app kind of interface for some of my customers.

    Also, maybe you've got everything ready, and it's prepared, and you want to just show this and print it. And maybe it's a static report. You can come through and export it as a PDF, Word, LaTeX, or HTML. All these ways are easy ways for you to start to pass this-- your work out and share them really easily.

    And so as people have started to move towards optimization, a lot of people are starting to move towards AI and using deep learning for a lot of these really nonlinear problems. People are trying to explore and understand how you might be working with those, and a lot of people are getting really comfortable with using deep learning and machine learning. And those workflows aren't always necessarily connected to finance workflows.

    So let's look at one of the examples that we have for those. We're going to evaluate our AI using finance. So in this case, I want to show you that we've been working a lot on this. I'm going to open up the documentation that's here. And we've got five new examples for you as you're getting started and you're wanting to move out of just building your networks and putting things together, and really starting to think about, how do I use this and fully shape full workflows in different industries across the financial services?

    We've got five examples that are all through here using deep learning and reinforcement learning to show you examples of what these workflows might look like. So I'm going to go through one of those where we're going to test and look at a deep learning-based trading strategy, and evaluate this AI not just based off of the metrics that you might have in typical data science workflows, but concrete financial ones.

    So I've opened another live script, and we see that I've got this table of contents that shows me the overall workflow that we're looking at. We're going to start with where we're going to start with each time with our three pillars-- loading in and cleaning our data. And then we're going to perform an entire AI workflow. We're going to go through the standard processes to define the architecture, prepare, and train, and validate our model. But then we're going to take that AI and we're going to drop it into true financial services. We're going to put it in and test it using some financial backtesting. So let's go ahead and get started with this.

    In this case, I'm looking at some commodities that are here, and pulled in some data so I could take a look at it with some of those, where I've imported this data. And I've, once again, used my generated functions from the import tool to get started on there. I can take a look at some of the life span that's been with this data. So I see it ages all the way back to the '80s.

    And I've also gone through and cleaned up my data, prepared it for my returns. And so as you're getting started with your workflow, and your data's generally clean, you start to have to section it off into three main pieces. You'll have some training data. You have some validation data. In this case, we're also going to use and set aside some pieces for backtesting that we'll show later, which is that actual financial piece of this whole puzzle.

    And so we're going to go through and define our architecture that we have for our model. And so some of you may know what some of these functions are and are familiar with the interface, understanding what each of those layers might be, but if you're like me and you're kind of newer to this space, we've got really great apps to help you get started with those workflows.

    In this case, I've come back to my Apps tab up at the top, and I can come down and look at this Deep Network Designer. This is a great interface as I'm getting started to really start to understand and work with these custom layers.

    So in this case, I've got my data. I've got my model and I'm pulling it in. It's actually in my workspace already. MATLAB's already recognized that. And I can come through and take a look at It. In this case, it's a pretty small model deep learning-wise, and it only has a few layers that are in there. And I can see some of those ways that I could maybe add different layers and move things in, or as I click with each of these layers, I can start to see some of the parameters and hyperparameters that are available for each of these layers.

    And so I can come through and start to build this, reorganize it if I needed to, and start to use this data science tools. And then I'm ready to just immediately go back and export, generate the code, generating with parameters, and moving things forward. But this app does more than just give me a nice interface for a couple of lines of code. It gives me a full workflow for me to start working with actual data to move that in and get it prepared, as well as do training, harnessing all of the different hardware that I might have available to me to start to get these models up and running.

    And so coming back to the code, we've got our models. And in this case, we're not going to show you the full training. It does take some time. As you're moving into the space, do reach out to us as you're having questions about how to start to scale up your deep learning processes-- working with things like the parallel cores that you might have on your computer, GPUs, or clusters, and maybe even moving things to the cloud.

    MATLAB has ways for you to interact with all of those really easily and quickly for you to be able to scale up as you start doing a lot of your training. So in this case, I'm just loading my network that's already been pre-trained, and I'm going to use that for the rest of this example.

    So now that I've gotten my data-- or my model, and it's ready, all I have to do is call predict on all of my data, and I can start to see the validation step, which is still in the AI workflow. When we're looking at this evaluation, we're looking, comparing to see how well the model is doing based off of what is its expected response.

    In this case, the output of our model is a prediction on the daily change in our price data. We can look through some of these and see that it's not doing a great job. We only have a few layers that are in here. But it's really typical of the workflow of the full scope of using AI and finance. Our model's ready. It's trained. We've got it validated that it's working pretty well.

    So we'll move into the finance section. And we're going to do that using the framework that we have in the Financial Toolbox that was introduced a couple of releases ago that's using our backtesting strategies. This is a way for you to really easily start and develop a training strategy. In this case, we're going to be basing it off of our AI.

    We're then going to set it up in a backtesting engine, where there's other things that you may be needing to add in. In this case, we're going to end up adding things like a risk-free rate. Then we'll also have this final piece, where we actually run it. And we could run this not only on historical data that we're going to run in this example, but if you want to scale up and run Monte Carlo simulations and use simulated data, you can do that with this framework as well. And then we'll finally take a look at some of the different summaries and ways that we can look at this data.

    So we'll go through, and I'll start to run this section. The first thing that we need to do is to create our strategies. We're going to create four total strategies, and we're doing that using this backteststrategy function. You see here we've got it four times, which are each of our four strategies that we're going to use-- three of which are based off of the AI model, and one is just equal weighting, which is a really nice way for us to give a benchmark.

    In this case, we can go through, and we've got our back test engine that's been incorporated already with our risk-free rate that we established. And finally, we've run our back test engine. That's it-- one line of code passing in the engine, and finally the data that we wanted to run it on.

    We can call the summary, and now we have the ability to actually have evaluated our deep learning-based strategies using actual financial metrics. We could look at things like the Sharpe ratio, max drawdown, and start to compare and see how this AI model has performed in each of our different strategies, and compare it to a nice benchmark.

    And so of course, another way to look at this as well is to just to take a look at how this portfolio has performed over time. And so in this case, as we looked at our predictions, we see that the full use of this AI model, in fact, did work really well compared to some of our other strategies that we had.

    And so as you're starting to work with all of this and moving to AI, a lot of your colleagues, or maybe even you yourself, may be also starting to work with Python. There's a lot of tools that are available that are through there using PyTorch. We show some interactions that we have that are through there.

    But this next step that I show you is that MATLAB is going to be a really great tool for you as you're needing to glue a lot of these sections together. You could replace the entire AI section with Python models, and then evaluate it in MATLAB based off of its financial metrics. And so I want to show you some examples that we have of showing this interoperability between MATLAB and Python.

    And the key here that we're looking to show you is that, when you're working with these together, there's no need to recode. It's not an either/or kind of thing. This operability is constantly getting updated, getting easier and better for you to start to work with all the models and all the colleagues that you already need to.

    So we'll go ahead and open up this example, where we're wanting to call Python from MATLAB. This is a very common example that we have maybe you're wanting to use some of MATLAB's visualization. Maybe you're wanting to use MATLAB's optimization engine right from one of the earlier scripts we ran.

    Maybe you want to take some of your data that's processed and accessed in Python, and you want to use some of the GUI interfaces to start to develop some of your AI workflows. In this case, we're just going to show this example that's using it as a plot, but any of those ways-- if you've got work that's already been done in Python, just go ahead and use it.

    In this case, we're going to show an example where a colleague has set up an ability for us to access Coinbase data to look at some crypto analysis, and we're going to show you how to usher that data in and around from Python back into MATLAB. So in this case, I can just go ahead and set up and take a look at my Python environment to make sure everything's working well.

    And then I've worked with my colleague already to go ahead and use and call these Python functions. And at the end of it, I've got this data, and it's pulled in as a Python tuple. Great-- we've already made this live call. But if you're like me and you wanted to take a look at some things, or maybe you forgot, or you're building this on your own, you now have the ability for you to also take a look at this Python code directly in MATLAB.

    And when we open it now-- if you've done it before, it was just a text file interface where you had to scroll through, but now we've updated this to make it much easier as you're starting to look through this, which is a new feature we have in 22a. As we're starting to continue to develop this ways for you to kind of inter-op between MATLAB and Python.

    So going back to the script that we have, we've got our data that's been pulled in, and like I said, we're working with our interfaces that we have. We're trying to constantly update them and make them easier and easier. In this case, in 22a we've given the ability for you to work much easier with lists and tuples.

    And in this case, we can immediately take this list that we have that's of strings, and with one call to the MATLAB string function, immediately have that pulled in as a string array, making it even easier as you're starting to work with this and work with some of the native data types that you're wanting to. Finally, of course, we're going to do that final piece, which is visualizing our data here in MATLAB. So in this case, we've gone through, and we can see all of these different pieces.

    So it's a very similar workflow as you're wanting to start with MATLAB and Python. Going to show you an example here in VS Code of some Python that a colleague of mine wrote as we're starting to work with some of this. In this case, all of the calls to MATLAB are happening right here. This is a really easy three-piece step. We import the MATLAB engine, we then do data ushering in on line 38 calling in the MATLAB double, and then finally, we're using MATLAB to use our AI that we have to project the coins and what their future values are going to be.

    And so it's really easy which is those three steps to import the engine, do your data ushering, and then make your MATLAB calls. And then you can move back forward using the work that maybe your colleagues are using that have already developed those in MATLAB.

    And so as we're looking with those, we spent a lot of ways for you to really speed up a lot of your work. And as you're starting to want to share some of these things, this is ways that you can really easily start to work well with some of the other key MATLAB features. In this case, I've shown you this example that's kind of been hidden back here a little bit, which is working with MATLAB projects.

    This is great as you're starting to interface with source control. You've got a lot of data. You maybe got a lot of models, a lot of scripts. How do you categorize them and keep them all together? In this case, we've gotten really great ways for me to open up shortcuts. But this project gives me the ability to do things like startup and shutdown scripts, making it so that, every time I run my script, I don't have to bang my head against the wall because of some error messages, when I realized that, oh, I forgot to run the startup script that's already there. This is going to happen and do it automatically.

    In this case as well, we've got a really great tool, which is the Dependency Analyzer. For those of you that are looking with regulators that have a lot of questions about how and where some of our data is going to pass around and move through, this is a really great tool for you to automatically know and just see without having to dig back through and have to do a manual process or doing all of that. You can see all of that directly from here.

    In this case, you can save some of those, but you can also just generate a report automatically that you can save and put as part of your resource control. Or if you need to just copy this as an image and put it into a Word doc or somewhere else, you can do that as well.

    So in this case, I'm going to go ahead and close this down. And I want to show you another piece, which is, as you're really starting to work with some of your other colleagues with MATLAB, you really want to start to share some of your models. Maybe you've got some people-- some upper management that's asking for not just some PDFs, but I need to take a look at this. I need to change some of your parameters. I need to do some due diligence, and I want to see how this works.

    Can you just make a web app for me? Well, if you're a MATLAB user, you can do that really easily. In this case, I'll show you an example, and we'll walk through the whole step of automatically creating these. So once again, I'm using my projects to set everything up for me. And I can double click and show you this app that we've got that we built here MATLAB.

    This app that we're going to have-- we're going to show it first-- is the desktop piece. And we're building this in App Designer. There's not a special toolbox that's needed for this. You can do this with just base MATLAB as you're getting started and start to see all of these ways that you can start to move them in.

    So you see that I've got this nice design view, which gives me an easy interface for me to drag, and drop, and move some of these different pieces in. And I can run it on my desktop if I want to and move that, or I can start to share it. And so after I've built this interface that holds all of my models, makes all of my calls, I can share this as a web app, or even as a standalone desktop app, as just an EXE that you can pass around and move to different people.

    But in this case, a lot of our customers are moving towards the cloud. This is one of the big desires is, how can we really easily and quickly scale? And so if I've done all of this work, and I've packaged all of this, and I've done it all in MATLAB, how easy is it for me to suddenly move everything to the web? In this case, I'm going to hit one button, and within three minutes I'm going to have a live web app.

    This is going to go through a compilation process. It's going to do dependency analysis. It's going to go through and make sure that everything's all there and prepared. It's going to go through and it's going to generate my files, and at the end of it, I'm only going to need one file, what's known as a CTF.

    It's an encrypted file, which makes things a lot easier for trying to hide some of your algorithms and put some of those things that are there. And all I have to do is I need to take this one CTF and move it over into my server. So in this case, we'll take this app process that's generating, and we'll open up this output folder.

    So here we've got a lot of other artifacts that we can use, and see some things, like our logs and our files. But in this case, all I need to do is, like I said, take the CTF-- I'm going to copy it over. I'm going to go back to my lab, where I've got a little shortcut for our web app folder, and I'm going to paste it in. That's it.

    So now I'm going to open up my browser. In this case, I'm using just a local spun up server that's here. And as you saw before, I didn't have any apps, but with a refresh of my page, it's there. I can click it and open it, and we can start to take a look at this app. In this case, this app is going to be using HRP, hierarchical risk parity analysis, to pick, and perform, and look at some assets for me to find an optimal portfolio.

    So now we have a nice clean interface that we didn't even have to make that's automatically done with this really familiar format for web apps. I can select this file that's come through here, go ahead and upload it. Now all of my algorithms are going to be happening here on the cloud. My data's gotten pulled in. I can take a look at the table that's here. And then I can run my analysis.

    We've got sections where we could add constraints. We've got outs again, interactions that we have with dots and ways for us to check mark boxes. And then in the background with-- under this run HRP is an optimization problem that's running in the background. I don't have to expose that to the customer. That's all there. All of those models that may be running are all hidden behind just one button click, making it easy for your users.

    In this case, I get to use MATLAB's graphic engines to be able to make it really easy for me to start to look at all of my different data and look at some pieces. I can add things like generating reports, where I upload data and then I get back out a standard PDF, or maybe it's an Excel file as well, so that I can hand this off.

    Looking at some of the custom graphs that you can make in MATLAB-- and finally, I can add some of these controls, where I can even live and change some of the graphics that are available here. And so as MATLAB's starting to move towards the cloud, if you have an active MATLAB license, you have access to MATLAB Online.

    This is a great way, as you're really starting to look with some things or you've got some colleagues that need to try some things in MATLAB or might want to put some things together-- and you can access MATLAB through the browser with no installation needed, which is a really great way as you're getting started.

    Also, do you notice anything different? That's right. As of 22a just a couple of weeks ago, MATLAB Online is now officially have a true dark mode. It's available through the preferences. So if you like me, and you go through some long coding binges, and your eyes feel like they're just burned out from staring at the white screen all day, MATLAB Online gives you this ability for you to get to use, and see, and preview the dark mode.

    So we've gone through a lot of different ways that we can interact with this. We've shared some models, we've released them to the cloud, and we got to see the most requested MATLAB feature of all time. So let's go ahead and go back to our slides as we start to wrap up.

    So as we're working with MATLAB, we can share our work all over the place in cloud enterprise solutions. And you can do that through our compiler products. You can connect to whatever you need to as you're moving things into full production, and really need to start to share your work.

    And so if there's any way that you want to take the work that you're doing in MATLAB and move it somewhere, reach out to us. We'd love to help you as you're getting started and start to move some things. We're constantly adding features to this as well, and so for those of you that may be familiar, they may see this done here, which is our new dockers.

    We now have the ability for you to spin up microservices directly using MATLAB with no other products that are needed. It's going to give you the ability. This is brand new in our 22a. And if you have any questions about how to get started with this workflow, please do reach out to us so that we can show you some of the new key ways that we can use this feature to move things to production really easily. Or maybe your IT has been starting to ask for things about, how do we start to make some containers and move some things around? We can do that here in MATLAB.

    There are a couple of new updates as well that we have-- some financial tools, really specifically. The Risk Management Toolbox we've been constantly-- releasing new risk-loss models that are available. You can now do whole life credit risk analysis in MATLAB, which is really great. And that framework for risk analysis can also get extended if you're in the climate space as well, and looking at things like climate risk in ways that can can inter-op

    For those that are also working in using-- building some more classical time series models, the Economic Modeler app now supports multivariate analysis, which has been a highly requested feature that we were able to release 22a. And so you maybe have seen some of these different pieces in our models, but across the board, we've been making ways for you-- to show you how to do point and click on apps to make MATLAB easy to use and make you really speed up a lot of your processes, and not have to scratch your head and look through documentation, wasting that time, to start to build out your models really quickly.

    We then showed you how to use some of that generated code to streamline your workflows to connect each of these three pillars-- data imports, model development, sharing your work. And finally, we also have the ability for you to really start to develop tools and enable others, whether that's creating web apps or packaging up your MATLAB functions as Python packages.

    Maybe you're a Toolbox creator creating things for other MATLAB users. We have ways for you to really start to share and enable your work so that, if you're a one-man show, you can help everyone in your company be able to do their work even easier.

    So hopefully you've seen some things that have sparked your interest or maybe some things that you haven't seen before. And so as you're moving in, there's a lot of free resources that we have available to on-ramp you back with some trainings, ways that you can look at MATLAB and learn that for free and some of the latest features with Matlab Onramp.

    Or maybe you're looking at some of the other ways that you can take a look at some new and advancing places, like deep learning and machine learning, reinforcement learning. And so along with these, we also have some paid trainings that are available that really are going to help you expedite your skills and grow them through. All of these are going to be financially-specific-oriented, where you're going to be working with and dealing with financial data, and specifically looking at workflows that affect our customers in the financial industries.

    So I want to thank you so much for attending our webinar today. We really appreciate it, and we thank you so much for coming. Please do feel free to reach out to us. Jot these emails down. We'd love to hear from you and find out little bit more of some ways that we can help you and see how MATLAB can help your workflows. Thanks so much.

    View more related videos