Kurze Zusammenfassung
Das Video erklärt, wie man die Strategien von Quant-Tradern wie Jim Simons durch die Analyse von Konzepten wie Markov-Ketten und Mean-Reversion-Strategien verstehen und anwenden kann. Es wird gezeigt, wie man Markov-Prozesse nutzt, um Handelsstrategien zu entwickeln, indem man Wahrscheinlichkeiten basierend auf dem aktuellen Zustand des Marktes berechnet. Abschließend wird demonstriert, wie man diese Konzepte in Python anwendet, um eine Transition Matrix für den SPY zu erstellen und eine einfache Trading-Strategie in Pine Script zu testen.
- Jim Simons' Erfolg basiert auf quantitativen Strategien, die auf mathematischen Modellen und Datenanalysen beruhen.
- Markov-Prozesse können verwendet werden, um Handelsstrategien zu entwickeln, indem man Wahrscheinlichkeiten basierend auf dem aktuellen Zustand des Marktes berechnet.
- Die Anwendung von Markov-Modellen in Python ermöglicht die Erstellung von Transition Matrixen und die Analyse von Wahrscheinlichkeiten für verschiedene Marktszenarien.
Der Sprecher diskutiert die Erfolge von Quant-Tradern wie Jim Simons und dessen Medallion Fund, der über drei Jahrzehnte eine Nettorendite von 39 % erzielt hat. Simons' Strategien basieren auf quantitativen Ansätzen, die im Verborgenen liegen, aber durch Bücher und Analysen aufgedeckt werden können. Viele der persönlichen Strategien des Sprechers sind von diesem Buch inspiriert. Ziel des Videos ist es, Informationen aus diesem Buch zu nutzen, um Handelsstrategien zu entwickeln und zu codieren, um so Einblicke in Simons' Arbeitsweise zu gewinnen.
Der Sprecher geht auf Erkenntnisse aus dem Buch über Jim Simons ein, insbesondere auf die Arbeit von Axe, einem ehemaligen Mitarbeiter von Simons, der sich auf Markov-Ketten konzentrierte. Markov-Ketten ermöglichen es, zukünftige Schritte mit einer gewissen Wahrscheinlichkeit vorherzusagen, basierend auf einem geeigneten Modell. Eine weitere wichtige Strategie, die von Loer, einem anderen mathematischen Genie bei Simmons, angewendet wurde, ist die Mean-Reversion-Strategie. Diese basiert auf der Idee, dass Preise nach anfänglichen Bewegungen dazu neigen, sich wieder zu normalisieren. Der Sprecher betont, dass Simons auch in Rezessionszeiten hohe Renditen erzielte, was auf den Erfolg seiner Strategien in volatilen Marktphasen hindeutet.
Der Sprecher demonstriert die Ergebnisse einer Mean-Reversion-Strategie (Q5) aus seinem Kurs, die in den letzten zwei Jahren und während der Rezession von 2008 sehr erfolgreich war. Die Strategie zeigt viele erfolgreiche Trades in einem Rezessionsumfeld. Die Ergebnisse dieser Strategie auf dem SPY zeigen, dass sie in Zeiten, in denen der S&P 500 stark gefallen ist, gut performt hat. Dies war insbesondere in den Jahren 2001, 2002 und in den letzten zwei Jahren der Fall. Der Sprecher ermutigt die Zuschauer, die Strategie im Quant Program Prometheus zu erkunden, das zehn Strategien sowie Tools für Simulation, Portfoliooptimierung und Forward-Testing umfasst.
Ein Markov-Prozess ist eine zufällige Abfolge von Ereignissen, bei denen die Wahrscheinlichkeiten der Zukunft auf dem aktuellen Zustand basieren und nicht auf der Vergangenheit. Das bedeutet, dass die Wahrscheinlichkeiten für morgen von heute abhängen und nicht von gestern. Der Sprecher erklärt den Markov-Prozess anhand eines Beispiels: Die Wettervorhersage für morgen basiert auf dem heutigen Wetter und nicht auf dem gestrigen. Markov-Prozesse werden in verschiedenen Bereichen eingesetzt, nicht nur im quantitativen Handel, sondern auch in der Wettervorhersage.
Der Sprecher veranschaulicht den Markov-Prozess anhand eines Beispiels mit einem "Markov-Typ" und einem Menschen. Ein Mensch, der von zu Hause zum Laden und dann zur Arbeit geht, weiß, dass er nicht zum Laden zurückkehren muss. Ein Markov-Typ hingegen, der sich im Laden befindet, kann entweder nach Hause oder zur Arbeit gehen, da er sich nicht an den vorherigen Zustand erinnert. Die Wahrscheinlichkeiten basieren auf dem aktuellen Zustand. Wenn sich der Markov-Typ zu Hause befindet, geht er mit 100%iger Wahrscheinlichkeit zum Laden. Befindet er sich im Laden, hat er eine 50%ige Chance, nach Hause oder zur Arbeit zu gehen. Befindet er sich bei der Arbeit, geht er mit 100%iger Wahrscheinlichkeit zum Laden.
Der Sprecher erklärt, wie Markov-Wahrscheinlichkeiten im Trading angewendet werden können. Er verwendet hypothetische Zahlen, um zu veranschaulichen, wie die Wahrscheinlichkeit für einen positiven oder negativen Tag berechnet wird. Wenn der Markt heute um 5 % gestiegen ist, beträgt die Wahrscheinlichkeit, dass der nächste Tag ebenfalls positiv ist, beispielsweise 0,7. Die Wahrscheinlichkeit für einen negativen Tag beträgt dann 0,3 (1 - 0,7). Wenn der heutige Tag negativ ist, beträgt die Wahrscheinlichkeit für einen negativen Tag am nächsten Tag beispielsweise 0,2, und die Wahrscheinlichkeit für einen positiven Tag beträgt 0,8. Diese Zahlen können auf Basis historischer Daten oder mithilfe von Machine-Learning-Modellen berechnet werden.
Der Sprecher erklärt, wie die berechneten Wahrscheinlichkeiten in einer Transition Matrix dargestellt werden können. Diese Matrix zeigt die Wahrscheinlichkeiten für den Übergang von einem Zustand (positiver oder negativer Tag) zum nächsten. Beispielsweise beträgt die Wahrscheinlichkeit, dass auf einen positiven Tag ein weiterer positiver Tag folgt, 0,7, und die Wahrscheinlichkeit, dass auf einen positiven Tag ein negativer Tag folgt, 0,3. Die Summe der Wahrscheinlichkeiten in jeder Zeile der Matrix beträgt 1. Die Matrix kann erweitert werden, um mehr Permutationen und Kombinationen von Tagen zu berücksichtigen.
Der Sprecher demonstriert, wie man den Markov-Prozess in Python anwendet, um die Wahrscheinlichkeiten für den SPY zu berechnen. Er verwendet Bibliotheken wie Y Finance, Pandas und NumPy. Zuerst werden die Daten für den SPY von 2010 bis 2022 heruntergeladen. Anschließend wird die tägliche Rendite berechnet und der Zustand (Up oder Down) für jeden Tag bestimmt. Die Daten werden in einem Dataframe gespeichert, der die tägliche Rendite und den Zustand anzeigt.
Der Sprecher erklärt, wie die Wahrscheinlichkeiten für den SPY berechnet werden, basierend auf historischen Daten. Er berechnet die Anzahl der Up- und Down-Tage sowie die Anzahl der aufeinanderfolgenden Up- und Down-Tage. Anschließend berechnet er die Wahrscheinlichkeiten für Übergänge wie "Up to Up", "Down to Up", "Up to Down" und "Down to Down". Diese Wahrscheinlichkeiten werden in einer Transition Matrix dargestellt. Die Ergebnisse zeigen, dass die Wahrscheinlichkeit für einen Up-Tag nach einem Down-Tag am höchsten ist (57 %).
Der Sprecher demonstriert, wie man die Erkenntnisse aus der Markov-Analyse in eine einfache Trading-Strategie in Pine Script umsetzt. Er verwendet die Bedingung, dass der Schlusskurs niedriger ist als der vorherige Schlusskurs für fünf bis sechs Tage in Folge als Einstiegssignal. Die Position wird geschlossen, wenn der Schlusskurs am nächsten Tag höher ist als der heutige Schlusskurs.
Die Ergebnisse der einfachen Strategie zeigen eine Trefferquote von 46 % mit einem Drawdown von 5 %. Der Sprecher betont, dass dies nur eine einfache Strategie mit einer einzigen Bedingung ist. Durch das Hinzufügen weiterer Bedingungen und die Kombination mit anderen Strategien können die Ergebnisse verbessert werden. Er schlägt vor, verschiedene Kombinationen von Up- und Down-Tagen zu testen und die Strategie auf mehrere Aktien anzuwenden, um den Drawdown zu reduzieren. Das Ziel ist es, die Wahrscheinlichkeiten zu Gunsten des Traders zu verschieben und effiziente Strategien zu entwickeln.
Fasse jedes YouTube-Video in Sekunden zusammen
Hol dir Zusammenfassungen wie diese für jedes Video, in deiner Sprache, mit der kostenlosen Summ-App.
Transkript
Vollständiges Transkript von „Jim Simons Trading Secrets 1.1 MARKOV Process“. Klicke auf einen Zeitstempel, um das Video an dieser Stelle zu öffnen. Du brauchst ein anderes Video? Nutze den YouTube-Transkript-Generator.
0:00 what do you think of quants Jim Simon's Medallion fund has done 39% net of fees for three decades which proves that it worked they were very very smart yes they got very rich very very smart and very smart and very rich yeah and and and very high grade by the way yeah Jim Simons Jim Simmons is considered to be one of the greatest traders of all time who has beaten the likes of Warren Buffett or Charlie Munger and his strategy has been purely a quan based strategy um what he does in his fund is extremely secretive but there are certain ideas and there are certain concept that we could get from what he does through this book that I've been reading and most of my uh strategies that I've come across uh which I do in my personal life has also been inspired
0:45 from this book uh so what we're going to do today is we're going to take some of the information that we can find in this book and start coding uh and try to see the results uh and try to figure out what Jim Simmons has been doing in this fund so one of the pages in the book here um it's about axe ax used to work for Jim Simmons he was part of the fund and he's also some kind of a mathematical genius thing he's got like amazing Papers written by him uh and if you can see in this paragraph he focuses on a thing called Mark of chain so in a mark of chain each step along the way is impossible to predict with certainty but future steps can be predicted with some degree of accuracy if one relies on a capable model um and they go on to create a stochastic equation based on
1:30 this Mark of chain um another important thing which is just a few pages prior to this was this one uh loer again another mathematical genius working for Simmons uh and they did more of a mean reverting strategy so here the strategies were often based on the idea that prices tend to revert after an initial move higher or lower and they would buy Futures Contract if they open it un usually low prices so that is a typical example of a mean reverting strategies um so at the end of the book one of the things that I noticed was his uh trading result and if you can see in 2008 2007 which was basically the recessionary time frame uh he went on to make 152% return 136% return that's substantially higher than
2:16 any of those years and you've got to understand that during recessionary periods the volatility is extremely high and Main reverting strategies perform extremely well so even the strategies that we do in our course especially Q3 and Q5 worked tremendously well during the 2008 2007 recession and also the past 2 years so this is one of the uh strategies that we teach in the course Q5 uh and it's performed very well the past two years and also in the 2008 recession this is a mean reverting strategy so if I can zoom into some of the strategies I can hear short here uh close position there uh long here close position next day long here closer position there so you're we're always going to see lots of good trades in recession environment the past two years
3:01 has been really good for a mean reverting base strategy so uh this is the trading result of that mean reverting strategy on the spy and if I can look into that Buy and Hold equity line this period you see here that was the 2008 recession you can literally see uh the blue line which is the S&P 500 Buy and Hold has crashed almost 50% but the mean reverting strategy performed extremely well now if you can go back to the 20012 2002 period is literally an X the Blue Line went down considerably while strategy performed extremely well same thing can be seen the past two years uh because 2001 to 20 2021 2022 and including now the market still hasn't recovered you can see from the peak it's been going down and still is in like a consolidation hasn't recovered the highs but the strategy has performed
3:46 extremely well and the reason why is because of the recessionary environment recessionary volatility based uh High volatility based environment gives great results uh for M inverting strategy so what we're going to do so if you guys want to check out this of course feel free to visit our website a quan program and this strategy comes in the Quan program Prometheus uh which includes 10 strategies and it also includes many other important strategies along with Trend following and momentum based and also monol simulation portfolio optimization forward testing and all the other important Quant trading tools necessary uh so what we're going to do in this video is we're going to discuss what the marov process is because marov process is what um what we saw from the book and what is
4:32 a Marco process and how we can create trading strategies from the Marco process so to start off with uh Marco process is basically uh random sequence of events where the probabilities of the future is based on the current state okay it's not based on the past so tomorrow's probabilities depends upon today it's not dependent on yesterday so for instance if I have to predict the weather um the weather prediction for tomorrow is based on today and not yesterday so Marco process used in many different fields just not in the quantitative trading field it's also used in weather forecasting and many other fields um so I hope you guys understood the definition of Marco process now I'm going through the example of it so you
5:18 guys get an idea uh in simple terms so let's take two scenarios so one is a mar of guy and the other is a human being so let's take the case of a human being let's take myself as a condition so I wake up in the morning I uh wake up at home and then I go to the shop to buy some stuff and I buy the stuff and then I go to work uh so when I reach the shop I know I came from home so there's no reason for me to go back to home so I can go straight to work so Marco on the other hand he goes from home and goes straight to the shop and now he's in the corent state right uh so in the Corin State he can go either home or to work cuz he doesn't know what happened the previous instance as compared to human
6:03 being so the whole Mark of probabilities is based on this um this current state and future State cuz the shop is where the current state is and once marov is in that current state of the shop he can go either to home or to work but when marov is at work he has nowhere else to go so he goes straight to shop same thing goes when he's at home he has nowhere else to go and then he goes straight to the shop uh so if you're calculating the probabilities of the marov that's when things get slightly uh not complicated but the numbers start to come into play so when he is at home there's only one place for him to go and that is to the shop so there's 100% probability that he will go to the shop so then we write one uh now on the other scenario when he's at the shop as I said
6:50 before he doesn't know where where he came back from so he can go either to home or to work so now there's a 50% chance for him to go either home or work now once markco reaches work again he has nowhere else to go so he's got a 100% probability that he will go to the shop so this is how simple the mark probability is now if you are putting this into trading perspective so let's let's take a trading example into consideration so forget the thing that's going on here let's just focus on this one here so these numbers are hypothetical numbers so I'm going to explain to you uh what this all about so you see this positive percentage and negative percentage so whenever you see the news you always see the market went up 5% and the market went down 2% and things like that so that's a percentage
7:36 move for the specific day so in this percentage positive percentage move the 0.7 depicts the probability of the next day being positive percentage so if today is a positive percentage close if today is an up day uh then the next day's probability is 0.7 now the 0.7 is just a hypothetical number so don't don't go deep into it as of now um so this positive percentage for the next St positive percentage is 0.7 so what will be a negative percentage it's pretty simple it's 1 - 0.7 that is 0.3 so you can see the arrow here that's minus percentage so similarly when it's today is negative percentage what is the probability that the next day will be negative well here I put in 0.2 so
8:22 what's the probability that it will be a positive it's 1 - 0.2 which is 0.8 now how did I come across all these numbers well you can calculate in many ways you can calculate just based on historical data you can we can calculate the number of updates and the number of down days and divided by the uh up day and the total number of down days we will get the probability of the up days and down days and then there are machine learning models as well so if you can go through that book uh one of the things that they have done is even before many years you're talking about 30 years or so um they've been using machine learning models uh but now these days you can use machine learning models with just a few lines of code uh so I hope you guys understood the whole idea of this thing of this Mark of probabilities these numbers are just hypothetical but now you can put this into a matrix right
9:09 this is called a transition Matrix so you've got the positive percentage you've got the negative percentage you got the positive percentage you got the negative percentage here as well in the columns so a positive percentage and the next days a positive percentage is 0.7 as you saw here similarly a positive percentage and the next St is a negative percentage is 0.3 again negative percentage day and the next day is a positive percentage day is 0.8 as you can see here and a negative percentage followed by the next day a negative percentage is 0.2 so if you can observe something 0.7 + 0.3 is 1 and 0.8 + 0.2 is again 1 so this is basically a transition Matrix so here we have just taken two days in a row so we can
9:55 actually have more rows and more columns where we can have uh plus plus minus minus here or plus plus plus-- minus you can have many kinds of permutations and combinations in this but this is basically a mark of trading and this is how we calculate the trading probability so now what we're going to do is we're going to go to a real world example on spy and we're going to calculate the probabilities uh of the Spy getting a positive percentage on the next day following the previous day being the positive percentage and similarly negative and negative and negative and positive so this is the Anaconda notebook where we'll be calculating the um marov process and transition probabilities um and if you don't know anything about
10:41 python then I would suggest you to go to our video in our Channel algorithmic trading in Python so you get the basics of how to do python uh so it'll be really beneficial for you in your Quan trading Journey you can also do the trading with pine script if you're fancy as well so now going to the Anaconda notebook so first thing we do is basically we download the Y Finance library and the pandas and the numpy which is necessary for us to calculate many things uh then we download the data so if we download the data for spy from 2010 to 2022 you can download more data or you can keep the data smaller so you can assess different time periods for example if you want to just assess a recessionary time period you can just do the 2008 or the 2011.com bubble card so you get the recession environment data as well so it's up to you really so I've
11:26 just randomly chosen 2010 uh to 2022 um and then we've actually downloaded the data um and basically you can see the Open high low close and the adjusted close and the volume so we need to calc the daily return so we're going to take the adjusted close and Dot percentage change function and that will give us the percentage difference between yesterday and today uh and also the state so basically States is where uh the daily return is greater equal to Z we have got up so we got the num uh uh nump pandas nump as NP so that's why we use NP here uh so daily return is greater than equal to zero then it's an up day else it's a down day and then we' have stored it in data of State um so then here is the data frame of the data
12:12 and you can see the daily return here and whether it's an up percentage close or down percentage close so you can see whenever there's a positive one it's up uh and whenever there's a negative one it's down negative here again it's down uh negative here it's again down as well so basically uh we using uh just pure math to find out the probabilities as compared to using machine learning models however uh in the book they have talked about machine learning models and that was years ago so now you can do uh machine learning models just with a few lines of code so if you guys are stoked about doing this making this more efficient then go ahead with the machine learning model as well but as of now we're just going to make it simple so you guys can understand the process so we've got the up counts and the down counts so UPC counts is basically you take the length of the data of
13:00 um the state wears up so how many days is there been up and then similarly down counts give you the length how many days it's been down so if you can get that information then we can calculate the properties we're not going to use these two lines of codes anywhere but it's just created to give you an understanding of how to calculate the probabilities so up to up is like two consecutive positive percentage close uh down to up is a negative day followed by uh positive day and up to down similarly and down to down two consecutive uh down days so we calculate the length of the how many times the days has been like consecutive up dayss and then we divide it by the upate and that will give us the probability of a two consecutive update similarly uh down to up up to down and down to down and then we'll do a transition Matrix where we've got like
13:46 a pandas data frame and we're going to put all these results into like a matrix kind of a a fancy kind of a way uh and then we'll print the transition Matrix and we've got the information so you can see up to up is 54% % up to down is 45% down to up is 57 and down to down is 42 so the best performing is an up day after a down day so that is 57% so if I'm going to take any bet in all these four conditions my bet will be to go uh for an up day after a down day because there's a 50% 57% chance for that to work out uh now down to down is significantly lower so it's just 42% so there's nothing significant for us to uh you know make a trade in so in all these numbers these numbers are not that
14:33 significant it's on the 50% 40% area so I want something more effective so let's do another one let's do uh what's the probability of upate if there is five consecutive down day so down day down day down day down day down day and then we divided by the length that's here again length of the uh five or six down days and what is the probability of that so that probability is 66% now that is a pretty good probability 66% is something that I can work with so what I'm going to do is I'm going to take this information that I've got like five to six days of down days and the probability of the next day being an up there is pretty good so I'm going to take this information and I'm going to back test it so nine times out
15:18 of 10 I would back test in Ami broker but now just to make things simple I'm just going to go into Pine editor uh and I'm going to do a condition where close is less than one close of one is less than close of two so B basically yesterday's close is lower than the prior day so we got that condition for 5 to 6 days and that is our entry if that condition is met and then we are going to close our position if the next day close is higher than uh today's close um so it's pretty simple now you can create a mark of model for the exit condition as well so what is the probability of us having a greater return if the close is tomorrow or 2 days later so then we calculate a better probability and create even better strategy so when you run this strategy you would see the result as 46%
16:05 with a draw down of just 5% so this is not at all significant uh when you look at simple terms but when you look in the overall perspective it's pretty good because you can see there's only 20 trades place and that's from 1994 and it's only based on one condition so imagine if you create multiple conditions on Marco model so here we did 6 days of consecutive close below so what about 5 days what about 4 days what about a combination like uh up down up followed by an upate or down down up followed by an update so then you can add up more and more conditions uh if the probability is suiting you like 60% up and then your net profit starts climbing up and up and up again and because you've got more conditions the draw Downs start to uh be better as
16:51 well cuz if you're basing it on just one strategy then the draw Downs won't be that significant so you need to have more strategy so we did the video uh just the prior video the GPT 4 where we did a strategy wherein we had a strategy applied to 25 stocks and also 90 stocks and how we were able to reduce a draw down considerably just by doing the uh strategy in multiple stocks similarly if you can add more conditions to this this will uh be spectacular so the whole idea of this video is for you guys to understand what a mark of process is to code it in Python and then apply it uh in your trading goal so for example assemble the Q5 strategy that we did uh in our course if you can look at it um because it's a mainting strategy
17:37 and also the fact that it's kind of inspired from the marov model uh you can see how amazingly it performs so this is the 21.com B where the market just crashed considerably well and you can see it's literally a diagonal uh you know literally a cross uh similarly here again 2008 crash where it been down 54% and look at the results of that strategy again recently past 2 years uh the market went down and this strategy has outperformed the market and the draw down is quite minimal as well so this is the advantage of marov model so in this strategy I took the marov model uh and I effectively uh did I don't want to give out much information about it but the people who know the course uh know how I combine two different things I've chosen the days similar to what we saw here uh the close is less than one kind
18:22 of thing but then I used the exit condition to be slightly tweaked um so these are some of the things that you can efficiently do in creating good strategies great strategies based on good probabilities so in this case we've got a 66% probability and that why it kind of worked uh so even if I go to the ETF of QQQ again you will see a 21% return and Microsoft and Walmart and the list just goes on so you will basically see just on just based on one condition right so imagine having multiple conditions and applying this to multiple stocks and this is pretty much what Jim simth is doing uh and we don't know exactly what he's doing but all we can do is to get information from the book information from any kind of interviews she does you know combine together uh and kind of improve but regardless when you are in a Quant trting Journey you're
19:07 trying to get the probabilities in your favor so any tool including the Marian process uh and calculate the transition probabilities is highly efficient so in this case we actually did you know just based on historical data probabilities now you can actually tweak that to use a machine learning model to calculate the probabilities of these uh you can go a step further create a for Loop and change these down datas and you know down and up to different combinations and calculate more properties create a massive Matrix not just up up down like you know like 10 10 rows here 10 uh 10 columns there and then uh you can tweak the data points you know instead of this you can actually do the recession environment so you can create a recession based environment strategy or Trend following strategy so so sky is
19:54 the limit when you have data and when you have the tools and the skills to process it so I hope you guys like this video if you have any queries any uh any doubts or clarifications feel free to leave a comment uh and I'll be more than happy to help you guys out so hope you guys enjoy this video uh have a great great day bye-bye