Welcome to my channel where we take complex concepts in statistics, data science analytics and break them down to their essentials. My goal is to help you better understand topics that might at first seem confusing. Examples demonstrate concepts in an applied manner with my tools of choice being Python and Excel, but you will also find tutorials on MySQL, R, minitab and SPSS. Whether you are looking for an explanation of hypothesis testing or want to know how to use tools like matplotlib, you have to come the right place. Most of the content used in my tutorials is available for download at: alphabench.com/resources.html
A problem with your approach is that stock prices are lognormally distributed. This becomes problematic for stock prices with a starting point closer to the zero bound, particularly if their standard deviation is high. Any thoughts on how to make that adjustment?
That's true, however by iterating each day you end up the with a log normal distribution x days out. But really the video is meant to demonstrate Monte Carlo techniques, not necessarily the best way to simulate a stock price action. I have several other videos that you may like better for simulating price action. There is an option pricing sim and VaR sim on my channel.
@@MattMacarty Fair enough. I was able to use Gen AI to get the right Excel coding for my task. I had to assume a lognormal distribution because the starting price for the asset I was modeling is close to zero (crypto token).
It's the average value calculating from the population of whatever you are looking at. I just made it up for this example. In practice, you probably don't know the population mean but would estimate it from a sample measurement
Hi Matt, thank you for this clear and helpful video! I have 2 questions you can hopefully help me out with: 1. Can you please explain why you use instantaneous returns and not simple daily returns ((p1/p0)-1)? 2. And how would you calculate the annual average returns? I ask because I would like to compare annual average returns and volatility for different portfolios (by changing the weights). Hope to hear from you, thank you!
This is typically how finance applications formulate returns. it has the benefit of being summable. The standard percent change over estimates returns. I would use instantaneous for annualized returns too.
Ho i am implenting a trading application with REST. Stream and Websockets. It supoort live and paper use cases for allpaca users I am stock with the get_account() initialize_api_client since its Ouath 2.0 how do we ensure the api calls are made to ensure the alpaca user information is fetch. Will this be done woith headers annd base_url or access_token and base_url
Thank you for sharing Matt! I have one question - It's very cool to generate a Plotly interactive graph from Lumibot. I wanted to dig into the package and find the code that generated the graph but I couldn't find it. Do you know where in Lumibot embedded this function? It'll be so much easier to leverage it on other data visualization projects.
@@MattMacartyYea, that's what I did. I was guessing it's in lumibot.strategies but I only found matplotlib library but the graph is generated by plotly. Also, I didn't find where in lumibot is embedded QuantStats neither. Appreciate it if you could help provide some clues.
what is the maximum amount of iterations you can run on Excel for something such as this? I have a project similar but must run about 1 000 000 iterations
This kind of model will forecast out one period into the future. Most of the work is to fit the model and measure how well it can be expected to forecast.
Hi, great tutorial! Just one quick question, for the value of the moving average, what does 21 stand for, is it the length of the moving average or the actual value of the moving average? Can you elaborate further on how you derived the value of 21 for the moving average?
Can you elaborate more on why you multiplied the variance of AAPL by 252? I downloaded data for a stock of the past 3 years, what would i do there to adjust the variance? Also multiply by 252? If I do this, is my VaR having the same interpretation as yours?
Great video! Can you tell me how to stop the bot/ the run_all function for the Trader? I know there is a function called stop_all, but once I started run_all, it runs forever
Hi, try not to use price, lagging indicators, instead use price action strategy, will give accurate results, can you do this, many viewers are fed-up seeing these price lagging indicators usage in different channels of youtube.
This is for demonstrating how to write a simple back tester, not really interested in a strategy. Any strategy worth anything will not be found on RU-vid.
I'm new to coding. I straight up cannot figure out how to get Lumibot available for this program. I went to terminal. Did the pip install. Now what? I cannot find out to actually include it.
@ 11:27 should the square of cell I5 equal to cell D5 since SPY to SPY is variance of SPY? Square of .3204=.1017 which is not what is shown in cell D5!!!
Hi Matt, thanks for the really useful tutorial, wondered if you are able to add a variable to this calculations if you invest an extra amount each month? i would assume to use an average of the month beg or month end price, or just by picking month end or month beginning. if you have a video on that already or a way to add it to the model this would be great.
Thanks. Yes you can do it that way , or just add money at the end of each month where you have a data point that is closer to where you can buy. Just remember these models are approximations.
hey matt!, loved the video! i have trouble installing pip lumibot. it says there is something wrong with the package itself(not pip). is it possible that lumibot isnt working with my python version (3.12.12)? thank you!
My guess is it is one of the dependencies such as pandas that is causing the problem. You likely havea newer version of pandas than is supported by lumibot. You can try downgrading to something like 1.5 and see if that solves the probelm. ALso you can contact lumiwealth and they will get you going.
So the blue line shows what would happen if you bought in 2016 and just held gold without any adjustments. The orange line is what would have happened if you tried to catch the swings in prices based on a simple moving average.